OSDN Git Service

4f0281b9a8ea343430460cf65aca43f8d3faf4f8
[lamexp/LameXP.git] / src / Dialog_Processing.h
1 ///////////////////////////////////////////////////////////////////////////////
2 // LameXP - Audio Encoder Front-End
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, but always including the *additional*
9 // restrictions defined in the "License.txt" file.
10 //
11 // This program is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14 // GNU General Public License for more details.
15 //
16 // You should have received a copy of the GNU General Public License along
17 // with this program; if not, write to the Free Software Foundation, Inc.,
18 // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
19 //
20 // http://www.gnu.org/licenses/gpl-2.0.txt
21 ///////////////////////////////////////////////////////////////////////////////
22
23 #pragma once
24
25 #include <QDialog>
26 #include <QUuid>
27 #include <QSystemTrayIcon>
28 #include <QMap>
29
30 class AbstractEncoder;
31 class AudioFileModel;
32 class AudioFileModel_MetaInfo;
33 class CPUObserverThread;
34 class DiskObserverThread;
35 class FileListModel;
36 class ProcessThread;
37 class ProgressModel;
38 class QActionGroup;
39 class QLabel;
40 class QMenu;
41 class QModelIndex;
42 class QMovie;
43 class RAMObserverThread;
44 class SettingsModel;
45 class QThreadPool;
46 class lamexp_icon_t;
47
48 enum shutdownFlag_t
49 {
50         shutdownFlag_None = 0,
51         shutdownFlag_TurnPowerOff = 1,
52         shutdownFlag_Hibernate = 2
53 };
54
55 //UIC forward declartion
56 namespace Ui {
57         class ProcessingDialog;
58 }
59
60 //ProcessingDialog class
61 class ProcessingDialog : public QDialog
62 {
63         Q_OBJECT
64
65 public:
66         ProcessingDialog(FileListModel *fileListModel, const AudioFileModel_MetaInfo *metaInfo, SettingsModel *settings, QWidget *parent = 0);
67         ~ProcessingDialog(void);
68         
69         int getShutdownFlag(void) { return m_shutdownFlag; }
70
71 private slots:
72         void initEncoding(void);
73         void initNextJob(void);
74         void startNextJob(void);
75         void doneEncoding(void);
76         void abortEncoding(bool force = false);
77         void processFinished(const QUuid &jobId, const QString &outFileName, int success);
78         void progressModelChanged(void);
79         void logViewDoubleClicked(const QModelIndex &index);
80         void logViewSectionSizeChanged(int, int, int);
81         void contextMenuTriggered(const QPoint &pos);
82         void contextMenuDetailsActionTriggered(void);
83         void contextMenuShowFileActionTriggered(void);
84         void contextMenuFilterActionTriggered(void);
85         void systemTrayActivated(QSystemTrayIcon::ActivationReason reason);
86         void cpuUsageHasChanged(const double val);
87         void ramUsageHasChanged(const double val);
88         void diskUsageHasChanged(const quint64 val);
89         void progressViewFilterChanged(void);
90
91 signals:
92         void abortRunningTasks(void);
93
94 protected:
95         void showEvent(QShowEvent *event);
96         void closeEvent(QCloseEvent *event);
97         bool eventFilter(QObject *obj, QEvent *event);
98         virtual bool event(QEvent *e);
99         virtual bool winEvent(MSG *message, long *result);
100         virtual void resizeEvent(QResizeEvent *event);
101
102 private:
103         Ui::ProcessingDialog *ui; //for Qt UIC
104
105         AudioFileModel updateMetaInfo(AudioFileModel &audioFile);
106         void writePlayList(void);
107         bool shutdownComputer(void);
108         QString time2text(const double timeVal) const;
109         
110         lamexp_icon_t *m_windowIcon;
111         QThreadPool *m_threadPool;
112         QList<AudioFileModel> m_pendingJobs;
113         SettingsModel *m_settings;
114         const AudioFileModel_MetaInfo *const m_metaInfo;
115         QMovie *m_progressIndicator;
116         ProgressModel *m_progressModel;
117         QMap<QUuid,QString> m_playList;
118         QMenu *m_contextMenu;
119         QActionGroup *m_progressViewFilterGroup;
120         QLabel *m_filterInfoLabel;
121         QLabel *m_filterInfoLabelIcon;
122         unsigned int m_initThreads;
123         unsigned int m_runningThreads;
124         unsigned int m_currentFile;
125         QList<QUuid> m_allJobs;
126         QList<QUuid> m_succeededJobs;
127         QList<QUuid> m_failedJobs;
128         QList<QUuid> m_skippedJobs;
129         bool m_userAborted;
130         bool m_forcedAbort;
131         bool m_firstShow;
132         QSystemTrayIcon *m_systemTray;
133         int m_shutdownFlag;
134         CPUObserverThread *m_cpuObserver;
135         RAMObserverThread *m_ramObserver;
136         DiskObserverThread *m_diskObserver;
137         qint64 m_timerStart;
138         int m_progressViewFilter;
139         QColor *m_defaultColor;
140 };