OSDN Git Service

Implemented option to switch GUI style at runtime
authorlordmulder <mulder2@gmx.de>
Sun, 7 Nov 2010 23:24:54 +0000 (00:24 +0100)
committerlordmulder <mulder2@gmx.de>
Sun, 7 Nov 2010 23:24:54 +0000 (00:24 +0100)
LameXP.rc
gui/MainWindow.ui
src/Dialog_MainWindow.cpp
src/Dialog_MainWindow.h
src/Main.cpp
src/Thread_FileAnalyzer.cpp

index f72d9e6..ae1581e 100644 (file)
--- a/LameXP.rc
+++ b/LameXP.rc
 #undef APSTUDIO_READONLY_SYMBOLS
 
 /////////////////////////////////////////////////////////////////////////////
-// German (Germany) resources
+// Neutral resources
 
-#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_DEU)
+#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_NEU)
 #ifdef _WIN32
-LANGUAGE LANG_GERMAN, SUBLANG_GERMAN
+LANGUAGE LANG_NEUTRAL, SUBLANG_NEUTRAL
 #pragma code_page(1252)
 #endif //_WIN32
 
-#ifdef APSTUDIO_INVOKED
-/////////////////////////////////////////////////////////////////////////////
-//
-// TEXTINCLUDE
-//
-
-1 TEXTINCLUDE 
-BEGIN
-    "src\\Resource.h\0"
-END
-
-2 TEXTINCLUDE 
-BEGIN
-    "#include ""afxres.h""\r\n"
-    "\0"
-END
-
-3 TEXTINCLUDE 
-BEGIN
-    "\r\n"
-    "\0"
-END
-
-#endif    // APSTUDIO_INVOKED
-
-
-/////////////////////////////////////////////////////////////////////////////
-//
-// WAVE
-//
-
-IDR_WAVE_ABOUT          WAVE                    "res\\sounds\\uuaarrgh.wav"
-
 /////////////////////////////////////////////////////////////////////////////
 //
 // Version
@@ -79,7 +46,7 @@ BEGIN
             VALUE "Comments", "This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY"
             VALUE "CompanyName", "Free Software Foundation"
             VALUE "FileDescription", "LameXP - Audio Encoder Front-End"
-                       VALUE "FileVersion", VER_LAMEXP_STR
+            VALUE "FileVersion", VER_LAMEXP_STR
             VALUE "InternalName", "LameXP Qt"
             VALUE "LegalCopyright", "Copyright (C) 2004-2010 LoRd_MuldeR <MuldeR2@GMX.de>"
             VALUE "LegalTrademarks", "This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License <http://www.gnu.org/>"
@@ -94,6 +61,51 @@ BEGIN
     END
 END
 
+#endif    // Neutral resources
+/////////////////////////////////////////////////////////////////////////////
+
+
+/////////////////////////////////////////////////////////////////////////////
+// German (Germany) resources
+
+#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_DEU)
+#ifdef _WIN32
+LANGUAGE LANG_GERMAN, SUBLANG_GERMAN
+#pragma code_page(1252)
+#endif //_WIN32
+
+#ifdef APSTUDIO_INVOKED
+/////////////////////////////////////////////////////////////////////////////
+//
+// TEXTINCLUDE
+//
+
+1 TEXTINCLUDE 
+BEGIN
+    "src\\Resource.h\0"
+END
+
+2 TEXTINCLUDE 
+BEGIN
+    "#include ""afxres.h""\r\n"
+    "\0"
+END
+
+3 TEXTINCLUDE 
+BEGIN
+    "\r\n"
+    "\0"
+END
+
+#endif    // APSTUDIO_INVOKED
+
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// WAVE
+//
+
+IDR_WAVE_ABOUT          WAVE                    "res\\sounds\\uuaarrgh.wav"
 
 /////////////////////////////////////////////////////////////////////////////
 //
index e7fb160..1af5f1f 100644 (file)
     <property name="title">
      <string>View</string>
     </property>
+    <widget class="QMenu" name="menuStyle">
+     <property name="title">
+      <string>Style</string>
+     </property>
+     <addaction name="actionStylePlastique"/>
+     <addaction name="actionStyleCleanlooks"/>
+     <addaction name="actionStyleWindows"/>
+     <addaction name="actionStyleClassic"/>
+    </widget>
     <addaction name="actionSourceFiles"/>
     <addaction name="actionOutputDirectory"/>
     <addaction name="actionCompression"/>
     <addaction name="actionMetaData"/>
     <addaction name="actionAdvancedOptions"/>
+    <addaction name="separator"/>
+    <addaction name="menuStyle"/>
    </widget>
    <addaction name="menuFile"/>
    <addaction name="menuView"/>
      <normaloff>:/icons/world.png</normaloff>:/icons/world.png</iconset>
    </property>
    <property name="text">
-    <string>Visit Official Homepage</string>
+    <string>Visit Official Web-Site</string>
    </property>
    <property name="toolTip">
     <string>Visit Official Web-Site</string>
     <string>Clear All</string>
    </property>
   </action>
+  <action name="actionStylePlastique">
+   <property name="checkable">
+    <bool>true</bool>
+   </property>
+   <property name="checked">
+    <bool>true</bool>
+   </property>
+   <property name="text">
+    <string>Plastique</string>
+   </property>
+  </action>
+  <action name="actionStyleCleanlooks">
+   <property name="checkable">
+    <bool>true</bool>
+   </property>
+   <property name="text">
+    <string>Cleanlooks</string>
+   </property>
+  </action>
+  <action name="actionStyleWindows">
+   <property name="checkable">
+    <bool>true</bool>
+   </property>
+   <property name="text">
+    <string>Windows</string>
+   </property>
+  </action>
+  <action name="actionStyleClassic">
+   <property name="checkable">
+    <bool>true</bool>
+   </property>
+   <property name="text">
+    <string>Classic</string>
+   </property>
+  </action>
  </widget>
  <resources>
   <include location="../res/Icons.qrc"/>
   <include location="../res/Images.qrc"/>
   <include location="../res/Images.qrc"/>
   <include location="../res/Images.qrc"/>
+  <include location="../res/Images.qrc"/>
+  <include location="../res/Images.qrc"/>
  </resources>
  <connections>
   <connection>
index 76ce099..b1e1620 100644 (file)
 #include <QFileSystemModel>
 #include <QDesktopServices>
 #include <QUrl>
+#include <QPlastiqueStyle>
+#include <QCleanlooksStyle>
+#include <QWindowsVistaStyle>
+#include <QWindowsStyle>
 
 //Win32 includes
 #include <Windows.h>
@@ -115,6 +119,15 @@ MainWindow::MainWindow(QWidget *parent)
        actionSourceFiles->setChecked(true);
        connect(m_tabActionGroup, SIGNAL(triggered(QAction*)), this, SLOT(tabActionActivated(QAction*)));
 
+       //Activate style menu actions
+       m_styleActionGroup = new QActionGroup(this);
+       m_styleActionGroup->addAction(actionStylePlastique);
+       m_styleActionGroup->addAction(actionStyleCleanlooks);
+       m_styleActionGroup->addAction(actionStyleWindows);
+       m_styleActionGroup->addAction(actionStyleClassic);
+       actionStylePlastique->setChecked(true);
+       connect(m_styleActionGroup, SIGNAL(triggered(QAction*)), this, SLOT(styleActionActivated(QAction*)));
+
        //Activate help menu actions
        connect(actionCheckUpdates, SIGNAL(triggered()), this, SLOT(checkUpdatesActionActivated()));
        connect(actionVisitHomepage, SIGNAL(triggered()), this, SLOT(visitHomepageActionActivated()));
@@ -136,6 +149,7 @@ MainWindow::MainWindow(QWidget *parent)
 MainWindow::~MainWindow(void)
 {
        LAMEXP_DELETE(m_tabActionGroup);
+       LAMEXP_DELETE(m_styleActionGroup);
        LAMEXP_DELETE(m_fileListModel);
        LAMEXP_DELETE(m_banner);
        LAMEXP_DELETE(m_fileSystemModel);
@@ -282,6 +296,7 @@ void MainWindow::addFilesButtonClicked(void)
  */
 void MainWindow::openFolderActionActivated(void)
 {
+       tabWidget->setCurrentIndex(0);
        QString selectedFolder = QFileDialog::getExistingDirectory(this, "Add folder", QDesktopServices::storageLocation(QDesktopServices::MusicLocation));
        
        if(!selectedFolder.isEmpty())
@@ -431,6 +446,17 @@ void MainWindow::tabActionActivated(QAction *action)
 }
 
 /*
+ * Style action triggered
+ */
+void MainWindow::styleActionActivated(QAction *action)
+{
+       if(action == actionStylePlastique) QApplication::setStyle(new QPlastiqueStyle());
+       else if(action == actionStyleCleanlooks) QApplication::setStyle(new QCleanlooksStyle());
+       else if(action == actionStyleWindows) QApplication::setStyle(new QWindowsVistaStyle());
+       else if(action == actionStyleClassic) QApplication::setStyle(new QWindowsStyle());
+}
+
+/*
  * Output folder changed
  */
 void MainWindow::outputFolderViewClicked(const QModelIndex &index)
index 6739f15..38fee2d 100644 (file)
@@ -48,6 +48,7 @@ private slots:
        void editMetaButtonClicked(void);
        void tabPageChanged(int idx);
        void tabActionActivated(QAction *action);
+       void styleActionActivated(QAction *action);
        void outputFolderViewClicked(const QModelIndex &index);
        void makeFolderButtonClicked(void);
        void gotoHomeFolderButtonClicked(void);
@@ -61,5 +62,6 @@ private:
        FileListModel *m_fileListModel;
        QFileSystemModel *m_fileSystemModel;
        QActionGroup *m_tabActionGroup;
+       QActionGroup *m_styleActionGroup;
        WorkingBanner *m_banner;
 };
index 39b8231..b305ee5 100644 (file)
@@ -46,7 +46,7 @@ int lamexp_main(int argc, char* argv[])
        
        //print license info
        qDebug("This program is free software: you can redistribute it and/or modify");
-    qDebug("it under the terms of the GNU General Public License <http://www.gnu.org/>.");
+       qDebug("it under the terms of the GNU General Public License <http://www.gnu.org/>.");
        qDebug("This program comes with ABSOLUTELY NO WARRANTY.\n");
        
        //Print warning, if this is a "debug" build
index 30b768f..d26279d 100644 (file)
@@ -64,7 +64,7 @@ void FileAnalyzer::run()
                qDebug("Analyzing: %s", currentFile.toUtf8().constData());
                emit fileSelected(QFileInfo(currentFile).fileName());
                AudioFileModel file = analyzeFile(currentFile);
-               if(file.formatContainerType().isEmpty() || file.formatAudioType().isEmpty())
+               if(file.fileName().isEmpty() || file.formatContainerType().isEmpty() || file.formatAudioType().isEmpty())
                {
                        qDebug("Skipped: %s", file.filePath().toUtf8().constData());
                        continue;
@@ -85,6 +85,17 @@ const AudioFileModel FileAnalyzer::analyzeFile(const QString &filePath)
        AudioFileModel audioFile(filePath);
        m_currentSection = sectionOther;
 
+       QFile readTest(filePath);
+       if(!readTest.open(QIODevice::ReadOnly))
+       {
+               qWarning("Cannot access file for reading, skipping!");
+               return audioFile;
+       }
+       else
+       {
+               readTest.close();
+       }
+
        QProcess process;
        process.setProcessChannelMode(QProcess::MergedChannels);
        process.setReadChannel(QProcess::StandardOutput);
@@ -93,7 +104,17 @@ const AudioFileModel FileAnalyzer::analyzeFile(const QString &filePath)
 
        while(process.state() != QProcess::NotRunning)
        {
-               process.waitForReadyRead(1000);
+               if(!process.waitForReadyRead())
+               {
+                       if(process.state() == QProcess::Running)
+                       {
+                               qWarning("MediaInfo time out. Killing process and skipping file!");
+                               process.kill();
+                               process.waitForFinished(-1);
+                               return audioFile;
+                       }
+               }
+
                QByteArray data = process.readLine().constData();
                while(data.size() > 0)
                {
@@ -139,7 +160,7 @@ const AudioFileModel FileAnalyzer::analyzeFile(const QString &filePath)
 
                audioFile.setFileName(baseName);
        }
-
+       
        return audioFile;
 }
 
@@ -307,4 +328,4 @@ unsigned int FileAnalyzer::parseDuration(const QString &str)
 // EVENTS
 ////////////////////////////////////////////////////////////
 
-/*NONE*/
\ No newline at end of file
+/*NONE*/