From 78bf57fce45a044d6e0bc9a92145e9a457e3e751 Mon Sep 17 00:00:00 2001 From: Ernie Pasveer Date: Tue, 4 Jan 2022 19:41:01 -0600 Subject: [PATCH] Checkpoint. Still working on saving highlight colors. --- src/SeerConfigDialog.cpp | 65 ++++++++++++++++++++++++++++++------- src/SeerConfigDialog.h | 3 +- src/SeerConfigDialog.ui | 7 ++-- src/SeerEditorConfigPage.ui | 6 ++++ src/SeerGdbConfigPage.ui | 6 ++++ src/SeerMainWindow.cpp | 18 ++++++++++ src/SeerSeerConfigPage.ui | 6 ++++ src/SeerSourceConfigPage.ui | 6 ++++ 8 files changed, 102 insertions(+), 15 deletions(-) diff --git a/src/SeerConfigDialog.cpp b/src/SeerConfigDialog.cpp index 963c764..a6e5926 100644 --- a/src/SeerConfigDialog.cpp +++ b/src/SeerConfigDialog.cpp @@ -2,6 +2,7 @@ #include #include #include +#include #include SeerConfigDialog::SeerConfigDialog(QWidget* parent) : QDialog(parent) { @@ -54,7 +55,8 @@ SeerConfigDialog::SeerConfigDialog(QWidget* parent) : QDialog(parent) { configSeerButton->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled); // Connect things. - connect(contentsListWidget, &QListWidget::currentItemChanged, this, &SeerConfigDialog::changePage); + connect(contentsListWidget, &QListWidget::currentItemChanged, this, &SeerConfigDialog::handleChangePage); + connect(buttonBox, &QDialogButtonBox::clicked, this, &SeerConfigDialog::handleButtonClicked); // Set to first page. contentsListWidget->setCurrentRow(0); @@ -63,17 +65,6 @@ SeerConfigDialog::SeerConfigDialog(QWidget* parent) : QDialog(parent) { SeerConfigDialog::~SeerConfigDialog() { } -void SeerConfigDialog::changePage(QListWidgetItem* current, QListWidgetItem* previous) { - - //qDebug() << __PRETTY_FUNCTION__ << ":" << current << previous; - - if (!current) { - current = previous; - } - - pagesStackedWidget->setCurrentIndex(contentsListWidget->row(current)); -} - void SeerConfigDialog::setGdbProgram (const QString& program) { _gdbConfigPage->setGdbProgram(program); @@ -124,3 +115,53 @@ const SeerHighlighterSettings& SeerConfigDialog::editorHighlighterSettings () co return _editorConfigPage->highlighterSettings(); } +void SeerConfigDialog::handleChangePage(QListWidgetItem* current, QListWidgetItem* previous) { + + //qDebug() << __PRETTY_FUNCTION__ << ":" << current << previous; + + if (!current) { + current = previous; + } + + pagesStackedWidget->setCurrentIndex(contentsListWidget->row(current)); +} + +void SeerConfigDialog::handleButtonClicked (QAbstractButton* button) { + + // Handle resetting the config pages if "Reset" is clicked. + if (buttonBox->buttonRole(button) == QDialogButtonBox::ResetRole) { + + QString itemLabel = contentsListWidget->currentItem()->text(); + + if (itemLabel == "GDB") { + + int result = QMessageBox::warning(this, "Seer", + QString("Reset settings for '") + itemLabel + "'?", + QMessageBox::Ok|QMessageBox::Cancel, QMessageBox::Cancel); + + if (result == QMessageBox::Ok) { + setGdbProgram("/usr/bin/gdb"); + setGdbArguments("--interpreter=mi"); + setGdbAsyncMode(true); + } + + }else if (itemLabel == "Editor") { + + int result = QMessageBox::warning(this, "Seer", + QString("Reset settings for '") + itemLabel + "'?", + QMessageBox::Ok|QMessageBox::Cancel, QMessageBox::Cancel); + + if (result == QMessageBox::Ok) { + setEditorFont(QFont("Source Code Pro")); + setEditorHighlighterSettings(SeerHighlighterSettings::populateForCPP()); + } + + }else if (itemLabel == "Source") { + + }else if (itemLabel == "Seer") { + + }else{ + } + } +} + diff --git a/src/SeerConfigDialog.h b/src/SeerConfigDialog.h index 1e4d385..a7e9411 100644 --- a/src/SeerConfigDialog.h +++ b/src/SeerConfigDialog.h @@ -39,7 +39,8 @@ class SeerConfigDialog : public QDialog, protected Ui::SeerConfigDialogForm { const SeerHighlighterSettings& editorHighlighterSettings () const; public slots: - void changePage (QListWidgetItem* current, QListWidgetItem* previous); + void handleChangePage (QListWidgetItem* current, QListWidgetItem* previous); + void handleButtonClicked (QAbstractButton* button); private: SeerGdbConfigPage* _gdbConfigPage; diff --git a/src/SeerConfigDialog.ui b/src/SeerConfigDialog.ui index d93f16c..11d4784 100644 --- a/src/SeerConfigDialog.ui +++ b/src/SeerConfigDialog.ui @@ -32,18 +32,21 @@ 0 + + 1 + -1 - + Qt::Horizontal - QDialogButtonBox::Cancel|QDialogButtonBox::Ok + QDialogButtonBox::Cancel|QDialogButtonBox::Ok|QDialogButtonBox::Reset diff --git a/src/SeerEditorConfigPage.ui b/src/SeerEditorConfigPage.ui index d0c4fd6..e5b7c99 100644 --- a/src/SeerEditorConfigPage.ui +++ b/src/SeerEditorConfigPage.ui @@ -14,6 +14,12 @@ SeerEditorConfigPage + + 0 + + + 0 + diff --git a/src/SeerGdbConfigPage.ui b/src/SeerGdbConfigPage.ui index 0fd91ff..fd338cf 100644 --- a/src/SeerGdbConfigPage.ui +++ b/src/SeerGdbConfigPage.ui @@ -14,6 +14,12 @@ SeerGdbConfigPage + + 0 + + + 0 + diff --git a/src/SeerMainWindow.cpp b/src/SeerMainWindow.cpp index 795a522..8e8952e 100644 --- a/src/SeerMainWindow.cpp +++ b/src/SeerMainWindow.cpp @@ -286,6 +286,7 @@ void SeerMainWindow::handleSettingsConfiguration () { dlg.setGdbArguments(gdbWidget->gdbArguments()); dlg.setGdbAsyncMode(gdbWidget->gdbAsyncMode()); dlg.setEditorFont(gdbWidget->editorManager()->editorFont()); + dlg.setEditorHighlighterSettings(gdbWidget->editorManager()->editorHighlighterSettings()); int ret = dlg.exec(); @@ -590,6 +591,23 @@ void SeerMainWindow::writeConfigSettings () { settings.beginGroup("editor"); settings.setValue("font", gdbWidget->editorManager()->editorFont().toString()); + + settings.beginGroup("highlighter"); { + + SeerHighlighterSettings highlighter = gdbWidget->editorManager()->editorHighlighterSettings(); + QStringList keys = highlighter.keys(); + + for (int i=0; iSeerSeerConfigPage + + 0 + + + 0 + diff --git a/src/SeerSourceConfigPage.ui b/src/SeerSourceConfigPage.ui index 2240a7e..30f3a17 100644 --- a/src/SeerSourceConfigPage.ui +++ b/src/SeerSourceConfigPage.ui @@ -14,6 +14,12 @@ SeerSourceConfigPage + + 0 + + + 0 +