OSDN Git Service

Happy new year 2020!
[x264-launcher/x264-launcher.git] / src / win_main.h
1 ///////////////////////////////////////////////////////////////////////////////
2 // Simple x264 Launcher
3 // Copyright (C) 2004-2020 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 //Internal
25 #include "global.h"
26
27 //Qt
28 #include <QMainWindow>
29
30 //Forward declarations
31 class JobListModel;
32 class OptionsModel;
33 class SysinfoModel;
34 class QFile;
35 class QLibrary;
36 class PreferencesModel;
37 class RecentlyUsed;
38 class InputEventFilter;
39 class QModelIndex;
40 class QLabel;
41 class QSystemTrayIcon;
42 class IPCThread_Recv;
43 enum JobStatus;
44
45 namespace Ui
46 {
47         class MainWindow;
48 }
49
50 namespace MUtils
51 {
52         class IPCChannel;
53         class Taskbar7;
54         namespace CPUFetaures
55         {
56                 typedef struct _cpu_info_t cpu_info_t;
57         }
58 }
59
60 class MainWindow: public QMainWindow
61 {
62         Q_OBJECT
63
64 public:
65         MainWindow(const MUtils::CPUFetaures::cpu_info_t &cpuFeatures, MUtils::IPCChannel *const ipcChannel);
66         ~MainWindow(void);
67
68 protected:
69         virtual void closeEvent(QCloseEvent *e);
70         virtual void showEvent(QShowEvent *e);
71         virtual void resizeEvent(QResizeEvent *e);
72         virtual void dragEnterEvent(QDragEnterEvent *event);
73         virtual void dropEvent(QDropEvent *event);
74
75 private:
76         typedef enum
77         {
78                 POST_OP_DONOTHING = 0,
79                 POST_OP_POWERDOWN = 1,
80                 POST_OP_HIBERNATE = 2
81         }
82         postOp_t;
83
84         Ui::MainWindow *const ui;
85         MUtils::IPCChannel *const m_ipcChannel;
86
87         postOp_t m_postOperation;
88         bool m_initialized;
89
90         QScopedPointer<QLabel> m_label[2];
91         QScopedPointer<QMovie> m_animation;
92         QScopedPointer<QTimer> m_fileTimer;
93
94         QScopedPointer<IPCThread_Recv>   m_ipcThread;
95         QScopedPointer<MUtils::Taskbar7> m_taskbar;
96         QScopedPointer<QSystemTrayIcon>  m_sysTray;
97
98         QScopedPointer<InputEventFilter> m_inputFilter_jobList;
99         QScopedPointer<InputEventFilter> m_inputFilter_version;
100         QScopedPointer<InputEventFilter> m_inputFilter_checkUp;
101
102         QScopedPointer<JobListModel> m_jobList;
103         QScopedPointer<OptionsModel> m_options;
104         QScopedPointer<QStringList> m_pendingFiles;
105         
106         QScopedPointer<SysinfoModel> m_sysinfo;
107         QScopedPointer<PreferencesModel> m_preferences;
108         QScopedPointer<RecentlyUsed> m_recentlyUsed;
109         
110         bool createJob(QString &sourceFileName, QString &outputFileName, OptionsModel *options, bool &runImmediately, const bool restart = false, int fileNo = -1, int fileTotal = 0, bool *applyToAll = NULL);
111         bool createJobMultiple(const QStringList &filePathIn);
112
113         bool appendJob(const QString &sourceFileName, const QString &outputFileName, OptionsModel *options, const bool runImmediately);
114         void updateButtons(JobStatus status);
115         void updateTaskbar(JobStatus status, const QIcon &icon);
116         unsigned int countPendingJobs(void);
117         unsigned int countRunningJobs(void);
118
119         bool parseCommandLineArgs(void);
120
121 private slots:
122         void addButtonPressed();
123         void openActionTriggered();
124         void cleanupActionTriggered(void);
125         void postOpActionTriggered(void);
126         void abortButtonPressed(void);
127         void browseButtonPressed(void);
128         void deleteButtonPressed(void);
129         void copyLogToClipboard(bool checked);
130         void saveLogToLocalFile(bool checked);
131         void toggleLineWrapping(bool checked);
132         void checkUpdates(void);
133         void handlePendingFiles(void);
134         void init(void);
135         void handleCommand(const int &command, const QStringList &args, const quint32 &flags = 0);
136         void jobSelected(const QModelIndex &current, const QModelIndex &previous);
137         void jobChangedData(const  QModelIndex &top, const  QModelIndex &bottom);
138         void jobLogExtended(const QModelIndex & parent, int start, int end);
139         void jobListKeyPressed(const int &tag);
140         void launchNextJob();
141         void moveButtonPressed(void);
142         void pauseButtonPressed(bool checked);
143         void restartButtonPressed(void);
144         void saveLogFile(const QModelIndex &index);
145         void showAbout(void);
146         void showPreferences(void);
147         void showWebLink(void);
148         void shutdownComputer(void);
149         void startButtonPressed(void);
150         void sysTrayActived(void);
151         void updateLabelPos(void);
152         void versionLabelMouseClicked(const int &tag);
153 };