Use KMainWindow if KF5 integration is enabled.
authorManuel Nickschas <sputnick@quassel-irc.org>
Sun, 8 Feb 2015 23:58:49 +0000 (00:58 +0100)
committerManuel Nickschas <sputnick@quassel-irc.org>
Sun, 8 Feb 2015 23:58:49 +0000 (00:58 +0100)
With this commit, Quassel uses a proper KMainWindow if KF5 integration
is enabled. This works pretty much like the KDE4 version, so we just had
to add the appropriate #includes and adapt the #ifdefs.

CMakeLists.txt
src/qtui/CMakeLists.txt
src/qtui/mainwin.cpp
src/qtui/mainwin.h

index 956f647..1cd2cca 100644 (file)
@@ -262,23 +262,17 @@ if (USE_QT5)
         endif()
 
         if (WITH_KDE)
-            find_package(KF5CoreAddons QUIET)
-            set_package_properties(KF5CoreAddons PROPERTIES TYPE REQUIRED
-                URL "http://inqlude.org/libraries/kcoreaddons.html"
-                DESCRIPTION "framework for solving common problems such as caching, randomization, and more"
-                PURPOSE     "Required for KDE Frameworks integration"
-            )
-
-            find_package(KF5TextWidgets QUIET)
-            set_package_properties(KF5TextWidgets PROPERTIES TYPE REQUIRED
-                URL "http://inqlude.org/libraries/ktextwidgets.html"
-                DESCRIPTION "framework providing an assortment of widgets for displaying and editing text"
-                PURPOSE     "Allows to use extra features provided by KDE Frameworks in input widgets"
+            find_package(KF5 COMPONENTS ConfigWidgets CoreAddons TextWidgets XmlGui QUIET)
+            set_package_properties(KF5 PROPERTIES TYPE REQUIRED
+                URL "http://www.kde.org"
+                DESCRIPTION "KDE Frameworks"
+                PURPOSE     "Required for integration into the Plasma desktop"
             )
 
         endif()
 
     endif(BUILD_GUI)
+
     if (BUILD_CORE)
         find_package(Qt5Script QUIET)
         set_package_properties(Qt5Script PROPERTIES TYPE REQUIRED
@@ -303,6 +297,7 @@ if (USE_QT5)
                            DESCRIPTION "contains tools for handling translation files"
                            PURPOSE "Required for having translations"
     )
+
     # Some Qt5 versions do not define a target for lconvert, so we need to find it ourselves
     if (Qt5LinguistTools_FOUND)
         if (NOT TARGET Qt5::lconvert AND TARGET Qt5::lrelease)
index c9274a2..f54c00e 100644 (file)
@@ -81,13 +81,17 @@ set(FORMS
 set(LIBS )
 set(QT_MODULES )
 
-if (KDE4_FOUND)
+if (WITH_KDE4)
     add_definitions(-DHAVE_KDE ${KDE4_DEFINITIONS})
     include_directories(${KDE4_INCLUDES})
     list(APPEND SOURCES knotificationbackend.cpp)
     list(APPEND LIBS ${KDE4_KDECORE_LIBS} ${KDE4_KDEUI_LIBRARY} ${KDE4_KNOTIFYCONFIG_LIBRARY})
 endif()
 
+if (WITH_KF5)
+    list(APPEND LIBS KF5::ConfigWidgets KF5::XmlGui)
+endif()
+
 if (LIBSNORE_FOUND)
     add_definitions(-DHAVE_LIBSNORE)
     include_directories(${LIBSNORE_INCLUDE_DIRS})
index cd4a5fe..b64a0d9 100644 (file)
 #  include <KWindowSystem>
 #endif
 
+#ifdef HAVE_KF5
+#  include <KConfigWidgets/KStandardAction>
+#  include <KXmlGui/KHelpMenu>
+#endif
+
 #ifdef Q_WS_X11
 #  include <QX11Info>
 #endif
 #endif
 
 MainWin::MainWin(QWidget *parent)
-#ifdef HAVE_KDE4
-    : KMainWindow(parent),
-    _kHelpMenu(new KHelpMenu(this, KGlobal::mainComponent().aboutData())),
+#ifdef HAVE_KDE
+    : KMainWindow(parent), _kHelpMenu(new KHelpMenu(this)),
 #else
     : QMainWindow(parent),
 #endif
@@ -249,7 +253,7 @@ void MainWin::init()
 
     setDisconnectedState(); // Disable menus and stuff
 
-#ifdef HAVE_KDE4
+#ifdef HAVE_KDE
     setAutoSaveSettings();
 #endif
 
@@ -295,7 +299,7 @@ void MainWin::saveStateToSettings(UiSettings &s)
     if (lastBufId.isValid())
         s.setValue("LastUsedBufferId", lastBufId.toInt());
 
-#ifdef HAVE_KDE4
+#ifdef HAVE_KDE
     saveAutoSaveSettings();
 #endif
 }
@@ -307,7 +311,7 @@ void MainWin::restoreStateFromSettings(UiSettings &s)
     _normalPos = s.value("MainWinPos", pos()).toPoint();
     bool maximized = s.value("MainWinMaximized", false).toBool();
 
-#ifndef HAVE_KDE4
+#ifndef HAVE_KDE
     restoreGeometry(s.value("MainWinGeometry").toByteArray());
 
     if (maximized) {
@@ -396,14 +400,14 @@ void MainWin::setupActions()
     configureShortcutsAct->setMenuRole(QAction::NoRole);
     coll->addAction("ConfigureShortcuts", configureShortcutsAct);
 
-  #ifdef Q_OS_MAC
+#ifdef Q_OS_MAC
     QAction *configureQuasselAct = new Action(QIcon::fromTheme("configure"), tr("&Configure Quassel..."), coll,
         this, SLOT(showSettingsDlg()));
     configureQuasselAct->setMenuRole(QAction::PreferencesRole);
-  #else
+#else
     QAction *configureQuasselAct = new Action(QIcon::fromTheme("configure"), tr("&Configure Quassel..."), coll,
         this, SLOT(showSettingsDlg()), QKeySequence(Qt::Key_F7));
-  #endif
+#endif
     coll->addAction("ConfigureQuassel", configureQuasselAct);
 
     // Help
@@ -551,8 +555,9 @@ void MainWin::setupMenus()
     _settingsMenu->addAction(coll->action("ConfigureQuassel"));
 
     _helpMenu = menuBar()->addMenu(tr("&Help"));
+
     _helpMenu->addAction(coll->action("AboutQuassel"));
-#ifndef HAVE_KDE4
+#ifndef HAVE_KDE
     _helpMenu->addAction(coll->action("AboutQt"));
 #else
     _helpMenu->addAction(KStandardAction::aboutKDE(_kHelpMenu, SLOT(aboutKDE()), this));
index 30e5726..f7d279d 100644 (file)
  *   51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.         *
  ***************************************************************************/
 
-#ifndef MAINWIN_H_
-#define MAINWIN_H_
+#pragma once
 
 #ifdef HAVE_KDE4
 #  include <KMainWindow>
+#elif defined HAVE_KF5
+#  include <KXmlGui/KMainWindow>
 #else
 #  include <QMainWindow>
 #endif
@@ -56,11 +57,10 @@ class KHelpMenu;
 
 //!\brief The main window of Quassel's QtUi.
 class MainWin
-#ifdef HAVE_KDE4
-    : public KMainWindow
-{
+#ifdef HAVE_KDE
+    : public KMainWindow {
 #else
-: public QMainWindow {
+    : public QMainWindow {
 #endif
     Q_OBJECT
 
@@ -169,7 +169,7 @@ signals:
     void disconnectFromCore();
 
 private:
-#ifdef HAVE_KDE4
+#ifdef HAVE_KDE
     KHelpMenu *_kHelpMenu;
 #endif
 
@@ -220,6 +220,3 @@ private:
 
     friend class QtUi;
 };
-
-
-#endif