Commit 41075e74 authored by Nicolas Fella's avatar Nicolas Fella

Don't build tray icon on Android

KStatusNotifierItem is not available on Android
parent 752d8f21
......@@ -148,7 +148,6 @@ set(viewer_SRCS
viewer/quickbutton.cpp
viewer/searchbar.cpp
viewer/irccontextmenus.cpp
viewer/trayicon.cpp
viewer/viewspringloader.cpp
viewer/channeloptionsdialog.cpp
viewer/topicedit.cpp
......@@ -160,6 +159,10 @@ set(viewer_SRCS
viewer/actioncollectionmodel.cpp
)
if(NOT ANDROID)
list(APPEND viewer_SRCS viewer/trayicon.cpp)
endif()
ki18n_wrap_ui(viewer_SRCS
viewer/channeloptionsui.ui
viewer/irccolorchooserui.ui
......@@ -268,6 +271,10 @@ if (WIN32)
target_link_libraries(konversation ws2_32) # for symbols from winsock2.h: ntohl, etc.
endif()
if (ANDROID)
target_link_libraries(konversation KF5::Kirigami2)
endif()
install(TARGETS konversation ${INSTALL_TARGETS_DEFAULT_ARGS})
add_subdirectory(qtquick)
......@@ -269,6 +269,7 @@ void Application::newInstance(QCommandLineParser *args)
m_viewListModel = new KDescendantsProxyModel(this);
m_viewListModel->setSourceModel(mainWindow->getViewContainer());
#ifndef Q_OS_ANDROID
QObject::connect(mainWindow->systemTrayIcon(), &KStatusNotifierItem::activateRequested, this,
[this](bool active, const QPoint &pos) {
Q_UNUSED(pos)
......@@ -280,6 +281,7 @@ void Application::newInstance(QCommandLineParser *args)
}
}
);
#endif
qputenv("QT_QUICK_CONTROLS_STYLE", "org.kde.desktop");
m_qmlEngine = new QQmlApplicationEngine(this);
......@@ -462,8 +464,10 @@ bool Application::loadUiPackage(const QString &packageName)
QObject::connect(m_qmlEngine->rootObjects().first(), SIGNAL(quitApp()),
mainWindow, SLOT(quitProgram()));
#ifndef Q_OS_ANDROID
QObject::connect(m_qmlEngine->rootObjects().first(), SIGNAL(endNotification()),
mainWindow->systemTrayIcon(), SLOT(endNotification()));
#endif
QObject::connect(m_qmlEngine->rootObjects().first(), SIGNAL(setStatusBarTempText(QString)),
mainWindow->getStatusBar(), SLOT(setMainLabelTempText(QString)));
......
......@@ -164,6 +164,7 @@ void AwayManager::updateGlobalAwayAction(bool away)
Application* konvApp = Application::instance();
KToggleAction* awayAction = qobject_cast<KToggleAction*>(konvApp->getMainWindow()->actionCollection()->action(QStringLiteral("toggle_away")));
#ifndef Q_OS_ANDROID
Konversation::TrayIcon* trayIcon = konvApp->getMainWindow()->systemTrayIcon();
if (!awayAction)
......@@ -193,6 +194,7 @@ void AwayManager::updateGlobalAwayAction(bool away)
awayAction->setIcon(QIcon::fromTheme(QStringLiteral("im-user-away")));
if (trayIcon) trayIcon->setAway(false);
}
#endif
}
int AwayManager::calculateRemainingTime(int identityId)
......
......@@ -59,7 +59,9 @@ MainWindow::MainWindow() : KXmlGuiWindow(nullptr) // WIPQTQUICK
m_hasDirtySettings = false;
m_closeApp = false;
m_serverListDialog = nullptr;
#ifndef Q_OS_ANDROID
m_trayIcon = nullptr;
#endif
m_settingsDialog = nullptr;
m_viewContainer = new ViewContainer(this);
......@@ -577,8 +579,10 @@ MainWindow::MainWindow() : KXmlGuiWindow(nullptr) // WIPQTQUICK
MainWindow::~MainWindow()
{
#ifndef Q_OS_ANDROID
delete m_trayIcon; // WIPQTQUICK
m_trayIcon = nullptr; // WIPQTQUICK
#endif
}
QSize MainWindow::sizeHint() const
......@@ -625,6 +629,7 @@ int MainWindow::confirmQuit()
void MainWindow::activateAndRaiseWindow()
{
#ifndef Q_OS_ANDROID
if (isMinimized())
KWindowSystem::unminimizeWindow(winId());
else if (Preferences::self()->showTrayIcon() && !isVisible())
......@@ -632,13 +637,16 @@ void MainWindow::activateAndRaiseWindow()
KWindowSystem::setOnDesktop(winId(), KWindowSystem::currentDesktop());
KWindowSystem::activateWindow(winId());
#endif
}
void MainWindow::quitProgram()
{
#ifndef Q_OS_ANDROID
if (Preferences::self()->showTrayIcon() &&
sender() != m_trayIcon &&
confirmQuit() == KMessageBox::Cancel) return;
#endif
// will call queryClose()
Application::instance()->getQuickMainWindow()->close(); // WIPQTQUICK
......@@ -654,9 +662,10 @@ bool MainWindow::queryClose()
if (!konvApp->isSavingSession())
{
#ifndef Q_OS_ANDROID
if (sender() == m_trayIcon)
m_closeApp = true;
#endif
if (Preferences::self()->showTrayIcon() && !m_closeApp)
{
bool doit = KMessageBox::warningContinueCancel(this,
......@@ -747,6 +756,7 @@ void MainWindow::resetHasDirtySettings()
void MainWindow::updateTrayIcon()
{
#ifndef Q_OS_ANDROID
if (Preferences::self()->showTrayIcon())
{
if (!m_trayIcon)
......@@ -768,6 +778,7 @@ void MainWindow::updateTrayIcon()
delete m_trayIcon;
m_trayIcon = nullptr;
}
#endif
}
void MainWindow::toggleMenubar(bool dontShowWarning)
......
......@@ -54,8 +54,9 @@ class MainWindow : public KXmlGuiWindow
ActionCollectionModel* getActionCollectionModel() { return m_actionCollectionModel; } // WIPQTQUICK
Konversation::StatusBar* getStatusBar() { return m_statusBar; } // WIPQTQUICK
bool getCloseApp() { return m_closeApp; } // WIPQTQUICK
#ifndef Q_OS_ANDROID
Konversation::TrayIcon* systemTrayIcon() const { return m_trayIcon; }
#endif
/** Some errors need to be shown, even when konversation is minimized.
*/
void focusAndShowErrorMessage(const QString &errorMsg);
......@@ -127,8 +128,9 @@ class MainWindow : public KXmlGuiWindow
ViewContainer* m_viewContainer;
Konversation::StatusBar* m_statusBar;
#ifndef Q_OS_ANDROID
Konversation::TrayIcon* m_trayIcon;
#endif
KToggleAction* m_showMenuBarAction;
KonviSettingsDialog *m_settingsDialog;
......
......@@ -191,12 +191,12 @@ namespace Konversation
return;
qDebug() << m_quickMainWindow->isActive();
#ifndef Q_OS_ANDROID
if (((!m_quickMainWindow->isActive() && !m_mainWindow->isActiveWindow())) && chatWin->getServer()->isConnected() && m_mainWindow->systemTrayIcon()) {
qDebug() << "starting";
m_mainWindow->systemTrayIcon()->startNotification();
}
#endif
}
void NotificationHandler::join(ChatWindow* chatWin, const QString& nick)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment