Implemented a portable mode. Will be enabled, if the string "portable" is found in the EXE name.
This commit is contained in:
parent
074e9f9b7e
commit
5ceb25656c
@ -372,6 +372,25 @@ const char *x264_version_arch(void)
|
|||||||
return g_x264_version_arch;
|
return g_x264_version_arch;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Check for portable mode
|
||||||
|
*/
|
||||||
|
bool x264_portable(void)
|
||||||
|
{
|
||||||
|
static bool detected = false;
|
||||||
|
static bool portable = false;
|
||||||
|
|
||||||
|
if(!detected)
|
||||||
|
{
|
||||||
|
portable = portable || QFileInfo(QApplication::applicationFilePath()).baseName().contains(QRegExp("^portable[^A-Za-z0-9]", Qt::CaseInsensitive));
|
||||||
|
portable = portable || QFileInfo(QApplication::applicationFilePath()).baseName().contains(QRegExp("[^A-Za-z0-9]portable[^A-Za-z0-9]", Qt::CaseInsensitive));
|
||||||
|
portable = portable || QFileInfo(QApplication::applicationFilePath()).baseName().contains(QRegExp("[^A-Za-z0-9]portable$", Qt::CaseInsensitive));
|
||||||
|
detected = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return portable;
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Get build date date
|
* Get build date date
|
||||||
*/
|
*/
|
||||||
|
@ -99,6 +99,7 @@ unsigned int x264_version_major(void);
|
|||||||
unsigned int x264_version_minor(void);
|
unsigned int x264_version_minor(void);
|
||||||
unsigned int x264_version_patch(void);
|
unsigned int x264_version_patch(void);
|
||||||
const QDate &x264_version_date(void);
|
const QDate &x264_version_date(void);
|
||||||
|
bool x264_portable(void);
|
||||||
bool x264_is_prerelease(void);
|
bool x264_is_prerelease(void);
|
||||||
const char *x264_version_time(void);
|
const char *x264_version_time(void);
|
||||||
const char *x264_version_compiler(void);
|
const char *x264_version_compiler(void);
|
||||||
|
@ -69,6 +69,12 @@ static int x264_main(int argc, char* argv[])
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//Running in portable mode?
|
||||||
|
if(x264_portable())
|
||||||
|
{
|
||||||
|
qDebug("Application is running in portable mode!\n");
|
||||||
|
}
|
||||||
|
|
||||||
//Taskbar init
|
//Taskbar init
|
||||||
WinSevenTaskbar::init();
|
WinSevenTaskbar::init();
|
||||||
|
|
||||||
|
@ -26,6 +26,7 @@
|
|||||||
#include <QDesktopServices>
|
#include <QDesktopServices>
|
||||||
#include <QSettings>
|
#include <QSettings>
|
||||||
#include <QStringList>
|
#include <QStringList>
|
||||||
|
#include <QApplication>
|
||||||
|
|
||||||
OptionsModel::OptionsModel(void)
|
OptionsModel::OptionsModel(void)
|
||||||
{
|
{
|
||||||
@ -82,7 +83,7 @@ bool OptionsModel::equals(OptionsModel *model)
|
|||||||
bool OptionsModel::saveTemplate(OptionsModel *model, const QString &name)
|
bool OptionsModel::saveTemplate(OptionsModel *model, const QString &name)
|
||||||
{
|
{
|
||||||
const QString templateName = name.simplified();
|
const QString templateName = name.simplified();
|
||||||
const QString appDir = QDesktopServices::storageLocation(QDesktopServices::DataLocation);
|
const QString appDir = x264_portable() ? QApplication::applicationDirPath() : QDesktopServices::storageLocation(QDesktopServices::DataLocation);
|
||||||
|
|
||||||
if(templateName.contains('\\') || templateName.contains('/'))
|
if(templateName.contains('\\') || templateName.contains('/'))
|
||||||
{
|
{
|
||||||
@ -108,7 +109,7 @@ bool OptionsModel::saveTemplate(OptionsModel *model, const QString &name)
|
|||||||
|
|
||||||
bool OptionsModel::loadTemplate(OptionsModel *model, const QString &name)
|
bool OptionsModel::loadTemplate(OptionsModel *model, const QString &name)
|
||||||
{
|
{
|
||||||
const QString appDir = QDesktopServices::storageLocation(QDesktopServices::DataLocation);
|
const QString appDir = x264_portable() ? QApplication::applicationDirPath() : QDesktopServices::storageLocation(QDesktopServices::DataLocation);
|
||||||
|
|
||||||
if(name.contains('\\') || name.contains('/'))
|
if(name.contains('\\') || name.contains('/'))
|
||||||
{
|
{
|
||||||
@ -145,7 +146,7 @@ bool OptionsModel::loadTemplate(OptionsModel *model, const QString &name)
|
|||||||
QMap<QString, OptionsModel*> OptionsModel::loadAllTemplates(void)
|
QMap<QString, OptionsModel*> OptionsModel::loadAllTemplates(void)
|
||||||
{
|
{
|
||||||
QMap<QString, OptionsModel*> list;
|
QMap<QString, OptionsModel*> list;
|
||||||
const QString appDir = QDesktopServices::storageLocation(QDesktopServices::DataLocation);
|
const QString appDir = x264_portable() ? QApplication::applicationDirPath() : QDesktopServices::storageLocation(QDesktopServices::DataLocation);
|
||||||
QSettings settings(QString("%1/templates.ini").arg(appDir), QSettings::IniFormat);
|
QSettings settings(QString("%1/templates.ini").arg(appDir), QSettings::IniFormat);
|
||||||
QStringList allTemplates = settings.childGroups();
|
QStringList allTemplates = settings.childGroups();
|
||||||
|
|
||||||
@ -169,7 +170,7 @@ QMap<QString, OptionsModel*> OptionsModel::loadAllTemplates(void)
|
|||||||
|
|
||||||
bool OptionsModel::templateExists(const QString &name)
|
bool OptionsModel::templateExists(const QString &name)
|
||||||
{
|
{
|
||||||
const QString appDir = QDesktopServices::storageLocation(QDesktopServices::DataLocation);
|
const QString appDir = x264_portable() ? QApplication::applicationDirPath() : QDesktopServices::storageLocation(QDesktopServices::DataLocation);
|
||||||
QSettings settings(QString("%1/templates.ini").arg(appDir), QSettings::IniFormat);
|
QSettings settings(QString("%1/templates.ini").arg(appDir), QSettings::IniFormat);
|
||||||
QStringList allGroups = settings.childGroups();
|
QStringList allGroups = settings.childGroups();
|
||||||
return allGroups.contains(name, Qt::CaseInsensitive);
|
return allGroups.contains(name, Qt::CaseInsensitive);
|
||||||
@ -177,7 +178,7 @@ bool OptionsModel::templateExists(const QString &name)
|
|||||||
|
|
||||||
bool OptionsModel::deleteTemplate(const QString &name)
|
bool OptionsModel::deleteTemplate(const QString &name)
|
||||||
{
|
{
|
||||||
const QString appDir = QDesktopServices::storageLocation(QDesktopServices::DataLocation);
|
const QString appDir = x264_portable() ? QApplication::applicationDirPath() : QDesktopServices::storageLocation(QDesktopServices::DataLocation);
|
||||||
QSettings settings(QString("%1/templates.ini").arg(appDir), QSettings::IniFormat);
|
QSettings settings(QString("%1/templates.ini").arg(appDir), QSettings::IniFormat);
|
||||||
|
|
||||||
if(settings.childGroups().contains(name, Qt::CaseInsensitive))
|
if(settings.childGroups().contains(name, Qt::CaseInsensitive))
|
||||||
|
@ -21,7 +21,7 @@
|
|||||||
|
|
||||||
#define VER_X264_MAJOR 2
|
#define VER_X264_MAJOR 2
|
||||||
#define VER_X264_MINOR 0
|
#define VER_X264_MINOR 0
|
||||||
#define VER_X264_PATCH 72
|
#define VER_X264_PATCH 79
|
||||||
|
|
||||||
#define VER_X264_MINIMUM_REV 2146
|
#define VER_X264_MINIMUM_REV 2146
|
||||||
#define VER_X264_CURRENT_API 120
|
#define VER_X264_CURRENT_API 120
|
||||||
|
@ -189,7 +189,7 @@ AddJobDialog::AddJobDialog(QWidget *parent, OptionsModel *options, bool x64suppo
|
|||||||
connect(cbxTemplate, SIGNAL(currentIndexChanged(int)), this, SLOT(templateSelected()));
|
connect(cbxTemplate, SIGNAL(currentIndexChanged(int)), this, SLOT(templateSelected()));
|
||||||
|
|
||||||
//Load directories
|
//Load directories
|
||||||
const QString appDir = QDesktopServices::storageLocation(QDesktopServices::DataLocation);
|
const QString appDir = x264_portable() ? QApplication::applicationDirPath() : QDesktopServices::storageLocation(QDesktopServices::DataLocation);
|
||||||
QSettings settings(QString("%1/last.ini").arg(appDir), QSettings::IniFormat);
|
QSettings settings(QString("%1/last.ini").arg(appDir), QSettings::IniFormat);
|
||||||
initialDir_src = settings.value("path/directory_openFrom", initialDir_src).toString();
|
initialDir_src = settings.value("path/directory_openFrom", initialDir_src).toString();
|
||||||
initialDir_out = settings.value("path/directory_saveTo", initialDir_out).toString();
|
initialDir_out = settings.value("path/directory_saveTo", initialDir_out).toString();
|
||||||
@ -305,7 +305,7 @@ void AddJobDialog::accept(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
//Save directories
|
//Save directories
|
||||||
const QString appDir = QDesktopServices::storageLocation(QDesktopServices::DataLocation);
|
const QString appDir = x264_portable() ? QApplication::applicationDirPath() : QDesktopServices::storageLocation(QDesktopServices::DataLocation);
|
||||||
QSettings settings(QString("%1/last.ini").arg(appDir), QSettings::IniFormat);
|
QSettings settings(QString("%1/last.ini").arg(appDir), QSettings::IniFormat);
|
||||||
if(settings.isWritable())
|
if(settings.isWritable())
|
||||||
{
|
{
|
||||||
|
@ -541,6 +541,24 @@ void MainWindow::init(void)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//Check for portable mode
|
||||||
|
if(x264_portable())
|
||||||
|
{
|
||||||
|
bool ok = false;
|
||||||
|
static const char *data = "Lorem ipsum dolor sit amet, consectetur adipiscing elit.";
|
||||||
|
QFile writeTest(QString("%1/%2").arg(QApplication::applicationDirPath(), QUuid::createUuid().toString()));
|
||||||
|
if(writeTest.open(QIODevice::WriteOnly))
|
||||||
|
{
|
||||||
|
ok = (writeTest.write(data) == strlen(data));
|
||||||
|
writeTest.remove();
|
||||||
|
}
|
||||||
|
if(!ok)
|
||||||
|
{
|
||||||
|
int val = QMessageBox::warning(this, tr("Write Test Failed"), tr("<nobr>The application was launched in portable mode, but the program path is <b>not</b> writable!</nobr>"), tr("Quit"), tr("Ignore"));
|
||||||
|
if(val != 1) { close(); qApp->exit(-1); return; }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
//Pre-release popup
|
//Pre-release popup
|
||||||
if(x264_is_prerelease())
|
if(x264_is_prerelease())
|
||||||
{
|
{
|
||||||
|
@ -130,7 +130,7 @@ void PreferencesDialog::initPreferences(Preferences *preferences)
|
|||||||
|
|
||||||
void PreferencesDialog::loadPreferences(Preferences *preferences)
|
void PreferencesDialog::loadPreferences(Preferences *preferences)
|
||||||
{
|
{
|
||||||
const QString appDir = QDesktopServices::storageLocation(QDesktopServices::DataLocation);
|
const QString appDir = x264_portable() ? QApplication::applicationDirPath() : QDesktopServices::storageLocation(QDesktopServices::DataLocation);
|
||||||
QSettings settings(QString("%1/preferences.ini").arg(appDir), QSettings::IniFormat);
|
QSettings settings(QString("%1/preferences.ini").arg(appDir), QSettings::IniFormat);
|
||||||
|
|
||||||
Preferences defaults;
|
Preferences defaults;
|
||||||
@ -145,7 +145,7 @@ void PreferencesDialog::loadPreferences(Preferences *preferences)
|
|||||||
|
|
||||||
void PreferencesDialog::savePreferences(Preferences *preferences)
|
void PreferencesDialog::savePreferences(Preferences *preferences)
|
||||||
{
|
{
|
||||||
const QString appDir = QDesktopServices::storageLocation(QDesktopServices::DataLocation);
|
const QString appDir = x264_portable() ? QApplication::applicationDirPath() : QDesktopServices::storageLocation(QDesktopServices::DataLocation);
|
||||||
QSettings settings(QString("%1/preferences.ini").arg(appDir), QSettings::IniFormat);
|
QSettings settings(QString("%1/preferences.ini").arg(appDir), QSettings::IniFormat);
|
||||||
|
|
||||||
settings.beginGroup("preferences");
|
settings.beginGroup("preferences");
|
||||||
|
Loading…
Reference in New Issue
Block a user