1
0
Fork 0

GUI: fixed a bug when closing the AppearanceDialog + all actions in MainWindow now have customizable shortcuts + fixed a bug in the configuration with loading the shortcuts

This commit is contained in:
Mr. eXoDia 2014-07-29 23:27:58 +02:00
parent 421808da52
commit 4f896bd82a
7 changed files with 106 additions and 67 deletions

View File

@ -21,6 +21,7 @@ AppearanceDialog::AppearanceDialog(QWidget *parent) : QDialog(parent), ui(new Ui
fontMap=&Config()->Fonts;
fontBackupMap=*fontMap;
fontInit();
connect(this, SIGNAL(rejected()), this, SLOT(rejectedSlot()));
}
AppearanceDialog::~AppearanceDialog()
@ -327,15 +328,6 @@ void AppearanceDialog::on_buttonSave_clicked()
GuiUpdateAllViews();
}
void AppearanceDialog::on_buttonCancel_clicked()
{
Config()->Colors=colorBackupMap;
Config()->writeColors();
Config()->Fonts=fontBackupMap;
Config()->writeFonts();
GuiUpdateAllViews();
}
void AppearanceDialog::defaultValueSlot()
{
ColorInfo info=colorInfoList.at(colorInfoIndex);
@ -929,3 +921,12 @@ void AppearanceDialog::on_buttonFontDefaults_clicked()
Config()->writeFonts();
GuiUpdateAllViews();
}
void AppearanceDialog::rejectedSlot()
{
Config()->Colors=colorBackupMap;
Config()->writeColors();
Config()->Fonts=fontBackupMap;
Config()->writeFonts();
GuiUpdateAllViews();
}

View File

@ -52,7 +52,6 @@ private slots:
void on_listColorNames_itemSelectionChanged();
void defaultValueSlot();
void currentSettingSlot();
void on_buttonCancel_clicked();
void on_fontAbstractTables_currentFontChanged(const QFont &f);
void on_fontAbstractTablesStyle_currentIndexChanged(int index);
void on_fontAbstractTablesSize_currentIndexChanged(const QString &arg1);
@ -73,6 +72,7 @@ private slots:
void on_fontHexEditSize_currentIndexChanged(const QString &arg1);
void on_buttonApplicationFont_clicked();
void on_buttonFontDefaults_clicked();
void rejectedSlot();
private:
Ui::AppearanceDialog *ui;

View File

@ -260,6 +260,17 @@ void MainWindow::refreshShortcuts()
ui->actionCommand->setShortcut(ConfigShortcut("DebugCommand"));
ui->actionScylla->setShortcut(ConfigShortcut("PluginsScylla"));
ui->actionSettings->setShortcut(ConfigShortcut("OptionsPreferences"));
ui->actionAppearance->setShortcut(ConfigShortcut("OptionsAppearance"));
ui->actionShortcuts->setShortcut(ConfigShortcut("OptionsShortcuts"));
ui->actionAbout->setShortcut(ConfigShortcut("HelpAbout"));
ui->actionDonate->setShortcut(ConfigShortcut("HelpDonate"));
ui->actionCheckUpdates->setShortcut(ConfigShortcut("HelpCheckForUpdates"));
ui->actionStrings->setShortcut(ConfigShortcut("ActionFindStrings"));
ui->actionCalls->setShortcut(ConfigShortcut("ActionFindIntermodularCalls"));
}
//Reads recent files list from settings

View File

@ -1,12 +1,7 @@
#include "ShortcutsDialog.h"
#include "ui_ShortcutsDialog.h"
ShortcutsDialog::ShortcutsDialog(QWidget *parent) :
QDialog(parent),
ui(new Ui::ShortcutsDialog)
ShortcutsDialog::ShortcutsDialog(QWidget *parent) : QDialog(parent), ui(new Ui::ShortcutsDialog)
{
ui->setupUi(this);
//set window flags
@ -39,11 +34,11 @@ ShortcutsDialog::ShortcutsDialog(QWidget *parent) :
tbl->setItem(j, 1, shortcutKey);
}
connect(ui->tblShortcuts, SIGNAL(clicked(QModelIndex)), this, SLOT(syncTextfield()));
connect(ui->tblShortcuts, SIGNAL(itemSelectionChanged()), this, SLOT(syncTextfield()));
connect(ui->shortcutEdit, SIGNAL(askForSave()), this, SLOT(updateShortcut()));
connect(this, SIGNAL(rejected()), this, SLOT(rejectedSlot()));
}
void ShortcutsDialog::updateShortcut()
{
const QKeySequence newKey = ui->shortcutEdit->getKeysequence();
@ -97,7 +92,7 @@ void ShortcutsDialog::syncTextfield()
}
ui->shortcutEdit->setErrorState(false);
ui->shortcutEdit->setText(currentShortcut.Hotkey.toString(QKeySequence::NativeText));
ui->shortcutEdit->setFocus();
}
ShortcutsDialog::~ShortcutsDialog()
@ -105,11 +100,17 @@ ShortcutsDialog::~ShortcutsDialog()
delete ui;
}
void ShortcutsDialog::on_buttonBox_clicked(QAbstractButton *button)
void ShortcutsDialog::on_btnSave_clicked()
{
Config()->save();
QMessageBox msg(QMessageBox::Information, "Information", "Shortcuts updated!\n\nYou may need to restart the debugger for all changes to take in effect.");
msg.setWindowIcon(QIcon(":/icons/images/information.png"));
msg.setParent(this, Qt::Dialog);
msg.setWindowFlags(msg.windowFlags()&(~Qt::WindowContextHelpButtonHint));
msg.exec();
}
void ShortcutsDialog::rejectedSlot()
{
Config()->readShortcuts();
}

View File

@ -29,10 +29,12 @@ protected slots:
void updateShortcut();
private slots:
void on_buttonBox_clicked(QAbstractButton *button);
void on_btnSave_clicked();
void rejectedSlot();
private:
Ui::ShortcutsDialog *ui;
QMap<QString, Configuration::Shortcut> ShortcutsBackup;
};
#endif // SHORTCUTSDIALOG_H

View File

@ -7,7 +7,7 @@
<x>0</x>
<y>0</y>
<width>622</width>
<height>409</height>
<height>401</height>
</rect>
</property>
<property name="windowTitle">
@ -17,22 +17,6 @@
<iconset resource="../../resource.qrc">
<normaloff>:/icons/images/shortcut.png</normaloff>:/icons/images/shortcut.png</iconset>
</property>
<widget class="QDialogButtonBox" name="buttonBox">
<property name="geometry">
<rect>
<x>270</x>
<y>370</y>
<width>341</width>
<height>32</height>
</rect>
</property>
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="standardButtons">
<set>QDialogButtonBox::Close</set>
</property>
</widget>
<widget class="QTableWidget" name="tblShortcuts">
<property name="geometry">
<rect>
@ -66,6 +50,32 @@
</property>
</widget>
</widget>
<widget class="QPushButton" name="btnSave">
<property name="geometry">
<rect>
<x>460</x>
<y>370</y>
<width>75</width>
<height>23</height>
</rect>
</property>
<property name="text">
<string>&amp;Save</string>
</property>
</widget>
<widget class="QPushButton" name="btnCancel">
<property name="geometry">
<rect>
<x>540</x>
<y>370</y>
<width>75</width>
<height>23</height>
</rect>
</property>
<property name="text">
<string>&amp;Cancel</string>
</property>
</widget>
</widget>
<customwidgets>
<customwidget>
@ -79,34 +89,34 @@
</resources>
<connections>
<connection>
<sender>buttonBox</sender>
<signal>accepted()</signal>
<receiver>ShortcutsDialog</receiver>
<slot>accept()</slot>
<hints>
<hint type="sourcelabel">
<x>248</x>
<y>254</y>
</hint>
<hint type="destinationlabel">
<x>157</x>
<y>274</y>
</hint>
</hints>
</connection>
<connection>
<sender>buttonBox</sender>
<signal>rejected()</signal>
<sender>btnCancel</sender>
<signal>clicked()</signal>
<receiver>ShortcutsDialog</receiver>
<slot>reject()</slot>
<hints>
<hint type="sourcelabel">
<x>316</x>
<y>260</y>
<x>572</x>
<y>379</y>
</hint>
<hint type="destinationlabel">
<x>286</x>
<y>274</y>
<x>558</x>
<y>368</y>
</hint>
</hints>
</connection>
<connection>
<sender>btnSave</sender>
<signal>clicked()</signal>
<receiver>ShortcutsDialog</receiver>
<slot>accept()</slot>
<hints>
<hint type="sourcelabel">
<x>498</x>
<y>380</y>
</hint>
<hint type="destinationlabel">
<x>443</x>
<y>378</y>
</hint>
</hints>
</connection>

View File

@ -200,6 +200,17 @@ Configuration::Configuration() : QObject()
defaultShortcuts.insert("PluginsScylla", Shortcut(tr("Plugins -> Scylla"), "Ctrl+I"));
defaultShortcuts.insert("OptionsPreferences", Shortcut(tr("Options -> Preferences")));
defaultShortcuts.insert("OptionsAppearance", Shortcut(tr("Options -> Preferences")));
defaultShortcuts.insert("OptionsShortcuts", Shortcut(tr("Options -> Preferences")));
defaultShortcuts.insert("HelpAbout", Shortcut(tr("Help -> About")));
defaultShortcuts.insert("HelpDonate", Shortcut(tr("Help -> Donate")));
defaultShortcuts.insert("HelpCheckForUpdates", Shortcut(tr("Help -> Check for Updates")));
defaultShortcuts.insert("ActionFindStrings", Shortcut(tr("Actions -> Find Strings")));
defaultShortcuts.insert("ActionFindIntermodularCalls", Shortcut(tr("Actions -> Find Intermodular Calls")));
Shortcuts = defaultShortcuts;
load();
@ -349,13 +360,16 @@ void Configuration::readShortcuts()
{
const QString id = it.key();
QString key = shortcutFromConfig(id);
if(key != "")
if(key != "NOT_SET")
{
QKeySequence KeySequence(shortcutFromConfig(id));
Shortcuts[it.key()].Hotkey = KeySequence;
if(key != "")
{
QKeySequence KeySequence(key);
Shortcuts[it.key()].Hotkey = KeySequence;
}
else
Shortcuts[it.key()].Hotkey = QKeySequence();
}
else
Shortcuts[it.key()].Hotkey = QKeySequence();
it++;
}
emit shortcutsUpdated();
@ -642,7 +656,7 @@ QString Configuration::shortcutFromConfig(const QString id)
{
return QString(setting);
}
return "";
return "NOT_SET";
}
bool Configuration::shortcutToConfig(const QString id, const QKeySequence shortcut)