File indexing completed on 2024-05-19 04:55:56
0001 /** 0002 * \file rendirconfig.h 0003 * Configuration for directory renaming. 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 "trackdata.h" 0031 #include "kid3api.h" 0032 0033 /** 0034 * Configuration for directory renaming. 0035 */ 0036 class KID3_CORE_EXPORT RenDirConfig : public StoredConfig<RenDirConfig> { 0037 Q_OBJECT 0038 /** directory name format */ 0039 Q_PROPERTY(QString dirFormat READ dirFormat WRITE setDirFormat 0040 NOTIFY dirFormatChanged) 0041 /** available directory name formats */ 0042 Q_PROPERTY(QStringList dirFormats READ dirFormats WRITE setDirFormats 0043 NOTIFY dirFormatsChanged) 0044 /** rename directory from tags 1, tags 2, or both */ 0045 Q_PROPERTY(int renDirSource READ renDirSource WRITE setRenDirSrcInt 0046 NOTIFY renDirSourceChanged) 0047 /** window geometry */ 0048 Q_PROPERTY(QByteArray windowGeometry READ windowGeometry 0049 WRITE setWindowGeometry NOTIFY windowGeometryChanged) 0050 0051 public: 0052 /** 0053 * Constructor. 0054 */ 0055 RenDirConfig(); 0056 0057 /** 0058 * Destructor. 0059 */ 0060 ~RenDirConfig() override = default; 0061 0062 /** 0063 * Persist configuration. 0064 * 0065 * @param config configuration 0066 */ 0067 void writeToConfig(ISettings* config) const override; 0068 0069 /** 0070 * Read persisted configuration. 0071 * 0072 * @param config configuration 0073 */ 0074 void readFromConfig(ISettings* config) override; 0075 0076 /** Get directory name format. */ 0077 QString dirFormat() const { return m_dirFormatText; } 0078 0079 /** Set directory name format. */ 0080 void setDirFormat(const QString& dirFormat); 0081 0082 /** Get available directory name formats. */ 0083 QStringList dirFormats() const { return m_dirFormatItems; } 0084 0085 /** Set available directory name formats. */ 0086 void setDirFormats(const QStringList& dirFormatItems); 0087 0088 /** Get tag source when renaming directory. */ 0089 Frame::TagVersion renDirSource() const { return m_renDirSrc; } 0090 0091 /** Set tag source when renaming directory. */ 0092 void setRenDirSource(Frame::TagVersion renDirSource); 0093 0094 /** 0095 * Get window geometry. 0096 * @return window geometry. 0097 */ 0098 QByteArray windowGeometry() const { return m_windowGeometry; } 0099 0100 /** 0101 * Set window geometry. 0102 * @param windowGeometry geometry 0103 */ 0104 void setWindowGeometry(const QByteArray& windowGeometry); 0105 0106 signals: 0107 /** Emitted when @a dirFormatText changed. */ 0108 void dirFormatChanged(const QString& dirFormat); 0109 0110 /** Emitted when @a dirFormats changed. */ 0111 void dirFormatsChanged(const QStringList& dirFormats); 0112 0113 /** Emitted when @a renDirSrc changed. */ 0114 void renDirSourceChanged(Frame::TagVersion renDirSource); 0115 0116 /** Emitted when @a windowGeometry changed. */ 0117 void windowGeometryChanged(const QByteArray& windowGeometry); 0118 0119 private: 0120 friend RenDirConfig& StoredConfig<RenDirConfig>::instance(); 0121 0122 void setRenDirSrcInt(int renDirSrc) { 0123 setRenDirSource(Frame::tagVersionCast(renDirSrc)); 0124 } 0125 0126 QString m_dirFormatText; 0127 QStringList m_dirFormatItems; 0128 Frame::TagVersion m_renDirSrc; 0129 QByteArray m_windowGeometry; 0130 0131 static const char** s_defaultDirFmtList; 0132 0133 /** Index in configuration storage */ 0134 static int s_index; 0135 };