diff --git a/app/SettingsBase.h b/app/SettingsBase.h index be392a89..763cdeea 100644 --- a/app/SettingsBase.h +++ b/app/SettingsBase.h @@ -1,96 +1,96 @@ /*************************************************************************** * Copyright (C) 2009 by Ben Cooksley * * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * * the Free Software Foundation; either version 2 of the License, or * * (at your option) any later version. * * * * This program is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU General Public License for more details. * * * * You should have received a copy of the GNU General Public License * * along with this program; if not, write to the * * Free Software Foundation, Inc., * * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA * ***************************************************************************/ #ifndef SETTINGS_BASE_H #define SETTINGS_BASE_H #include "MenuItem.h" #include "BaseMode.h" #include "tooltipmanager.h" #include "ui_configDialog.h" #include #include #include #include #include #include #include #include class SettingsBase : public KXmlGuiWindow { Q_OBJECT public: explicit SettingsBase(QWidget * parent = nullptr); - ~SettingsBase(); - bool queryClose() Q_DECL_OVERRIDE; + ~SettingsBase() override; + bool queryClose() override; protected: - QSize sizeHint() const Q_DECL_OVERRIDE; + QSize sizeHint() const override; private Q_SLOTS: void initApplication(); void initToolBar(); void initHelpMenu(); void initConfig(); void initMenuList(MenuItem * parent); void configUpdated(); void configShow(); void about(); void changePlugin(); void viewChange(bool state); void updateViewActions(); void changeToolBar( BaseMode::ToolBarItems toolbar ); void changeAboutMenu( const KAboutData * menuAbout, QAction * menuItem, QString fallback ); private: // The plugins QMap possibleViews; QList tooltipManagers; BaseMode * activeView = nullptr; // The search bar KLineEdit * searchText = nullptr; QWidget * spacerWidget = nullptr; // The toolbar QWidgetAction * searchAction = nullptr; QWidgetAction * spacerAction = nullptr; QAction * configureAction = nullptr; QAction * quitAction = nullptr; // The help menu QAction * aboutViewAction = nullptr; QAction * aboutModuleAction = nullptr; KActionMenu * helpActionMenu = nullptr; // The configuration KConfigDialog * configDialog = nullptr; Ui::ConfigDialog configWidget; QButtonGroup viewSelection; // The control module QStackedWidget * stackedWidget = nullptr; // The module list MenuItem * rootModule = nullptr; MenuItem * lostFound = nullptr; KService::List categories; KService::List modules; // The about dialog KAboutApplicationDialog * aboutDialog = nullptr; }; #endif diff --git a/app/SystemSettingsApp.h b/app/SystemSettingsApp.h index 8dcd41af..d0f227b5 100644 --- a/app/SystemSettingsApp.h +++ b/app/SystemSettingsApp.h @@ -1,49 +1,49 @@ /** * Copyright (C) 2009 Ben Cooksley * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Library General Public License for more details. * * You should have received a copy of the GNU Library General Public License * along with this library; see the file COPYING.LIB. If not, write to * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, * Boston, MA 02110-1301, USA. */ /** * Any changes to this header file need to have the following command executed afterwards to regenerate the dbus interface * qdbuscpp2xml SystemSettingsApp.h -o org.kde.systemsettings.xml */ #ifndef SYSTEMSETTINGSAPP_H #define SYSTEMSETTINGSAPP_H #include #include "SettingsBase.h" class SystemSettingsApp : public QApplication { Q_OBJECT public: SystemSettingsApp(int& argc, char* argv[]); - ~SystemSettingsApp(); + ~SystemSettingsApp() override; void setMainWindow(SettingsBase * main); public Q_SLOTS: Q_SCRIPTABLE void quit(); private: SettingsBase * window = nullptr; }; #endif diff --git a/app/ToolTips/tooltipmanager.h b/app/ToolTips/tooltipmanager.h index 99774467..253ff4a9 100644 --- a/app/ToolTips/tooltipmanager.h +++ b/app/ToolTips/tooltipmanager.h @@ -1,74 +1,74 @@ /******************************************************************************* * Copyright (C) 2008 by Konstantin Heil * * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * * the Free Software Foundation; either version 2 of the License, or * * (at your option) any later version. * * * * This program is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU General Public License for more details. * * * * You should have received a copy of the GNU General Public License * * along with this program; if not, write to the * * Free Software Foundation, Inc., * * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * *******************************************************************************/ #ifndef TOOLTIPMANAGER_H #define TOOLTIPMANAGER_H #include #include class QLayout; class QAbstractItemView; /** * @brief Manages the tooltips for an item view. * * When hovering an item, a tooltip is shown after * a short timeout. The tooltip is hidden again when the * viewport is hovered or the item view has been left. */ class ToolTipManager : public QObject { Q_OBJECT public: /** * Standard constructor. The ToolTipManager will start handling ToolTip events on the provided * view immediately. * * @param parent The view which will have the tooltips displayed for. */ explicit ToolTipManager(QAbstractItemView* parent); - virtual ~ToolTipManager(); + ~ToolTipManager() override; public Q_SLOTS: /** * Hides the currently shown tooltip. Invoking this method is * only needed when the tooltip should be hidden although * an item is hovered. */ void hideToolTip(); protected: - bool eventFilter(QObject* watched, QEvent* event) Q_DECL_OVERRIDE; + bool eventFilter(QObject* watched, QEvent* event) override; private Q_SLOTS: void prepareToolTip(); void requestToolTip(const QModelIndex& index); private: void showToolTip( QModelIndex menuItem ); QWidget * createTipContent( QModelIndex item ); QLayout * generateToolTipLine( QModelIndex * item, QWidget * toolTip, QSize iconSize, bool comment ); class Private; ToolTipManager::Private* d; }; #endif diff --git a/classic/CategoryList.h b/classic/CategoryList.h index 447309af..fcebab72 100644 --- a/classic/CategoryList.h +++ b/classic/CategoryList.h @@ -1,52 +1,52 @@ /* Copyright (c) 2000,2001 Matthias Elter This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #ifndef CATEGORYLIST_H #define CATEGORYLIST_H #include class QModelIndex; class QAbstractItemModel; class CategoryList : public QWidget { Q_OBJECT public: explicit CategoryList( QWidget *parent, QAbstractItemModel *model ); - virtual ~CategoryList(); + ~CategoryList() override; void changeModule( const QModelIndex &newItem); Q_SIGNALS: void moduleSelected( const QModelIndex &itemSelected ); private Q_SLOTS: void slotModuleLinkClicked( const QUrl& moduleName ); private: void updatePixmap(); private: class Private; Private *const d; }; #endif diff --git a/classic/ClassicMode.h b/classic/ClassicMode.h index fa88817e..b827bb80 100644 --- a/classic/ClassicMode.h +++ b/classic/ClassicMode.h @@ -1,66 +1,66 @@ /************************************************************************** * Copyright (C) 2009 Ben Cooksley * * * * This program is free software; you can redistribute it and/or * * modify it under the terms of the GNU General Public License * * as published by the Free Software Foundation; either version 2 * * of the License, or (at your option) any later version. * * * * This program is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU General Public License for more details. * * * * You should have received a copy of the GNU General Public License * * along with this program; if not, write to the Free Software * * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA * * 02110-1301, USA. * ***************************************************************************/ #ifndef CLASSICMODE_H #define CLASSICMODE_H #include "BaseMode.h" class MenuItem; class ModuleView; class QModelIndex; class ClassicMode : public BaseMode { Q_OBJECT public: ClassicMode(QObject * parent, const QVariantList& ); - ~ClassicMode(); - void initEvent() Q_DECL_OVERRIDE; - void leaveModuleView() Q_DECL_OVERRIDE; - QWidget * mainWidget() Q_DECL_OVERRIDE; - KAboutData * aboutData() Q_DECL_OVERRIDE; - ModuleView * moduleView() const Q_DECL_OVERRIDE; + ~ClassicMode() override; + void initEvent() override; + void leaveModuleView() override; + QWidget * mainWidget() override; + KAboutData * aboutData() override; + ModuleView * moduleView() const override; protected: - QList views() const Q_DECL_OVERRIDE; - bool eventFilter(QObject* watched, QEvent* event) Q_DECL_OVERRIDE; + QList views() const override; + bool eventFilter(QObject* watched, QEvent* event) override; public Q_SLOTS: void expandColumns(); - void searchChanged( const QString& text ) Q_DECL_OVERRIDE; + void searchChanged( const QString& text ) override; void selectModule( const QModelIndex& selectedModule ); void changeModule( const QModelIndex& activeModule ); - void saveState() Q_DECL_OVERRIDE; - void giveFocus() Q_DECL_OVERRIDE; - void addConfiguration( KConfigDialog * config ) Q_DECL_OVERRIDE; - void loadConfiguration() Q_DECL_OVERRIDE; - void saveConfiguration() Q_DECL_OVERRIDE; + void saveState() override; + void giveFocus() override; + void addConfiguration( KConfigDialog * config ) override; + void loadConfiguration() override; + void saveConfiguration() override; private Q_SLOTS: void moduleLoaded(); void initWidget(); void moveUp( MenuItem * item ); private: class Private; Private *const d; }; #endif diff --git a/core/BaseData.h b/core/BaseData.h index a4ad67a6..4d162231 100644 --- a/core/BaseData.h +++ b/core/BaseData.h @@ -1,88 +1,88 @@ /*************************************************************************** * Copyright (C) 2009 Ben Cooksley * * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * * the Free Software Foundation; either version 2 of the License, or * * (at your option) any later version. * * * * This program is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU General Public License for more details. * * * * You should have received a copy of the GNU General Public License * * along with this program; if not, write to the * * Free Software Foundation, Inc., * * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA * ***************************************************************************/ #ifndef BASEDATA_H #define BASEDATA_H #include #include "systemsettingsview_export.h" class QString; class MenuItem; class KConfigGroup; /** * @brief Provides a interface sharing common data between modules in System Settings * * BaseData is a standard interface in System Settings to retrieve information that is shared between all modules. * It is a singleton, and will be automatically cleaned up. * * @author Ben Cooksley */ class SYSTEMSETTINGSVIEW_EXPORT BaseData : public QObject { Q_OBJECT Q_DISABLE_COPY(BaseData) private: explicit BaseData(); public: /** * Provides a pointer to access the shared BaseData instance in order to retrieve data. * * @returns Access to the shared instance of BaseData. */ static BaseData* instance(); /** * Normal destructor that handles cleanup. Any objects created through BaseData must be assumed * to be invalid afterwards. */ - ~BaseData(); + ~BaseData() override; /** * Provides the shared MenuItem which lists all categories and modules, for use with MenuModel. * * @returns the shared MenuItem. */ MenuItem * menuItem(); /** * Sets the MenuItem which the Singleton will return. * For internal use only. * * @param item A pointer to the MenuItem object */ void setMenuItem( MenuItem * item ); /** * Returns the configuration group by the name provided in the current applications configuration file. * * @param pluginName the name of the group that is required. * @returns The configuration group that is required. */ KConfigGroup configGroup( const QString& pluginName ); private: MenuItem * rootMenu; }; #endif diff --git a/core/BaseMode.h b/core/BaseMode.h index 48096d52..7f04c691 100644 --- a/core/BaseMode.h +++ b/core/BaseMode.h @@ -1,257 +1,257 @@ /***************************************************************************** * Copyright (C) 2009 Ben Cooksley * * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * * the Free Software Foundation; either version 2 of the License, or * * (at your option) any later version. * * * * This program is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU General Public License for more details. * * * * You should have received a copy of the GNU General Public License * * along with this program; if not, write to the * * Free Software Foundation, Inc., * * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA * *****************************************************************************/ #ifndef BASEMODE_H #define BASEMODE_H #include #include "systemsettingsview_export.h" #include class QAction; class MenuItem; class ModuleView; class KAboutData; class KConfigDialog; class KConfigGroup; class QAbstractItemView; template class QList; /** * @brief Provides a interface for System Settings views * * BaseMode is a standard interface for all plugins to System Settings to allow them to provide * their own interface to KDE control modules.\n * * The developer need only ensure that they perform all initialization of their plugin in * initEvent() to ensure that the plugin is displayed, and initial actions are loaded. * * @author Ben Cooksley * @author Mathias Soeken */ class SYSTEMSETTINGSVIEW_EXPORT BaseMode : public QObject { Q_OBJECT /** * System Settings main application is allowed privilaged access to handle tooltips */ friend class SettingsBase; public: /** * Constructs a BaseMode for use in System Settings.\n * Plugin developers should perform all initialisation in initEvent() not here. * * @param parent The parent of this BaseMode. */ explicit BaseMode( QObject * parent ); /** * Normal destructor. Plugin developers only need destroy what they created * not what is provided by BaseMode itself. */ - virtual ~BaseMode(); + ~BaseMode() override; /** * These flags are used to control the presence of the Search and Configure actions on the toolbar */ enum ToolBarItemsFlags { NoItems = 0x1, /**< The Toolbar will not have any items added by System Settings */ Search = 0x2, /**< The Toolbar will have the search bar added by System Settings */ Configure = 0x4, /**< The Toolbar will have configure added by System Settings */ Quit = 0x8 /**< The toolbar will have exit added by System Settings */ }; Q_DECLARE_FLAGS(ToolBarItems, ToolBarItemsFlags) /** * Performs internal setup.\n * Plugin developers should perform initialisation in initEvent() not here. * * @param modeService Plugins service object, used for providing extra information to System Settings. */ void init( const KService::Ptr modeService ); /** * Prepares the BaseMode for use.\n * Plugin developers should perform initialisation here, creating the Models. They should perform widget * initialisation the first time mainWidget() is called, not here. */ virtual void initEvent(); /** * Returns the widget to be displayed in the center of System Settings.\n * The widget should be created the first time this function is called. * * @warning This function is called multiple times, ensure the widget is only created once. * @returns The main widget of the plugin. */ virtual QWidget * mainWidget(); /** * Provides information about the plugin, which is used in the About dialog of System Settings.\n * This does not need to be implemented, and need only be implemented if the author * wants information about the view displayed in the About dialog. * * @returns The about data of the plugin. */ virtual KAboutData * aboutData(); /** * The state of the plugin ( position of the splitter for instance ) should be saved * to the configuration object when this is called. */ virtual void saveState(); /** * Causes the view to unload all modules in the module view, and return to their module selection state * * @warning Failure to reimplement will cause modules to not be unloaded when changing views. * This must be implemented. */ virtual void leaveModuleView(); /** * Used to give focus to the plugin. Plugin should call setFocus() on the appropriate widget * * @note Failure to reimplement will cause keyboard accessibiltity and widget focusing problems */ virtual void giveFocus(); /** * Provides access to the ModuleView the application uses to display control modules.\n * * @warning Failure to reimplement will cause modules not to be checked for configuration * changes, and for the module to not be displayed in the About dialog. It must be implemented. * @returns The ModuleView used by the plugin for handling modules. */ virtual ModuleView * moduleView() const; /** * Provides the list of actions the plugin wants System Settings to display in the toolbar when * it is loaded. This function does not need to be implemented if adding actions to the toolbar * is not required. * * @returns The list of actions the plugin provides. */ virtual QList& actionsList() const; /** * Provides the service object, which is used to retrieve information for the configuration dialog. * * @returns the service object of the plugin. */ const KService::Ptr& service() const; /** * tells the config view wether to make use of tooltips or not */ void setShowToolTips( bool show); /** * @returns true if the view should use tooltips */ bool showToolTips() const; public Q_SLOTS: /** * Called when the text in the search box changes allowing the display to be filtered. * * @warning Search will not work in the view if this function is not implemented. */ virtual void searchChanged( const QString& text ); /** * Allows views to add custom configuration pages to the System Settings configure dialog * * @warning Deleting the config object will cause System Settings to crash */ virtual void addConfiguration( KConfigDialog * config ); /** * Allows views to load their configuration before the configuration dialog is shown * Views should revert any changes that have not been saved */ virtual void loadConfiguration(); /** * Should be implmented to ensure that views settings are saved when the user confirms their changes * Views should also apply the configuration at the same time */ virtual void saveConfiguration(); Q_SIGNALS: /** * Triggers a reload of the views actions by the host application. * * @warning Actions previously contained in the list must not be destroyed before this has been emitted. */ void actionsChanged(); /** * Should be emitted when the type ( list of modules / display of module ) * of displayed view is changed. * * @param state Determines whether changes have been made in the view. * @warning Failure to emit this will result in inconsistent application headers and change state. */ void viewChanged( bool state ); /** * Causes System Settings to hide / show the toolbar items specified. * This is used to control the display of the Configure and Search actions * * @param items The items that are wanted in the toolbar */ void changeToolBarItems( BaseMode::ToolBarItems items ); protected: /** * Returns the root item of the list of categorised modules. * This is usually passed to the constructor of MenuModel. * * @warning This is shared between all views, and should not be deleted manually. * @returns The root menu item as provided by System Settings. */ MenuItem * rootItem() const; /** * Provides access to the configuration for the plugin. * * @returns The configuration group for the plugin. */ KConfigGroup& config() const; /** * Provides access to item views used by the plugin. * This is currently used to show the enhanced tooltips. * * @returns A list of pointers to item views used by the mode. * The list can be empty. */ virtual QList views() const; private: class Private; Private *const d; }; Q_DECLARE_OPERATORS_FOR_FLAGS(BaseMode::ToolBarItems) #endif diff --git a/core/ExternalAppModule.h b/core/ExternalAppModule.h index b04d5b64..9be29315 100644 --- a/core/ExternalAppModule.h +++ b/core/ExternalAppModule.h @@ -1,50 +1,50 @@ /*************************************************************************** * Copyright (C) 2009 Ben Cooksley * * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * * the Free Software Foundation; either version 2 of the License, or * * (at your option) any later version. * * * * This program is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU General Public License for more details. * * * * You should have received a copy of the GNU General Public License * * along with this program; if not, write to the * * Free Software Foundation, Inc., * * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA * ***************************************************************************/ #ifndef EXTERNALAPPMODULE_H #define EXTERNALAPPMODULE_H #include #include "ui_externalModule.h" class QShowEvent; class KCModuleInfo; class ExternalAppModule : public QWidget { Q_OBJECT public: explicit ExternalAppModule(QWidget * parent = 0, KCModuleInfo * module = 0); - ~ExternalAppModule(); + ~ExternalAppModule() override; protected: - void showEvent(QShowEvent * event) Q_DECL_OVERRIDE; + void showEvent(QShowEvent * event) override; private Q_SLOTS: void runExternal(); private: KCModuleInfo * moduleInfo; Ui::ExternalModule externalModule; bool firstShow; }; #endif diff --git a/core/MenuModel.h b/core/MenuModel.h index ec9d7865..434e04d1 100644 --- a/core/MenuModel.h +++ b/core/MenuModel.h @@ -1,172 +1,172 @@ /************************************************************************** * Copyright (C) 2009 Ben Cooksley * * Copyright (C) 2007 Will Stephenson * * * * This program is free software; you can redistribute it and/or * * modify it under the terms of the GNU General Public License * * as published by the Free Software Foundation; either version 2 * * of the License, or (at your option) any later version. * * * * This program is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU General Public License for more details. * * * * You should have received a copy of the GNU General Public License * * along with this program; if not, write to the Free Software * * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA * * 02110-1301, USA. * ***************************************************************************/ #ifndef MENUMODEL_H #define MENUMODEL_H #include #include "systemsettingsview_export.h" class MenuItem; /** * @brief Provides a menu of the MenuItem objects * * Provides a standardised model to be used with views to display the list of modules in a variety of ways.\n * It is recommended to also use this with the MenuProxyModel to provide searching * and correct ordering of modules. * * @author Ben Cooksley * @author Will Stephenson */ class SYSTEMSETTINGSVIEW_EXPORT MenuModel : public QAbstractItemModel { Q_OBJECT public: /** * Creates a MenuModel using the MenuItem specified. The MenuItem must always be valid * throughout the life of the MenuModel, otherwise it will cause crashes. * * @param menuRoot The MenuItem to use as the basis for providing information. * @param parent The QObject to use as a parent of the MenuModel. */ explicit MenuModel( MenuItem * menuRoot, QObject *parent = 0 ); /** * Destroys the MenuModel. The menuRoot will not be destroyed. */ - ~MenuModel(); + ~MenuModel() override; /** * Please see Qt QAbstractItemModel documentation for more details.\n * Provides the name, tooltip, icon, category, keywords and the internal MenuItem to views. * * @param index The QModelIndex you want information about. * @param role The information role you want information about. * @returns The data requested for the role provided from the QModelIndex provided. */ - QVariant data( const QModelIndex &index, int role ) const Q_DECL_OVERRIDE; + QVariant data( const QModelIndex &index, int role ) const override; /** * Please see Qt QAbstractItemModel documentation for more details.\n * Provides the status flags for the QModelIndex specified. * The item always has selectable and enabled for its status unless invalid. * * @returns The flags for the QModelIndex provided. */ - Qt::ItemFlags flags( const QModelIndex &index ) const Q_DECL_OVERRIDE; + Qt::ItemFlags flags( const QModelIndex &index ) const override; /** * Please see Qt QAbstractItemModel documentation for more details.\n * Provides a QModelIndex at the row and column specified who belongs to the parent specified. * * @param row Vertical position in the grid of children. * @param column Horizontal position in the grid of children. * @param parent The parent of the requested child. * @returns The QModelIndex for the item requested. */ - QModelIndex index( int row, int column, const QModelIndex &parent = QModelIndex() ) const Q_DECL_OVERRIDE; + QModelIndex index( int row, int column, const QModelIndex &parent = QModelIndex() ) const override; /** * Please see Qt QAbstractItemModel documentation for more details.\n * Provides the parent QModelIndex for the child specified. * * @param index The child of the parent. * @returns A QModelIndex for the parent. */ - QModelIndex parent( const QModelIndex &index ) const Q_DECL_OVERRIDE; + QModelIndex parent( const QModelIndex &index ) const override; /** * Please see Qt QAbstractItemModel documentation for more details.\n * Provides the number of MenuItems ( categories or modules ) that the specified parent has. * * @param parent The QModelIndex the count is performed on. * @returns The number of rows ( children ) in the parent. */ - int rowCount( const QModelIndex &parent = QModelIndex() ) const Q_DECL_OVERRIDE; + int rowCount( const QModelIndex &parent = QModelIndex() ) const override; /** * Please see Qt QAbstractItemModel documentation for more details.\n * Returns 1, the number of columns of information about a row. * * @param parent This is ignored, as the count is always 1. * @returns The number of columns ( 1 ) in the parent. */ - int columnCount( const QModelIndex &parent = QModelIndex() ) const Q_DECL_OVERRIDE; + int columnCount( const QModelIndex &parent = QModelIndex() ) const override; /** * Makes the MenuItem specified be hidden from the list, while still showing its children.\n * Children of exceptions consider their grand parents as their parent. * Parents of exceptions consider the exceptions children as theirs. * * @param exception The MenuItem to give an exception to. */ void addException( MenuItem * exception ); /** * Revokes the exception granted above. After this, the MenuItem's parents will return their children * as normal and the grand children will return their true parents, restoring normal operation. * It has no effect if the MenuItem does not have an exception. * * @param exception The MenuItem to revoke an exception from. */ void removeException( MenuItem * exception ); /** * Role used to request the keywords to filter the items when searching. */ static const int UserFilterRole; /** * Role used to request the weight of a module, used to sort the items. */ static const int UserSortRole; protected: /** * Provides the MenuItem which is used internally to provide information. * * @returns The MenuItem used internally. */ MenuItem* rootItem() const; /** * Provides a list of children of an item which has been altered by the exceptions list * * @param parent The parent of the children desired * @returns The list of children for the item specified */ QList childrenList( MenuItem * parent ) const; /** * Provides the parent of the child specified altered by the exceptions list * * @param child The child of the parent * @returns The exceptions list affected parent of the child */ MenuItem* parentItem( MenuItem * child ) const; private: class Private; Private *const d; }; #endif diff --git a/core/MenuProxyModel.h b/core/MenuProxyModel.h index 4d8f5d5b..47623e68 100644 --- a/core/MenuProxyModel.h +++ b/core/MenuProxyModel.h @@ -1,125 +1,125 @@ /************************************************************************** * Copyright (C) 2009 Ben Cooksley * * Copyright (C) 2007 Will Stephenson * * * * This program is free software; you can redistribute it and/or * * modify it under the terms of the GNU General Public License * * as published by the Free Software Foundation; either version 2 * * of the License, or (at your option) any later version. * * * * This program is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU General Public License for more details. * * * * You should have received a copy of the GNU General Public License * * along with this program; if not, write to the Free Software * * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA * * 02110-1301, USA. * ***************************************************************************/ #ifndef MENUPROXYMODEL_H #define MENUPROXYMODEL_H #include #include "systemsettingsview_export.h" /** * @brief Provides a filter model for MenuModel * * Provides a standardised model to be used with views to filter a MenuModel.\n * It automatically sorts the items appropriately depending on if it is categorised * or not. * Call setFilterRegExp(QString) with the desired text to filter to perform searching. * Items that do not match the search parameters will be disabled, not hidden. * * @author Will Stephenson * @author Ben Cooksley */ class SYSTEMSETTINGSVIEW_EXPORT MenuProxyModel : public KCategorizedSortFilterProxyModel { Q_OBJECT Q_PROPERTY(QString filterRegExp READ filterRegExp WRITE setFilterRegExp NOTIFY filterRegExpChanged) public: /** * Constructs a MenuProxyModel with the specified parent. * * @param parent The QObject to use as a parent. */ MenuProxyModel( QObject *parent = 0 ); - QHash roleNames() const Q_DECL_OVERRIDE; + QHash roleNames() const override; /** * Please see the Qt QSortFilterProxyModel documentation for further information.\n * Provides information on whether or not the QModelIndex specified by left is below right. * * @param left the QModelIndex that is being used for comparing. * @param right the QModelIndex to compare aganist. * @returns true if the left is below the right. */ - bool lessThan( const QModelIndex &left, const QModelIndex &right ) const Q_DECL_OVERRIDE; + bool lessThan( const QModelIndex &left, const QModelIndex &right ) const override; /** * Please see the KDE KCategorizedSortFilterProxyModel documentation for futher information.\n * Provides information on whether or not the QModelIndex specified by left is below right. * * @param left the QModelIndex that is being used for comparing. * @param right the QModelIndex to compare aganist. * @returns true if the left is below the right. */ - bool subSortLessThan( const QModelIndex &left, const QModelIndex &right ) const Q_DECL_OVERRIDE; + bool subSortLessThan( const QModelIndex &left, const QModelIndex &right ) const override; /** * Please see the Qt QSortFilterProxyModel documentation for futher information.\n * Provides additional filtering of the MenuModel to only show categories which contain modules. * * @param source_column Please see QSortFilterProxyModel documentation. * @param source_parent Please see QSortFilterProxyModel documentation. * @returns true if the row should be displayed, false if it should not. */ - bool filterAcceptsRow( int source_column, const QModelIndex &source_parent ) const Q_DECL_OVERRIDE; + bool filterAcceptsRow( int source_column, const QModelIndex &source_parent ) const override; /** * Please see Qt QAbstractItemModel documentation for more details.\n * Provides the status flags for the QModelIndex specified. * The item will be selectable and enabled for its status unless invalid or filtered by search terms. * * @returns The flags for the QModelIndex provided. */ - Qt::ItemFlags flags( const QModelIndex &index ) const Q_DECL_OVERRIDE; + Qt::ItemFlags flags( const QModelIndex &index ) const override; /** * Please see Qt QAbstractItemModel documentation for more details.\n * Reimplemented for internal reasons. */ void setFilterRegExp ( const QRegExp & regExp ); /** * Please see Qt QAbstractItemModel documentation for more details.\n * Reimplemented for internal reasons. */ void setFilterRegExp ( const QString & pattern ); QString filterRegExp() const; /** * makes the filter highlight matching entries instead of hiding them */ void setFilterHighlightsEntries (bool highlight ); /** * @returns the filter highlight matching entries instead of hiding them, default true */ bool filterHighlightsEntries() const; Q_SIGNALS: void filterRegExpChanged(); private: bool m_filterHighlightsEntries : 1; }; #endif diff --git a/core/ModuleView.h b/core/ModuleView.h index e82a3f21..4daa0ba3 100644 --- a/core/ModuleView.h +++ b/core/ModuleView.h @@ -1,160 +1,160 @@ /***************************************************************************** * Copyright (C) 2009 Ben Cooksley * * Copyright (C) 2009 by Mathias Soeken * * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * * the Free Software Foundation; either version 2 of the License, or * * (at your option) any later version. * * * * This program is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU General Public License for more details. * * * * You should have received a copy of the GNU General Public License * * along with this program; if not, write to the * * Free Software Foundation, Inc., * * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA * *****************************************************************************/ #ifndef MODULE_VIEW_H #define MODULE_VIEW_H #include #include #include #include "systemsettingsview_export.h" class KAboutData; class KCModuleInfo; class KCModuleProxy; class KPageWidgetItem; /** * @brief Provides a convienent way to display modules * * Provides a standardised interface for displaying multiple modules simultaneously * and provides facilities to access the current module, and to load its help, restore * default settings, save new settings and revert changes to settings * * It also provides checking for when a module has changed its configuration, and will prompt * if the user tries to change module or view if BaseMode is reimplemented correctly * * It also provides signals for active module changes, configuration changes and for when it has * been requested to close by button press * * @author Mathias Soeken * @author Ben Cooksley */ class SYSTEMSETTINGSVIEW_EXPORT ModuleView : public QWidget { Q_OBJECT public: /** * Constructs a ModuleView, with the parent specified. */ explicit ModuleView(QWidget * parent = 0); /** * Destroys the module view, along with all modules loaded, and any changes present in them. * * @warning The user will not be prompted to save changes if any exist.\n */ - ~ModuleView(); + ~ModuleView() override; /** * Provides the module information, which is used to set the caption of the window when either the * active module or configuration changes. */ KCModuleInfo * activeModule() const; /** * Provides the about data of the active module, used for the about dialog. */ const KAboutData * aboutData() const; /** * Resolves any changes in the currently active module by prompting the user if they exist. * * @returns true if the user saved or discarded changes, or there were no changes at all. * @returns false if the user canceled the module change. */ bool resolveChanges(); /** * Closes all active modules, after checking there are no active changes. * * @warning This forces all modules to be destroyed regardless of if changes exist or not * If possible, always check with resolveChanges() first. */ void closeModules(); void setFaceType(KPageView::FaceType type); KPageView::FaceType faceType() const; public Q_SLOTS: /** * Loads the module specified by menuItem.\n * If the module has children, they will all be loaded instead of the module. * * @param menuItem the QModelIndex that you want to load. Must be sourced from either MenuModel or MenuProxyModel */ void loadModule(const QModelIndex &menuItem ); /** * Will open KHelpCenter, and load the help for the active module. */ void moduleHelp(); /** * Causes the active module to reload its configuration, reverting all changes. */ void moduleLoad(); /** * Causes the active module to save its configuration, applying all changes. */ bool moduleSave(); /** * Causes the active module to revert all changes to the configuration, and return to defaults. */ void moduleDefaults(); /** * Reimplemented for internal reasons.\n */ - void keyPressEvent( QKeyEvent * event ) Q_DECL_OVERRIDE; + void keyPressEvent( QKeyEvent * event ) override; private: bool resolveChanges( KCModuleProxy *currentProxy ); void addModule( KCModuleInfo *module ); bool moduleSave( KCModuleProxy *module ); void updatePageIconHeader( KPageWidgetItem * page, bool light = false ); private Q_SLOTS: void activeModuleChanged( KPageWidgetItem* current, KPageWidgetItem* previous); void updateButtons(); void stateChanged(); Q_SIGNALS: /** * Emitted when the currently active module is changed. This occurs whenever the active module or * its configuration changes. This causes the window caption to update. */ void moduleChanged( bool state ); /** * Emitted when the ModuleView is asked to close.\n */ void closeRequest(); private: class Private; Private *const d; }; #endif diff --git a/icons/CategorizedView.h b/icons/CategorizedView.h index 4da69fbb..da483690 100644 --- a/icons/CategorizedView.h +++ b/icons/CategorizedView.h @@ -1,35 +1,35 @@ /*************************************************************************** * Copyright (C) 2009 by Rafael Fernández López * * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * * the Free Software Foundation; either version 2 of the License, or * * (at your option) any later version. * * * * This program is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU General Public License for more details. * * * * You should have received a copy of the GNU General Public License * * along with this program; if not, write to the * * Free Software Foundation, Inc., * * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA * ***************************************************************************/ #ifndef CATEGORIZEDVIEW_H #define CATEGORIZEDVIEW_H #include class CategorizedView : public KCategorizedView { public: CategorizedView( QWidget *parent = 0 ); - void setModel( QAbstractItemModel *model ) Q_DECL_OVERRIDE; + void setModel( QAbstractItemModel *model ) override; protected: - void wheelEvent(QWheelEvent *) Q_DECL_OVERRIDE; + void wheelEvent(QWheelEvent *) override; }; #endif diff --git a/icons/CategoryDrawer.h b/icons/CategoryDrawer.h index cd0ce413..f0fe63d5 100644 --- a/icons/CategoryDrawer.h +++ b/icons/CategoryDrawer.h @@ -1,45 +1,45 @@ /*************************************************************************** * Copyright (C) 2009 by Rafael Fernández López * * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * * the Free Software Foundation; either version 2 of the License, or * * (at your option) any later version. * * * * This program is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU General Public License for more details. * * * * You should have received a copy of the GNU General Public License * * along with this program; if not, write to the * * Free Software Foundation, Inc., * * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA * ***************************************************************************/ #ifndef CATEGORYDRAWER_H #define CATEGORYDRAWER_H #include class QPainter; class QModelIndex; class QStyleOption; class CategoryDrawer : public KCategoryDrawer { Q_OBJECT public: CategoryDrawer(KCategorizedView *view); void drawCategory(const QModelIndex &index, int sortRole, const QStyleOption &option, - QPainter *painter) const Q_DECL_OVERRIDE; + QPainter *painter) const override; - int categoryHeight(const QModelIndex &index, const QStyleOption &option) const Q_DECL_OVERRIDE; - int leftMargin() const Q_DECL_OVERRIDE; - int rightMargin() const Q_DECL_OVERRIDE; + int categoryHeight(const QModelIndex &index, const QStyleOption &option) const override; + int leftMargin() const override; + int rightMargin() const override; }; #endif diff --git a/icons/IconMode.h b/icons/IconMode.h index 8fb65e1a..e6872be3 100644 --- a/icons/IconMode.h +++ b/icons/IconMode.h @@ -1,62 +1,62 @@ /*************************************************************************** * Copyright (C) 2009 by Ben Cooksley * * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * * the Free Software Foundation; either version 2 of the License, or * * (at your option) any later version. * * * * This program is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU General Public License for more details. * * * * You should have received a copy of the GNU General Public License * * along with this program; if not, write to the * * Free Software Foundation, Inc., * * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA * ***************************************************************************/ #ifndef ICONMODE_H #define ICONMODE_H #include "BaseMode.h" class ModuleView; class KAboutData; class QModelIndex; class QAbstractItemView; class IconMode : public BaseMode { Q_OBJECT public: IconMode(QObject * parent, const QVariantList& ); - ~IconMode(); - QWidget * mainWidget() Q_DECL_OVERRIDE; - void initEvent() Q_DECL_OVERRIDE; - void giveFocus() Q_DECL_OVERRIDE; - void leaveModuleView() Q_DECL_OVERRIDE; - KAboutData * aboutData() Q_DECL_OVERRIDE; - ModuleView * moduleView() const Q_DECL_OVERRIDE; + ~IconMode() override; + QWidget * mainWidget() override; + void initEvent() override; + void giveFocus() override; + void leaveModuleView() override; + KAboutData * aboutData() override; + ModuleView * moduleView() const override; protected: - QList views() const Q_DECL_OVERRIDE; - bool eventFilter(QObject* watched, QEvent* event) Q_DECL_OVERRIDE; + QList views() const override; + bool eventFilter(QObject* watched, QEvent* event) override; public Q_SLOTS: - void searchChanged( const QString& text ) Q_DECL_OVERRIDE; + void searchChanged( const QString& text ) override; private Q_SLOTS: void changeModule( const QModelIndex& activeModule ); void moduleLoaded(); void backToOverview(); void initWidget(); private: class Private; Private *const d; }; #endif diff --git a/sidebar/CategorizedView.h b/sidebar/CategorizedView.h index 4da69fbb..da483690 100644 --- a/sidebar/CategorizedView.h +++ b/sidebar/CategorizedView.h @@ -1,35 +1,35 @@ /*************************************************************************** * Copyright (C) 2009 by Rafael Fernández López * * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * * the Free Software Foundation; either version 2 of the License, or * * (at your option) any later version. * * * * This program is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU General Public License for more details. * * * * You should have received a copy of the GNU General Public License * * along with this program; if not, write to the * * Free Software Foundation, Inc., * * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA * ***************************************************************************/ #ifndef CATEGORIZEDVIEW_H #define CATEGORIZEDVIEW_H #include class CategorizedView : public KCategorizedView { public: CategorizedView( QWidget *parent = 0 ); - void setModel( QAbstractItemModel *model ) Q_DECL_OVERRIDE; + void setModel( QAbstractItemModel *model ) override; protected: - void wheelEvent(QWheelEvent *) Q_DECL_OVERRIDE; + void wheelEvent(QWheelEvent *) override; }; #endif diff --git a/sidebar/CategoryDrawer.h b/sidebar/CategoryDrawer.h index cd0ce413..f0fe63d5 100644 --- a/sidebar/CategoryDrawer.h +++ b/sidebar/CategoryDrawer.h @@ -1,45 +1,45 @@ /*************************************************************************** * Copyright (C) 2009 by Rafael Fernández López * * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * * the Free Software Foundation; either version 2 of the License, or * * (at your option) any later version. * * * * This program is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU General Public License for more details. * * * * You should have received a copy of the GNU General Public License * * along with this program; if not, write to the * * Free Software Foundation, Inc., * * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA * ***************************************************************************/ #ifndef CATEGORYDRAWER_H #define CATEGORYDRAWER_H #include class QPainter; class QModelIndex; class QStyleOption; class CategoryDrawer : public KCategoryDrawer { Q_OBJECT public: CategoryDrawer(KCategorizedView *view); void drawCategory(const QModelIndex &index, int sortRole, const QStyleOption &option, - QPainter *painter) const Q_DECL_OVERRIDE; + QPainter *painter) const override; - int categoryHeight(const QModelIndex &index, const QStyleOption &option) const Q_DECL_OVERRIDE; - int leftMargin() const Q_DECL_OVERRIDE; - int rightMargin() const Q_DECL_OVERRIDE; + int categoryHeight(const QModelIndex &index, const QStyleOption &option) const override; + int leftMargin() const override; + int rightMargin() const override; }; #endif diff --git a/sidebar/SidebarDelegate.h b/sidebar/SidebarDelegate.h index c3c09541..699746da 100644 --- a/sidebar/SidebarDelegate.h +++ b/sidebar/SidebarDelegate.h @@ -1,44 +1,44 @@ /************************************************************************** * Copyright (C) 2017 Marco Martin * * * * This program is free software; you can redistribute it and/or * * modify it under the terms of the GNU General Public License * * as published by the Free Software Foundation; either version 2 * * of the License, or (at your option) any later version. * * * * This program is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU General Public License for more details. * * * * You should have received a copy of the GNU General Public License * * along with this program; if not, write to the Free Software * * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA * * 02110-1301, USA. * ***************************************************************************/ #ifndef SIDEBARDELEGATE_H #define SIDEBARDELEGATE_H #include class SidebarDelegate : public QAbstractItemDelegate { Q_OBJECT public: explicit SidebarDelegate(QObject *parent = nullptr); - ~SidebarDelegate(); + ~SidebarDelegate() override; - QSize sizeHint(const QStyleOptionViewItem &option, const QModelIndex &index) const Q_DECL_OVERRIDE; + QSize sizeHint(const QStyleOptionViewItem &option, const QModelIndex &index) const override; - void paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const Q_DECL_OVERRIDE; + void paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const override; protected: void initStyleOption(QStyleOptionViewItem *option, const QModelIndex &index) const; QBrush foregroundBrush(const QStyleOptionViewItem &option, const QModelIndex &index) const; }; #endif diff --git a/sidebar/SidebarMode.cpp b/sidebar/SidebarMode.cpp index 8cf3fb33..18aa7575 100644 --- a/sidebar/SidebarMode.cpp +++ b/sidebar/SidebarMode.cpp @@ -1,557 +1,557 @@ /************************************************************************** * Copyright (C) 2009 by Ben Cooksley * * * * This program is free software; you can redistribute it and/or * * modify it under the terms of the GNU General Public License * * as published by the Free Software Foundation; either version 2 * * of the License, or (at your option) any later version. * * * * This program is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU General Public License for more details. * * * * You should have received a copy of the GNU General Public License * * along with this program; if not, write to the Free Software * * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA * * 02110-1301, USA. * ***************************************************************************/ #include "SidebarMode.h" #include "CategoryDrawer.h" #include "CategorizedView.h" #include "MenuItem.h" #include "MenuModel.h" #include "ModuleView.h" #include "MenuProxyModel.h" #include "BaseData.h" #include "SidebarDelegate.h" #include "ToolTips/tooltipmanager.h" #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include namespace KAStats = KActivities::Stats; using namespace KAStats; using namespace KAStats::Terms; K_PLUGIN_FACTORY( SidebarModeFactory, registerPlugin(); ) FocusHackWidget::FocusHackWidget(QWidget *parent) : QWidget(parent) {} FocusHackWidget::~FocusHackWidget() {} void FocusHackWidget::focusNext() { focusNextChild(); } void FocusHackWidget::focusPrevious() { focusNextPrevChild(false); } class SubcategoryModel : public QStandardItemModel { public: explicit SubcategoryModel(QAbstractItemModel *parentModel, QObject *parent = nullptr) : QStandardItemModel(parent), m_parentModel(parentModel) {} void setParentIndex(const QModelIndex &activeModule) { blockSignals(true); //make the view receive a single signal when the new subcategory is loaded, //never make the view believe there are zero items if this is not the final count //this avoids the brief flash it had clear(); const int subRows = m_parentModel->rowCount(activeModule); if ( subRows > 1) { for (int i = 0; i < subRows; ++i) { const QModelIndex& index = m_parentModel->index(i, 0, activeModule); QStandardItem *item = new QStandardItem(m_parentModel->data(index, Qt::DecorationRole).value(), m_parentModel->data(index, Qt::DisplayRole).toString()); item->setData(index.data(Qt::UserRole), Qt::UserRole); appendRow(item); } } blockSignals(false); beginResetModel(); endResetModel(); } private: QAbstractItemModel *m_parentModel; }; class MostUsedModel : public QSortFilterProxyModel { public: explicit MostUsedModel(QObject *parent = nullptr) : QSortFilterProxyModel (parent) { sort(0, Qt::DescendingOrder); setSortRole(ResultModel::ScoreRole); setDynamicSortFilter(true); //prepare default items m_defaultModel = new QStandardItemModel(this); QStandardItem *item = new QStandardItem(); item->setData(QUrl(QStringLiteral("kcm:kcm_lookandfeel.desktop")), ResultModel::ResourceRole); m_defaultModel->appendRow(item); item = new QStandardItem(); item->setData(QUrl(QStringLiteral("kcm:user_manager.desktop")), ResultModel::ResourceRole); m_defaultModel->appendRow(item); item = new QStandardItem(); item->setData(QUrl(QStringLiteral("kcm:screenlocker.desktop")), ResultModel::ResourceRole); m_defaultModel->appendRow(item); item = new QStandardItem(); item->setData(QUrl(QStringLiteral("kcm:powerdevilprofilesconfig.desktop")), ResultModel::ResourceRole); m_defaultModel->appendRow(item); item = new QStandardItem(); item->setData(QUrl(QStringLiteral("kcm:kcm_kscreen.desktop")), ResultModel::ResourceRole); m_defaultModel->appendRow(item); } void setResultModel(ResultModel *model) { if (m_resultModel == model) { return; } auto updateModel = [this]() { if (m_resultModel->rowCount() >= 5) { setSourceModel(m_resultModel); } else { setSourceModel(m_defaultModel); } }; m_resultModel = model; connect(m_resultModel, &QAbstractItemModel::rowsInserted, this, updateModel); connect(m_resultModel, &QAbstractItemModel::rowsRemoved, this, updateModel); updateModel(); } - QHash roleNames() const + QHash roleNames() const override { QHash roleNames; roleNames.insert(Qt::DisplayRole, "display"); roleNames.insert(Qt::DecorationRole, "decoration"); roleNames.insert(ResultModel::ScoreRole, "score"); return roleNames; } QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override { MenuItem *mi; const QString desktopName = QSortFilterProxyModel::data(index, ResultModel::ResourceRole).toUrl().path(); if (m_menuItems.contains(desktopName)) { mi = m_menuItems.value(desktopName); } else { mi = new MenuItem(false, nullptr); const_cast(this)->m_menuItems.insert(desktopName, mi); KService::Ptr service = KService::serviceByStorageId(desktopName); if (!service || !service->isValid()) { return QVariant(); } mi->setService(service); } switch (role) { case Qt::UserRole: return QVariant::fromValue(mi); case Qt::DisplayRole: if (mi->service() && mi->service()->isValid()) { return mi->service()->name(); } else { return QVariant(); } case Qt::DecorationRole: if (mi->service() && mi->service()->isValid()) { return mi->service()->icon(); } else { return QVariant(); } case ResultModel::ScoreRole: return QSortFilterProxyModel::data(index, ResultModel::ScoreRole).toInt(); default: return QVariant(); } } private: QHash m_menuItems; QStandardItemModel *m_defaultModel; ResultModel *m_resultModel; }; class SidebarMode::Private { public: Private() : quickWidget( nullptr ), moduleView( nullptr ), collection( nullptr ), activeCategory( -1 ), activeSubCategory( -1 ) {} virtual ~Private() { delete aboutIcon; } ToolTipManager *toolTipManager = nullptr; QQuickWidget * quickWidget = nullptr; KPackage::Package package; SubcategoryModel * subCategoryModel = nullptr; MostUsedModel * mostUsedModel = nullptr; FocusHackWidget * mainWidget = nullptr; QQuickWidget * placeHolderWidget = nullptr; QHBoxLayout * mainLayout = nullptr; KDeclarative::KDeclarative kdeclarative; MenuProxyModel * categorizedModel = nullptr; MenuProxyModel * searchModel = nullptr; KAboutData * aboutIcon = nullptr; ModuleView * moduleView = nullptr; KActionCollection *collection = nullptr; QPersistentModelIndex activeCategoryIndex; int activeCategory; int activeSubCategory; }; SidebarMode::SidebarMode( QObject *parent, const QVariantList& ) : BaseMode( parent ) , d( new Private() ) { qApp->setAttribute(Qt::AA_DontCreateNativeWidgetSiblings); d->aboutIcon = new KAboutData( QStringLiteral("SidebarView"), i18n( "Sidebar View" ), QStringLiteral("1.0"), i18n( "Provides a categorized sidebar for control modules." ), KAboutLicense::GPL, i18n( "(c) 2017, Marco Martin" ) ); d->aboutIcon->addAuthor( i18n( "Marco Martin" ), i18n( "Author" ), QStringLiteral("mart@kde.org") ); d->aboutIcon->addAuthor( i18n( "Ben Cooksley" ), i18n( "Author" ), QStringLiteral("bcooksley@kde.org") ); d->aboutIcon->addAuthor( i18n( "Mathias Soeken" ), i18n( "Developer" ), QStringLiteral("msoeken@informatik.uni-bremen.de") ); d->aboutIcon->setProgramIconName( QStringLiteral("view-sidetree") ); qmlRegisterType(); } SidebarMode::~SidebarMode() { delete d; } KAboutData * SidebarMode::aboutData() { return d->aboutIcon; } ModuleView * SidebarMode::moduleView() const { return d->moduleView; } QWidget * SidebarMode::mainWidget() { if( !d->quickWidget ) { initWidget(); } return d->mainWidget; } QAbstractItemModel * SidebarMode::categoryModel() const { return d->searchModel; } QAbstractItemModel * SidebarMode::subCategoryModel() const { return d->subCategoryModel; } QAbstractItemModel * SidebarMode::mostUsedModel() const { return d->mostUsedModel; } QList SidebarMode::views() const { QList list; //list.append( d->categoryView ); return list; } void SidebarMode::initEvent() { MenuModel * model = new MenuModel( rootItem(), this ); foreach( MenuItem * child, rootItem()->children() ) { model->addException( child ); } d->categorizedModel = new MenuProxyModel( this ); d->categorizedModel->setCategorizedModel( true ); d->categorizedModel->setSourceModel( model ); d->categorizedModel->sort( 0 ); d->categorizedModel->setFilterHighlightsEntries( false ); d->searchModel = new MenuProxyModel( this ); d->searchModel->setFilterHighlightsEntries( false ); d->searchModel->setSourceModel( d->categorizedModel ); connect( d->searchModel, &MenuProxyModel::filterRegExpChanged, this, [this] () { if (d->activeCategoryIndex.isValid() && d->activeCategoryIndex.row() >= 0) { d->subCategoryModel->setParentIndex( d->activeCategoryIndex ); emit activeCategoryChanged(); } }); d->mostUsedModel = new MostUsedModel( this ); d->subCategoryModel = new SubcategoryModel( d->searchModel, this ); d->mainWidget = new FocusHackWidget(); d->mainWidget->installEventFilter(this); d->mainLayout = new QHBoxLayout(d->mainWidget); d->mainLayout->setContentsMargins(0, 0, 0, 0); d->moduleView = new ModuleView( d->mainWidget ); connect( d->moduleView, &ModuleView::moduleChanged, this, &SidebarMode::moduleLoaded ); d->quickWidget = 0; moduleView()->setFaceType(KPageView::Plain); } QAction *SidebarMode::action(const QString &name) const { if (!d->collection) { return nullptr; } return d->collection->action(name); } QString SidebarMode::actionIconName(const QString &name) const { if (QAction *a = action(name)) { return a->icon().name(); } return QString(); } void SidebarMode::requestToolTip(int index, const QRectF &rect) { if (showToolTips()) { d->toolTipManager->requestToolTip(d->searchModel->index(index, 0), rect.toRect()); } } void SidebarMode::hideToolTip() { d->toolTipManager->hideToolTip(); } void SidebarMode::loadMostUsed(int index) { const QModelIndex idx = d->mostUsedModel->index(index, 0); d->moduleView->closeModules(); d->moduleView->loadModule( idx ); } void SidebarMode::changeModule( const QModelIndex& activeModule ) { d->moduleView->closeModules(); const int subRows = d->searchModel->rowCount(activeModule); if ( subRows < 2) { d->moduleView->loadModule( activeModule ); } else { d->moduleView->loadModule( d->searchModel->index(0, 0, activeModule) ); } d->subCategoryModel->setParentIndex( activeModule ); } void SidebarMode::moduleLoaded() { d->placeHolderWidget->hide(); d->moduleView->show(); } int SidebarMode::activeCategory() const { return d->searchModel->mapFromSource(d->searchModel->sourceModel()->index(d->activeCategory, 0)).row(); } void SidebarMode::setActiveCategory(int cat) { const QModelIndex idx = d->searchModel->index(cat, 0); d->activeCategoryIndex = idx; const int newCategoryRow = d->searchModel->mapToSource(idx).row(); if (d->activeCategory ==newCategoryRow) { return; } d->activeCategoryIndex = idx; d->activeCategory = newCategoryRow; changeModule(idx); d->activeSubCategory = 0; emit activeCategoryChanged(); emit activeSubCategoryChanged(); } int SidebarMode::activeSubCategory() const { return d->activeSubCategory; } void SidebarMode::setActiveSubCategory(int cat) { if (d->activeSubCategory == cat) { return; } d->activeSubCategory = cat; d->moduleView->closeModules(); d->moduleView->loadModule( d->subCategoryModel->index(cat, 0) ); emit activeSubCategoryChanged(); } int SidebarMode::width() const { return d->mainWidget->width(); } void SidebarMode::initWidget() { // Create the widgets if (!KMainWindow::memberList().isEmpty()) { KXmlGuiWindow *mainWindow = qobject_cast(KMainWindow::memberList().first()); if (mainWindow) { d->collection = mainWindow->actionCollection(); } } d->quickWidget = new QQuickWidget(d->mainWidget); d->quickWidget->quickWindow()->setTitle(i18n("Sidebar")); d->quickWidget->setResizeMode(QQuickWidget::SizeRootObjectToView); d->quickWidget->engine()->rootContext()->setContextProperty(QStringLiteral("systemsettings"), this); d->package = KPackage::PackageLoader::self()->loadPackage(QStringLiteral("KPackage/GenericQML")); d->package.setPath(QStringLiteral("org.kde.systemsettings.sidebar")); d->kdeclarative.setDeclarativeEngine(d->quickWidget->engine()); d->kdeclarative.setupBindings(); d->quickWidget->setSource(QUrl::fromLocalFile(d->package.filePath("mainscript"))); const int rootImplicitWidth = d->quickWidget->rootObject()->property("implicitWidth").toInt(); if (rootImplicitWidth != 0) { d->quickWidget->setFixedWidth(rootImplicitWidth); } else { d->quickWidget->setFixedWidth(240); } connect(d->quickWidget->rootObject(), &QQuickItem::implicitWidthChanged, this, [this]() { const int rootImplicitWidth = d->quickWidget->rootObject()->property("implicitWidth").toInt(); if (rootImplicitWidth != 0) { d->quickWidget->setFixedWidth(rootImplicitWidth); } else { d->quickWidget->setFixedWidth(240); } }); connect(d->quickWidget->rootObject(), SIGNAL(focusNextRequest()), d->mainWidget, SLOT(focusNext())); connect(d->quickWidget->rootObject(), SIGNAL(focusPreviousRequest()), d->mainWidget, SLOT(focusPrevious())); d->quickWidget->installEventFilter(this); d->toolTipManager = new ToolTipManager(d->searchModel, d->quickWidget); d->placeHolderWidget = new QQuickWidget(d->mainWidget); d->placeHolderWidget->quickWindow()->setTitle(i18n("Most Used")); d->placeHolderWidget->setResizeMode(QQuickWidget::SizeRootObjectToView); d->placeHolderWidget->engine()->rootContext()->setContextObject(new KLocalizedContext(d->placeHolderWidget)); d->placeHolderWidget->engine()->rootContext()->setContextProperty(QStringLiteral("systemsettings"), this); d->placeHolderWidget->setSource(QUrl::fromLocalFile(d->package.filePath("ui", QStringLiteral("introPage.qml")))); connect(d->placeHolderWidget->rootObject(), SIGNAL(focusNextRequest()), d->mainWidget, SLOT(focusNext())); connect(d->placeHolderWidget->rootObject(), SIGNAL(focusPreviousRequest()), d->mainWidget, SLOT(focusPrevious())); d->placeHolderWidget->installEventFilter(this); d->mainLayout->addWidget( d->quickWidget ); d->moduleView->hide(); d->mainLayout->addWidget( d->moduleView ); d->mainLayout->addWidget( d->placeHolderWidget ); emit changeToolBarItems(BaseMode::NoItems); d->mostUsedModel->setResultModel(new ResultModel( AllResources | Agent(QStringLiteral("org.kde.systemsettings")) | HighScoredFirst | Limit(5), this)); } bool SidebarMode::eventFilter(QObject* watched, QEvent* event) { //FIXME: those are all workarounds around the QQuickWidget brokeness if ((watched == d->quickWidget || watched == d->placeHolderWidget) && event->type() == QEvent::KeyPress) { //allow tab navigation inside the qquickwidget QKeyEvent *ke = static_cast(event); QQuickWidget *qqw = static_cast(watched); if (ke->key() == Qt::Key_Tab || ke->key() == Qt::Key_Backtab) { QCoreApplication::sendEvent(qqw->quickWindow(), event); return true; } } else if ((watched == d->quickWidget || watched == d->placeHolderWidget) && event->type() == QEvent::FocusIn) { QFocusEvent *fe = static_cast(event); QQuickWidget *qqw = static_cast(watched); if (qqw && qqw->rootObject()) { if (fe->reason() == Qt::TabFocusReason) { QMetaObject::invokeMethod(qqw->rootObject(), "focusFirstChild"); } else if (fe->reason() == Qt::BacktabFocusReason) { QMetaObject::invokeMethod(qqw->rootObject(), "focusLastChild"); } } } else if (watched == d->quickWidget && event->type() == QEvent::Leave) { QCoreApplication::sendEvent(d->quickWidget->quickWindow(), event); } else if (watched == d->mainWidget && event->type() == QEvent::Resize) { emit widthChanged(); } else if (watched == d->mainWidget && event->type() == QEvent::Show) { emit changeToolBarItems(BaseMode::NoItems); } return BaseMode::eventFilter(watched, event); } void SidebarMode::giveFocus() { d->quickWidget->setFocus(); } #include "SidebarMode.moc" diff --git a/sidebar/SidebarMode.h b/sidebar/SidebarMode.h index 7bed567a..d10aee72 100644 --- a/sidebar/SidebarMode.h +++ b/sidebar/SidebarMode.h @@ -1,101 +1,101 @@ /*************************************************************************** * Copyright (C) 2009 by Ben Cooksley * * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * * the Free Software Foundation; either version 2 of the License, or * * (at your option) any later version. * * * * This program is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU General Public License for more details. * * * * You should have received a copy of the GNU General Public License * * along with this program; if not, write to the * * Free Software Foundation, Inc., * * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA * ***************************************************************************/ #ifndef SIDEBARMODE_H #define SIDEBARMODE_H #include "BaseMode.h" #include class ModuleView; class KAboutData; class QModelIndex; class QAbstractItemView; class QAbstractItemModel; class QAction; class FocusHackWidget : public QWidget { Q_OBJECT public: FocusHackWidget(QWidget *parent = nullptr); - ~FocusHackWidget(); + ~FocusHackWidget() override; public Q_SLOTS: void focusNext(); void focusPrevious(); }; class SidebarMode : public BaseMode { Q_OBJECT Q_PROPERTY(QAbstractItemModel *categoryModel READ categoryModel CONSTANT) Q_PROPERTY(QAbstractItemModel *subCategoryModel READ subCategoryModel CONSTANT) Q_PROPERTY(QAbstractItemModel *mostUsedModel READ mostUsedModel CONSTANT) Q_PROPERTY(int activeCategory READ activeCategory WRITE setActiveCategory NOTIFY activeCategoryChanged) Q_PROPERTY(int activeSubCategory READ activeSubCategory WRITE setActiveSubCategory NOTIFY activeSubCategoryChanged) Q_PROPERTY(int width READ width NOTIFY widthChanged) public: SidebarMode(QObject * parent, const QVariantList& ); - ~SidebarMode(); - QWidget * mainWidget() Q_DECL_OVERRIDE; - void initEvent() Q_DECL_OVERRIDE; - void giveFocus() Q_DECL_OVERRIDE; - KAboutData * aboutData() Q_DECL_OVERRIDE; - ModuleView * moduleView() const Q_DECL_OVERRIDE; + ~SidebarMode() override; + QWidget * mainWidget() override; + void initEvent() override; + void giveFocus() override; + KAboutData * aboutData() override; + ModuleView * moduleView() const override; QAbstractItemModel *categoryModel() const; QAbstractItemModel *subCategoryModel() const; QAbstractItemModel *mostUsedModel() const; int activeCategory() const; void setActiveCategory(int cat); int activeSubCategory() const; void setActiveSubCategory(int cat); int width() const; Q_INVOKABLE QAction *action(const QString &name) const; // QML doesn't understand QIcon, otherwise we could get it from the QAction itself Q_INVOKABLE QString actionIconName(const QString &name) const; Q_INVOKABLE void requestToolTip(int index, const QRectF &rect); Q_INVOKABLE void hideToolTip(); Q_INVOKABLE void loadMostUsed(int index); protected: - QList views() const Q_DECL_OVERRIDE; - bool eventFilter(QObject* watched, QEvent* event) Q_DECL_OVERRIDE; + QList views() const override; + bool eventFilter(QObject* watched, QEvent* event) override; private Q_SLOTS: void changeModule( const QModelIndex& activeModule ); void moduleLoaded(); void initWidget(); Q_SIGNALS: void activeCategoryChanged(); void activeSubCategoryChanged(); void widthChanged(); private: class Private; Private *const d; }; #endif diff --git a/sidebar/ToolTips/tooltipmanager.h b/sidebar/ToolTips/tooltipmanager.h index f5ed82a4..70323196 100644 --- a/sidebar/ToolTips/tooltipmanager.h +++ b/sidebar/ToolTips/tooltipmanager.h @@ -1,75 +1,75 @@ /******************************************************************************* * Copyright (C) 2008 by Konstantin Heil * * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * * the Free Software Foundation; either version 2 of the License, or * * (at your option) any later version. * * * * This program is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU General Public License for more details. * * * * You should have received a copy of the GNU General Public License * * along with this program; if not, write to the * * Free Software Foundation, Inc., * * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * *******************************************************************************/ #ifndef TOOLTIPMANAGER_H #define TOOLTIPMANAGER_H #include #include #include class QLayout; class QAbstractItemView; /** * @brief Manages the tooltips for an item view. * * When hovering an item, a tooltip is shown after * a short timeout. The tooltip is hidden again when the * viewport is hovered or the item view has been left. */ class ToolTipManager : public QObject { Q_OBJECT public: /** * Standard constructor. The ToolTipManager will start handling ToolTip events on the provided * view immediately. * * @param parent The view which will have the tooltips displayed for. */ explicit ToolTipManager(QAbstractItemModel *model, QWidget* parent); - virtual ~ToolTipManager(); + ~ToolTipManager() override; public Q_SLOTS: /** * Hides the currently shown tooltip. Invoking this method is * only needed when the tooltip should be hidden although * an item is hovered. */ void hideToolTip(); void requestToolTip(const QModelIndex& index, const QRect &rect); protected: - bool eventFilter(QObject* watched, QEvent* event) Q_DECL_OVERRIDE; + bool eventFilter(QObject* watched, QEvent* event) override; private Q_SLOTS: void prepareToolTip(); private: void showToolTip( QModelIndex menuItem ); QWidget * createTipContent( QModelIndex item ); QLayout * generateToolTipLine( QModelIndex * item, QWidget * toolTip, QSize iconSize, bool comment ); class Private; ToolTipManager::Private* d; }; #endif