OSDN Git Service

Code refactoring: Now "Preferences" and "Recently" used models are in separate classe...
[x264-launcher/x264-launcher.git] / src / win_main.h
1 ///////////////////////////////////////////////////////////////////////////////
2 // Simple x264 Launcher
3 // Copyright (C) 2004-2013 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_main.h"
25 #include "thread_ipc.h"
26 #include "thread_encode.h"
27
28 class JobListModel;
29 class OptionsModel;
30 class QFile;
31 class QLibrary;
32 class PreferencesModel;
33 class RecentlyUsed;
34
35 class MainWindow: public QMainWindow, private Ui::MainWindow
36 {
37         Q_OBJECT
38
39 public:
40         MainWindow(const x264_cpu_t *const cpuFeatures);
41         ~MainWindow(void);
42
43 protected:
44         virtual void closeEvent(QCloseEvent *e);
45         virtual void showEvent(QShowEvent *e);
46         virtual void resizeEvent(QResizeEvent *e);
47         virtual bool eventFilter(QObject *o, QEvent *e);
48         virtual void dragEnterEvent(QDragEnterEvent *event);
49         virtual void dropEvent(QDropEvent *event);
50         virtual bool winEvent(MSG *message, long *result);
51
52 private:
53         bool m_firstShow;
54         QLabel *m_label;
55         IPCThread *m_ipcThread;
56
57         JobListModel *m_jobList;
58         OptionsModel *m_options;
59         QStringList *m_droppedFiles;
60         QList<QFile*> m_toolsList;
61         
62         PreferencesModel *m_preferences;
63         RecentlyUsed *m_recentlyUsed;
64
65         const x264_cpu_t *const m_cpuFeatures;
66         const QString m_appDir;
67         
68         bool createJob(QString &sourceFileName, QString &outputFileName, OptionsModel *options, bool &runImmediately, const bool restart = false, int fileNo = -1, int fileTotal = 0, bool *applyToAll = NULL);
69         bool createJobMultiple(const QStringList &filePathIn);
70
71         bool appendJob(const QString &sourceFileName, const QString &outputFileName, OptionsModel *options, const bool runImmediately);
72         void updateButtons(EncodeThread::JobStatus status);
73         void updateTaskbar(EncodeThread::JobStatus status, const QIcon &icon);
74         unsigned int countPendingJobs(void);
75         unsigned int countRunningJobs(void);
76
77 private slots:
78         void addButtonPressed();
79         void openActionTriggered();
80         void abortButtonPressed(void);
81         void browseButtonPressed(void);
82         void deleteButtonPressed(void);
83         void copyLogToClipboard(bool checked);
84         void handleDroppedFiles(void);
85         void init(void);
86         void instanceCreated(DWORD pid);
87         void jobSelected(const QModelIndex & current, const QModelIndex & previous);
88         void jobChangedData(const  QModelIndex &top, const  QModelIndex &bottom);
89         void jobLogExtended(const QModelIndex & parent, int start, int end);
90         void launchNextJob();
91         void pauseButtonPressed(bool checked);
92         void restartButtonPressed(void);
93         void saveLogFile(const QModelIndex &index);
94         void showAbout(void);
95         void showPreferences(void);
96         void showWebLink(void);
97         void shutdownComputer(void);
98         void startButtonPressed(void);
99         void updateLabelPos(void);
100 };