diff options
| author | trialuser02 <trialuser02@90c681e8-e032-0410-971d-27865f9a5e38> | 2016-06-30 10:16:02 +0000 |
|---|---|---|
| committer | trialuser02 <trialuser02@90c681e8-e032-0410-971d-27865f9a5e38> | 2016-06-30 10:16:02 +0000 |
| commit | 3f1dae2f25d7fd509e6ca8d2d4cb54a83fd69b10 (patch) | |
| tree | a5d73b19f5d2304c366a8f0d03d97893ba1b7e52 | |
| parent | c0618d949632c7601fb589b8b7e12302db614350 (diff) | |
| download | qmmp-3f1dae2f25d7fd509e6ca8d2d4cb54a83fd69b10.tar.gz qmmp-3f1dae2f25d7fd509e6ca8d2d4cb54a83fd69b10.tar.bz2 qmmp-3f1dae2f25d7fd509e6ca8d2d4cb54a83fd69b10.zip | |
added portable mode (for windows only)
git-svn-id: http://svn.code.sf.net/p/qmmp-dev/code/trunk/qmmp@6545 90c681e8-e032-0410-971d-27865f9a5e38
| -rw-r--r-- | src/qmmp/qmmp.cpp | 24 | ||||
| -rw-r--r-- | src/qmmp/qmmp.h | 6 | ||||
| -rw-r--r-- | src/qmmpui/configdialog.cpp | 9 |
3 files changed, 34 insertions, 5 deletions
diff --git a/src/qmmp/qmmp.cpp b/src/qmmp/qmmp.cpp index f0946da90..cbd0412ba 100644 --- a/src/qmmp/qmmp.cpp +++ b/src/qmmp/qmmp.cpp @@ -1,5 +1,5 @@ /*************************************************************************** - * Copyright (C) 2008-2013 by Ilya Kotov * + * Copyright (C) 2008-2016 by Ilya Kotov * * forkotov02@hotmail.ru * * * * This program is free software; you can redistribute it and/or modify * @@ -19,9 +19,10 @@ ***************************************************************************/ #include <QDir> -#include <QApplication> +#include <QCoreApplication> #include <QSettings> #include <QLocale> +#include <QFile> #include <QByteArray> #ifndef LIB_DIR @@ -42,7 +43,19 @@ const QString Qmmp::configFile() const QString Qmmp::configDir() { +#ifdef Q_OS_WIN + if(m_configDir.isEmpty()) + { + if(isPortable()) + return QCoreApplication::applicationDirPath() + "/.qmmp/"; + else + return QDir::homePath() +"/.qmmp/"; + } + else + return m_configDir; +#else return m_configDir.isEmpty() ? QDir::homePath() +"/.qmmp/" : m_configDir; +#endif } void Qmmp::setConfigDir(const QString &path) @@ -123,3 +136,10 @@ void Qmmp::setUiLanguageID(const QString &code) settings.setValue("General/locale", code); m_langID.clear(); } + +#if Q_OS_WIN +bool Qmmp::isPortable() +{ + QFile::exists(QCoreApplication::applicationDirPath() + "/qmmp_portable.txt"); +} +#endif diff --git a/src/qmmp/qmmp.h b/src/qmmp/qmmp.h index e5f577842..b6cfeafb5 100644 --- a/src/qmmp/qmmp.h +++ b/src/qmmp/qmmp.h @@ -158,6 +158,12 @@ public: * @param code Language code; code "auto" means autodetection. */ static void setUiLanguageID(const QString &code); +#ifdef Q_OS_WIN + /*! + * Returns \b true if portable mode is enabled. Otherwise returns \b false. + */ + static bool isPortable(); +#endif private: static QString m_configDir; diff --git a/src/qmmpui/configdialog.cpp b/src/qmmpui/configdialog.cpp index f4ac08d75..423c1aae9 100644 --- a/src/qmmpui/configdialog.cpp +++ b/src/qmmpui/configdialog.cpp @@ -81,9 +81,12 @@ ConfigDialog::ConfigDialog (QWidget *parent) : QDialog (parent) m_ui->informationButton->setIcon(QIcon::fromTheme("dialog-information")); //file associations #ifdef Q_OS_WIN - m_ui->stackedWidget->addWidget(new WinFileAssocPage(this)); - m_ui->contentsWidget->addItem(tr("File Types")); - m_ui->contentsWidget->item(m_ui->contentsWidget->count() - 1)->setIcon(QIcon(":associations.png")); + if(!Qmmp::isPortable()) + { + m_ui->stackedWidget->addWidget(new WinFileAssocPage(this)); + m_ui->contentsWidget->addItem(tr("File Types")); + m_ui->contentsWidget->item(m_ui->contentsWidget->count() - 1)->setIcon(QIcon(":associations.png")); + } #endif } |
