Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --- git.orig/src/applicationinfo.cpp
- +++ git/src/applicationinfo.cpp
- @@ -10,7 +10,7 @@
- #include <QStandardPaths>
- #endif
- -#ifdef HAVE_X11
- +#ifdef Q_OS_UNIX
- #include <sys/stat.h> // chmod
- #endif
- @@ -58,8 +58,8 @@
- #define PROG_APPCAST_URL ""
- #endif
- -#if defined(HAVE_X11) && !defined(PSI_DATADIR)
- -#define PSI_DATADIR "/usr/local/share/psi"
- +#if defined(Q_OS_UNIX) && !defined(PSI_DATADIR)
- +#define PSI_DATADIR APP_PREFIX"/share/"APP_BIN_NAME
- #endif
- @@ -141,7 +141,7 @@ QString ApplicationInfo::getCertificateS
- QString ApplicationInfo::resourcesDir()
- {
- -#if defined(HAVE_X11)
- +#if defined(Q_OS_UNIX)
- return PSI_DATADIR;
- #elif defined(Q_OS_WIN)
- return qApp->applicationDirPath();
- @@ -238,7 +238,7 @@ QString ApplicationInfo::homeDir(Applica
- QDir configDir(QDir::homePath() + "/Library/Application Support/" + name());
- QDir cacheDir(QDir::homePath() + "/Library/Caches/" + name());
- QDir dataDir(configDir);
- -#elif defined HAVE_X11
- +#elif defined HAVE_FREEDESKTOP
- QString XdgConfigHome = QString::fromLocal8Bit(getenv("XDG_CONFIG_HOME"));
- QString XdgDataHome = QString::fromLocal8Bit(getenv("XDG_DATA_HOME"));
- QString XdgCacheHome = QString::fromLocal8Bit(getenv("XDG_CACHE_HOME"));
- @@ -383,3 +383,14 @@ QString ApplicationInfo::currentProfileD
- {
- return pathToProfile(activeProfile, type);
- }
- +
- +QString ApplicationInfo::desktopFile()
- +{
- + QString dFile;
- + const QString _desktopFile(APP_PREFIX "/share/applications/" APP_BIN_NAME ".desktop");
- + QFile f(_desktopFile);
- + if(f.open(QIODevice::ReadOnly)) {
- + dFile = QString::fromUtf8(f.readAll());
- + }
- + return dFile;
- +}
- --- git.orig/src/applicationinfo.h
- +++ git/src/applicationinfo.h
- @@ -44,6 +44,9 @@ public:
- static QString optionsNS();
- static QString storageNS();
- static QString fileCacheNS();
- +
- + // Common
- + static QString desktopFile();
- };
- #endif
- --- git.orig/src/options/opt_application.cpp
- +++ git/src/options/opt_application.cpp
- @@ -13,9 +13,17 @@
- #include "qsettings.h"
- #include <QList>
- #include <QMessageBox>
- +#include <QDir>
- #include "ui_opt_application.h"
- +#ifdef Q_OS_WIN
- + static const QString regString = "HKEY_CURRENT_USER\\Software\\Microsoft\\Windows\\CurrentVersion\\Run";
- +#endif
- +#ifdef HAVE_FREEDESKTOP
- + static const QString psiAutoStart("/.config/autostart/" APP_BIN_NAME ".desktop");
- +#endif
- +
- class OptApplicationUI : public QWidget, public Ui::OptApplication
- {
- public:
- @@ -60,6 +68,7 @@ QWidget *OptionsTabApplication::widget()
- #ifdef Q_OS_MAC
- d->gb_docklet->hide();
- + d->ck_auto_load->hide();
- #endif
- if (!haveAutoUpdater_) {
- @@ -126,6 +135,29 @@ void OptionsTabApplication::applyOptions
- }
- QSettings s(ApplicationInfo::homeDir(ApplicationInfo::ConfigLocation) + "/psirc", QSettings::IniFormat);
- s.setValue("last_lang", itemData);
- +
- + //Auto-load
- +#ifdef Q_OS_WIN
- + QSettings set(regString, QSettings::NativeFormat);
- + if(d->ck_auto_load->isChecked()) {
- + set.setValue(ApplicationInfo::name(), QDir::toNativeSeparators(qApp->applicationFilePath()));
- + }
- + else {
- + set.remove(ApplicationInfo::name());
- + }
- +#endif
- +#ifdef HAVE_FREEDESKTOP
- + QDir home = QDir::home();
- + if (!home.exists(".config/autostart")) {
- + home.mkpath(".config/autostart");
- + }
- + QFile f(home.absolutePath() + psiAutoStart);
- + if (f.open(QIODevice::WriteOnly | QIODevice::Text | QIODevice::Truncate)) {
- + const QString contents = ApplicationInfo::desktopFile().trimmed();
- + f.write(contents.toUtf8());
- + f.write(QString("\nHidden=%1").arg(d->ck_auto_load->isChecked() ? "false\n" : "true\n").toUtf8());
- + }
- +#endif
- }
- void OptionsTabApplication::restoreOptions()
- @@ -164,6 +196,21 @@ void OptionsTabApplication::restoreOptio
- d->cb_lang->setCurrentIndex( 0 );
- else if(!curLang.isEmpty() && lang.contains(curLang) )
- d->cb_lang->setCurrentIndex( d->cb_lang->findText(vList.get(curLang)) );
- +
- + //Auto-load
- +#ifdef Q_OS_WIN
- + QSettings set(regString, QSettings::NativeFormat);
- + const QString path = set.value(ApplicationInfo::name()).toString();
- + d->ck_auto_load->setChecked( (path == QDir::toNativeSeparators(qApp->applicationFilePath())) );
- +#endif
- +#ifdef HAVE_FREEDESKTOP
- + QFile desktop(QDir::homePath() + psiAutoStart);
- + if (desktop.open(QIODevice::ReadOnly)
- + && QString(desktop.readAll()).contains(QRegExp("\\bhidden\\s*=\\s*false", Qt::CaseInsensitive)))
- + {
- + d->ck_auto_load->setChecked(true);
- + }
- +#endif
- }
- void OptionsTabApplication::doEnableQuitOnClose(int state)
- --- git.orig/src/options/opt_application.ui
- +++ git/src/options/opt_application.ui
- @@ -14,6 +14,13 @@
- </property>
- <layout class="QVBoxLayout" >
- <item>
- + <widget class="QCheckBox" name="ck_auto_load">
- + <property name="text">
- + <string>Automatically launch application when OS starts</string>
- + </property>
- + </widget>
- + </item>
- + <item>
- <widget class="QCheckBox" name="ck_winDecor" >
- <property name="text" >
- <string>Decorate windows</string>
- --- git.orig/src/src.pri
- +++ git/src/src.pri
- @@ -9,7 +9,10 @@ greaterThan(QT_MAJOR_VERSION, 4) {
- QT += x11extras
- }
- }
- -unix:!mac:DEFINES += HAVE_X11
- +unix:!mac {
- + DEFINES += HAVE_X11
- + DEFINES += HAVE_FREEDESKTOP
- +}
- CONFIG(debug, debug|release) {
- mac: DEFINES += DEBUG_POSTFIX=\\\"_debug\\\"
- --- git.orig/src/src.pro
- +++ git/src/src.pro
- @@ -32,6 +32,8 @@ include(../qa/oldtest/unittest.pri)
- include($$top_builddir/conf.pri)
- unix {
- + DEFINES += APP_PREFIX=$$PREFIX
- + DEFINES += APP_BIN_NAME=$$target
- # Target
- target.path = $$BINDIR
- INSTALLS += target
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement