OSDN Git Service

Updated Monkey's Audio binary to v4.11 (2013-01-20), including STDERR flush fix.
[lamexp/LameXP.git] / src / Dialog_Processing.h
1 ///////////////////////////////////////////////////////////////////////////////
2 // LameXP - Audio Encoder Front-End
3 // Copyright (C) 2004-2013 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 #include <QDialog>
25 #include <QUuid>
26 #include <QSystemTrayIcon>
27 #include <QMap>
28
29 class AbstractEncoder;
30 class AudioFileModel;
31 class CPUObserverThread;
32 class DiskObserverThread;
33 class FileListModel;
34 class ProcessThread;
35 class ProgressModel;
36 class QActionGroup;
37 class QLabel;
38 class QMenu;
39 class QModelIndex;
40 class QMovie;
41 class RAMObserverThread;
42 class SettingsModel;
43
44 enum shutdownFlag_t
45 {
46         shutdownFlag_None = 0,
47         shutdownFlag_TurnPowerOff = 1,
48         shutdownFlag_Hibernate = 2
49 };
50
51 //UIC forward declartion
52 namespace Ui {
53         class ProcessingDialog;
54 }
55
56 //ProcessingDialog class
57 class ProcessingDialog : public QDialog
58 {
59         Q_OBJECT
60
61 public:
62         ProcessingDialog(FileListModel *fileListModel, AudioFileModel *metaInfo, SettingsModel *settings, QWidget *parent = 0);
63         ~ProcessingDialog(void);
64         
65         int getShutdownFlag(void) { return m_shutdownFlag; }
66
67 private slots:
68         void initEncoding(void);
69         void doneEncoding(void);
70         void abortEncoding(bool force = false);
71         void processFinished(const QUuid &jobId, const QString &outFileName, int success);
72         void progressModelChanged(void);
73         void logViewDoubleClicked(const QModelIndex &index);
74         void logViewSectionSizeChanged(int, int, int);
75         void contextMenuTriggered(const QPoint &pos);
76         void contextMenuDetailsActionTriggered(void);
77         void contextMenuShowFileActionTriggered(void);
78         void contextMenuFilterActionTriggered(void);
79         void systemTrayActivated(QSystemTrayIcon::ActivationReason reason);
80         void cpuUsageHasChanged(const double val);
81         void ramUsageHasChanged(const double val);
82         void diskUsageHasChanged(const quint64 val);
83         void progressViewFilterChanged(void);
84
85 protected:
86         void showEvent(QShowEvent *event);
87         void closeEvent(QCloseEvent *event);
88         bool eventFilter(QObject *obj, QEvent *event);
89         virtual bool event(QEvent *e);
90         virtual bool winEvent(MSG *message, long *result);
91         virtual void resizeEvent(QResizeEvent *event);
92
93 private:
94         Ui::ProcessingDialog *ui; //for Qt UIC
95
96         void setCloseButtonEnabled(bool enabled);
97         void startNextJob(void);
98         AbstractEncoder *makeEncoder(bool *nativeResampling);
99         AudioFileModel updateMetaInfo(const AudioFileModel &audioFile);
100         void writePlayList(void);
101         bool shutdownComputer(void);
102         QString time2text(const double timeVal) const;
103         
104         QList<AudioFileModel> m_pendingJobs;
105         SettingsModel *m_settings;
106         AudioFileModel *m_metaInfo;
107         QList<ProcessThread*> m_threadList;
108         QMovie *m_progressIndicator;
109         ProgressModel *m_progressModel;
110         QMap<QUuid,QString> m_playList;
111         QMenu *m_contextMenu;
112         QActionGroup *m_progressViewFilterGroup;
113         QLabel *m_filterInfoLabel;
114         QLabel *m_filterInfoLabelIcon;
115         unsigned int m_runningThreads;
116         unsigned int m_currentFile;
117         QList<QUuid> m_allJobs;
118         QList<QUuid> m_succeededJobs;
119         QList<QUuid> m_failedJobs;
120         QList<QUuid> m_skippedJobs;
121         bool m_userAborted;
122         bool m_forcedAbort;
123         bool m_firstShow;
124         QSystemTrayIcon *m_systemTray;
125         int m_shutdownFlag;
126         CPUObserverThread *m_cpuObserver;
127         RAMObserverThread *m_ramObserver;
128         DiskObserverThread *m_diskObserver;
129         qint64 m_timerStart;
130         int m_progressViewFilter;
131 };