Added support for a true "portable" mode: If you rename the LameXP executable to 'LameXP-Portable.exe' it will store the configuration file in the same folder where the executable is located. This might be helpful if you put LameXP onto your USB stick and use it on different computers regularly. Important: In "portable" mode the user is responsible to make sure that write-access to LameXP folder is available!

This commit is contained in:
LoRd_MuldeR 2011-01-24 00:04:07 +01:00
parent dcf4181974
commit fb707cb257
5 changed files with 35 additions and 4 deletions

View File

@ -25,7 +25,7 @@
#define VER_LAMEXP_MAJOR 4
#define VER_LAMEXP_MINOR_HI 0
#define VER_LAMEXP_MINOR_LO 0
#define VER_LAMEXP_BUILD 252
#define VER_LAMEXP_BUILD 253
#define VER_LAMEXP_SUFFIX Beta-1
/*

View File

@ -61,6 +61,7 @@
#include <QCryptographicHash>
#include <QTranslator>
#include <QResource>
#include <QScrollBar>
//Win32 includes
#include <Windows.h>
@ -693,11 +694,13 @@ void MainWindow::windowShown(void)
else
{
radioButtonEncoderAAC->setEnabled(false);
QString appPath = QDir(QCoreApplication::applicationDirPath()).canonicalPath();
if(appPath.isEmpty()) appPath = QCoreApplication::applicationDirPath();
QString messageText;
messageText += QString("<nobr>%1<br>").arg(tr("The Nero AAC encoder could not be found. AAC encoding support will be disabled."));
messageText += QString("%1<br><br>").arg(tr("Please put 'neroAacEnc.exe', 'neroAacDec.exe' and 'neroAacTag.exe' into the LameXP directory!"));
messageText += QString("%1<br>").arg(tr("Your LameXP directory is located here:"));
messageText += QString("<i><nobr><a href=\"file:///%1\">%1</a></nobr></i><br><br>").arg(QDir::toNativeSeparators(QCoreApplication::applicationDirPath()));
messageText += QString("<i><nobr><a href=\"file:///%1\">%1</a></nobr></i><br><br>").arg(QDir::toNativeSeparators(appPath));
messageText += QString("%1<br>").arg(tr("You can download the Nero AAC encoder for free from the official Nero website at:"));
messageText += "<b>" + LINK(AboutDialog::neroAacUrl) + "</b><br></nobr>";
QMessageBox::information(this, tr("AAC Support Disabled"), messageText);
@ -1702,6 +1705,7 @@ void MainWindow::resetAdvancedOptionsButtonClicked()
comboBoxNeroAACProfile->setCurrentIndex(m_settings->neroAACProfileDefault());
while(checkBoxBitrateManagement->isChecked() != m_settings->bitrateManagementEnabledDefault()) checkBoxBitrateManagement->click();
while(checkBoxNeroAAC2PassMode->isChecked() != m_settings->neroAACEnable2PassDefault()) checkBoxNeroAAC2PassMode->click();
scrollArea->verticalScrollBar()->setValue(0);
}
/*

View File

@ -715,6 +715,15 @@ void lamexp_ipc_read(unsigned int *command, char* message, size_t buffSize)
LAMEXP_DELETE(lamexp_ipc);
}
/*
* Check for LameXP "portable" mode
*/
bool lamexp_portable_mode(void)
{
QString baseName = QFileInfo(QApplication::applicationFilePath()).completeBaseName();
return baseName.contains("lamexp", Qt::CaseInsensitive) && baseName.contains("portable", Qt::CaseInsensitive);
}
/*
* Get a random string
*/

View File

@ -92,6 +92,7 @@ const QString &lamexp_temp_folder(void);
void lamexp_ipc_read(unsigned int *command, char* message, size_t buffSize);
void lamexp_ipc_send(unsigned int command, const char* message);
lamexp_cpu_t lamexp_detect_cpu_features(void);
bool lamexp_portable_mode(void);
//Translation support
QStringList lamexp_query_translations(void);

View File

@ -28,6 +28,7 @@
#include <QApplication>
#include <QString>
#include <QFileInfo>
#include <QDir>
#include <QStringList>
#include <QLocale>
@ -87,8 +88,24 @@ SettingsModel::SettingsModel(void)
:
m_defaultLanguage(NULL)
{
QString appPath = QDesktopServices::storageLocation(QDesktopServices::DataLocation);
m_settings = new QSettings(appPath.append("/config.ini"), QSettings::IniFormat);
QString configPath;
if(!lamexp_portable_mode())
{
QString dataPath = QDir(QDesktopServices::storageLocation(QDesktopServices::DataLocation)).canonicalPath();
if(dataPath.isEmpty()) dataPath = QDesktopServices::storageLocation(QDesktopServices::DataLocation);
QDir(dataPath).mkpath(".");
configPath = QString("%1/config.ini").arg(dataPath);
}
else
{
qDebug("LameXP is running in \"portable\" mode -> config in application dir!\n");
QString appPath = QFileInfo(QApplication::applicationFilePath()).canonicalFilePath();
if(appPath.isEmpty()) appPath = QApplication::applicationFilePath();
configPath = QString("%1/%2.ini").arg(QFileInfo(appPath).absolutePath(), QFileInfo(appPath).completeBaseName());
}
m_settings = new QSettings(configPath, QSettings::IniFormat);
m_settings->beginGroup(QString().sprintf("LameXP_%u%02u%05u", lamexp_version_major(), lamexp_version_minor(), lamexp_version_build()));
m_settings->setValue(g_settingsId_versionNumber, QApplication::applicationVersion());
m_settings->sync();