File indexing completed on 2024-04-28 15:51:42

0001 /*
0002     SPDX-FileCopyrightText: 2019-2021 David Hurka <david.hurka@mailbox.org>
0003 
0004     SPDX-License-Identifier: GPL-2.0-or-later
0005 */
0006 
0007 #ifndef COLORMODEMENU_H
0008 #define COLORMODEMENU_H
0009 
0010 #include "toggleactionmenu.h"
0011 
0012 class KActionCollection;
0013 class KToggleAction;
0014 
0015 /**
0016  * Color Mode menu. Allows to change Okular::Settings::RenderMode from the toolbar.
0017  *
0018  * The toolbar button will always show the last selected color mode (except normal mode),
0019  * so it can be quickly enabled and disabled by just clicking the button.
0020  * Clicking on the menu arrow opens a menu with all color modes (including normal mode),
0021  * and an action to configure the color modes.
0022  *
0023  * Every color mode actions is available in the action collection, in addition to this menu itself.
0024  *
0025  * Color mode actions are enabled/disabled automatically when this menu is enabled/disabled.
0026  */
0027 class ColorModeMenu : public ToggleActionMenu
0028 {
0029     Q_OBJECT
0030 
0031 public:
0032     explicit ColorModeMenu(KActionCollection *ac, QObject *parent);
0033 
0034 protected:
0035     /** Makes color mode actions exclusive */
0036     QActionGroup *m_colorModeActionGroup;
0037 
0038     KToggleAction *m_aNormal;
0039     KToggleAction *m_aPaperColor;
0040     KToggleAction *m_aDarkLight;
0041 
0042     /** Allows to set a shortcut to toggle the Change Colors feature. */
0043     KToggleAction *m_aChangeColors;
0044 
0045 protected Q_SLOTS:
0046     /**
0047      * Sets the color mode (render mode) to the one represented by @p action.
0048      *
0049      * If @p action represents the current mode, toggles the Change Colors feature.
0050      */
0051     void slotColorModeActionTriggered(QAction *action);
0052 
0053     /**
0054      * Sets the change colors feature on or off.
0055      */
0056     void slotSetChangeColors(bool on);
0057 
0058     /**
0059      * Updates the default action and the checked states of the color mode menu.
0060      *
0061      * Call this when the color mode was changed or Change Colors was toggled.
0062      */
0063     void slotConfigChanged();
0064 
0065     /**
0066      * Updates child actions as necessary
0067      */
0068     void slotChanged();
0069 };
0070 
0071 #endif // COLORMODEMENU_H