From 7e09b818c75472cce311836855eaeedb6e10db27 Mon Sep 17 00:00:00 2001 From: Yuriy Puchkov Date: Tue, 8 Dec 2020 09:19:05 +0200 Subject: [PATCH] fix - MacOS - In shortcuts: Ctrl now is Cmd while Ctrl is Meta --- src/config/shortcutswidget.cpp | 25 +++++++++++++++++++++++++ src/config/shortcutswidget.h | 5 +++++ src/utils/configshortcuts.cpp | 3 +++ 3 files changed, 33 insertions(+) diff --git a/src/config/shortcutswidget.cpp b/src/config/shortcutswidget.cpp index b11e9afa..75386cab 100644 --- a/src/config/shortcutswidget.cpp +++ b/src/config/shortcutswidget.cpp @@ -86,7 +86,13 @@ void ShortcutsWidget::initInfoTable() for (int i = 0; i < shortcuts().size(); ++i) { m_table->setItem(i, 0, new QTableWidgetItem(m_shortcuts.at(i).at(1))); +#if (defined(Q_OS_MAC) || defined(Q_OS_MAC64) || defined(Q_OS_MACOS) || \ + defined(Q_OS_MACX)) + QTableWidgetItem* item = + new QTableWidgetItem(nativeOSHotKeyText(m_shortcuts.at(i).at(2))); +#else QTableWidgetItem* item = new QTableWidgetItem(m_shortcuts.at(i).at(2)); +#endif item->setTextAlignment(Qt::AlignCenter); m_table->setItem(i, 1, item); @@ -138,8 +144,14 @@ void ShortcutsWidget::slotShortcutCellClicked(int row, int col) } if (m_config.setShortcut(shortcutName, shortcutValue.toString())) { +#if (defined(Q_OS_MAC) || defined(Q_OS_MAC64) || defined(Q_OS_MACOS) || \ + defined(Q_OS_MACX)) + QTableWidgetItem* item = new QTableWidgetItem( + nativeOSHotKeyText(shortcutValue.toString())); +#else QTableWidgetItem* item = new QTableWidgetItem(shortcutValue.toString()); +#endif item->setTextAlignment(Qt::AlignCenter); item->setFlags(item->flags() ^ Qt::ItemIsEditable); m_table->setItem(row, col, item); @@ -148,3 +160,16 @@ void ShortcutsWidget::slotShortcutCellClicked(int row, int col) delete setShortcutDialog; } } + +#if (defined(Q_OS_MAC) || defined(Q_OS_MAC64) || defined(Q_OS_MACOS) || \ + defined(Q_OS_MACX)) +const QString& ShortcutsWidget::nativeOSHotKeyText(const QString& text) +{ + m_res = text; + m_res.replace("Ctrl+", "⌘"); + m_res.replace("Alt+", "⌥"); + m_res.replace("Meta+", "⌃"); + m_res.replace("Shift+", "⇧"); + return m_res; +} +#endif \ No newline at end of file diff --git a/src/config/shortcutswidget.h b/src/config/shortcutswidget.h index 20fc3909..8845c45b 100644 --- a/src/config/shortcutswidget.h +++ b/src/config/shortcutswidget.h @@ -36,11 +36,16 @@ public: private: void initInfoTable(); +#if (defined(Q_OS_MAC) || defined(Q_OS_MAC64) || defined(Q_OS_MACOS) || \ + defined(Q_OS_MACX)) + const QString& nativeOSHotKeyText(const QString& text); +#endif private slots: void slotShortcutCellClicked(int, int); private: + QString m_res; ConfigHandler m_config; QTableWidget* m_table; QVBoxLayout* m_layout; diff --git a/src/utils/configshortcuts.cpp b/src/utils/configshortcuts.cpp index 4cba9c77..432ae60c 100644 --- a/src/utils/configshortcuts.cpp +++ b/src/utils/configshortcuts.cpp @@ -54,10 +54,13 @@ const QVector& ConfigShortcuts::captureShortcutsDefault( m_shortcuts << (QStringList() << "" << QObject::tr("Quit capture") << QKeySequence(Qt::Key_Escape).toString()); +#if not(defined(Q_OS_MAC) || defined(Q_OS_MAC64) || defined(Q_OS_MACOS) || \ + defined(Q_OS_MACX)) m_shortcuts << (QStringList() << "" << QObject::tr("Screenshot history") << "Shift+Print Screen"); m_shortcuts << (QStringList() << "" << QObject::tr("Capture screen") << "Print Screen"); +#endif m_shortcuts << (QStringList() << "" << QObject::tr("Show color picker") << "Right Click"); m_shortcuts << (QStringList()