diff --git a/CMakeLists.txt b/CMakeLists.txt index caeab80..01bcb50 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -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) @@ -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) @@ -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}) diff --git a/src/core/config.cpp b/src/core/config.cpp index 1d71cec..98c1f10 100644 --- a/src/core/config.cpp +++ b/src/core/config.cpp @@ -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 diff --git a/src/modules/uploader/uploaderconfig.cpp b/src/modules/uploader/uploaderconfig.cpp index d3656d3..a8093a3 100644 --- a/src/modules/uploader/uploaderconfig.cpp +++ b/src/modules/uploader/uploaderconfig.cpp @@ -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