use qsettings instead of xml stuff
This commit is contained in:
parent
020ea2c4d2
commit
0f795eaeba
|
@ -6,11 +6,11 @@ set(CMAKE_INCLUDE_CURRENT_DIR ON)
|
|||
|
||||
find_package(KDE4)
|
||||
|
||||
if(MINGW)
|
||||
SET (CMAKE_RC_COMPILER_INIT windres)
|
||||
ENABLE_LANGUAGE (RC)
|
||||
SET (CMAKE_RC_COMPILE_OBJECT "<CMAKE_RC_COMPILER> -O coff -i <SOURCE> -o <OBJECT>")
|
||||
endif(MINGW)
|
||||
if(MINGW)
|
||||
SET (CMAKE_RC_COMPILER_INIT windres)
|
||||
ENABLE_LANGUAGE (RC)
|
||||
SET (CMAKE_RC_COMPILE_OBJECT "<CMAKE_RC_COMPILER> -O coff -i <SOURCE> -o <OBJECT>")
|
||||
endif(MINGW)
|
||||
|
||||
if(KDE4_FOUND)
|
||||
add_definitions(-DHAVE_KDE ${KDE4_DEFINITIONS} -D_UNICODE)
|
||||
|
|
|
@ -6,8 +6,6 @@ include_directories(
|
|||
${QT_QTCORE_INCLUDE_DIR} ${QT_QTGUI_INCLUDE_DIR}
|
||||
${QT_QTNETWORK_INCLUDE_DIR} ${QT_QTDBUS_INCLUDE_DIR})
|
||||
|
||||
|
||||
|
||||
include( ${QT_USE_FILE} )
|
||||
|
||||
if (CMAKE_COMPILER_IS_GNUCXX)
|
||||
|
|
|
@ -16,7 +16,7 @@ endif(WIN32)
|
|||
|
||||
automoc4_add_executable( snorenotify ${WIN32_SPECIFIC} main.cpp snorenotify.cpp trayicon.cpp ${SNORENOTIFY_DEPS})
|
||||
|
||||
target_link_libraries( snorenotify snorecore ${QT_QTGUI_LIBRARY} ${QT_QTXML_LIBRARY} )
|
||||
target_link_libraries( snorenotify snorecore ${QT_QTGUI_LIBRARY} )
|
||||
|
||||
if(MSVC)
|
||||
set_target_properties(snorenotify PROPERTIES LINK_FLAGS "/ENTRY:\"mainCRTStartup\"")
|
||||
|
|
|
@ -35,19 +35,16 @@ QString const SnoreServer::snoreTMP(){
|
|||
return tmp;
|
||||
}
|
||||
|
||||
void SnoreServer::initTMP(){
|
||||
|
||||
SnoreServer::SnoreServer ( QSystemTrayIcon *trayIcon ) :
|
||||
_notificationBackend ( NULL ),
|
||||
_trayIcon ( trayIcon )
|
||||
{
|
||||
QDir home ( snoreTMP() );
|
||||
if ( !home.exists() ){
|
||||
home.cdUp();
|
||||
home.mkdir("SnoreNotify");
|
||||
}
|
||||
}
|
||||
|
||||
SnoreServer::SnoreServer ( QSystemTrayIcon *trayIcon ) :
|
||||
_notificationBackend ( NULL ),
|
||||
_trayIcon ( trayIcon )
|
||||
{
|
||||
qDebug() <<"Inititalized";
|
||||
|
||||
if ( trayIcon!=NULL )
|
||||
{
|
||||
|
|
|
@ -29,8 +29,6 @@ class SNORE_EXPORT SnoreServer:public QObject
|
|||
public:
|
||||
static const QString version();
|
||||
static const QString snoreTMP();
|
||||
static void initTMP();
|
||||
|
||||
|
||||
public:
|
||||
SnoreServer ( class QSystemTrayIcon *trayIcon=0 );
|
||||
|
|
|
@ -35,7 +35,7 @@ using namespace Snarl::V42;
|
|||
Q_EXPORT_PLUGIN2(snarl_backend,Snarl_Backend);
|
||||
|
||||
Snarl_Backend::Snarl_Backend(SnoreServer *snore):
|
||||
Notification_Backend("SnarlBackend",snore)
|
||||
Notification_Backend("Snarl",snore)
|
||||
{
|
||||
winIDWidget = new SnarlWidget(this);
|
||||
SnarlInterface *snarlInterface = new SnarlInterface();
|
||||
|
|
|
@ -24,26 +24,17 @@
|
|||
#include <QDebug>
|
||||
#include <QPluginLoader>
|
||||
#include <QSystemTrayIcon>
|
||||
#include <QtXml/qdom.h>
|
||||
#include <QFile>
|
||||
#include <QTextStream>
|
||||
#include <QSettings>
|
||||
|
||||
#include <iostream>
|
||||
|
||||
#ifdef Q_WS_WIN
|
||||
#define PROFILEPATH qgetenv("APPDATA") + "\\snorenotify\\"
|
||||
#elif defined(Q_OS_LINUX)
|
||||
#define PROFILEPATH qgetenv("HOME") + "/.snorenotify/"
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
|
||||
SnoreNotify::SnoreNotify()
|
||||
SnoreNotify::SnoreNotify():
|
||||
_settings("TheOneRing","SnoreNotify")
|
||||
{
|
||||
_trayIcon = new TrayIcon();
|
||||
_snore = new SnoreServer(_trayIcon->trayIcon());
|
||||
_snore->initTMP();
|
||||
|
||||
QDir pluginsDir ( qApp->applicationDirPath() +"/snoreplugins" );
|
||||
foreach ( QString fileName, pluginsDir.entryList ( QDir::Files ) )
|
||||
|
@ -65,50 +56,11 @@ SnoreNotify::~SnoreNotify(){
|
|||
}
|
||||
|
||||
void SnoreNotify::load(){
|
||||
QDomDocument doc( "Settings" );
|
||||
QFile file( PROFILEPATH + "settings.xml" );
|
||||
if(!file.open( QFile::ReadOnly )){
|
||||
std::cout<<"Failed openeing settings file: "<<QString(PROFILEPATH).toLatin1().data()<<"settings.xml"<<std::endl;
|
||||
return;
|
||||
}
|
||||
|
||||
QString errorMessage;
|
||||
int errorLine = -1;
|
||||
int errorCulumn = -1;
|
||||
|
||||
if(!doc.setContent(&file,&errorMessage,&errorLine, &errorCulumn )){
|
||||
std::cout<<"Failed parsing settings file: "<<QString(PROFILEPATH).toLatin1().data()<<"settings.xml\n"
|
||||
<<"Error: "<<errorMessage.toLatin1().data()<<" line: "
|
||||
<<QString::number(errorLine).toLatin1().data()<<" collumn: "<<QString::number(errorCulumn).toLatin1().data()<<std::endl;
|
||||
file.close();
|
||||
return;
|
||||
}
|
||||
file.close();
|
||||
|
||||
QDomElement root = doc.documentElement();
|
||||
QDomElement backend = root.elementsByTagName("notificationBackend").item(0).toElement();
|
||||
if(!backend.isNull())
|
||||
_snore->setPrimaryNotificationBackend(backend.text());
|
||||
_snore->setPrimaryNotificationBackend(_settings.value("notificationBackend").toString());
|
||||
}
|
||||
|
||||
void SnoreNotify::save(){
|
||||
QDomDocument doc("Settings");
|
||||
QDomElement root = doc.createElement( "SnoreNotifyProfile" );
|
||||
doc.appendChild(root);
|
||||
QDomElement backend = doc.createElement( "notificationBackend");
|
||||
backend.appendChild(doc.createTextNode(_snore->primaryNotificationBackend()));
|
||||
root.appendChild(backend);
|
||||
|
||||
|
||||
QFile file( PROFILEPATH + "settings.xml" );
|
||||
if(!file.exists()){
|
||||
QDir(PROFILEPATH).mkpath(PROFILEPATH);
|
||||
}
|
||||
file.open(QFile::WriteOnly);
|
||||
|
||||
QTextStream ts( &file );
|
||||
doc.save(ts,4);
|
||||
file.close();
|
||||
_settings.setValue("notificationBackend",_snore->primaryNotificationBackend());
|
||||
}
|
||||
|
||||
void SnoreNotify::exit(){
|
||||
|
|
|
@ -31,6 +31,7 @@ public:
|
|||
private:
|
||||
class TrayIcon *_trayIcon;
|
||||
class SnoreServer *_snore;
|
||||
class QSettings _settings;
|
||||
|
||||
private slots:
|
||||
void exit();
|
||||
|
|
Loading…
Reference in New Issue