OSDN Git Service

Refactored the Main() function into several sub-functions + some improvements of...
[lamexp/LameXP.git] / src / Dialog_Processing.h
index e6ece17..9a99bff 100644 (file)
@@ -1,11 +1,12 @@
 ///////////////////////////////////////////////////////////////////////////////
 // LameXP - Audio Encoder Front-End
-// Copyright (C) 2004-2012 LoRd_MuldeR <MuldeR2@GMX.de>
+// Copyright (C) 2004-2014 LoRd_MuldeR <MuldeR2@GMX.de>
 //
 // This program is free software; you can redistribute it and/or modify
 // it under the terms of the GNU General Public License as published by
 // the Free Software Foundation; either version 2 of the License, or
-// (at your option) any later version.
+// (at your option) any later version, but always including the *additional*
+// restrictions defined in the "License.txt" file.
 //
 // This program is distributed in the hope that it will be useful,
 // but WITHOUT ANY WARRANTY; without even the implied warranty of
 
 #pragma once
 
-#include "../tmp/UIC_ProcessingDialog.h"
-
+#include <QDialog>
 #include <QUuid>
 #include <QSystemTrayIcon>
+#include <QMap>
 
-class QMovie;
-class QMenu;
-class ProgressModel;
-class ProcessThread;
-class FileListModel;
+class AbstractEncoder;
 class AudioFileModel;
-class SettingsModel;
+class AudioFileModel_MetaInfo;
 class CPUObserverThread;
-class RAMObserverThread;
 class DiskObserverThread;
-class AbstractEncoder;
+class FileListModel;
+class ProcessThread;
+class ProgressModel;
+class QActionGroup;
+class QLabel;
+class QMenu;
+class QModelIndex;
+class QMovie;
+class QThreadPool;
+class QElapsedTimer;
+class RAMObserverThread;
+class SettingsModel;
 
-enum shutdownFlag_t
+enum lamexp_shutdownFlag_t
 {
-       shutdownFlag_None = 0,
-       shutdownFlag_TurnPowerOff = 1,
-       shutdownFlag_Hibernate = 2
+       SHUTDOWN_FLAG_NONE = 0,
+       SHUTDOWN_FLAG_POWER_OFF = 1,
+       SHUTDOWN_FLAG_HIBERNATE = 2
 };
 
-class ProcessingDialog : public QDialog, private Ui::ProcessingDialog
+//UIC forward declartion
+namespace Ui {
+       class ProcessingDialog;
+}
+
+//ProcessingDialog class
+class ProcessingDialog : public QDialog
 {
        Q_OBJECT
 
 public:
-       ProcessingDialog(FileListModel *fileListModel, AudioFileModel *metaInfo, SettingsModel *settings, QWidget *parent = 0);
+       ProcessingDialog(FileListModel *fileListModel, const AudioFileModel_MetaInfo *metaInfo, SettingsModel *settings, QWidget *parent = 0);
        ~ProcessingDialog(void);
        
        int getShutdownFlag(void) { return m_shutdownFlag; }
 
 private slots:
        void initEncoding(void);
+       void initNextJob(void);
+       void startNextJob(void);
        void doneEncoding(void);
        void abortEncoding(bool force = false);
        void processFinished(const QUuid &jobId, const QString &outFileName, int success);
@@ -73,6 +88,9 @@ private slots:
        void diskUsageHasChanged(const quint64 val);
        void progressViewFilterChanged(void);
 
+signals:
+       void abortRunningTasks(void);
+
 protected:
        void showEvent(QShowEvent *event);
        void closeEvent(QCloseEvent *event);
@@ -82,18 +100,17 @@ protected:
        virtual void resizeEvent(QResizeEvent *event);
 
 private:
-       void setCloseButtonEnabled(bool enabled);
-       void startNextJob(void);
-       AbstractEncoder *makeEncoder(bool *nativeResampling);
-       AudioFileModel updateMetaInfo(const AudioFileModel &audioFile);
+       Ui::ProcessingDialog *ui; //for Qt UIC
+
+       AudioFileModel updateMetaInfo(AudioFileModel &audioFile);
        void writePlayList(void);
        bool shutdownComputer(void);
-       QString time2text(const double timeVal) const;
+       QString time2text(const qint64 &msec) const;
        
+       QThreadPool *m_threadPool;
        QList<AudioFileModel> m_pendingJobs;
        SettingsModel *m_settings;
-       AudioFileModel *m_metaInfo;
-       QList<ProcessThread*> m_threadList;
+       const AudioFileModel_MetaInfo *const m_metaInfo;
        QMovie *m_progressIndicator;
        ProgressModel *m_progressModel;
        QMap<QUuid,QString> m_playList;
@@ -101,6 +118,7 @@ private:
        QActionGroup *m_progressViewFilterGroup;
        QLabel *m_filterInfoLabel;
        QLabel *m_filterInfoLabelIcon;
+       unsigned int m_initThreads;
        unsigned int m_runningThreads;
        unsigned int m_currentFile;
        QList<QUuid> m_allJobs;
@@ -115,6 +133,7 @@ private:
        CPUObserverThread *m_cpuObserver;
        RAMObserverThread *m_ramObserver;
        DiskObserverThread *m_diskObserver;
-       qint64 m_timerStart;
+       QScopedPointer<QElapsedTimer> m_totalTime;
        int m_progressViewFilter;
+       QColor *m_defaultColor;
 };