From 7e09b818c75472cce311836855eaeedb6e10db27 Mon Sep 17 00:00:00 2001 From: Yuriy Puchkov Date: Tue, 8 Dec 2020 09:19:05 +0200 Subject: [PATCH 1/2] 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() From d48d4299e27632e52a78943dd746ee2759e2fe79 Mon Sep 17 00:00:00 2001 From: Yuriy Puchkov Date: Tue, 8 Dec 2020 12:32:03 +0200 Subject: [PATCH 2/2] fix - stretch to fit shortcuts table on the configuration window --- src/config/configwindow.cpp | 4 ++-- src/config/shortcutswidget.cpp | 8 +++----- src/config/shortcutswidget.h | 3 +++ 3 files changed, 8 insertions(+), 7 deletions(-) diff --git a/src/config/configwindow.cpp b/src/config/configwindow.cpp index e7d5be6a..48e5a270 100644 --- a/src/config/configwindow.cpp +++ b/src/config/configwindow.cpp @@ -37,8 +37,8 @@ ConfigWindow::ConfigWindow(QWidget* parent) : QTabWidget(parent) { setAttribute(Qt::WA_DeleteOnClose); - const int size = GlobalValues::buttonBaseSize() * 12; - setMinimumSize(size, size); + setMinimumSize(GlobalValues::buttonBaseSize() * 15, + GlobalValues::buttonBaseSize() * 12); setWindowIcon(QIcon(":img/app/flameshot.svg")); setWindowTitle(tr("Configuration")); diff --git a/src/config/shortcutswidget.cpp b/src/config/shortcutswidget.cpp index 75386cab..24c27c1d 100644 --- a/src/config/shortcutswidget.cpp +++ b/src/config/shortcutswidget.cpp @@ -48,7 +48,7 @@ ShortcutsWidget::ShortcutsWidget(QWidget* parent) #endif m_layout = new QVBoxLayout(this); - m_layout->setAlignment(Qt::AlignHCenter); + m_layout->setAlignment(Qt::AlignHCenter | Qt::AlignVCenter); m_shortcuts = m_config.shortcuts(); initInfoTable(); @@ -116,10 +116,8 @@ void ShortcutsWidget::initInfoTable() // adjust size m_table->resizeColumnsToContents(); m_table->resizeRowsToContents(); - m_table->setMinimumWidth(400); - m_table->setMaximumWidth(600); - - m_table->horizontalHeader()->setSectionResizeMode(1, QHeaderView::Stretch); + m_table->horizontalHeader()->setMinimumSectionSize(200); + m_table->horizontalHeader()->setSectionResizeMode(0, QHeaderView::Stretch); m_table->horizontalHeader()->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); } diff --git a/src/config/shortcutswidget.h b/src/config/shortcutswidget.h index 8845c45b..3d01657a 100644 --- a/src/config/shortcutswidget.h +++ b/src/config/shortcutswidget.h @@ -45,7 +45,10 @@ private slots: void slotShortcutCellClicked(int, int); private: +#if (defined(Q_OS_MAC) || defined(Q_OS_MAC64) || defined(Q_OS_MACOS) || \ + defined(Q_OS_MACX)) QString m_res; +#endif ConfigHandler m_config; QTableWidget* m_table; QVBoxLayout* m_layout;