Skip to content

Commit

Permalink
热键保存
Browse files Browse the repository at this point in the history
  • Loading branch information
zhanlangsir committed Feb 25, 2013
1 parent 75a1089 commit 034513b
Show file tree
Hide file tree
Showing 4 changed files with 49 additions and 1 deletion.
6 changes: 6 additions & 0 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,9 @@ set(CORE_HEADERS
rostermodel/contact_proxy_model.h
rostermodel/contact_searcher.h

#setting
setting/setting.h

#skinengine
skinengine/qqskinengine.h
skinengine/msgstyle_manager.h
Expand Down Expand Up @@ -232,6 +235,9 @@ set(CORE_SOURCES
rostermodel/contact_proxy_model.cpp
rostermodel/contact_searcher.cpp

#setting
setting/setting.cpp

#skinengine
skinengine/qqskinengine.cpp
skinengine/msgstyle_manager.cpp
Expand Down
7 changes: 6 additions & 1 deletion src/hotkeymanager/hotkey_manager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,14 @@

#include <QWidget>
#include <QKeySequence>
#include <QVariant>
#include <QDebug>

#include "qxtglobalshortcut.h"

#include "utils/menu.h"
#include "mainwindow.h"
#include "setting/setting.h"
#include "qtqq.h"

HotkeyManager *HotkeyManager::instance_ = NULL;
Expand Down Expand Up @@ -45,7 +47,9 @@ HotkeyManager::HotkeyManager()

void HotkeyManager::initHotkeys()
{
QxtGlobalShortcut *snapshot = new QxtGlobalShortcut(QKeySequence("Ctrl+Alt+S"), this);
QKeySequence snapshot_ks = Setting::instance()->value("hotkeymanager/snapshot", QKeySequence("Ctrl+Alt+S")).value<QKeySequence>();
QxtGlobalShortcut *snapshot = new QxtGlobalShortcut(snapshot_ks, this);

hotkeys_.append(snapshot);
}

Expand Down Expand Up @@ -83,6 +87,7 @@ void HotkeyManager::onHotKeyApply()
else
{
hotkey_dlg_->msg_label->setVisible(false);
Setting::instance()->setValue("hotkeymanager/snapshot", QVariant::fromValue<QKeySequence>(new_ks));
}
}
}
Expand Down
11 changes: 11 additions & 0 deletions src/setting/setting.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#include "setting.h"

#include "qqglobal.h"

Setting *Setting::instance_ = NULL;

Setting::Setting() :
QSettings(QQGlobal::configDir() + "/options.ini", QSettings::IniFormat)
{

}
26 changes: 26 additions & 0 deletions src/setting/setting.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
#ifndef SETTING_H
#define SETTING_H

#include <QSettings>

class Setting : public QSettings
{
public:
static Setting *instance()
{
if ( !instance_ )
instance_ = new Setting();

return instance_;
}


private:
Setting();
Setting(const Setting&);
Setting &operator=(const Setting&);

static Setting *instance_;
};

#endif //SETTING_H

0 comments on commit 034513b

Please sign in to comment.