File indexing completed on 2024-05-19 04:55:56
0001 /** 0002 * \file mainwindowconfig.h 0003 * Main window configuration. 0004 * 0005 * \b Project: Kid3 0006 * \author Urs Fleisch 0007 * \date 08 Apr 2013 0008 * 0009 * Copyright (C) 2013-2024 Urs Fleisch 0010 * 0011 * This file is part of Kid3. 0012 * 0013 * Kid3 is free software; you can redistribute it and/or modify 0014 * it under the terms of the GNU General Public License as published by 0015 * the Free Software Foundation; either version 2 of the License, or 0016 * (at your option) any later version. 0017 * 0018 * Kid3 is distributed in the hope that it will be useful, 0019 * but WITHOUT ANY WARRANTY; without even the implied warranty of 0020 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 0021 * GNU General Public License for more details. 0022 * 0023 * You should have received a copy of the GNU General Public License 0024 * along with this program. If not, see <http://www.gnu.org/licenses/>. 0025 */ 0026 0027 #pragma once 0028 0029 #include "generalconfig.h" 0030 #include "kid3api.h" 0031 0032 /** 0033 * Main window configuration. 0034 */ 0035 class KID3_CORE_EXPORT MainWindowConfig : public StoredConfig<MainWindowConfig> { 0036 Q_OBJECT 0037 /** mainwindow geometry */ 0038 Q_PROPERTY(QByteArray geometry READ geometry WRITE setGeometry 0039 NOTIFY geometryChanged) 0040 /** mainwindow state */ 0041 Q_PROPERTY(QByteArray windowState READ windowState WRITE setWindowState 0042 NOTIFY windowStateChanged) 0043 /** application language */ 0044 Q_PROPERTY(QString language READ language WRITE setLanguage 0045 NOTIFY languageChanged) 0046 /** custom application font family */ 0047 Q_PROPERTY(QString fontFamily READ fontFamily WRITE setFontFamily 0048 NOTIFY fontFamilyChanged) 0049 /** custom application font size */ 0050 Q_PROPERTY(int fontSize READ fontSize WRITE setFontSize 0051 NOTIFY fontSizeChanged) 0052 /** custom application style, empty if not used */ 0053 Q_PROPERTY(QString style READ style WRITE setStyle NOTIFY styleChanged) 0054 /** true if custom application font is used */ 0055 Q_PROPERTY(bool useFont READ useFont WRITE setUseFont NOTIFY useFontChanged) 0056 /** true to hide toolbar */ 0057 Q_PROPERTY(bool hideToolBar READ hideToolBar WRITE setHideToolBar 0058 NOTIFY hideToolBarChanged) 0059 /** true to hide statusbar */ 0060 Q_PROPERTY(bool hideStatusBar READ hideStatusBar WRITE setHideStatusBar 0061 NOTIFY hideStatusBarChanged) 0062 /** Don't use the native file dialog if true */ 0063 Q_PROPERTY(bool dontUseNativeDialogs READ dontUseNativeDialogs 0064 WRITE setDontUseNativeDialogs NOTIFY dontUseNativeDialogsChanged) 0065 /** Qt Quick style and theme, empty if not used */ 0066 Q_PROPERTY(QString qtQuickStyle READ qtQuickStyle WRITE setQtQuickStyle 0067 NOTIFY qtQuickStyleChanged) 0068 0069 public: 0070 /** 0071 * Constructor. 0072 */ 0073 MainWindowConfig(); 0074 0075 /** 0076 * Destructor. 0077 */ 0078 ~MainWindowConfig() override = default; 0079 0080 /** 0081 * Persist configuration. 0082 * 0083 * @param config configuration 0084 */ 0085 void writeToConfig(ISettings* config) const override; 0086 0087 /** 0088 * Read persisted configuration. 0089 * 0090 * @param config configuration 0091 */ 0092 void readFromConfig(ISettings* config) override; 0093 0094 /** Get mainwindow geometry. */ 0095 QByteArray geometry() const { return m_geometry; } 0096 0097 /** Set mainwindow geometry. */ 0098 void setGeometry(const QByteArray& geometry); 0099 0100 /** Get mainwindow state. */ 0101 QByteArray windowState() const { return m_windowState; } 0102 0103 /** Set mainwindow state. */ 0104 void setWindowState(const QByteArray& windowState); 0105 0106 /** Get application language. */ 0107 QString language() const { return m_language; } 0108 0109 /** Set application language. */ 0110 void setLanguage(const QString& language); 0111 0112 /** Get custom application font family. */ 0113 QString fontFamily() const { return m_fontFamily; } 0114 0115 /** Set custom application font family. */ 0116 void setFontFamily(const QString& fontFamily); 0117 0118 /** Get custom application font size. */ 0119 int fontSize() const { return m_fontSize; } 0120 0121 /** Set custom application font size. */ 0122 void setFontSize(int fontSize); 0123 0124 /** Get custom application style, empty if not used. */ 0125 QString style() const { return m_style; } 0126 0127 /** Set custom application style. */ 0128 void setStyle(const QString& style); 0129 0130 /** Check if custom application font is used. */ 0131 bool useFont() const { return m_useFont; } 0132 0133 /** Set if custom application font is used. */ 0134 void setUseFont(bool useFont); 0135 0136 /** Check if toolbar is hidden. */ 0137 bool hideToolBar() const { return m_hideToolBar; } 0138 0139 /** Set if hide toolbar is hidden. */ 0140 void setHideToolBar(bool hideToolBar); 0141 0142 /** Check if statusbar is hidden. */ 0143 bool hideStatusBar() const { return m_hideStatusBar; } 0144 0145 /** Set if statusbar is hidden. */ 0146 void setHideStatusBar(bool hideStatusBar); 0147 0148 /** Check if native file dialogs are used. */ 0149 bool dontUseNativeDialogs() const { return m_dontUseNativeDialogs; } 0150 0151 /** Set if native file dialogs are used. */ 0152 void setDontUseNativeDialogs(bool dontUseNativeDialogs); 0153 0154 /** Get Qt Quick style, empty if not used. */ 0155 QString qtQuickStyle() const { return m_qtQuickStyle; } 0156 0157 /** Set Qt Quick style. */ 0158 void setQtQuickStyle(const QString& qtQuickStyle); 0159 0160 /** 0161 * String list of available Qt Quick styles. 0162 */ 0163 Q_INVOKABLE static QStringList getQtQuickStyleNames(); 0164 0165 /** 0166 * List of available languages. 0167 */ 0168 Q_INVOKABLE static QStringList availableLanguages(); 0169 0170 signals: 0171 /** Emitted when @a geometry changed. */ 0172 void geometryChanged(const QByteArray& geometry); 0173 0174 /** Emitted when @a windowState changed. */ 0175 void windowStateChanged(const QByteArray& windowState); 0176 0177 /** Emitted when @a language changed. */ 0178 void languageChanged(const QString& language); 0179 0180 /** Emitted when @a fontFamily changed. */ 0181 void fontFamilyChanged(const QString& fontFamily); 0182 0183 /** Emitted when @a fontSize changed. */ 0184 void fontSizeChanged(int fontSize); 0185 0186 /** Emitted when @a style changed. */ 0187 void styleChanged(const QString& style); 0188 0189 /** Emitted when @a useFont changed. */ 0190 void useFontChanged(bool useFont); 0191 0192 /** Emitted when @a hideToolBar changed. */ 0193 void hideToolBarChanged(bool hideToolBar); 0194 0195 /** Emitted when @a hideStatusBar changed. */ 0196 void hideStatusBarChanged(bool hideStatusBar); 0197 0198 /** Emitted when @a dontUseNativeDialogs changed. */ 0199 void dontUseNativeDialogsChanged(bool dontUseNativeDialogs); 0200 0201 /** Emitted when @a qtQuickStyle changed. */ 0202 void qtQuickStyleChanged(const QString& qtQuickStyle); 0203 0204 private: 0205 friend MainWindowConfig& StoredConfig<MainWindowConfig>::instance(); 0206 0207 QByteArray m_geometry; 0208 QByteArray m_windowState; 0209 QString m_language; 0210 QString m_fontFamily; 0211 int m_fontSize; 0212 QString m_style; 0213 QString m_qtQuickStyle; 0214 bool m_useFont; 0215 bool m_hideToolBar; 0216 bool m_hideStatusBar; 0217 bool m_dontUseNativeDialogs; 0218 0219 /** Index in configuration storage */ 0220 static int s_index; 0221 };