File indexing completed on 2024-05-19 04:55:54

0001 /**
0002  * \file exportconfig.h
0003  * Configuration for export dialog.
0004  *
0005  * \b Project: Kid3
0006  * \author Urs Fleisch
0007  * \date 30 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 <QStringList>
0030 #include "generalconfig.h"
0031 #include "frame.h"
0032 
0033 /**
0034  * Export configuration.
0035  */
0036 class KID3_CORE_EXPORT ExportConfig : public StoredConfig<ExportConfig> {
0037   Q_OBJECT
0038   /** Tag1 to export ID3v1 tags, Tag2 for ID3v2 tags */
0039   Q_PROPERTY(int exportSource READ exportSource WRITE setExportSourceInt
0040              NOTIFY exportSourceChanged)
0041   /** Names of export formats */
0042   Q_PROPERTY(QStringList exportFormatNames READ exportFormatNames
0043              WRITE setExportFormatNames NOTIFY exportFormatNamesChanged)
0044   /** regexp describing header export format */
0045   Q_PROPERTY(QStringList exportFormatHeaders READ exportFormatHeaders
0046              WRITE setExportFormatHeaders NOTIFY exportFormatHeadersChanged)
0047   /** regexp describing track export format */
0048   Q_PROPERTY(QStringList exportFormatTracks READ exportFormatTracks
0049              WRITE setExportFormatTracks NOTIFY exportFormatTracksChanged)
0050   /** regexp describing trailer export format */
0051   Q_PROPERTY(QStringList exportFormatTrailers READ exportFormatTrailers
0052              WRITE setExportFormatTrailers NOTIFY exportFormatTrailersChanged)
0053   /** selected export format */
0054   Q_PROPERTY(int exportFormatIndex READ exportFormatIndex
0055              WRITE setExportFormatIndex NOTIFY exportFormatIndexChanged)
0056   /** export window geometry */
0057   Q_PROPERTY(QByteArray exportWindowGeometry READ exportWindowGeometry
0058              WRITE setExportWindowGeometry NOTIFY exportWindowGeometryChanged)
0059 
0060 public:
0061   /**
0062    * Constructor.
0063    */
0064   ExportConfig();
0065 
0066   /**
0067    * Destructor.
0068    */
0069   ~ExportConfig() override = default;
0070 
0071   /**
0072    * Persist configuration.
0073    *
0074    * @param config configuration
0075    */
0076   void writeToConfig(ISettings* config) const override;
0077 
0078   /**
0079    * Read persisted configuration.
0080    *
0081    * @param config configuration
0082    */
0083   void readFromConfig(ISettings* config) override;
0084 
0085   /**
0086    * Get tag source to export.
0087    * @return Tag1 to export ID3v1 tags, Tag2 for ID3v2 tags.
0088    */
0089   Frame::TagVersion exportSource() const { return m_exportSrcV1; }
0090 
0091   /** Set tag source to export. */
0092   void setExportSource(Frame::TagVersion exportSource);
0093 
0094   /** Get names of export formats */
0095   QStringList exportFormatNames() const { return m_exportFormatNames; }
0096 
0097   /** Set names of export formats */
0098   void setExportFormatNames(const QStringList& exportFormatNames);
0099 
0100   /** Get regexp describing header export format. */
0101   QStringList exportFormatHeaders() const { return m_exportFormatHeaders; }
0102 
0103   /** Set regexp describing header export format. */
0104   void setExportFormatHeaders(const QStringList& exportFormatHeaders);
0105 
0106   /** Get regexp describing track export format. */
0107   QStringList exportFormatTracks() const { return m_exportFormatTracks; }
0108 
0109   /** Set regexp describing track export format. */
0110   void setExportFormatTracks(const QStringList& exportFormatTracks);
0111 
0112   /** Get regexp describing trailer export format. */
0113   QStringList exportFormatTrailers() const { return m_exportFormatTrailers; }
0114 
0115   /** Set regexp describing trailer export format. */
0116   void setExportFormatTrailers(const QStringList& exportFormatTrailers);
0117 
0118   /** Get index of selected export format. */
0119   int exportFormatIndex() const { return m_exportFormatIdx; }
0120 
0121   /** Set index of selected export format. */
0122   void setExportFormatIndex(int exportFormatIndex);
0123 
0124   /** Get export window geometry. */
0125   QByteArray exportWindowGeometry() const { return m_exportWindowGeometry; }
0126 
0127   /** Set export window geometry. */
0128   void setExportWindowGeometry(const QByteArray& exportWindowGeometry);
0129 
0130 signals:
0131   /** Emitted when @a exportSrcV1 changed. */
0132   void exportSourceChanged(Frame::TagVersion exportSource);
0133 
0134   /** Emitted when @a exportFormatNames changed. */
0135   void exportFormatNamesChanged(const QStringList& exportFormatNames);
0136 
0137   /** Emitted when @a exportFormatHeaders changed. */
0138   void exportFormatHeadersChanged(const QStringList& exportFormatHeaders);
0139 
0140   /** Emitted when @a exportFormatTracks changed. */
0141   void exportFormatTracksChanged(const QStringList& exportFormatTracks);
0142 
0143   /** Emitted when @a exportFormatTrailers changed. */
0144   void exportFormatTrailersChanged(const QStringList& exportFormatTrailers);
0145 
0146   /** Emitted when @a exportFormatIdx changed. */
0147   void exportFormatIndexChanged(int exportFormatIndex);
0148 
0149   /** Emitted when @a exportWindowGeometry changed. */
0150   void exportWindowGeometryChanged(const QByteArray& exportWindowGeometry);
0151 
0152 private:
0153   friend ExportConfig& StoredConfig<ExportConfig>::instance();
0154 
0155   void setExportSourceInt(int exportSrc) {
0156     setExportSource(Frame::tagVersionCast(exportSrc));
0157   }
0158 
0159   Frame::TagVersion m_exportSrcV1;
0160   QStringList m_exportFormatNames;
0161   QStringList m_exportFormatHeaders;
0162   QStringList m_exportFormatTracks;
0163   QStringList m_exportFormatTrailers;
0164   int m_exportFormatIdx;
0165   QByteArray m_exportWindowGeometry;
0166 
0167   /** Index in configuration storage */
0168   static int s_index;
0169 };