OSDN Git Service

Some more refactoring to allow better handling of multiple input files.
[x264-launcher/x264-launcher.git] / src / win_addJob.h
1 ///////////////////////////////////////////////////////////////////////////////
2 // Simple x264 Launcher
3 // Copyright (C) 2004-2012 LoRd_MuldeR <MuldeR2@GMX.de>
4 //
5 // This program is free software; you can redistribute it and/or modify
6 // it under the terms of the GNU General Public License as published by
7 // the Free Software Foundation; either version 2 of the License, or
8 // (at your option) any later version.
9 //
10 // This program is distributed in the hope that it will be useful,
11 // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13 // GNU General Public License for more details.
14 //
15 // You should have received a copy of the GNU General Public License along
16 // with this program; if not, write to the Free Software Foundation, Inc.,
17 // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
18 //
19 // http://www.gnu.org/licenses/gpl-2.0.txt
20 ///////////////////////////////////////////////////////////////////////////////
21
22 #pragma once
23
24 #include "uic_win_addJob.h"
25
26 #include <QDir>
27
28 class OptionsModel;
29
30 class AddJobDialog : public QDialog, private Ui::AddJobDialog
31 {
32         Q_OBJECT
33
34 public:
35         typedef struct
36         {
37                 QString sourceDirectory;
38                 QString outputDirectory;
39                 int filterIndex;
40         }
41         RecentlyUsed;
42
43         AddJobDialog(QWidget *parent, OptionsModel *options, RecentlyUsed *recentlyUsed, bool x64supported, bool use10BitEncoding, bool saveToSourceFolder);
44         ~AddJobDialog(void);
45
46         QString sourceFile(void);
47         QString outputFile(void);
48         QString preset(void) { return cbxPreset->itemText(cbxPreset->currentIndex()); }
49         QString tuning(void) { return cbxTuning->itemText(cbxTuning->currentIndex()); }
50         QString profile(void) { return cbxProfile->itemText(cbxProfile->currentIndex()); }
51         QString params(void) { return editCustomX264Params->text().simplified(); }
52         bool runImmediately(void) { return checkBoxRun->isChecked(); }
53         bool applyToAll(void) { return checkBoxApplyToAll->isChecked(); }
54         void setRunImmediately(bool run) { checkBoxRun->setChecked(run); }
55         void setSourceFile(const QString &path) { editSource->setText(QDir::toNativeSeparators(path)); }
56         void setOutputFile(const QString &path) { editOutput->setText(QDir::toNativeSeparators(path)); }
57         void setSourceEditable(const bool editable) { buttonBrowseSource->setEnabled(editable); }
58         void setApplyToAllVisible(const bool visible) { checkBoxApplyToAll->setVisible(visible); }
59
60         static void initRecentlyUsed(RecentlyUsed *recentlyUsed);
61         static void loadRecentlyUsed(RecentlyUsed *recentlyUsed);
62         static void saveRecentlyUsed(RecentlyUsed *recentlyUsed);
63         
64         static QString generateOutputFileName(const QString &sourceFilePath, const QString &destinationDirectory, const int filterIndex, const bool saveToSourceDir);
65         static int getFilterIdx(const QString &fileExt);
66         static QString getFilterExt(const int filterIndex);
67         static QString AddJobDialog::getFilterStr(const int filterIndex);
68         static QString getFilterLst(void);
69         static QString getInputFilterLst(void);
70
71 protected:
72         OptionsModel *m_options;
73         OptionsModel *m_defaults;
74         RecentlyUsed *m_recentlyUsed;
75
76         const bool m_x64supported;
77         const bool m_use10BitEncoding;
78         const bool m_saveToSourceFolder;
79
80         virtual void showEvent(QShowEvent *event);
81         virtual bool eventFilter(QObject *o, QEvent *e);
82         virtual void dragEnterEvent(QDragEnterEvent *event);
83         virtual void dropEvent(QDropEvent *event);
84
85 private slots:
86         void modeIndexChanged(int index);
87         void browseButtonClicked(void);
88         void configurationChanged(void);
89         void templateSelected(void);
90         void saveTemplateButtonClicked(void);
91         void deleteTemplateButtonClicked(void);
92         void editorActionTriggered(void);
93         void copyActionTriggered(void);
94         void pasteActionTriggered(void);
95         
96         virtual void accept(void);
97
98 private:
99         void loadTemplateList(void);
100         void restoreOptions(OptionsModel *options);
101         void saveOptions(OptionsModel *options);
102         void updateComboBox(QComboBox *cbox, const QString &text);
103 };