1 /**
2  * \file rendirdialog.h
3  * Rename directory dialog.
4  *
5  * \b Project: Kid3
6  * \author Urs Fleisch
7  * \date 21 Mar 2004
8  *
9  * Copyright (C) 2004-2018  Urs Fleisch
10  *
11  * This file is part of Kid3.
12  *
13  * Kid3 is free software; you can redistribute it and/or modify
14  * it under the terms of the GNU General Public License as published by
15  * the Free Software Foundation; either version 2 of the License, or
16  * (at your option) any later version.
17  *
18  * Kid3 is distributed in the hope that it will be useful,
19  * but WITHOUT ANY WARRANTY; without even the implied warranty of
20  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
21  * GNU General Public License for more details.
22  *
23  * You should have received a copy of the GNU General Public License
24  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
25  */
26 
27 #pragma once
28 
29 #include <QString>
30 #include <QList>
31 #include <QWizard>
32 
33 class QComboBox;
34 class QLabel;
35 class TaggedFile;
36 class QVBoxLayout;
37 class QTextEdit;
38 class DirRenamer;
39 
40 /**
41  * Rename directory dialog.
42  */
43 class RenDirDialog : public QWizard {
44   Q_OBJECT
45 public:
46   /**
47    * Constructor.
48    *
49    * @param parent     parent widget
50    * @param dirRenamer directory renamer
51    */
52   RenDirDialog(QWidget* parent, DirRenamer* dirRenamer);
53 
54   /**
55    * Destructor.
56    */
57   virtual ~RenDirDialog() override = default;
58 
59   /**
60    * Start dialog.
61    *
62    * @param taggedFile file to use for rename preview
63    * @param dirName    if taggedFile is 0, the directory can be set here
64    */
65   void startDialog(TaggedFile* taggedFile, const QString& dirName = QString());
66 
67   /**
68    * Set new directory name.
69    *
70    * @param dir new directory name
71    */
72   void setNewDirname(const QString& dir);
73 
74   /**
75    * Get new directory name.
76    *
77    * @return new directory name.
78    */
79   QString getNewDirname() const;
80 
81 public slots:
82   /**
83    * Display action preview.
84    *
85    * @param actionStrs description of action
86    */
87   void displayActionPreview(const QStringList& actionStrs);
88 
89 protected:
90   /**
91    * Called when the wizard is canceled.
92    */
93   virtual void reject() override;
94 
95 signals:
96   /**
97    * Emitted when scheduling of actions using clearActions() followed by
98    * one or multiple scheduleAction() calls is requested.
99    */
100   void actionSchedulingRequested();
101 
102 private slots:
103   /**
104    * Set new directory name according to current settings.
105    */
106   void slotUpdateNewDirname();
107 
108   /**
109    * Save the local settings to the configuration.
110    */
111   void saveConfig();
112 
113   /**
114    * Show help.
115    */
116   void showHelp();
117 
118   /**
119    * Request action scheduling and then accept dialog.
120    */
121   void requestActionSchedulingAndAccept();
122 
123   /**
124    * Wizard page changed.
125    */
126   void pageChanged();
127 
128   /**
129    * Open dialog to edit formats.
130    */
131   void editFormats();
132 
133 private:
134   /** Action to be performed. */
135   enum Action { ActionRename = 0, ActionCreate = 1 };
136 
137   /**
138    * Set up the main wizard page.
139    *
140    * @param page    widget
141    * @param vlayout layout
142    */
143   void setupMainPage(QWidget* page, QVBoxLayout* vlayout);
144 
145   /**
146    * Set up the preview wizard page.
147    *
148    * @param page widget
149    */
150   void setupPreviewPage(QWidget* page);
151 
152   /**
153    * Clear action preview.
154    */
155   void clearPreview();
156 
157   /**
158    * Set configuration from dialog in directory renamer.
159    */
160   void setDirRenamerConfiguration();
161 
162   /**
163    * Set items of format combo box from configuration.
164    */
165   void setFormats();
166 
167   QComboBox* m_formatComboBox;
168   QComboBox* m_actionComboBox;
169   QComboBox* m_tagversionComboBox;
170   QLabel* m_currentDirLabel;
171   QLabel* m_newDirLabel;
172   QTextEdit* m_edit;
173   TaggedFile* m_taggedFile;
174   DirRenamer* m_dirRenamer;
175   QStringList m_formats;
176   QString m_format;
177 };
178