File indexing completed on 2025-02-23 04:34:17
0001 /** 0002 * \file editframefieldsdialog.h 0003 * Field edit dialog. 0004 * 0005 * \b Project: Kid3 0006 * \author Urs Fleisch 0007 * \date 10 Jun 2009 0008 * 0009 * Copyright (C) 2003-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 <QDialog> 0030 #include <QLabel> 0031 #include <QList> 0032 #include "frame.h" 0033 0034 class QVBoxLayout; 0035 class TaggedFile; 0036 class IPlatformTools; 0037 class Kid3Application; 0038 class FieldControl; 0039 0040 /** Row of buttons to load, save and view binary data */ 0041 class BinaryOpenSave : public QWidget { 0042 Q_OBJECT 0043 public: 0044 /** 0045 * Constructor. 0046 * 0047 * @param platformTools platform tools 0048 * @param app application context 0049 * @param parent parent widget 0050 * @param field field containing binary data 0051 * @param requiresPicture true if data must be picture 0052 */ 0053 BinaryOpenSave(IPlatformTools* platformTools, Kid3Application* app, 0054 QWidget* parent, const Frame::Field& field, 0055 bool requiresPicture); 0056 0057 /** 0058 * Set label. 0059 * 0060 * @param txt label 0061 */ 0062 void setLabel(const QString& txt) { m_label->setText(txt); } 0063 0064 /** 0065 * Check if data changed. 0066 * @return true if data changed. 0067 */ 0068 bool isChanged() const { return m_isChanged; } 0069 0070 /** 0071 * Get binary data. 0072 * @return byte array. 0073 */ 0074 const QByteArray& getData() const { return m_byteArray; } 0075 0076 /** 0077 * Set default directory name. 0078 * @param defaultDir default directory name 0079 */ 0080 void setDefaultDir(const QString& defaultDir) { m_defaultDir = defaultDir; } 0081 0082 /** 0083 * Set default file name. 0084 * @param defaultFile default file name 0085 */ 0086 void setDefaultFile(const QString& defaultFile) { m_defaultFile = defaultFile; } 0087 0088 /** 0089 * Set filter. 0090 * @param filter filter for file dialog 0091 */ 0092 void setFilter(const QString& filter) { m_filter = filter; } 0093 0094 public slots: 0095 /** 0096 * Enable the "From Clipboard" button if the clipboard contains an image. 0097 */ 0098 void setClipButtonState(); 0099 0100 /** 0101 * Load image from clipboard. 0102 */ 0103 void clipData(); 0104 0105 /** 0106 * Request name of file to import binary data from. 0107 * The data is imported later when Ok is pressed in the parent dialog. 0108 */ 0109 void loadData(); 0110 0111 /** 0112 * Request name of file and export binary data. 0113 */ 0114 void saveData(); 0115 0116 /** 0117 * Create image from binary data and copy it to clipboard. 0118 */ 0119 void copyData(); 0120 0121 /** 0122 * Create image from binary data and display it in window. 0123 */ 0124 void viewData(); 0125 0126 private: 0127 IPlatformTools* m_platformTools; 0128 Kid3Application* m_app; 0129 /** Array with binary data */ 0130 QByteArray m_byteArray; 0131 /** Label left of buttons */ 0132 QLabel* m_label; 0133 /** From Clipboard button */ 0134 QPushButton* m_clipButton; 0135 /** Default directory name */ 0136 QString m_defaultDir; 0137 /** Default file name */ 0138 QString m_defaultFile; 0139 /** Filter names */ 0140 QString m_filter; 0141 /** true if m_byteArray changed */ 0142 bool m_isChanged; 0143 /** true if data must be picture */ 0144 bool m_requiresPicture; 0145 }; 0146 0147 0148 /** Field edit dialog */ 0149 class EditFrameFieldsDialog : public QDialog { 0150 Q_OBJECT 0151 public: 0152 /** 0153 * Constructor. 0154 * 0155 * @param platformTools platform tools 0156 * @param app application context 0157 * @param parent parent widget 0158 */ 0159 EditFrameFieldsDialog(IPlatformTools* platformTools, Kid3Application* app, 0160 QWidget* parent = nullptr); 0161 0162 /** 0163 * Destructor. 0164 */ 0165 ~EditFrameFieldsDialog() override; 0166 0167 /** 0168 * Set frame to edit. 0169 * 0170 * @param frame frame with fields to edit 0171 * @param taggedFile file 0172 * @param tagNr tag number 0173 */ 0174 void setFrame(const Frame& frame, const TaggedFile* taggedFile, 0175 Frame::TagNumber tagNr); 0176 0177 /** 0178 * Update fields and get edited fields. 0179 * 0180 * @return field list. 0181 */ 0182 const Frame::FieldList& getUpdatedFieldList(); 0183 0184 /** 0185 * Get value of frame for frames without a field list. 0186 * First getUpdatedFieldList() has to be called, if the returned field list 0187 * is empty, the frame value is available with this method. 0188 * 0189 * @return frame value. 0190 */ 0191 QString getFrameValue() const; 0192 0193 private: 0194 QVBoxLayout* m_vlayout; 0195 IPlatformTools* m_platformTools; 0196 Kid3Application* m_app; 0197 Frame::FieldList m_fields; 0198 Frame::Field m_valueField; 0199 QList<FieldControl*> m_fieldcontrols; 0200 };