OSDN Git Service

Extinguished some remaining uses of argv[] or QApplication::arguments().
[lamexp/LameXP.git] / src / Dialog_Processing.cpp
index ab66acb..d73b199 100644 (file)
@@ -1,6 +1,6 @@
 ///////////////////////////////////////////////////////////////////////////////
 // LameXP - Audio Encoder Front-End
-// Copyright (C) 2004-2011 LoRd_MuldeR <MuldeR2@GMX.de>
+// Copyright (C) 2004-2012 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
@@ -107,7 +107,8 @@ ProcessingDialog::ProcessingDialog(FileListModel *fileListModel, AudioFileModel
        m_shutdownFlag(shutdownFlag_None),
        m_diskObserver(NULL),
        m_cpuObserver(NULL),
-       m_ramObserver(NULL)
+       m_ramObserver(NULL),
+       m_firstShow(true)
 {
        //Init the dialog, from the .ui file
        setupUi(this);
@@ -256,23 +257,29 @@ ProcessingDialog::~ProcessingDialog(void)
 
 void ProcessingDialog::showEvent(QShowEvent *event)
 {
-       static const char *NA = " N/A";
+       QDialog::showEvent(event);
 
-       setCloseButtonEnabled(false);
-       button_closeDialog->setEnabled(false);
-       button_AbortProcess->setEnabled(false);
-       m_systemTray->setVisible(true);
-       
-       if(!SetPriorityClass(GetCurrentProcess(), ABOVE_NORMAL_PRIORITY_CLASS))
+       if(m_firstShow)
        {
-               SetPriorityClass(GetCurrentProcess(), HIGH_PRIORITY_CLASS);
-       }
+               static const char *NA = " N/A";
+       
+               setCloseButtonEnabled(false);
+               button_closeDialog->setEnabled(false);
+               button_AbortProcess->setEnabled(false);
+               m_systemTray->setVisible(true);
+       
+               if(!SetPriorityClass(GetCurrentProcess(), ABOVE_NORMAL_PRIORITY_CLASS))
+               {
+                       SetPriorityClass(GetCurrentProcess(), HIGH_PRIORITY_CLASS);
+               }
 
-       label_cpu->setText(NA);
-       label_disk->setText(NA);
-       label_ram->setText(NA);
+               label_cpu->setText(NA);
+               label_disk->setText(NA);
+               label_ram->setText(NA);
 
-       QTimer::singleShot(1000, this, SLOT(initEncoding()));
+               QTimer::singleShot(1000, this, SLOT(initEncoding()));
+               m_firstShow = false;
+       }
 }
 
 void ProcessingDialog::closeEvent(QCloseEvent *event)
@@ -352,6 +359,8 @@ bool ProcessingDialog::winEvent(MSG *message, long *result)
 
 void ProcessingDialog::initEncoding(void)
 {
+       qDebug("Initializing encoding process...");
+       
        m_runningThreads = 0;
        m_currentFile = 0;
        m_allJobs.clear();
@@ -398,7 +407,7 @@ void ProcessingDialog::initEncoding(void)
        unsigned int maximumInstances = qBound(0U, m_settings->maximumInstances(), MAX_INSTANCES);
        if(maximumInstances < 1)
        {
-               lamexp_cpu_t cpuFeatures = lamexp_detect_cpu_features();
+               lamexp_cpu_t cpuFeatures = lamexp_detect_cpu_features(lamexp_arguments());
                maximumInstances = cores2instances(qBound(1, cpuFeatures.count, 64));
        }
 
@@ -962,7 +971,7 @@ void ProcessingDialog::systemTrayActivated(QSystemTrayIcon::ActivationReason rea
 {
        if(reason == QSystemTrayIcon::DoubleClick)
        {
-               SetForegroundWindow(this->winId());
+               SetForegroundWindow(reinterpret_cast<HWND>(this->winId()));
        }
 }