Browse files

Config coresponds XDG directory specification

  • Loading branch information...
1 parent bc87092 commit c70e9f0b0c71f803de1b1238a1e58db61df50685 @SokoloffA SokoloffA committed Feb 26, 2012
View
11 libraries/razorqt/razorapplication.cpp
@@ -28,10 +28,12 @@
#include "razorapplication.h"
#include "razorsettings.h"
#include <qtxdg/xdgicon.h>
+#include <qtxdg/xdgdirs.h>
+#include <QtCore/QDir>
#ifdef DEBUG
-#define COLOR_DEBUG "\033[32;1m"
-#define COLOR_WARN "\033[33;1m"
+#define COLOR_DEBUG "\033[32;2m"
+#define COLOR_WARN "\033[33;2m"
#define COLOR_CRITICAL "\033[31;1m"
#define COLOR_FATAL "\033[33;1m"
#define COLOR_RESET "\033[0m"
@@ -47,7 +49,10 @@ Used only in pure Debug builds.
void dbgMessageOutput(QtMsgType type, const char *msg)
{
FILE *f;
- f = fopen (razorConfigDir().toUtf8() + "/debug.log", "a+");
+ QDir dir(XdgDirs::dataHome().toUtf8() + "razor");
+ dir.mkpath(".");
+
+ f = fopen (XdgDirs::dataHome().toUtf8() + "razor/debug.log", "a+");
const char * dt = QDateTime::currentDateTime().toString("yyyy-MM-dd hh:mm:ss.zzz").toUtf8();
switch (type) {
case QtDebugMsg:
View
94 libraries/razorqt/razorsettings.cpp
@@ -28,24 +28,14 @@
#include "razorsettings.h"
#include <qtxdg/xdgicon.h>
-#include <QDebug>
+#include <qtxdg/xdgdirs.h>
+#include <QtCore/QDebug>
#include <QtCore/QEvent>
#include <QtCore/QDir>
#include <QtCore/QStringList>
#include <QtCore/QMutex>
#include <QtCore/QFileSystemWatcher>
-
-QString razorConfigDir()
-{
-#ifdef RAZOR_CONFIG_DIR
- return QDir::cleanPath(QDir::homePath() + "/" + RAZOR_CONFIG_DIR) + "/";
-#else
- return QDir::cleanPath(QDir::homePath() + "/.razor") + "/";
-#endif
-}
-
-
class RazorSettingsPrivate
{
public:
@@ -75,43 +65,15 @@ class RazorThemePrivate
};
-/************************************************
- Create parent directories, if necessary
- ************************************************/
-void createDir(const QString& file)
-{
- QDir dir(QFileInfo(file).absoluteDir());
-
- if (!dir.exists())
- dir.mkpath(".");
-
-
-}
-
/************************************************
This looks in all the usual paths for file
************************************************/
-QString findFile(const QString& fileName, bool onlyGlobal = false)
+QString findFile(const QString& fileName)
{
QStringList paths;
-
- if (!onlyGlobal)
- paths << razorConfigDir();
-
-#ifdef SHARE_DIR
- // test for non-standard install dirs - useful for development for example
- paths << SHARE_DIR;
-
-#else
- #warning SHARE_DIR is not defined. Config will not be searched in the CMAKE_INSTALL_PREFIX
- // this is ugly and it should be used only in a very special cases
- // standard cmake build contains the SHARE_DIR defined in the top level CMakeLists.txt
- //
- // /usr/local/ goes first as it's usually before the /usr in the PATH etc.
- paths << "/usr/local/share/razor/";
- paths << "/usr/share/razor/";
-#endif
+ paths << XdgDirs::dataHome(false);
+ paths << XdgDirs::dataDirs();
foreach(QString path, paths)
{
@@ -125,47 +87,12 @@ QString findFile(const QString& fileName, bool onlyGlobal = false)
/************************************************
- Copy the system configuration, if necessary.
- ************************************************/
-void copySysConfig(const QString& module, const QString& homeFile)
-{
- QFile hf(homeFile);
- if (hf.exists())
- return;
-
- QString sysFile(findFile(QString("%1.conf").arg(module), true));
- if (sysFile.isEmpty())
- return;
-
- QFile sf(sysFile);
- if (!sf.copy(homeFile))
- {
- qWarning() << "Cannot copy file from:" << sysFile << "to:" << homeFile;
- Q_ASSERT(0);
- }
-}
-
-
-/************************************************
-
- ************************************************/
-QString getFileName(const QString& module)
-{
- QString homeFile(razorConfigDir() + module + ".conf");
- createDir(homeFile);
- copySysConfig(module, homeFile);
- return homeFile;
-}
-
-
-/************************************************
************************************************/
RazorSettings::RazorSettings(const QString& module, QObject* parent) :
- QSettings(getFileName(module), QSettings::IniFormat, parent),
+ QSettings("razor", module, parent),
d_ptr(new RazorSettingsPrivate(this))
{
- sync();
}
@@ -190,6 +117,10 @@ RazorSettings::RazorSettings(const QSettings& parentSettings, const QString& sub
beginGroup(subGroup);
}
+
+/************************************************
+
+ ************************************************/
RazorSettings::~RazorSettings()
{
// because in the RazorSettings::RazorSettings(const QString& module, QObject* parent)
@@ -281,8 +212,7 @@ QString RazorTheme::qss(const QString& module) const
{
Q_D(const RazorTheme);
-
- QString path(findFile(QString("themes/%1/%2.qss").arg(d->mThemeName, module)));
+ QString path(findFile(QString("razor/themes/%1/%2.qss").arg(d->mThemeName, module)));
if (!path.isEmpty())
return d->loadQss(path);
@@ -323,7 +253,7 @@ QString RazorThemePrivate::loadQss(const QString& qssFile) const
QString RazorTheme::desktopBackground(int screen) const
{
Q_D(const RazorTheme);
- QString wallpapperCfgFileName = findFile(QString("themes/%1/wallpapper.cfg").arg(d->mThemeName));
+ QString wallpapperCfgFileName = findFile(QString("razor/themes/%1/wallpapper.cfg").arg(d->mThemeName));
if (wallpapperCfgFileName.isEmpty())
return QString();
View
8 libraries/razorqt/razorsettings.h
@@ -35,14 +35,6 @@
class QEvent;
-
-/*! Get the config rirectory. Usually "~/.razor/" but it can be changed
- configuration/compilation phase.
- \note Path includes end-slash!
-*/
-QString razorConfigDir();
-
-
class RazorSettingsPrivate;
/*! \brief User settings handling */
class RazorSettings : public QSettings
View
2 razorqt-desktop/CMakeLists.txt
@@ -33,7 +33,7 @@ add_executable ( razor-desktop ${razor-desktop_SRCS} ${UIS} ${RSCS} ${TRS} ${MOC
add_dependencies( razor-desktop razorqt)
target_link_libraries ( razor-desktop ${QT_QTCORE_LIBRARY} ${QT_QTGUI_LIBRARY} ${QT_QTXML_LIBRARY} ${QT_QTDBUS_LIBRARY} ${X11_X11_LIB} razorqt qtxdg)
INSTALL(TARGETS razor-desktop RUNTIME DESTINATION bin)
-install(DIRECTORY resources/ DESTINATION share/razor PATTERN ".svn" EXCLUDE)
+install(DIRECTORY resources/ DESTINATION /etc/xdg/razor)
add_subdirectory(config)
add_subdirectory( desktop-wm_native )
View
2 razorqt-panel/panel/CMakeLists.txt
@@ -102,4 +102,4 @@ add_executable(${PROJECT} ${HEADERS} ${SOURCES} ${MOC_SOURCES} ${QM_FILES} ${QRC
target_link_libraries(${PROJECT} ${LIBRARIES} ${QT_LIBRARIES})
install(TARGETS ${PROJECT} RUNTIME DESTINATION bin)
-install(FILES ${CONFIG_FILES} DESTINATION share/razor/razor-panel/)
+install(FILES ${CONFIG_FILES} DESTINATION /etc/xdg/razor/razor-panel/)
View
1 razorqt-panel/panel/razorpanel.cpp
@@ -456,7 +456,6 @@ void RazorPanelPrivate::realign()
rect.moveRight(screen.right());
}
q->setGeometry(rect);
- qDebug() << q->geometry();
// Reserve our space on the screen ..........
XfitMan xf = xfitMan();
View
10 razorqt-resources/CMakeLists.txt
@@ -1,9 +1,9 @@
cmake_minimum_required( VERSION 2.6 )
-install(DIRECTORY config/ DESTINATION share/razor)
install(DIRECTORY graphics DESTINATION share/razor/)
-add_subdirectory(autostart )
-add_subdirectory( sys )
-add_subdirectory( themes )
-add_subdirectory( application-menu )
+add_subdirectory(config)
+add_subdirectory(autostart)
+add_subdirectory(sys)
+add_subdirectory(themes)
+add_subdirectory(application-menu)
View
13 razorqt-resources/config/CMakeLists.txt
@@ -0,0 +1,13 @@
+cmake_minimum_required( VERSION 2.6 )
+
+file(GLOB CONF_FILES *.conf)
+file(GLOB CONF_FILES_IN *.conf.in)
+
+# Translations **********************************
+include(RazorTranslate)
+razor_translate_desktop(CONF_TR_FILES ${CONF_FILES_IN} )
+add_custom_target(resources_conf_files ALL DEPENDS ${CONF_TR_FILES})
+#************************************************
+
+install(FILES ${CONF_FILES} DESTINATION /etc/xdg/razor)
+install(FILES ${CONF_TR_FILES} DESTINATION /etc/xdg/razor)
View
2 razorqt-resources/themes/CMakeLists.txt
@@ -1,5 +1,5 @@
cmake_minimum_required( VERSION 2.6 )
-install(DIRECTORY . DESTINATION share/razor/themes PATTERN ".svn" EXCLUDE PATTERN "CMake*" EXCLUDE PATTERN "cmake*" EXCLUDE PATTERN "Makefile" EXCLUDE)
+install(DIRECTORY . DESTINATION share/razor/themes PATTERN "CMake*" EXCLUDE PATTERN "cmake*" EXCLUDE PATTERN "Makefile" EXCLUDE)

0 comments on commit c70e9f0

Please sign in to comment.