OSDN Git Service

Refactored calculation of the binary path to a separate class. Also more code refacto...
[x264-launcher/x264-launcher.git] / src / win_addJob.h
1 ///////////////////////////////////////////////////////////////////////////////
2 // Simple x264 Launcher
3 // Copyright (C) 2004-2014 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 <QDialog>
25
26 class OptionsModel;
27 class RecentlyUsed;
28 class SysinfoModel;
29 class PreferencesModel;
30 class QComboBox;
31
32 namespace Ui
33 {
34         class AddJobDialog;
35 }
36
37 class AddJobDialog : public QDialog
38 {
39         Q_OBJECT
40
41 public:
42         AddJobDialog(QWidget *parent, OptionsModel *const options, RecentlyUsed *const recentlyUsed, const SysinfoModel *const sysinfo, const PreferencesModel *const preferences);
43         ~AddJobDialog(void);
44
45         QString sourceFile(void);
46         QString outputFile(void);
47
48         bool runImmediately(void);
49         bool applyToAll(void);
50         void setRunImmediately(bool run);
51         void setSourceFile(const QString &path);
52         void setOutputFile(const QString &path);
53         void setSourceEditable(const bool editable);
54         void setApplyToAllVisible(const bool visible);
55         
56         static QString generateOutputFileName(const QString &sourceFilePath, const QString &destinationDirectory, const int filterIndex, const bool saveToSourceDir);
57         static int getFilterIdx(const QString &fileExt);
58         static QString getFilterExt(const int filterIndex);
59         static QString AddJobDialog::getFilterStr(const int filterIndex);
60         static QString getFilterLst(void);
61         static QString getInputFilterLst(void);
62
63 protected:
64         OptionsModel *const m_options;
65         RecentlyUsed *const m_recentlyUsed;
66
67         const SysinfoModel *const m_sysinfo;
68         const PreferencesModel *const m_preferences;
69         const OptionsModel *m_defaults;
70
71         virtual void showEvent(QShowEvent *event);
72         virtual bool eventFilter(QObject *o, QEvent *e);
73         virtual void dragEnterEvent(QDragEnterEvent *event);
74         virtual void dropEvent(QDropEvent *event);
75
76 private slots:
77         void encoderIndexChanged(int index);
78         void variantIndexChanged(int index);
79         void modeIndexChanged(int index);
80         void browseButtonClicked(void);
81         void configurationChanged(void);
82         void templateSelected(void);
83         void saveTemplateButtonClicked(void);
84         void deleteTemplateButtonClicked(void);
85         void editorActionTriggered(void);
86         void copyActionTriggered(void);
87         void pasteActionTriggered(void);
88         
89         virtual void accept(void);
90
91 private:
92         Ui::AddJobDialog *const ui;
93
94         void loadTemplateList(void);
95         void restoreOptions(const OptionsModel *options);
96         void saveOptions(OptionsModel *options);
97         void updateComboBox(QComboBox *cbox, const QString &text);
98
99         QString currentSourcePath(const bool bWithName = false);
100         QString currentOutputPath(const bool bWithName = false);
101         int currentOutputIndx(void);
102 };