LCOV - code coverage report
Current view: top level - src/tools/qt-gui/src - guisettings.hpp (source / functions) Hit Total Coverage
Test: coverage-filtered.info Lines: 0 5 0.0 %
Date: 2019-09-12 12:28:41 Functions: 0 3 0.0 %

          Line data    Source code
       1             : /**
       2             :  * @file
       3             :  *
       4             :  * @brief
       5             :  *
       6             :  * @copyright BSD License (see LICENSE.md or https://www.libelektra.org)
       7             :  */
       8             : 
       9             : #ifndef GUISETTINGS_HPP
      10             : #define GUISETTINGS_HPP
      11             : 
      12             : #include <QColor>
      13             : #include <QObject>
      14             : #include <kdb.hpp>
      15             : 
      16             : /**
      17             :  * @brief The GUISettings class. It manages the settings of the GUI. At the moment the only settings are colorsettings.
      18             :  */
      19           0 : class GUISettings : public QObject
      20             : {
      21           0 :         Q_OBJECT
      22             : 
      23             :         Q_PROPERTY (QColor highlightColor READ highlightColor () WRITE setHighlightColor (QColor) NOTIFY highlightColorChanged ())
      24             :         Q_PROPERTY (QColor frameColor READ frameColor () WRITE setFrameColor (QColor) NOTIFY frameColorChanged ())
      25             :         Q_PROPERTY (QColor nodeWithKeyColor READ nodeWithKeyColor () WRITE setNodeWithKeyColor (QColor) NOTIFY nodeWithKeyColorChanged ())
      26             :         Q_PROPERTY (QColor nodeWithoutKeyColor READ nodeWithoutKeyColor () WRITE setNodeWithoutKeyColor (QColor)
      27             :                             NOTIFY nodeWithoutKeyColorChanged ())
      28             :         Q_PROPERTY (bool useSystemIconTheme READ useSystemIconTheme () WRITE useSystemIconTheme (bool) NOTIFY useSystemIconThemeChanged ())
      29             :         Q_PROPERTY (bool viewermode READ viewermode () WRITE setViewermode (bool) NOTIFY viewermodeChanged ())
      30             : 
      31             : public:
      32             :         /**
      33             :          * @brief GUISettings The default constructor
      34             :          * @param parentGUISettings
      35             :          */
      36             :         explicit GUISettings (QObject * parentGUISettings = nullptr);
      37             : 
      38             :         /**
      39             :          * @brief GUISettings The copy contructor. Mandatory.
      40             :          * @param other
      41             :          */
      42           0 :         GUISettings (GUISettings const & other)
      43           0 :         : QObject (){ Q_UNUSED (other) }
      44             : 
      45             :           /**
      46             :            * @brief highlightColor The color of the highlight bar in the views.
      47             :            * @return The color of the highlight bar in the views.
      48             :            */
      49             :           QColor highlightColor () const;
      50             : 
      51             :         /**
      52             :          * @brief frameColor The color of the window frames in the views.
      53             :          * @return The color of the window frames in the views.
      54             :          */
      55             :         QColor frameColor () const;
      56             : 
      57             :         /**
      58             :          * @brief nodeWithKeyColor The color of the ConfigNodes that contain a kdb::Key
      59             :          * @return The color of the ConfigNodes that contain a kdb::Key
      60             :          */
      61             :         QColor nodeWithKeyColor () const;
      62             : 
      63             :         /**
      64             :          * @brief nodeWithoutKeyColor The color of the ConfigNodes that do not contain a kdb::Key
      65             :          * @return The color of the ConfigNodes that do not contain a kdb::Key
      66             :          */
      67             :         QColor nodeWithoutKeyColor () const;
      68             : 
      69             :         /**
      70             :          * @brief if the system icon theme should be used instead of qt guis own icon set
      71             :          * @return true if the system icon theme should be used
      72             :          */
      73             :         bool useSystemIconTheme () const;
      74             : 
      75             :         /**
      76             :          * @brief setKDB Makes the current color settings permanent.
      77             :          */
      78             :         Q_INVOKABLE void setKDB ();
      79             : 
      80             :         /**
      81             :          * @brief reset Deletes all permanent keys and restores the colors to the default values.
      82             :          */
      83             :         Q_INVOKABLE void reset ();
      84             : 
      85             :         bool viewermode () const;
      86             : 
      87             : public slots:
      88             :         /**
      89             :          * @brief setHighlightColor Sets the new highlight color.
      90             :          * @param color The new highlight color.
      91             :          */
      92             :         void setHighlightColor (const QColor & color);
      93             : 
      94             :         /**
      95             :          * @brief setFrameColor Sets the new frame color.
      96             :          * @param color The new frame color.
      97             :          */
      98             :         void setFrameColor (const QColor & color);
      99             : 
     100             :         /**
     101             :          * @brief setNodeWithKeyColor Sets the new color for ConfigNode s that contain a kdb::Key
     102             :          * @param color The new color for ConfigNodes that contain a kdb::Key
     103             :          */
     104             :         void setNodeWithKeyColor (const QColor & color);
     105             : 
     106             :         /**
     107             :          * @brief setNodeWithoutKeyColor Sets the new color for ConfigNode s that do not contain a kdb::Key
     108             :          * @param color The new color for ConfigNode s that do not contain a kdb::Key
     109             :          */
     110             :         void setNodeWithoutKeyColor (const QColor & color);
     111             : 
     112             :         /**
     113             :          * @brief set if the system icon theme should be used instead of qt guis own icon set
     114             :          * @param use bool if the system icon theme should be used or not
     115             :          */
     116             :         void useSystemIconTheme (const bool & use);
     117             : 
     118             :         void setViewermode (bool vmode);
     119             : 
     120             : signals:
     121             :         /**
     122             :          * @brief highlightColorChanged This signal is emitted if the highlight color is changed. The view will update accordingly.
     123             :          */
     124             :         void highlightColorChanged ();
     125             : 
     126             :         /**
     127             :          * @brief frameColorChanged This signal is emitted if the frame color is changed. The view will update accordingly.
     128             :          */
     129             :         void frameColorChanged ();
     130             : 
     131             :         /**
     132             :          * @brief nodeWithKeyColorChanged This signal is emitted if the color for @link ConfigNode s that contain a @link kdb::Key
     133             :          * is changed. The view will update accordingly.
     134             :          */
     135             :         void nodeWithKeyColorChanged ();
     136             : 
     137             :         /**
     138             :          * @brief nodeWithoutKeyColorChanged This signal is emitted if the color for @link ConfigNode s that do not contain
     139             :          * a @link kdb::Key is changed. The view will update accordingly.
     140             :          */
     141             :         void nodeWithoutKeyColorChanged ();
     142             : 
     143             :         /**
     144             :          * @brief This signal is emitted if the setting to use system icon theme has changed.
     145             :          */
     146             :         void useSystemIconThemeChanged ();
     147             : 
     148             :         /**
     149             :          * @brief This signal is emitted if the viewermode setting has changed.
     150             :          */
     151             :         void viewermodeChanged ();
     152             : 
     153             : private:
     154             :         void setDefaults ();
     155             :         void getKDB ();
     156             : 
     157             :         kdb::KeySet m_config;
     158             : 
     159             :         QColor m_highlightColor;
     160             :         QColor m_frameColor;
     161             :         QColor m_nodeWithKeyColor;
     162             :         QColor m_nodeWithoutKeyColor;
     163             : 
     164             :         bool m_useSystemIconTheme;
     165             :         bool m_viewermode;
     166             : 
     167             :         std::string m_profile;
     168             : 
     169             :         std::string m_base;
     170             :         std::string m_highlightColorString;
     171             :         std::string m_frameColorString;
     172             :         std::string m_nodeWKeyColorString;
     173             :         std::string m_nodeWOKeyColorString;
     174             :         std::string m_useSystemIconThemeString;
     175             : 
     176             :         std::string m_legacyBase;
     177             :         std::string m_legacyHighlightColorString;
     178             :         std::string m_legacyFrameColorString;
     179             :         std::string m_legacyNodeWKeyColorString;
     180             :         std::string m_legacyNodeWOKeyColorString;
     181             : 
     182             :         std::string m_viewermodeString;
     183             : 
     184             :         /**
     185             :          * @brief appendColor Updates a color. On the next @link setKDB() action this color will be permanent.
     186             :          * @param keyName The type of the color (e.g. "highlight_color")
     187             :          * @param color The color.
     188             :          */
     189             :         void appendColor (const std::string & keyName, const QColor & color);
     190             : 
     191             :         /**
     192             :          * @brief setBool Updates a boolean setting. On the next @link setKDB() action this settings value will be permanent.
     193             :          * @param keyName The name of the setting (e.g. "use_system_icon_theme")
     194             :          * @param value The boolean value for the option
     195             :          */
     196             :         void appendBool (const std::string & keyName, const bool value);
     197             : 
     198             :         /**
     199             :          * @brief lookupColor Retrieves the current color for an item.
     200             :          * @param keyName The type of the color (e.g. "highlight_color")
     201             :          * @param color the color to set
     202             :          */
     203             :         void lookupColor (const std::string & keyName, QColor & color) const;
     204             : 
     205             :         /**
     206             :          * @brief lookup bool option retrieves the current boolean value for an option.
     207             :          * @param keyName The name of the setting (e.g. "use_system_icon_theme")
     208             :          * @param value the value of the looked up setting
     209             :          */
     210             :         void lookupBool (const std::string & keyName, bool & value) const;
     211             : };
     212             : 
     213           0 : Q_DECLARE_METATYPE (GUISettings)
     214             : 
     215             : #endif // GUISETTINGS_HPP

Generated by: LCOV version 1.13