From 0b8db12543d2d02cc5c60498ea08b32622554bf9 Mon Sep 17 00:00:00 2001 From: Tobias Fella Date: Mon, 23 Nov 2020 00:03:49 +0100 Subject: [PATCH] Don't use trayicon on android --- qml/main.qml | 10 ++-------- src/CMakeLists.txt | 5 ++++- src/controller.cpp | 12 ++++++++++++ src/controller.h | 1 + src/main.cpp | 2 -- 5 files changed, 19 insertions(+), 11 deletions(-) diff --git a/qml/main.qml b/qml/main.qml index 8a71ef2c1..236497340 100644 --- a/qml/main.qml +++ b/qml/main.qml @@ -87,14 +87,6 @@ Kirigami.ApplicationWindow { root.requestActivate() } - TrayIcon { - id: trayIcon - visible: true - iconSource: ":/assets/img/icon.png" - isOnline: true - onShowWindow: root.showWindow() - } - contextDrawer: RoomDrawer { id: contextDrawer enabled: roomManager.hasOpenRoom @@ -177,6 +169,8 @@ Kirigami.ApplicationWindow { } onGlobalErrorOccured: showPassiveNotification(error + ": " + detail) + + onShowWindow: root.showWindow() } RoomListModel { diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index cddcdb54f..98f51a7c6 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -8,7 +8,6 @@ add_executable(neochat roomlistmodel.cpp neochatroom.cpp neochatuser.cpp - trayicon.cpp userlistmodel.cpp publicroomlistmodel.cpp userdirectorylistmodel.cpp @@ -19,6 +18,10 @@ add_executable(neochat ../res.qrc ) +if(NOT ANDROID) + target_sources(neochat PRIVATE trayicon.cpp) +endif() + target_include_directories(neochat PRIVATE ${CMAKE_BINARY_DIR}) target_link_libraries(neochat PRIVATE Qt5::Quick Qt5::Qml Qt5::Gui Qt5::Network Qt5::QuickControls2 KF5::I18n KF5::Kirigami2 KF5::Notifications KF5::ConfigCore KF5::ConfigGui KF5::CoreAddons Quotient cmark::cmark) kconfig_add_kcfg_files(neochat GENERATE_MOC neochatconfig.kcfgc) diff --git a/src/controller.cpp b/src/controller.cpp index 8d3e1e8db..07c73da21 100644 --- a/src/controller.cpp +++ b/src/controller.cpp @@ -46,6 +46,10 @@ #include "settings.h" #include "utils.h" +#ifndef Q_OS_ANDROID +#include "trayicon.h" +#endif + Controller::Controller(QObject *parent) : QObject(parent) { @@ -54,6 +58,14 @@ Controller::Controller(QObject *parent) Connection::setRoomType(); Connection::setUserType(); +#ifndef Q_OS_ANDROID + TrayIcon *trayIcon = new TrayIcon(this); + connect(trayIcon, &TrayIcon::showWindow, this, &Controller::showWindow); + trayIcon->setVisible(true); + trayIcon->setIconSource(":/assets/img/icon.png"); + trayIcon->setIsOnline(true); +#endif + QTimer::singleShot(0, this, [=] { invokeLogin(); }); diff --git a/src/controller.h b/src/controller.h index 45ac83dfb..41956b74b 100644 --- a/src/controller.h +++ b/src/controller.h @@ -102,6 +102,7 @@ Q_SIGNALS: void activeConnectionChanged(); void aboutDataChanged(); void passwordStatus(Controller::PasswordStatus status); + void showWindow(); public Q_SLOTS: void logout(Quotient::Connection *conn, bool serverSideLogout); diff --git a/src/main.cpp b/src/main.cpp index 1f63a3ce7..689c4b607 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -33,7 +33,6 @@ #include "room.h" #include "roomlistmodel.h" #include "sortfilterroomlistmodel.h" -#include "trayicon.h" #include "userdirectorylistmodel.h" #include "userlistmodel.h" #include "neochatconfig.h" @@ -72,7 +71,6 @@ int main(int argc, char *argv[]) qmlRegisterType("org.kde.neochat", 1, 0, "PublicRoomListModel"); qmlRegisterType("org.kde.neochat", 1, 0, "UserDirectoryListModel"); qmlRegisterType("org.kde.neochat", 1, 0, "EmojiModel"); - qmlRegisterType("org.kde.neochat", 1, 0, "TrayIcon"); qmlRegisterType("org.kde.neochat", 1, 0, "SortFilterRoomListModel"); qmlRegisterUncreatableType("org.kde.neochat", 1, 0, "RoomMessageEvent", "ENUM"); qmlRegisterUncreatableType("org.kde.neochat", 1, 0, "RoomType", "ENUM");