OSDN Git Service

Added project/solution files for VS2019.
[lamexp/LameXP.git] / src / Dialog_Processing.h
1 ///////////////////////////////////////////////////////////////////////////////
2 // LameXP - Audio Encoder Front-End
3 // Copyright (C) 2004-2019 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 QThreadPool;
44 class QElapsedTimer;
45 class RAMObserverThread;
46 class SettingsModel;
47 class FileExtsModel;
48
49 enum lamexp_shutdownFlag_t
50 {
51         SHUTDOWN_FLAG_NONE = 0,
52         SHUTDOWN_FLAG_POWER_OFF = 1,
53         SHUTDOWN_FLAG_HIBERNATE = 2
54 };
55
56 //UIC forward declartion
57 namespace Ui
58 {
59         class ProcessingDialog;
60 }
61
62 //MUtils forward declartion
63 namespace MUtils
64 {
65         class Taskbar7;
66 }
67
68 //ProcessingDialog class
69 class ProcessingDialog : public QDialog
70 {
71         Q_OBJECT
72
73 public:
74         ProcessingDialog(FileListModel *const fileListModel, const AudioFileModel_MetaInfo *const metaInfo, const SettingsModel *const settings, QWidget *const parent = 0);
75         ~ProcessingDialog(void);
76         
77         int getShutdownFlag(void) { return m_shutdownFlag; }
78
79 private slots:
80         void initEncoding(void);
81         void initNextJob(void);
82         void startNextJob(void);
83         void doneEncoding(void);
84         void abortEncoding(bool force = false);
85         void processFinished(const QUuid &jobId, const QString &outFileName, int success);
86         void progressModelChanged(void);
87         void logViewDoubleClicked(const QModelIndex &index);
88         void logViewSectionSizeChanged(int, int, int);
89         void contextMenuTriggered(const QPoint &pos);
90         void contextMenuDetailsActionTriggered(void);
91         void contextMenuShowFileActionTriggered(void);
92         void contextMenuFilterActionTriggered(void);
93         void systemTrayActivated(QSystemTrayIcon::ActivationReason reason);
94         void cpuUsageHasChanged(const double val);
95         void ramUsageHasChanged(const double val);
96         void diskUsageHasChanged(const quint64 val);
97         void progressViewFilterChanged(void);
98
99 signals:
100         void abortRunningTasks(void);
101
102 protected:
103         void showEvent(QShowEvent *event);
104         void closeEvent(QCloseEvent *event);
105         bool eventFilter(QObject *obj, QEvent *event);
106         virtual bool event(QEvent *e);
107         virtual void resizeEvent(QResizeEvent *event);
108
109 private:
110         Ui::ProcessingDialog *ui; //for Qt UIC
111
112         QThreadPool *createThreadPool(void);
113         void updateMetaInfo(AudioFileModel &audioFile);
114         void writePlayList(void);
115         bool shutdownComputer(void);
116         
117         QScopedPointer<QThreadPool> m_threadPool;
118         QList<AudioFileModel> m_pendingJobs;
119         const SettingsModel *const m_settings;
120         const AudioFileModel_MetaInfo *const m_metaInfo;
121         const QString m_tempFolder;
122         QScopedPointer<QMovie> m_progressIndicator;
123         QScopedPointer<ProgressModel> m_progressModel;
124         QMap<QUuid,QString> m_playList;
125         QScopedPointer<QMenu> m_contextMenu;
126         QScopedPointer<QActionGroup> m_progressViewFilterGroup;
127         QScopedPointer<QLabel> m_filterInfoLabel;
128         QScopedPointer<QLabel> m_filterInfoLabelIcon;
129         unsigned int m_initThreads;
130         unsigned int m_runningThreads;
131         unsigned int m_currentFile;
132         QList<QUuid> m_allJobs;
133         QList<QUuid> m_succeededJobs;
134         QList<QUuid> m_failedJobs;
135         QList<QUuid> m_skippedJobs;
136         bool m_userAborted;
137         bool m_forcedAbort;
138         bool m_firstShow;
139         QScopedPointer<QSystemTrayIcon> m_systemTray;
140         int m_shutdownFlag;
141         QScopedPointer<CPUObserverThread>  m_cpuObserver;
142         QScopedPointer<RAMObserverThread>  m_ramObserver;
143         QScopedPointer<DiskObserverThread> m_diskObserver;
144         QScopedPointer<QElapsedTimer> m_totalTime;
145         int m_progressViewFilter;
146         QScopedPointer<QColor> m_defaultColor;
147         QScopedPointer<FileExtsModel> m_fileExts;
148         QScopedPointer<MUtils::Taskbar7> m_taskbar;
149
150         static bool isFastSeekingDevice(const QString &path);
151         static quint32 cores2instances(const quint32 &cores);
152         static QString time2text(const qint64 &msec);
153 };