From acdb6369359eb2bf29fd50d7d24d894d6c8636ff Mon Sep 17 00:00:00 2001 From: Aesylwinn Date: Fri, 22 Jul 2016 02:41:00 -0400 Subject: [PATCH] Qt4 protected signal workaround and signed/unsigned mismatch. --- apps/opencs/model/prefs/shortcut.cpp | 19 +++++++++++++++ apps/opencs/model/prefs/shortcut.hpp | 8 ++++++- .../model/prefs/shortcuteventhandler.cpp | 24 +++++++++---------- apps/opencs/model/prefs/shortcutmanager.cpp | 2 +- 4 files changed, 39 insertions(+), 14 deletions(-) diff --git a/apps/opencs/model/prefs/shortcut.cpp b/apps/opencs/model/prefs/shortcut.cpp index 4aa6f0d84..247dadf99 100644 --- a/apps/opencs/model/prefs/shortcut.cpp +++ b/apps/opencs/model/prefs/shortcut.cpp @@ -125,6 +125,25 @@ namespace CSMPrefs mModifierStatus = status; } + void Shortcut::signalActivated(bool state) + { + emit activated(state); + } + + void Shortcut::signalActivated() + { + emit activated(); + } + + void Shortcut::signalSecondary(bool state) + { + emit secondary(state); + } + void Shortcut::signalSecondary() + { + emit secondary(); + } + QString Shortcut::toString() const { return QString(State::get().getShortcutManager().sequenceToString(std::make_pair(mSequence, mModifier)).data()); diff --git a/apps/opencs/model/prefs/shortcut.hpp b/apps/opencs/model/prefs/shortcut.hpp index 491cd7667..af3a20c06 100644 --- a/apps/opencs/model/prefs/shortcut.hpp +++ b/apps/opencs/model/prefs/shortcut.hpp @@ -66,6 +66,13 @@ namespace CSMPrefs void setActivationStatus(ActivationStatus status); void setModifierStatus(bool status); + // Workaround for Qt4 signals being "protected" + void signalActivated(bool state); + void signalActivated(); + + void signalSecondary(bool state); + void signalSecondary(); + QString toString() const; private: @@ -83,7 +90,6 @@ namespace CSMPrefs ActivationStatus mActivationStatus; bool mModifierStatus; - signals: /// Triggered when the shortcut is activated or deactivated; can be determined from \p state diff --git a/apps/opencs/model/prefs/shortcuteventhandler.cpp b/apps/opencs/model/prefs/shortcuteventhandler.cpp index 0537c53a2..c04f9e310 100644 --- a/apps/opencs/model/prefs/shortcuteventhandler.cpp +++ b/apps/opencs/model/prefs/shortcuteventhandler.cpp @@ -76,12 +76,12 @@ namespace CSMPrefs if (shortcut->getActivationStatus() == Shortcut::AS_Regular) { shortcut->setActivationStatus(Shortcut::AS_Inactive); - emit shortcut->activated(false); + shortcut->signalActivated(false); } else if (shortcut->getActivationStatus() == Shortcut::AS_Secondary) { shortcut->setActivationStatus(Shortcut::AS_Inactive); - emit shortcut->secondary(false); + shortcut->signalSecondary(false); } } } @@ -131,14 +131,14 @@ namespace CSMPrefs if (shortcut->getModifierStatus() && shortcut->getSecondaryMode() == Shortcut::SM_Replace) { shortcut->setActivationStatus(Shortcut::AS_Secondary); - emit shortcut->secondary(true); - emit shortcut->secondary(); + shortcut->signalSecondary(true); + shortcut->signalSecondary(); } else { shortcut->setActivationStatus(Shortcut::AS_Regular); - emit shortcut->activated(true); - emit shortcut->activated(); + shortcut->signalActivated(true); + shortcut->signalActivated(); } used = true; @@ -170,13 +170,13 @@ namespace CSMPrefs if (shortcut->getActivationStatus() == Shortcut::AS_Regular) { shortcut->setActivationStatus(Shortcut::AS_Inactive); - emit shortcut->activated(false); + shortcut->signalActivated(false); used = true; } else if (shortcut->getActivationStatus() == Shortcut::AS_Secondary) { shortcut->setActivationStatus(Shortcut::AS_Inactive); - emit shortcut->secondary(false); + shortcut->signalSecondary(false); used = true; } } @@ -201,12 +201,12 @@ namespace CSMPrefs { if (activate) { - emit shortcut->secondary(true); - emit shortcut->secondary(); + shortcut->signalSecondary(true); + shortcut->signalSecondary(); } else { - emit shortcut->secondary(false); + shortcut->signalSecondary(false); } used = true; @@ -215,7 +215,7 @@ namespace CSMPrefs { shortcut->setActivationStatus(Shortcut::AS_Inactive); shortcut->setPosition(0); - emit shortcut->secondary(false); + shortcut->signalSecondary(false); used = true; } } diff --git a/apps/opencs/model/prefs/shortcutmanager.cpp b/apps/opencs/model/prefs/shortcutmanager.cpp index 198804b3d..f8e9ccb8a 100644 --- a/apps/opencs/model/prefs/shortcutmanager.cpp +++ b/apps/opencs/model/prefs/shortcutmanager.cpp @@ -82,7 +82,7 @@ namespace CSMPrefs std::string output; // KeySequence - for (unsigned int i = 0; i < data.first.count(); ++i) + for (int i = 0; i < data.first.count(); ++i) { if (data.first[i] & ModMask) {