OSDN Git Service

Implemented corner widget for the menubar.
[x264-launcher/x264-launcher.git] / src / win_main.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 "global.h"
25 #include <QMainWindow>
26
27 class IPC;
28 class JobListModel;
29 class OptionsModel;
30 class SysinfoModel;
31 class QFile;
32 class QLibrary;
33 class PreferencesModel;
34 class RecentlyUsed;
35 class InputEventFilter;
36 class QModelIndex;
37 class QLabel;
38 enum JobStatus;
39
40 namespace Ui
41 {
42         class MainWindow;
43 }
44
45 class MainWindow: public QMainWindow
46 {
47         Q_OBJECT
48
49 public:
50         MainWindow(const x264_cpu_t *const cpuFeatures, IPC *ipc);
51         ~MainWindow(void);
52
53 protected:
54         virtual void closeEvent(QCloseEvent *e);
55         virtual void showEvent(QShowEvent *e);
56         virtual void resizeEvent(QResizeEvent *e);
57         virtual void dragEnterEvent(QDragEnterEvent *event);
58         virtual void dropEvent(QDropEvent *event);
59         virtual bool winEvent(MSG *message, long *result);
60
61         typedef enum
62         {
63                 STATUS_PRE_INIT = 0,
64                 STATUS_IDLE     = 1,
65                 STATUS_AWAITING = 2,
66                 STATUS_BLOCKED  = 3,
67                 STATUS_EXITTING = 4
68         }
69         x264_status_t;
70
71 private:
72         Ui::MainWindow *const ui;
73
74         x264_status_t m_status;
75         QLabel *m_label;
76
77         IPC *const m_ipc;
78
79         InputEventFilter *m_inputFilter_jobList;
80         InputEventFilter *m_inputFilter_version;
81         InputEventFilter *m_inputFilter_checkUp;
82
83         JobListModel *m_jobList;
84         OptionsModel *m_options;
85         QStringList *m_pendingFiles;
86         QList<QFile*> m_toolsList;
87         
88         SysinfoModel *m_sysinfo;
89         PreferencesModel *m_preferences;
90         RecentlyUsed *m_recentlyUsed;
91         
92         bool createJob(QString &sourceFileName, QString &outputFileName, OptionsModel *options, bool &runImmediately, const bool restart = false, int fileNo = -1, int fileTotal = 0, bool *applyToAll = NULL);
93         bool createJobMultiple(const QStringList &filePathIn);
94
95         bool appendJob(const QString &sourceFileName, const QString &outputFileName, OptionsModel *options, const bool runImmediately);
96         void updateButtons(JobStatus status);
97         void updateTaskbar(JobStatus status, const QIcon &icon);
98         unsigned int countPendingJobs(void);
99         unsigned int countRunningJobs(void);
100
101         bool parseCommandLineArgs(void);
102
103 private slots:
104         void addButtonPressed();
105         void openActionTriggered();
106         void abortButtonPressed(void);
107         void browseButtonPressed(void);
108         void deleteButtonPressed(void);
109         void copyLogToClipboard(bool checked);
110         void checkUpdates(void);
111         void handlePendingFiles(void);
112         void init(void);
113         void handleCommand(const int &command, const QStringList &args, const quint32 &flags = 0);
114         void jobSelected(const QModelIndex &current, const QModelIndex &previous);
115         void jobChangedData(const  QModelIndex &top, const  QModelIndex &bottom);
116         void jobLogExtended(const QModelIndex & parent, int start, int end);
117         void jobListKeyPressed(const int &tag);
118         void launchNextJob();
119         void moveButtonPressed(void);
120         void pauseButtonPressed(bool checked);
121         void restartButtonPressed(void);
122         void saveLogFile(const QModelIndex &index);
123         void showAbout(void);
124         void showPreferences(void);
125         void showWebLink(void);
126         void shutdownComputer(void);
127         void startButtonPressed(void);
128         void updateLabelPos(void);
129         void versionLabelMouseClicked(const int &tag);
130 };