gui: Remove unnecessary accessor to private member in Hotkey

This commit is contained in:
Povilas Kanapickas 2021-01-10 13:39:35 +02:00
parent e7da893f5a
commit 016393fb67
2 changed files with 10 additions and 11 deletions

View File

@ -28,9 +28,9 @@ Hotkey::Hotkey() :
QString Hotkey::text() const QString Hotkey::text() const
{ {
QString text = keySequence().toString(); QString text = m_KeySequence.toString();
if (keySequence().isMouseButton()) if (m_KeySequence.isMouseButton())
return "mousebutton(" + text + ")"; return "mousebutton(" + text + ")";
return "keystroke(" + text + ")"; return "keystroke(" + text + ")";
@ -38,16 +38,16 @@ QString Hotkey::text() const
void Hotkey::loadSettings(QSettings& settings) void Hotkey::loadSettings(QSettings& settings)
{ {
keySequence().loadSettings(settings); m_KeySequence.loadSettings(settings);
actions().clear(); m_Actions.clear();
int num = settings.beginReadArray("actions"); int num = settings.beginReadArray("actions");
for (int i = 0; i < num; i++) for (int i = 0; i < num; i++)
{ {
settings.setArrayIndex(i); settings.setArrayIndex(i);
Action a; Action a;
a.loadSettings(settings); a.loadSettings(settings);
actions().append(a); m_Actions.append(a);
} }
settings.endArray(); settings.endArray();
@ -55,21 +55,21 @@ void Hotkey::loadSettings(QSettings& settings)
void Hotkey::saveSettings(QSettings& settings) const void Hotkey::saveSettings(QSettings& settings) const
{ {
keySequence().saveSettings(settings); m_KeySequence.saveSettings(settings);
settings.beginWriteArray("actions"); settings.beginWriteArray("actions");
for (int i = 0; i < actions().size(); i++) for (int i = 0; i < m_Actions.size(); i++)
{ {
settings.setArrayIndex(i); settings.setArrayIndex(i);
actions()[i].saveSettings(settings); m_Actions[i].saveSettings(settings);
} }
settings.endArray(); settings.endArray();
} }
QTextStream& operator<<(QTextStream& outStream, const Hotkey& hotkey) QTextStream& operator<<(QTextStream& outStream, const Hotkey& hotkey)
{ {
for (int i = 0; i < hotkey.actions().size(); i++) for (int i = 0; i < hotkey.m_Actions.size(); i++)
outStream << "\t" << hotkey.text() << " = " << hotkey.actions()[i] << endl; outStream << "\t" << hotkey.text() << " = " << hotkey.m_Actions[i] << endl;
return outStream; return outStream;
} }

View File

@ -49,7 +49,6 @@ class Hotkey
void saveSettings(QSettings& settings) const; void saveSettings(QSettings& settings) const;
protected: protected:
KeySequence& keySequence() { return m_KeySequence; }
void setKeySequence(const KeySequence& seq) { m_KeySequence = seq; } void setKeySequence(const KeySequence& seq) { m_KeySequence = seq; }
ActionList& actions() { return m_Actions; } ActionList& actions() { return m_Actions; }