ckb-next  v0.2.8 at branch master
ckb-next driver for corsair devices
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
KbMode Class Reference

#include <src/ckb/kbmode.h>

+ Inheritance diagram for KbMode:
+ Collaboration diagram for KbMode:

Signals

void updated ()
 

Public Member Functions

 KbMode (Kb *parent, const KeyMap &keyMap, const QString &guid="", const QString &modified="")
 
 KbMode (Kb *parent, const KeyMap &keyMap, CkbSettings &settings)
 
 KbMode (Kb *parent, const KeyMap &keyMap, const KbMode &other)
 KbMode::KbMode. More...
 
 ~KbMode ()
 KbMode::~KbMode Destructor may be used for Debugging (issue #38 with SIGSEGV). Insert qDebug-statement. More...
 
const QString & name () const
 
void name (const QString &newName)
 
UsbIdid ()
 
void id (const UsbId &newId)
 
void newId ()
 
void keyMap (const KeyMap &keyMap)
 
KbLightlight ()
 
KbBindbind ()
 
KbPerfperf ()
 
void save (CkbSettings &settings)
 
bool needsSave () const
 
void setNeedsSave ()
 
void setNeedsUpdate ()
 

Private Slots

void doUpdate ()
 

Private Attributes

QString _name
 
UsbId _id
 
KbLight_light
 
KbBind_bind
 
KbPerf_perf
 
bool _needsSave
 

Detailed Description

Definition at line 36 of file kbmode.h.

Constructor & Destructor Documentation

KbMode::KbMode ( Kb parent,
const KeyMap keyMap,
const QString &  guid = "",
const QString &  modified = "" 
)

Definition at line 4 of file kbmode.cpp.

References _id, _light, doUpdate(), UsbId::guid, and updated().

4  :
5  QObject(parent),
6  _name("Unnamed"), _id(guid, modified),
7  _light(new KbLight(this, keyMap)), _bind(new KbBind(this, parent, keyMap)), _perf(new KbPerf(this)),
8  _needsSave(true)
9 {
10  connect(_light, SIGNAL(updated()), this, SLOT(doUpdate()));
11  if(_id.guid.isNull())
12  _id.guid = QUuid::createUuid();
13 }
QUuid guid
Definition: kbmode.h:12
KbBind * _bind
Definition: kbmode.h:78
bool _needsSave
Definition: kbmode.h:81
UsbId _id
Definition: kbmode.h:75
void doUpdate()
Definition: kbmode.cpp:82
KbLight * _light
Definition: kbmode.h:77
QString _name
Definition: kbmode.h:74
Definition: kbperf.h:15
Definition: kbbind.h:20
void updated()
Definition: moc_kbmode.cpp:131
KbPerf * _perf
Definition: kbmode.h:79

+ Here is the call graph for this function:

KbMode::KbMode ( Kb parent,
const KeyMap keyMap,
CkbSettings settings 
)

Definition at line 30 of file kbmode.cpp.

References _bind, _id, _light, _name, _perf, CkbSettings::contains(), doUpdate(), UsbId::guid, UsbId::hwModified, UsbId::hwModifiedString(), KbPerf::load(), KbBind::load(), KbLight::load(), UsbId::modified, updated(), and CkbSettings::value().

30  :
31  QObject(parent),
32  _name(settings.value("Name").toString().trimmed()),
33  _id(settings.value("GUID").toString().trimmed(), settings.value("Modified").toString().trimmed()),
34  _light(new KbLight(this, keyMap)), _bind(new KbBind(this, parent, keyMap)), _perf(new KbPerf(this)),
35  _needsSave(false)
36 {
37  if(settings.contains("HwModified"))
38  _id.hwModifiedString(settings.value("HwModified").toString());
39  else
41 
42  connect(_light, SIGNAL(updated()), this, SLOT(doUpdate()));
43  if(_id.guid.isNull())
44  _id.guid = QUuid::createUuid();
45  if(_name == "")
46  _name = "Unnamed";
47  _light->load(settings);
48  _bind->load(settings);
49  _perf->load(settings);
50 }
void load(CkbSettings &settings)
Definition: kbbind.cpp:58
QUuid guid
Definition: kbmode.h:12
KbBind * _bind
Definition: kbmode.h:78
bool _needsSave
Definition: kbmode.h:81
UsbId _id
Definition: kbmode.h:75
QVariant value(const QString &key, const QVariant &defaultValue=QVariant()) const
void doUpdate()
Definition: kbmode.cpp:82
bool contains(const QString &key) const
quint32 modified
Definition: kbmode.h:13
KbLight * _light
Definition: kbmode.h:77
void load(CkbSettings &settings)
Definition: kblight.cpp:408
QString _name
Definition: kbmode.h:74
Definition: kbperf.h:15
Definition: kbbind.h:20
void updated()
Definition: moc_kbmode.cpp:131
quint32 hwModified
Definition: kbmode.h:14
void load(CkbSettings &settings)
Definition: kbperf.cpp:106
KbPerf * _perf
Definition: kbmode.h:79
QString hwModifiedString() const
Definition: kbmode.h:24

+ Here is the call graph for this function:

KbMode::KbMode ( Kb parent,
const KeyMap keyMap,
const KbMode other 
)
Parameters
parentKb as parent (append to the Keyboard list
keyMapMap to copy from
otherMode to copy from Constructor to copy an existing Keyboard-Mode KbMode &other

Definition at line 21 of file kbmode.cpp.

References _light, doUpdate(), and updated().

21  :
22  QObject(parent),
23  _name(other._name), _id(other._id),
24  _light(new KbLight(this, keyMap, *other._light)), _bind(new KbBind(this, parent, keyMap, *other._bind)), _perf(new KbPerf(this, *other._perf)),
25  _needsSave(true)
26 {
27  connect(_light, SIGNAL(updated()), this, SLOT(doUpdate()));
28 }
KbBind * _bind
Definition: kbmode.h:78
bool _needsSave
Definition: kbmode.h:81
UsbId _id
Definition: kbmode.h:75
void doUpdate()
Definition: kbmode.cpp:82
KbLight * _light
Definition: kbmode.h:77
QString _name
Definition: kbmode.h:74
Definition: kbperf.h:15
Definition: kbbind.h:20
void updated()
Definition: moc_kbmode.cpp:131
KbPerf * _perf
Definition: kbmode.h:79

+ Here is the call graph for this function:

KbMode::~KbMode ( )

Definition at line 89 of file kbmode.cpp.

89  {
90 }

Member Function Documentation

KbBind* KbMode::bind ( )
inline

Definition at line 61 of file kbmode.h.

References _bind.

Referenced by KbPerf::bind(), Kb::currentBind(), Kb::frameUpdate(), KbBindWidget::on_copyButton_clicked(), and Kb::readNotify().

61 { return _bind; }
KbBind * _bind
Definition: kbmode.h:78

+ Here is the caller graph for this function:

void KbMode::doUpdate ( )
privateslot

Definition at line 82 of file kbmode.cpp.

References updated().

Referenced by KbMode().

82  {
83  emit updated();
84 }
void updated()
Definition: moc_kbmode.cpp:131

+ Here is the caller graph for this function:

UsbId& KbMode::id ( )
inline
void KbMode::id ( const UsbId newId)
inline

Definition at line 53 of file kbmode.h.

References _id, _needsSave, and newId().

53 { _needsSave = true; _id = newId; }
bool _needsSave
Definition: kbmode.h:81
UsbId _id
Definition: kbmode.h:75
void newId()
Definition: kbmode.cpp:52

+ Here is the call graph for this function:

void KbMode::keyMap ( const KeyMap keyMap)

Definition at line 60 of file kbmode.cpp.

References _bind, _light, _needsSave, KbLight::map(), and KbBind::map().

Referenced by KbProfile::keyMap().

60  {
61  _needsSave = true;
62  _light->map(keyMap);
63  _bind->map(keyMap);
64 }
KbBind * _bind
Definition: kbmode.h:78
bool _needsSave
Definition: kbmode.h:81
const KeyMap & map()
Definition: kbbind.h:41
KbLight * _light
Definition: kbmode.h:77
const KeyMap & map()
Definition: kblight.h:28

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

KbLight* KbMode::light ( )
inline

Definition at line 60 of file kbmode.h.

References _light.

Referenced by Kb::currentLight(), Kb::frameUpdate(), Kb::hwSave(), KbBind::light(), KbPerf::light(), Kb::readNotify(), and Kb::updateLayout().

60 { return _light; }
KbLight * _light
Definition: kbmode.h:77

+ Here is the caller graph for this function:

const QString& KbMode::name ( ) const
inline

Definition at line 50 of file kbmode.h.

References _name.

Referenced by Kb::hwSave(), ModeSelectDialog::ModeSelectDialog(), KbWidget::on_modesList_itemChanged(), KbWidget::profileChanged(), Kb::readNotify(), and RebindWidget::setBind().

50 { return _name; }
QString _name
Definition: kbmode.h:74

+ Here is the caller graph for this function:

void KbMode::name ( const QString &  newName)
inline

Definition at line 51 of file kbmode.h.

References _name, and _needsSave.

51 { _needsSave = true; _name = newName.trimmed(); if(_name == "") _name = "Unnamed"; }
bool _needsSave
Definition: kbmode.h:81
QString _name
Definition: kbmode.h:74
bool KbMode::needsSave ( ) const

Definition at line 78 of file kbmode.cpp.

References _bind, _light, _needsSave, _perf, KbPerf::needsSave(), KbBind::needsSave(), and KbLight::needsSave().

Referenced by KbProfile::needsSave().

78  {
79  return _needsSave || _light->needsSave() || _bind->needsSave() || _perf->needsSave();
80 }
KbBind * _bind
Definition: kbmode.h:78
bool _needsSave
Definition: kbmode.h:81
bool needsSave() const
Definition: kbbind.h:38
bool needsSave() const
Definition: kblight.cpp:474
KbLight * _light
Definition: kbmode.h:77
bool needsSave() const
Definition: kbperf.h:28
KbPerf * _perf
Definition: kbmode.h:79

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void KbMode::newId ( )

Definition at line 52 of file kbmode.cpp.

References _id, _light, _needsSave, anim, KbLight::animList(), and KbAnim::newId().

Referenced by id(), KbProfile::newId(), and KbWidget::on_modesList_customContextMenuRequested().

52  {
53  _needsSave = true;
54  _id = UsbId();
55  // Create new IDs for animations
56  foreach(KbAnim* anim, _light->animList())
57  anim->newId();
58 }
bool _needsSave
Definition: kbmode.h:81
UsbId _id
Definition: kbmode.h:75
const AnimList & animList()
Definition: kblight.h:49
Definition: kbmode.h:11
void newId()
Definition: kbanim.h:72
KbLight * _light
Definition: kbmode.h:77
Definition: kbanim.h:11
struct keyAnim * anim
Definition: main.c:55

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

KbPerf* KbMode::perf ( )
inline

Definition at line 62 of file kbmode.h.

References _perf.

Referenced by Kb::currentPerf(), Kb::frameUpdate(), Kb::hwSave(), KPerfWidget::on_copyButton_clicked(), MPerfWidget::on_copyButton_clicked(), KbBind::perf(), and Kb::readNotify().

62 { return _perf; }
KbPerf * _perf
Definition: kbmode.h:79

+ Here is the caller graph for this function:

void KbMode::save ( CkbSettings settings)

Definition at line 66 of file kbmode.cpp.

References _bind, _id, _light, _name, _needsSave, _perf, UsbId::guidString(), UsbId::hwModifiedString(), UsbId::modifiedString(), UsbId::newModified(), KbPerf::save(), KbBind::save(), KbLight::save(), and CkbSettings::setValue().

Referenced by KbProfile::save().

66  {
67  _needsSave = false;
68  _id.newModified();
69  settings.setValue("GUID", _id.guidString());
70  settings.setValue("Modified", _id.modifiedString());
71  settings.setValue("HwModified", _id.hwModifiedString());
72  settings.setValue("Name", _name);
73  _light->save(settings);
74  _bind->save(settings);
75  _perf->save(settings);
76 }
void setValue(const QString &key, const QVariant &value)
KbBind * _bind
Definition: kbmode.h:78
bool _needsSave
Definition: kbmode.h:81
QString modifiedString() const
Definition: kbmode.h:22
UsbId _id
Definition: kbmode.h:75
void save(CkbSettings &settings)
Definition: kblight.cpp:447
QString guidString() const
Definition: kbmode.h:20
KbLight * _light
Definition: kbmode.h:77
QString _name
Definition: kbmode.h:74
void save(CkbSettings &settings)
Definition: kbbind.cpp:81
void newModified()
Definition: kbmode.h:29
void save(CkbSettings &settings)
Definition: kbperf.cpp:211
KbPerf * _perf
Definition: kbmode.h:79
QString hwModifiedString() const
Definition: kbmode.h:24

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void KbMode::setNeedsSave ( )
inline

Definition at line 67 of file kbmode.h.

References _needsSave.

Referenced by Kb::hwSave(), and Kb::readNotify().

67 { _needsSave = true; }
bool _needsSave
Definition: kbmode.h:81

+ Here is the caller graph for this function:

void KbMode::setNeedsUpdate ( )
inline

Definition at line 68 of file kbmode.h.

References _bind, _perf, KbBind::setNeedsUpdate(), and KbPerf::setNeedsUpdate().

Referenced by KbProfile::setNeedsUpdate().

KbBind * _bind
Definition: kbmode.h:78
void setNeedsUpdate()
Definition: kbperf.h:116
void setNeedsUpdate()
Definition: kbbind.h:85
KbPerf * _perf
Definition: kbmode.h:79

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void KbMode::updated ( )
signal

Definition at line 131 of file moc_kbmode.cpp.

Referenced by doUpdate(), and KbMode().

132 {
133  QMetaObject::activate(this, &staticMetaObject, 0, Q_NULLPTR);
134 }

+ Here is the caller graph for this function:

Field Documentation

KbBind* KbMode::_bind
private

Definition at line 78 of file kbmode.h.

Referenced by bind(), KbMode(), keyMap(), needsSave(), save(), and setNeedsUpdate().

UsbId KbMode::_id
private

Definition at line 75 of file kbmode.h.

Referenced by id(), KbMode(), newId(), and save().

KbLight* KbMode::_light
private

Definition at line 77 of file kbmode.h.

Referenced by KbMode(), keyMap(), light(), needsSave(), newId(), and save().

QString KbMode::_name
private

Definition at line 74 of file kbmode.h.

Referenced by KbMode(), name(), and save().

bool KbMode::_needsSave
private

Definition at line 81 of file kbmode.h.

Referenced by id(), keyMap(), name(), needsSave(), newId(), save(), and setNeedsSave().

KbPerf* KbMode::_perf
private

Definition at line 79 of file kbmode.h.

Referenced by KbMode(), needsSave(), perf(), save(), and setNeedsUpdate().


The documentation for this class was generated from the following files: