- enhancement: show error message when user set a shortcut that's already being used.

This commit is contained in:
Roy Qu 2022-05-14 16:52:56 +08:00
parent a3946b6015
commit 6340dbe299
2 changed files with 13 additions and 0 deletions

View File

@ -5,6 +5,7 @@ Red Panda C++ Version 1.0.8
- enhancement: add compiler commandline argument for "-E" (only preprocessing)
- enhancement: auto set output suffix to ".expanded.cpp" when compiler commandline argument for "-E" is turned on
- enhancement: auto set output suffix to ".s" when compiler commandline argument for "-S" is turned on
- enhancement: show error message when user set a shortcut that's already being used.
Red Panda C++ Version 1.0.7
- change: use Shift+Enter to break line

View File

@ -19,6 +19,7 @@
#include "../mainwindow.h"
#include "../widgets/shortcutinputedit.h"
#include <QMenuBar>
#include <QMessageBox>
EnvironmentShortcutWidget::EnvironmentShortcutWidget(const QString& name, const QString& group, QWidget *parent) :
SettingsWidget(name,group,parent),
@ -119,6 +120,17 @@ bool EnvironmentShortcutModel::setData(const QModelIndex &index, const QVariant
PEnvironmentShortcut item = mShortcuts[index.row()];
QString s = value.toString().trimmed();
if (s!=item->shortcut) {
for (int i=0;i<mShortcuts.length();i++) {
if (i==index.row())
continue;
if (s==mShortcuts[i]->shortcut) {
QMessageBox::critical(nullptr,
tr("Error"),
tr("Shortcut \"%1\" is used by \"%2\".")
.arg(s,mShortcuts[i]->fullPath));
return false;
}
}
item->shortcut = value.toString();
emit shortcutChanged();
}