X-Git-Url: https://git.quassel-irc.org/?p=quassel.git;a=blobdiff_plain;f=src%2Fuisupport%2Fgraphicalui.h;h=dcd03942ee3fb47b05315c7543b4236ff7cdcaf6;hp=6d6306eda383b0b0fb8c0b9b04b9d9f98a3ec977;hb=c64a887d0f05222590299fb2bb8d56fa9fadb16d;hpb=4476cfb22f36ad9ba96e4978c3bcce1c2f6b5a04 diff --git a/src/uisupport/graphicalui.h b/src/uisupport/graphicalui.h index 6d6306ed..dcd03942 100644 --- a/src/uisupport/graphicalui.h +++ b/src/uisupport/graphicalui.h @@ -1,5 +1,5 @@ /*************************************************************************** - * Copyright (C) 2005-09 by the Quassel Project * + * Copyright (C) 2005-2012 by the Quassel Project * * devel@quassel-irc.org * * * * This program is free software; you can redistribute it and/or modify * @@ -15,7 +15,7 @@ * 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., * - * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * ***************************************************************************/ #ifndef GRAPHICALUI_H_ @@ -32,83 +32,96 @@ class UiStyle; # include #endif -class GraphicalUi : public AbstractUi { - Q_OBJECT +class GraphicalUi : public AbstractUi +{ + Q_OBJECT public: - GraphicalUi(QObject *parent = 0); - virtual void init(); + GraphicalUi(QObject *parent = 0); + virtual void init(); - //! Access global ActionCollections. - /** These ActionCollections are associated with the main window, i.e. they contain global - * actions (and thus, shortcuts). Widgets providing application-wide shortcuts should - * create appropriate Action objects using GraphicalUi::actionCollection(cat)->add\(). - * @param category The category (default: "General") - */ - static ActionCollection *actionCollection(const QString &category = "General"); + //! Access global ActionCollections. + /** These ActionCollections are associated with the main window, i.e. they contain global + * actions (and thus, shortcuts). Widgets providing application-wide shortcuts should + * create appropriate Action objects using GraphicalUi::actionCollection(cat)->add\(). + * @param category The category (default: "General") + */ + static ActionCollection *actionCollection(const QString &category = "General", const QString &translatedCategory = QString()); + static QHash actionCollections(); - inline static ContextMenuActionProvider *contextMenuActionProvider(); - inline static ToolBarActionProvider *toolBarActionProvider(); - inline static UiStyle *uiStyle(); - inline static QWidget *mainWidget(); + //! Load custom shortcuts from ShortcutSettings + /** @note This method assumes that all configurable actions are defined when being called + */ + static void loadShortcuts(); - //! Force the main widget to the front and focus it (may not work in all window systems) - static void activateMainWidget(); + //! Save custom shortcuts to ShortcutSettings + static void saveShortcuts(); - //! Hide main widget (storing the current desktop if possible) - static void hideMainWidget(); + inline static ContextMenuActionProvider *contextMenuActionProvider(); + inline static ToolBarActionProvider *toolBarActionProvider(); + inline static UiStyle *uiStyle(); + inline static QWidget *mainWidget(); - //! Toggle main widget - static void toggleMainWidget(); + //! Force the main widget to the front and focus it (may not work in all window systems) + static void activateMainWidget(); - //! Check if the main widget if (fully, in KDE) visible - static bool isMainWidgetVisible(); + //! Hide main widget (storing the current desktop if possible) + static void hideMainWidget(); + + //! Toggle main widget + static void toggleMainWidget(); + + //! Check if the main widget if (fully, in KDE) visible + static bool isMainWidgetVisible(); protected: - //! This is the widget we associate global actions with, typically the main window - void setMainWidget(QWidget *); + //! This is the widget we associate global actions with, typically the main window + void setMainWidget(QWidget *); + + //! Check if the mainWidget is visible and optionally toggle its visibility + /** With KDE integration, we check if the mainWidget is (partially) obscured in order to determine if + * it should be activated or hidden. Without KDE, we need to resort to checking the current state + * as Qt knows it, ignoring windows covering it. + * @param performToggle If true, toggle the window's state in addition to checking visibility + * @return True, if the window is currently *not* visible (needs activation) + */ + bool checkMainWidgetVisibility(bool performToggle); - //! Check if the mainWidget is visible and optionally toggle its visibility - /** With KDE integration, we check if the mainWidget is (partially) obscured in order to determine if - * it should be activated or hidden. Without KDE, we need to resort to checking the current state - * as Qt knows it, ignoring windows covering it. - * @param performToggle If true, toggle the window's state in addition to checking visibility - * @return True, if the window is currently *not* visible (needs activation) - */ - bool checkMainWidgetVisibility(bool performToggle); + //! Minimize to or restore main widget + virtual void minimizeRestore(bool show); - //! Minimize to or restore main widget - virtual void minimizeRestore(bool show); + //! Whether it is allowed to hide the mainWidget + /** The default implementation returns false, meaning that we won't hide the mainWidget even + * if requested. This is to prevent hiding in case we don't have a tray icon to restore from. + */ + virtual inline bool isHidingMainWidgetAllowed() const; - //! Whether it is allowed to hide the mainWidget - /** The default implementation returns false, meaning that we won't hide the mainWidget even - * if requested. This is to prevent hiding in case we don't have a tray icon to restore from. - */ - virtual inline bool isHidingMainWidgetAllowed() const; + void setContextMenuActionProvider(ContextMenuActionProvider *); + void setToolBarActionProvider(ToolBarActionProvider *); + void setUiStyle(UiStyle *); - void setContextMenuActionProvider(ContextMenuActionProvider *); - void setToolBarActionProvider(ToolBarActionProvider *); - void setUiStyle(UiStyle *); + virtual bool eventFilter(QObject *obj, QEvent *event); - virtual bool eventFilter(QObject *obj, QEvent *event); +protected slots: + virtual void disconnectedFromCore(); private: - static inline GraphicalUi *instance(); + static inline GraphicalUi *instance(); - static GraphicalUi *_instance; - static QWidget *_mainWidget; - static QHash _actionCollections; - static ContextMenuActionProvider *_contextMenuActionProvider; - static ToolBarActionProvider *_toolBarActionProvider; - static UiStyle *_uiStyle; - static bool _onAllDesktops; + static GraphicalUi *_instance; + static QWidget *_mainWidget; + static QHash _actionCollections; + static ContextMenuActionProvider *_contextMenuActionProvider; + static ToolBarActionProvider *_toolBarActionProvider; + static UiStyle *_uiStyle; + static bool _onAllDesktops; #ifdef Q_WS_WIN - DWORD _dwTickCount; + DWORD _dwTickCount; #endif - }; + // inlines GraphicalUi *GraphicalUi::instance() { return _instance; }