summaryrefslogtreecommitdiffhomepage
path: root/opentrack
diff options
context:
space:
mode:
authorStanislaw Halik <sthalik@misaki.pl>2016-06-12 16:48:09 +0200
committerStanislaw Halik <sthalik@misaki.pl>2016-06-14 18:14:46 +0200
commit216e20c26442fc3f46644635986216e8efcb96e1 (patch)
tree98bfbb1bd3bf86c69b6fdf6efd8c5fca0ffa2323 /opentrack
parent299391ade90fc5f64e57ee6d9431b90fcaf63db8 (diff)
api/shortcuts: use unsigned index where able
Diffstat (limited to 'opentrack')
-rw-r--r--opentrack/shortcuts.cpp12
-rw-r--r--opentrack/win32-shortcuts.cpp7
2 files changed, 10 insertions, 9 deletions
diff --git a/opentrack/shortcuts.cpp b/opentrack/shortcuts.cpp
index 3fd35b19..06c246af 100644
--- a/opentrack/shortcuts.cpp
+++ b/opentrack/shortcuts.cpp
@@ -77,8 +77,8 @@ void Shortcuts::bind_keyboard_shortcut(K &key, const key_opts& k, unused_on_unix
#ifdef _WIN32
void Shortcuts::receiver(const Key& k)
{
- const int sz = keys.size();
- for (int i = 0; i < sz; i++)
+ const unsigned sz = keys.size();
+ for (unsigned i = 0; i < sz; i++)
{
K& k_ = std::get<0>(keys[i]);
auto& fun = std::get<1>(keys[i]);
@@ -100,10 +100,10 @@ void Shortcuts::receiver(const Key& k)
void Shortcuts::reload(const std::vector<std::tuple<key_opts&, fun, bool>> &keys_)
{
- const int sz = keys_.size();
+ const unsigned sz = keys_.size();
keys = std::vector<tt>();
- for (int i = 0; i < sz; i++)
+ for (unsigned i = 0; i < sz; i++)
{
const auto& kk = keys_[i];
const key_opts& opts = std::get<0>(kk);
@@ -111,8 +111,8 @@ void Shortcuts::reload(const std::vector<std::tuple<key_opts&, fun, bool>> &keys
auto fun = std::get<1>(kk);
K k;
bind_keyboard_shortcut(k, opts, held);
- keys.push_back(tt(k,
- [=](unused_on_unix(bool, flag)) -> void {
+ keys.push_back(tt(k, [=](unused_on_unix(bool, flag)) -> void
+ {
#ifdef _WIN32
fun(flag);
#else
diff --git a/opentrack/win32-shortcuts.cpp b/opentrack/win32-shortcuts.cpp
index fb84e709..a93803a3 100644
--- a/opentrack/win32-shortcuts.cpp
+++ b/opentrack/win32-shortcuts.cpp
@@ -163,8 +163,9 @@ bool win_key::to_qt(const Key& k, QKeySequence& qt_, Qt::KeyboardModifiers &mods
bool win_key::from_qt(QKeySequence qt_, int& dik, Qt::KeyboardModifiers& mods)
{
- auto qt = static_cast<QVariant>(qt_).toInt();
- auto our_mods = qt & Qt::KeyboardModifierMask;
+ // CAVEAT don't use QVariant::toUInt() or conversion fails
+ const unsigned qt = static_cast<unsigned>(QVariant(qt_).toInt());
+ const unsigned our_mods = qt & Qt::KeyboardModifierMask;
{
const auto key_ = qt;
@@ -179,7 +180,7 @@ bool win_key::from_qt(QKeySequence qt_, int& dik, Qt::KeyboardModifiers& mods)
}
}
{
- const auto key = qt & ~Qt::KeyboardModifierMask;
+ const unsigned key = qt & ~Qt::KeyboardModifierMask;
for (auto& wk : windows_key_sequences)
{
if (wk.qt == key)