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

Commit

Permalink
Add build option SG_XDG_CONFIG_SUPPORT for enable storage config file…
Browse files Browse the repository at this point in the history
…s in XDG_CONFIG_JOME (issue
  • Loading branch information
DOOMer committed Apr 11, 2012
1 parent 26482ab commit 46fc7e8
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 28 deletions.
12 changes: 9 additions & 3 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ find_package( Qt4 REQUIRED COMPONENTS QtCore QtGui QtNetwork)
include( "${QT_USE_FILE}" )

# add version define
set(SCREENGRAB_VERSION "0.9.90")
set(SCREENGRAB_VERSION "0.9.91")
set(SCREENGRAB_VERSION_DEV "1.0")
set(DEV_BUILD True)

Expand Down Expand Up @@ -69,11 +69,19 @@ message(STATUS "Install prefix: " ${CMAKE_INSTALL_PREFIX})

# ------ options ---------------------------------
OPTION (SG_GLOBALSHORTCUTS "Enable global shortcuts" ON)
OPTION (SG_XDG_CONFIG_SUPPORT "Place config files into XDGC_ONFIG_HOME" ON)

if(SG_GLOBALSHORTCUTS)
add_definitions( -DSG_GLOBAL_SHORTCUTS="1")
endif(SG_GLOBALSHORTCUTS)

if(SG_XDG_CONFIG_SUPPORT)
add_definitions( -DSG_XDG_CONFIG_SUPPORT="1")
endif(SG_XDG_CONFIG_SUPPORT)

message(STATUS "Global shortcuts support: " ${SG_GLOBALSHORTCUTS})
message(STATUS "XDG_CONFIG_HOME support: " ${SG_XDG_CONFIG_SUPPORT})

# ------ doc dir name ---------------------------------
if(UNIX AND NOT APPLE)
if (NOT SG_DOCDIR)
Expand All @@ -84,8 +92,6 @@ if(UNIX AND NOT APPLE)
add_definitions( -DSG_DOCDIR="${CMAKE_INSTALL_PREFIX}/${DOCPATH}")
endif(UNIX AND NOT APPLE)

message(STATUS "Global shortcuts support: " ${SG_GLOBALSHORTCUTS})

set(SG_INCLUDE "${CMAKE_CURRENT_SOURCE_DIR}/src/")
message(STATUS "SG_INCLUDE: " ${SG_INCLUDE})

Expand Down
34 changes: 19 additions & 15 deletions src/core/config.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -147,21 +147,25 @@ QString Config::getConfigDir()
{
QString configDir;
#ifdef Q_WS_X11
// 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());
#ifdef SG_XDG_CONFIG_SUPPORT
// 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());
#else
configDir = QDir::homePath()+ QDir::separator()+".screengrab"+ QDir::separator();
#endif
#endif

// if win32
Expand Down
21 changes: 11 additions & 10 deletions src/modules/uploader/uploaderconfig.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,17 +32,18 @@ const QString groupName = "imageshack.us";
UploaderConfig::UploaderConfig()
{
QString configFile = Config::getConfigDir();
#ifdef Q_WS_X11
// old style config settings storage
QString oldConfigFile = QDir::homePath()+ QDir::separator()+".screengrab"+ QDir::separator() + "uploader.conf";

#ifdef Q_WS_X11
configFile += "uploader.conf";

// move config file to new location
if (QFile::exists(oldConfigFile) == true && QFile::exists(configFile) == false)
{
QFile::rename(oldConfigFile, configFile);
}
#ifdef SG_XDG_CONFIG_SUPPORT
// old style config settings storage
QString oldConfigFile = QDir::homePath()+ QDir::separator()+".screengrab"+ QDir::separator() + "uploader.conf";

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

#ifdef Q_WS_WIN
Expand Down

0 comments on commit 46fc7e8

Please sign in to comment.