fix - MacOS - In shortcuts: Ctrl now is Cmd while Ctrl is Meta

This commit is contained in:
Yuriy Puchkov
2020-12-08 09:19:05 +02:00
parent d08d109916
commit 7e09b818c7
3 changed files with 33 additions and 0 deletions

View File

@@ -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

View File

@@ -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;

View File

@@ -54,10 +54,13 @@ const QVector<QStringList>& 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()