Implemented option to switch GUI style at runtime

This commit is contained in:
LoRd_MuldeR 2010-11-08 00:24:54 +01:00
parent ce41761614
commit f6259b2482
6 changed files with 156 additions and 47 deletions

View File

@ -12,6 +12,59 @@
///////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////
#undef APSTUDIO_READONLY_SYMBOLS #undef APSTUDIO_READONLY_SYMBOLS
/////////////////////////////////////////////////////////////////////////////
// Neutral resources
#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_NEU)
#ifdef _WIN32
LANGUAGE LANG_NEUTRAL, SUBLANG_NEUTRAL
#pragma code_page(1252)
#endif //_WIN32
/////////////////////////////////////////////////////////////////////////////
//
// Version
//
VS_VERSION_INFO VERSIONINFO
FILEVERSION VER_LAMEXP_MAJOR,VER_LAMEXP_MINOR_HI,VER_LAMEXP_MINOR_LO,VER_LAMEXP_BUILD
PRODUCTVERSION VER_LAMEXP_MAJOR,VER_LAMEXP_MINOR_HI,VER_LAMEXP_MINOR_LO,VER_LAMEXP_BUILD
FILEFLAGSMASK 0x17L
#ifdef _DEBUG
FILEFLAGS 0x3L
#else
FILEFLAGS 0x2L
#endif
FILEOS 0x40004L
FILETYPE 0x1L
FILESUBTYPE 0x0L
BEGIN
BLOCK "StringFileInfo"
BEGIN
BLOCK "000004b0"
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 "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/>"
VALUE "OriginalFilename", "LameXP.exe"
VALUE "ProductName", "LameXP - Audio Encoder Front-End"
VALUE "ProductVersion", VER_LAMEXP_STR
END
END
BLOCK "VarFileInfo"
BEGIN
VALUE "Translation", 0x0, 1200
END
END
#endif // Neutral resources
/////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////
// German (Germany) resources // German (Germany) resources
@ -54,47 +107,6 @@ END
IDR_WAVE_ABOUT WAVE "res\\sounds\\uuaarrgh.wav" IDR_WAVE_ABOUT WAVE "res\\sounds\\uuaarrgh.wav"
/////////////////////////////////////////////////////////////////////////////
//
// Version
//
VS_VERSION_INFO VERSIONINFO
FILEVERSION VER_LAMEXP_MAJOR,VER_LAMEXP_MINOR_HI,VER_LAMEXP_MINOR_LO,VER_LAMEXP_BUILD
PRODUCTVERSION VER_LAMEXP_MAJOR,VER_LAMEXP_MINOR_HI,VER_LAMEXP_MINOR_LO,VER_LAMEXP_BUILD
FILEFLAGSMASK 0x17L
#ifdef _DEBUG
FILEFLAGS 0x3L
#else
FILEFLAGS 0x2L
#endif
FILEOS 0x40004L
FILETYPE 0x1L
FILESUBTYPE 0x0L
BEGIN
BLOCK "StringFileInfo"
BEGIN
BLOCK "000004b0"
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 "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/>"
VALUE "OriginalFilename", "LameXP.exe"
VALUE "ProductName", "LameXP - Audio Encoder Front-End"
VALUE "ProductVersion", VER_LAMEXP_STR
END
END
BLOCK "VarFileInfo"
BEGIN
VALUE "Translation", 0x0, 1200
END
END
///////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////
// //
// Icon // Icon

View File

@ -759,11 +759,22 @@
<property name="title"> <property name="title">
<string>View</string> <string>View</string>
</property> </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="actionSourceFiles"/>
<addaction name="actionOutputDirectory"/> <addaction name="actionOutputDirectory"/>
<addaction name="actionCompression"/> <addaction name="actionCompression"/>
<addaction name="actionMetaData"/> <addaction name="actionMetaData"/>
<addaction name="actionAdvancedOptions"/> <addaction name="actionAdvancedOptions"/>
<addaction name="separator"/>
<addaction name="menuStyle"/>
</widget> </widget>
<addaction name="menuFile"/> <addaction name="menuFile"/>
<addaction name="menuView"/> <addaction name="menuView"/>
@ -842,7 +853,7 @@
<normaloff>:/icons/world.png</normaloff>:/icons/world.png</iconset> <normaloff>:/icons/world.png</normaloff>:/icons/world.png</iconset>
</property> </property>
<property name="text"> <property name="text">
<string>Visit Official Homepage</string> <string>Visit Official Web-Site</string>
</property> </property>
<property name="toolTip"> <property name="toolTip">
<string>Visit Official Web-Site</string> <string>Visit Official Web-Site</string>
@ -875,6 +886,41 @@
<string>Clear All</string> <string>Clear All</string>
</property> </property>
</action> </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> </widget>
<resources> <resources>
<include location="../res/Icons.qrc"/> <include location="../res/Icons.qrc"/>
@ -898,6 +944,8 @@
<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"/> <include location="../res/Images.qrc"/>
<include location="../res/Images.qrc"/>
<include location="../res/Images.qrc"/>
</resources> </resources>
<connections> <connections>
<connection> <connection>

View File

@ -38,6 +38,10 @@
#include <QFileSystemModel> #include <QFileSystemModel>
#include <QDesktopServices> #include <QDesktopServices>
#include <QUrl> #include <QUrl>
#include <QPlastiqueStyle>
#include <QCleanlooksStyle>
#include <QWindowsVistaStyle>
#include <QWindowsStyle>
//Win32 includes //Win32 includes
#include <Windows.h> #include <Windows.h>
@ -115,6 +119,15 @@ MainWindow::MainWindow(QWidget *parent)
actionSourceFiles->setChecked(true); actionSourceFiles->setChecked(true);
connect(m_tabActionGroup, SIGNAL(triggered(QAction*)), this, SLOT(tabActionActivated(QAction*))); 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 //Activate help menu actions
connect(actionCheckUpdates, SIGNAL(triggered()), this, SLOT(checkUpdatesActionActivated())); connect(actionCheckUpdates, SIGNAL(triggered()), this, SLOT(checkUpdatesActionActivated()));
connect(actionVisitHomepage, SIGNAL(triggered()), this, SLOT(visitHomepageActionActivated())); connect(actionVisitHomepage, SIGNAL(triggered()), this, SLOT(visitHomepageActionActivated()));
@ -136,6 +149,7 @@ MainWindow::MainWindow(QWidget *parent)
MainWindow::~MainWindow(void) MainWindow::~MainWindow(void)
{ {
LAMEXP_DELETE(m_tabActionGroup); LAMEXP_DELETE(m_tabActionGroup);
LAMEXP_DELETE(m_styleActionGroup);
LAMEXP_DELETE(m_fileListModel); LAMEXP_DELETE(m_fileListModel);
LAMEXP_DELETE(m_banner); LAMEXP_DELETE(m_banner);
LAMEXP_DELETE(m_fileSystemModel); LAMEXP_DELETE(m_fileSystemModel);
@ -282,6 +296,7 @@ void MainWindow::addFilesButtonClicked(void)
*/ */
void MainWindow::openFolderActionActivated(void) void MainWindow::openFolderActionActivated(void)
{ {
tabWidget->setCurrentIndex(0);
QString selectedFolder = QFileDialog::getExistingDirectory(this, "Add folder", QDesktopServices::storageLocation(QDesktopServices::MusicLocation)); QString selectedFolder = QFileDialog::getExistingDirectory(this, "Add folder", QDesktopServices::storageLocation(QDesktopServices::MusicLocation));
if(!selectedFolder.isEmpty()) if(!selectedFolder.isEmpty())
@ -430,6 +445,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 * Output folder changed
*/ */

View File

@ -48,6 +48,7 @@ private slots:
void editMetaButtonClicked(void); void editMetaButtonClicked(void);
void tabPageChanged(int idx); void tabPageChanged(int idx);
void tabActionActivated(QAction *action); void tabActionActivated(QAction *action);
void styleActionActivated(QAction *action);
void outputFolderViewClicked(const QModelIndex &index); void outputFolderViewClicked(const QModelIndex &index);
void makeFolderButtonClicked(void); void makeFolderButtonClicked(void);
void gotoHomeFolderButtonClicked(void); void gotoHomeFolderButtonClicked(void);
@ -61,5 +62,6 @@ private:
FileListModel *m_fileListModel; FileListModel *m_fileListModel;
QFileSystemModel *m_fileSystemModel; QFileSystemModel *m_fileSystemModel;
QActionGroup *m_tabActionGroup; QActionGroup *m_tabActionGroup;
QActionGroup *m_styleActionGroup;
WorkingBanner *m_banner; WorkingBanner *m_banner;
}; };

View File

@ -46,7 +46,7 @@ int lamexp_main(int argc, char* argv[])
//print license info //print license info
qDebug("This program is free software: you can redistribute it and/or modify"); 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"); qDebug("This program comes with ABSOLUTELY NO WARRANTY.\n");
//Print warning, if this is a "debug" build //Print warning, if this is a "debug" build

View File

@ -64,7 +64,7 @@ void FileAnalyzer::run()
qDebug("Analyzing: %s", currentFile.toUtf8().constData()); qDebug("Analyzing: %s", currentFile.toUtf8().constData());
emit fileSelected(QFileInfo(currentFile).fileName()); emit fileSelected(QFileInfo(currentFile).fileName());
AudioFileModel file = analyzeFile(currentFile); 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()); qDebug("Skipped: %s", file.filePath().toUtf8().constData());
continue; continue;
@ -85,6 +85,17 @@ const AudioFileModel FileAnalyzer::analyzeFile(const QString &filePath)
AudioFileModel audioFile(filePath); AudioFileModel audioFile(filePath);
m_currentSection = sectionOther; 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; QProcess process;
process.setProcessChannelMode(QProcess::MergedChannels); process.setProcessChannelMode(QProcess::MergedChannels);
process.setReadChannel(QProcess::StandardOutput); process.setReadChannel(QProcess::StandardOutput);
@ -93,7 +104,17 @@ const AudioFileModel FileAnalyzer::analyzeFile(const QString &filePath)
while(process.state() != QProcess::NotRunning) 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(); QByteArray data = process.readLine().constData();
while(data.size() > 0) while(data.size() > 0)
{ {
@ -139,7 +160,7 @@ const AudioFileModel FileAnalyzer::analyzeFile(const QString &filePath)
audioFile.setFileName(baseName); audioFile.setFileName(baseName);
} }
return audioFile; return audioFile;
} }
@ -307,4 +328,4 @@ unsigned int FileAnalyzer::parseDuration(const QString &str)
// EVENTS // EVENTS
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
/*NONE*/ /*NONE*/