From: Manuel Nickschas Date: Sun, 8 Feb 2015 23:58:49 +0000 (+0100) Subject: Use KMainWindow if KF5 integration is enabled. X-Git-Tag: 0.12-beta1~17 X-Git-Url: https://git.quassel-irc.org/?p=quassel.git;a=commitdiff_plain;h=30b77d8f6e230f97e706e5a6630add16b88bda3f Use KMainWindow if KF5 integration is enabled. 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. --- diff --git a/CMakeLists.txt b/CMakeLists.txt index 956f6476..1cd2ccab 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -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) diff --git a/src/qtui/CMakeLists.txt b/src/qtui/CMakeLists.txt index c9274a22..f54c00e0 100644 --- a/src/qtui/CMakeLists.txt +++ b/src/qtui/CMakeLists.txt @@ -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}) diff --git a/src/qtui/mainwin.cpp b/src/qtui/mainwin.cpp index cd4a5fe1..b64a0d93 100644 --- a/src/qtui/mainwin.cpp +++ b/src/qtui/mainwin.cpp @@ -38,6 +38,11 @@ # include #endif +#ifdef HAVE_KF5 +# include +# include +#endif + #ifdef Q_WS_X11 # include #endif @@ -145,9 +150,8 @@ #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)); diff --git a/src/qtui/mainwin.h b/src/qtui/mainwin.h index 30e57269..f7d279d5 100644 --- a/src/qtui/mainwin.h +++ b/src/qtui/mainwin.h @@ -18,11 +18,12 @@ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * ***************************************************************************/ -#ifndef MAINWIN_H_ -#define MAINWIN_H_ +#pragma once #ifdef HAVE_KDE4 # include +#elif defined HAVE_KF5 +# include #else # include #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