diff --git a/code/bin/srv/pingme.txt b/code/bin/srv/pingme.txt new file mode 100644 index 0000000..e69de29 diff --git a/code/build/FileWatcher.pro b/code/build/FileWatcher.pro index 7476d81..fe40a8e 100644 --- a/code/build/FileWatcher.pro +++ b/code/build/FileWatcher.pro @@ -18,38 +18,5 @@ HEADERS += ../src/mainwindow.h FORMS += ../src/mainwindow.ui -OTHER_FILES += \ - res/arrow_fat_down.gif \ - res/arrow_fat_up.gif \ - res/arrow_mini_down.gif \ - res/arrow_mini_up.gif \ - res/block.gif \ - res/cross.gif \ - res/drop_box.gif \ - res/folder.gif \ - res/plus.gif \ - res/save.gif \ - res/script.gif \ - res/trash.gif \ - res/warning.gif \ - res/play.png \ - res/settings.png \ - res/stock_3d-texture-and-shading_16x16.png \ - res/stock_3d-texture-and-shading_32x32.png \ - res/stock_3d-texture-and-shading_48x48.png \ - res/stock_3d-texture-and-shading_128x128.png \ - res/stock_3d-texture-and-shading_256x256.png \ - res/stock_3d-texture-spherical_16x16.png \ - res/stock_3d-texture-spherical_32x32.png \ - res/stock_3d-texture-spherical_48x48.png \ - res/stock_3d-texture-spherical_128x128.png \ - res/stock_3d-texture-spherical_256x256.png \ - res/stop.png \ - res/stock_3d-texture-and-shading_16x16.ico \ - res/stock_3d-texture-and-shading_32x32.ico \ - res/stock_3d-texture-and-shading_128x128.ico \ - res/stock_3d-texture-and-shading_256x256.ico \ - res/stock_3d-texture-spherical_16x16.ico \ - res/stock_3d-texture-spherical_32x32.ico \ - res/stock_3d-texture-spherical_128x128.ico \ - res/stock_3d-texture-spherical_256x256.ico +RESOURCES += \ + res.qrc diff --git a/code/build/res.qrc b/code/build/res.qrc new file mode 100644 index 0000000..99d3952 --- /dev/null +++ b/code/build/res.qrc @@ -0,0 +1,22 @@ + + + res/arrow_fat_down.gif + res/arrow_fat_up.gif + res/arrow_mini_down.gif + res/arrow_mini_up.gif + res/block.gif + res/cross.gif + res/drop_box.gif + res/folder.gif + res/play.png + res/plus.gif + res/save.gif + res/script.gif + res/settings.png + res/stop.png + res/trash.gif + res/warning.gif + res/stock_3d-texture-and-shading_16x16.png + res/stock_3d-texture-spherical_16x16.png + + diff --git a/code/src/mainwindow.cpp b/code/src/mainwindow.cpp index 49d64fc..d9f65de 100644 --- a/code/src/mainwindow.cpp +++ b/code/src/mainwindow.cpp @@ -1,14 +1,91 @@ #include "mainwindow.h" #include "ui_mainwindow.h" +#include +#include + MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWindow) { + //QResource::registerResource("res.qrc"); + ui->setupUi(this); + + m_pActiveIcon = new QPixmap(":/images/res/stock_3d-texture-and-shading_16x16.png"); + m_pInactiveIcon = new QPixmap(":/images/res/stock_3d-texture-spherical_16x16.png"); + + const bool activeNotNull = QIcon(":/images/res/stock_3d-texture-and-shading_16x16.png").isNull(); + const bool inactiveNotNull = QIcon(":/images/res/stock_3d-texture-spherical_16x16.png").isNull(); + + m_pExitAction = new QAction(tr("&Exit"), this); + connect(m_pExitAction, SIGNAL(triggered()), this, SLOT(exit())); + + m_pTrayIconMenu = new QMenu(this); + m_pTrayIconMenu->addAction(m_pExitAction); + + m_pTrayIcon = new QSystemTrayIcon(this); + m_pTrayIcon->setContextMenu(m_pTrayIconMenu); + m_pTrayIcon->setIcon(QIcon(":/images/res/stock_3d-texture-and-shading_16x16.png")); + m_pTrayIcon->show(); + + connect(ui->actionSave, SIGNAL(triggered()), this, SLOT(save())); + connect(ui->actionHide, SIGNAL(triggered()), this, SLOT(hide())); + connect(ui->actionExit, SIGNAL(triggered()), this, SLOT(exit())); + + connect( + m_pTrayIcon, + SIGNAL(activated(QSystemTrayIcon::ActivationReason)), + this, + SLOT(iconActivated(QSystemTrayIcon::ActivationReason))); } MainWindow::~MainWindow() { + delete m_pInactiveIcon; + delete m_pActiveIcon; + delete m_pExitAction; + delete m_pTrayIcon; + delete m_pTrayIconMenu; delete ui; } + +void MainWindow::save() +{ + +} + +void MainWindow::exit() +{ + qApp->exit(); +} + +void MainWindow::iconActivated(QSystemTrayIcon::ActivationReason reason) +{ + switch(reason){ + case QSystemTrayIcon::Trigger: + break; + case QSystemTrayIcon::DoubleClick: + if (this->isHidden()) + { + this->show(); + } + break; + } +} + +void MainWindow::closeEvent(QCloseEvent* event) +{ + event->ignore(); + hide(); +} + +void MainWindow::hideEvent(QHideEvent* event) +{ + m_pTrayIcon->setIcon(QIcon(":/images/res/stock_3d-texture-spherical_16x16.png")); +} + +void MainWindow::showEvent(QShowEvent* event) +{ + m_pTrayIcon->setIcon(QIcon(":/images/res/stock_3d-texture-and-shading_16x16.png")); +} diff --git a/code/src/mainwindow.h b/code/src/mainwindow.h index a3948a9..3e13e0e 100644 --- a/code/src/mainwindow.h +++ b/code/src/mainwindow.h @@ -2,21 +2,43 @@ #define MAINWINDOW_H #include +#include namespace Ui { class MainWindow; } +/// +// http://qt-project.org/doc/qt-4.8/desktop-systray.html +/// class MainWindow : public QMainWindow { Q_OBJECT + typedef QMainWindow BaseType; + public: explicit MainWindow(QWidget *parent = 0); ~MainWindow(); +public slots: + void save(); + void exit(); + + void iconActivated(QSystemTrayIcon::ActivationReason reason); + private: Ui::MainWindow *ui; + + QSystemTrayIcon* m_pTrayIcon; + QMenu* m_pTrayIconMenu; + QAction* m_pExitAction; + QPixmap* m_pActiveIcon; + QPixmap* m_pInactiveIcon; + + virtual void closeEvent(QCloseEvent* event); + virtual void hideEvent(QHideEvent* event); + virtual void showEvent(QShowEvent* event); }; #endif // MAINWINDOW_H diff --git a/code/src/mainwindow.ui b/code/src/mainwindow.ui index c0e8eee..9ca90f5 100644 --- a/code/src/mainwindow.ui +++ b/code/src/mainwindow.ui @@ -11,7 +11,7 @@ - MainWindow + FileWatcher