File indexing completed on 2024-05-19 04:55:56
0001 /** 0002 * \file networkconfig.h 0003 * Network related configuration. 0004 * 0005 * \b Project: Kid3 0006 * \author Urs Fleisch 0007 * \date 29 Jun 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 * Network related configuration. 0034 */ 0035 class KID3_CORE_EXPORT NetworkConfig : public StoredConfig<NetworkConfig> { 0036 Q_OBJECT 0037 /** proxy used for access */ 0038 Q_PROPERTY(QString proxy READ proxy WRITE setProxy NOTIFY proxyChanged) 0039 /** proxy user name */ 0040 Q_PROPERTY(QString proxyUserName READ proxyUserName WRITE setProxyUserName 0041 NOTIFY proxyUserNameChanged) 0042 /** proxy password */ 0043 Q_PROPERTY(QString proxyPassword READ proxyPassword WRITE setProxyPassword 0044 NOTIFY proxyPasswordChanged) 0045 /** web browser substituted for %b */ 0046 Q_PROPERTY(QString browser READ browser WRITE setBrowser NOTIFY browserChanged) 0047 /** true if proxy is used */ 0048 Q_PROPERTY(bool useProxy READ useProxy WRITE setUseProxy NOTIFY useProxyChanged) 0049 /** true to use proxy authentication */ 0050 Q_PROPERTY(bool useProxyAuthentication READ useProxyAuthentication 0051 WRITE setUseProxyAuthentication NOTIFY useProxyAuthenticationChanged) 0052 0053 public: 0054 /** 0055 * Constructor. 0056 */ 0057 NetworkConfig(); 0058 0059 /** 0060 * Destructor. 0061 */ 0062 ~NetworkConfig() override = default; 0063 0064 /** 0065 * Persist configuration. 0066 * 0067 * @param config configuration 0068 */ 0069 void writeToConfig(ISettings* config) const override; 0070 0071 /** 0072 * Read persisted configuration. 0073 * 0074 * @param config configuration 0075 */ 0076 void readFromConfig(ISettings* config) override; 0077 0078 /** Get proxy used for access. */ 0079 QString proxy() const { return m_proxy; } 0080 0081 /** Set proxy used for access. */ 0082 void setProxy(const QString& proxy); 0083 0084 /** Get proxy user name. */ 0085 QString proxyUserName() const { return m_proxyUserName; } 0086 0087 /** Set proxy user name. */ 0088 void setProxyUserName(const QString& proxyUserName); 0089 0090 /** Get proxy password. */ 0091 QString proxyPassword() const { return m_proxyPassword; } 0092 0093 /** Set proxy password. */ 0094 void setProxyPassword(const QString& proxyPassword); 0095 0096 /** Get web browser substituted for %b. */ 0097 QString browser() const { return m_browser; } 0098 0099 /** Set web browser substituted for %b. */ 0100 void setBrowser(const QString& browser); 0101 0102 /** Check if proxy is used. */ 0103 bool useProxy() const { return m_useProxy; } 0104 0105 /** Set if proxy is used. */ 0106 void setUseProxy(bool useProxy); 0107 0108 /** Check if proxy authentication is used. */ 0109 bool useProxyAuthentication() const { return m_useProxyAuthentication; } 0110 0111 /** Set if proxy authentication is used. */ 0112 void setUseProxyAuthentication(bool useProxyAuthentication); 0113 0114 /** 0115 * Set default web browser. 0116 */ 0117 void setDefaultBrowser(); 0118 0119 signals: 0120 /** Emitted when @a proxy changed. */ 0121 void proxyChanged(const QString& proxy); 0122 0123 /** Emitted when @a proxyUserName changed. */ 0124 void proxyUserNameChanged(const QString& proxyUserName); 0125 0126 /** Emitted when @a proxyPassword changed. */ 0127 void proxyPasswordChanged(const QString& proxyPassword); 0128 0129 /** Emitted when @a browser changed. */ 0130 void browserChanged(const QString& browser); 0131 0132 /** Emitted when @a useProxy changed. */ 0133 void useProxyChanged(bool useProxy); 0134 0135 /** Emitted when @a useProxyAuthentication changed. */ 0136 void useProxyAuthenticationChanged(bool useProxyAuthentication); 0137 0138 private: 0139 friend NetworkConfig& StoredConfig<NetworkConfig>::instance(); 0140 0141 QString m_proxy; 0142 QString m_proxyUserName; 0143 QString m_proxyPassword; 0144 QString m_browser; 0145 bool m_useProxy; 0146 bool m_useProxyAuthentication; 0147 0148 /** Index in configuration storage */ 0149 static int s_index; 0150 };