OSDN Git Service

Updated changelog.
[lamexp/LameXP.git] / src / Dialog_Processing.h
1 ///////////////////////////////////////////////////////////////////////////////
2 // LameXP - Audio Encoder Front-End
3 // Copyright (C) 2004-2023 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; always including the non-optional
9 // LAMEXP GNU GENERAL PUBLIC LICENSE ADDENDUM. See "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 prepareEncoding(void);
81         void initEncoding(void);
82         void initNextJob(void);
83         void startNextJob(void);
84         void doneEncoding(void);
85         void abortEncoding(bool force = false);
86         void processFinished(const QUuid &jobId, const QString &outFileName, int success);
87         void progressModelChanged(void);
88         void logViewDoubleClicked(const QModelIndex &index);
89         void logViewSectionSizeChanged(int, int, int);
90         void contextMenuTriggered(const QPoint &pos);
91         void contextMenuDetailsActionTriggered(void);
92         void contextMenuShowFileActionTriggered(void);
93         void contextMenuFilterActionTriggered(void);
94         void systemTrayActivated(QSystemTrayIcon::ActivationReason reason);
95         void cpuUsageHasChanged(const double val);
96         void ramUsageHasChanged(const double val);
97         void diskUsageHasChanged(const quint64 val);
98         void progressViewFilterChanged(void);
99
100 signals:
101         void abortRunningTasks(void);
102
103 protected:
104         void showEvent(QShowEvent *event);
105         void closeEvent(QCloseEvent *event);
106         bool eventFilter(QObject *obj, QEvent *event);
107         virtual bool event(QEvent *e);
108         virtual void resizeEvent(QResizeEvent *event);
109
110 private:
111         Ui::ProcessingDialog *ui; //for Qt UIC
112
113         QThreadPool *createThreadPool(void);
114         void updateMetaInfo(AudioFileModel &audioFile);
115         void writePlayList(void);
116         bool shutdownComputer(void);
117         
118         QScopedPointer<QThreadPool> m_threadPool;
119         QList<AudioFileModel> m_pendingJobs;
120         const SettingsModel *const m_settings;
121         const AudioFileModel_MetaInfo *const m_metaInfo;
122         const QString m_tempFolder;
123         QScopedPointer<QMovie> m_progressIndicator;
124         QScopedPointer<ProgressModel> m_progressModel;
125         QMap<QUuid,QString> m_playList;
126         QScopedPointer<QMenu> m_contextMenu;
127         QScopedPointer<QActionGroup> m_progressViewFilterGroup;
128         QScopedPointer<QLabel> m_filterInfoLabel;
129         QScopedPointer<QLabel> m_filterInfoLabelIcon;
130         unsigned int m_initThreads;
131         unsigned int m_runningThreads;
132         unsigned int m_currentFile;
133         QList<QUuid> m_allJobs;
134         QList<QUuid> m_succeededJobs;
135         QList<QUuid> m_failedJobs;
136         QList<QUuid> m_skippedJobs;
137         bool m_userAborted;
138         bool m_forcedAbort;
139         bool m_firstShow;
140         QScopedPointer<QSystemTrayIcon> m_systemTray;
141         int m_shutdownFlag;
142         QScopedPointer<CPUObserverThread>  m_cpuObserver;
143         QScopedPointer<RAMObserverThread>  m_ramObserver;
144         QScopedPointer<DiskObserverThread> m_diskObserver;
145         QScopedPointer<QElapsedTimer> m_totalTime;
146         int m_progressViewFilter;
147         QScopedPointer<QColor> m_defaultColor;
148         QScopedPointer<FileExtsModel> m_fileExts;
149         QScopedPointer<MUtils::Taskbar7> m_taskbar;
150         QScopedPointer<QIcon> m_iconRunning;
151         QScopedPointer<QIcon> m_iconError;
152         QScopedPointer<QIcon> m_iconWarning;
153         QScopedPointer<QIcon> m_iconSuccess;
154
155         static bool isFastSeekingDevice(const QString &path);
156         static quint32 cores2instances(const quint32 &cores);
157         static QString time2text(const qint64 &msec);
158 };