Skip to content
This repository has been archived by the owner on Oct 30, 2021. It is now read-only.

Commit

Permalink
[X11 only] add moving config files from old-style location ($HOME/.sc…
Browse files Browse the repository at this point in the history
…reengrab/) to

XDG_CONFIG_HOME ($XDG_CONFIG_HOME/screengrab/)
  • Loading branch information
DOOMer committed Apr 11, 2012
1 parent acab0b6 commit 26482ab
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 4 deletions.
26 changes: 24 additions & 2 deletions src/core/config.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@
#include <QtCore/QVector>
#include <QtGui/QDesktopServices>

#include <QDebug>

const QString KEY_SAVEDIR = "defDir";
const QString KEY_SAVENAME = "defFilename";
const QString KEY_SAVEFORMAT = "defImgFormat";
Expand Down Expand Up @@ -125,6 +127,13 @@ QString Config::getConfigFile()

#ifdef Q_WS_X11
configFile = Config::getConfigDir() + "screengrab.conf";

// moving old stile storange setting to XDG_CONFIG_HOME storage
QString oldConfigFile = QDir::homePath()+ QDir::separator()+".screengrab"+ QDir::separator() + "screengrab.conf";
if (QFile::exists(oldConfigFile) == true && QFile::exists(configFile) == false)
{
QFile::rename(oldConfigFile, configFile);
}
#endif

#ifdef Q_WS_WIN
Expand All @@ -138,8 +147,21 @@ QString Config::getConfigDir()
{
QString configDir;
#ifdef Q_WS_X11
configDir.append(QDir::homePath()+ QDir::separator()+".screengrab"+
QDir::separator());
// old style config path
QString oldConfigDir = QDir::homePath()+ QDir::separator()+".screengrab"+ QDir::separator();
configDir = qgetenv("XDG_CONFIG_HOME");

// Ubuntu hack -- if XDG_CONFIG_HOME is missing
if (configDir.isEmpty() == true)
{
configDir = QDir::homePath();
configDir += QDir::separator();
configDir += ".config";
}

configDir.append(QDir::separator());
configDir.append("screengrab");
configDir.append(QDir::separator());
#endif

// if win32
Expand Down
15 changes: 13 additions & 2 deletions src/modules/uploader/uploaderconfig.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@

#include "uploaderconfig.h"
#include <QString>
#include <QFile>
#include <QDir>

#include "core/config.h"

Expand All @@ -28,10 +30,19 @@
const QString groupName = "imageshack.us";

UploaderConfig::UploaderConfig()
{
{
QString configFile = Config::getConfigDir();
#ifdef Q_WS_X11
#ifdef Q_WS_X11
// old style config settings storage
QString oldConfigFile = QDir::homePath()+ QDir::separator()+".screengrab"+ QDir::separator() + "uploader.conf";

configFile += "uploader.conf";

// move config file to new location
if (QFile::exists(oldConfigFile) == true && QFile::exists(configFile) == false)
{
QFile::rename(oldConfigFile, configFile);
}
#endif

#ifdef Q_WS_WIN
Expand Down

0 comments on commit 26482ab

Please sign in to comment.