OSDN Git Service

3cee9c0199d59dd57e9a8ed67e5bad215762d871
[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         QThreadPool *m_threadPool;
111         QList<AudioFileModel> m_pendingJobs;
112         SettingsModel *m_settings;
113         const AudioFileModel_MetaInfo *const m_metaInfo;
114         QMovie *m_progressIndicator;
115         ProgressModel *m_progressModel;
116         QMap<QUuid,QString> m_playList;
117         QMenu *m_contextMenu;
118         QActionGroup *m_progressViewFilterGroup;
119         QLabel *m_filterInfoLabel;
120         QLabel *m_filterInfoLabelIcon;
121         unsigned int m_initThreads;
122         unsigned int m_runningThreads;
123         unsigned int m_currentFile;
124         QList<QUuid> m_allJobs;
125         QList<QUuid> m_succeededJobs;
126         QList<QUuid> m_failedJobs;
127         QList<QUuid> m_skippedJobs;
128         bool m_userAborted;
129         bool m_forcedAbort;
130         bool m_firstShow;
131         QSystemTrayIcon *m_systemTray;
132         int m_shutdownFlag;
133         CPUObserverThread *m_cpuObserver;
134         RAMObserverThread *m_ramObserver;
135         DiskObserverThread *m_diskObserver;
136         qint64 m_timerStart;
137         int m_progressViewFilter;
138         QColor *m_defaultColor;
139 };