diff --git a/tests/build_resources_file b/tests/build_resources_file index dd3989a20..d39f8a1e0 100755 --- a/tests/build_resources_file +++ b/tests/build_resources_file @@ -7,7 +7,7 @@ for filename in $(find languages/ ui/ imgs/ -type f) do extension="${filename##*.}" - if [[ "${extension}" == @(qml|svg|qm|js) ]]; then + if [[ "${extension}" == @(qml|svg|png|qm|js) ]]; then echo " $filename" fi done diff --git a/tests/imgs/linphone.png b/tests/imgs/linphone.png new file mode 100644 index 000000000..4031d7205 Binary files /dev/null and b/tests/imgs/linphone.png differ diff --git a/tests/resources.qrc b/tests/resources.qrc index a1c763d6e..941fd287a 100644 --- a/tests/resources.qrc +++ b/tests/resources.qrc @@ -39,6 +39,7 @@ imgs/led_disconnected.svg imgs/valid.svg imgs/incoming_call.svg + imgs/linphone.png imgs/led_do_not_disturb.svg imgs/lost_incoming_call.svg imgs/conference.svg diff --git a/tests/src/app.cpp b/tests/src/app.cpp index e05a0ab99..59f5621fe 100644 --- a/tests/src/app.cpp +++ b/tests/src/app.cpp @@ -1,19 +1,21 @@ #include +#include #include - #include "app.hpp" #define LANGUAGES_PATH ":/languages/" // =================================================================== -App::App(int &argc, char **argv) : QGuiApplication(argc, argv) { - // Try to enable system translation by default. (else english) +App::App (int &argc, char **argv) : QApplication(argc, argv) { + // Try to use default locale. if (m_translator.load(QString(LANGUAGES_PATH) + QLocale::system().name()) || m_translator.load(LANGUAGES_PATH "en")) { this->installTranslator(&m_translator); } else { qWarning() << "No translation found."; } + + this->setWindowIcon(QIcon(":/imgs/linphone.png")); } diff --git a/tests/src/app.hpp b/tests/src/app.hpp index 731520f22..29ea42bf4 100644 --- a/tests/src/app.hpp +++ b/tests/src/app.hpp @@ -1,15 +1,17 @@ #ifndef APP_H_ #define APP_H_ -#include +#include #include // TODO: Make it Singleton. -class App : public QGuiApplication { +class App : public QApplication { public: App (int &argc, char **argv); virtual ~App () {} +private slots: + private: QTranslator m_translator; }; diff --git a/tests/src/main.cpp b/tests/src/main.cpp index 02a01ceab..9335b8b42 100644 --- a/tests/src/main.cpp +++ b/tests/src/main.cpp @@ -1,11 +1,36 @@ #include +#include #include +#include +#include #include "app.hpp" // =================================================================== +void createSystemTrayIcon (QQmlApplicationEngine &engine) { + QObject *root = engine.rootObjects().at(0); + QMenu *menu = new QMenu(); + QSystemTrayIcon *tray_icon = new QSystemTrayIcon(root); + + QAction *quitAction = new QAction(QObject::tr("Quit"), root); + root->connect(quitAction, &QAction::triggered, qApp, &QCoreApplication::quit); + + QAction *restoreAction = new QAction(QObject::tr("Restore")), root); + root->connect(restoreAction, SIGNAL(triggered()), root, SLOT(showNormal())); + + menu->addAction(restoreAction); + menu->addSeparator(); + menu->addAction(quitAction); + + tray_icon->setContextMenu(menu); + tray_icon->setIcon(QIcon(":/imgs/linphone.png")); + tray_icon->show(); + + return; +} + int main (int argc, char *argv[]) { App app(argc, argv); QQmlApplicationEngine engine(QUrl("qrc:/ui/views/mainWindow/mainWindow.qml")); @@ -13,5 +38,10 @@ int main (int argc, char *argv[]) { if (engine.rootObjects().isEmpty()) return EXIT_FAILURE; + if (!QSystemTrayIcon::isSystemTrayAvailable()) + qWarning() << "System tray not found on this system."; + else + createSystemTrayIcon(engine); + return app.exec(); }