diff --git a/src/DialogDrawingStyles.h b/src/DialogDrawingStyles.h index a1aa1c96..ba8fbdf8 100644 --- a/src/DialogDrawingStyles.h +++ b/src/DialogDrawingStyles.h @@ -6,6 +6,8 @@ #include "Verbosity.h" #include "ui_DialogDrawingStyles.h" +#include + #include class DialogSyntaxPatterns; @@ -52,7 +54,7 @@ class DialogDrawingStyles final : public Dialog { HighlightStyleModel *model_; std::vector &highlightStyles_; QModelIndex deleted_; - DialogSyntaxPatterns *dialogSyntaxPatterns_; + QPointer dialogSyntaxPatterns_; }; #endif diff --git a/src/DialogSyntaxPatterns.cpp b/src/DialogSyntaxPatterns.cpp index 90fbf39a..66d3bd90 100644 --- a/src/DialogSyntaxPatterns.cpp +++ b/src/DialogSyntaxPatterns.cpp @@ -24,8 +24,8 @@ * @param parent * @param f */ -DialogSyntaxPatterns::DialogSyntaxPatterns(MainWindow *window, Qt::WindowFlags f) - : Dialog(window, f), window_(window) { +DialogSyntaxPatterns::DialogSyntaxPatterns(QWidget *parent, Qt::WindowFlags f) + : Dialog(parent, f) { ui.setupUi(this); connectSlots(); @@ -277,9 +277,13 @@ void DialogSyntaxPatterns::buttonLanguageMode_clicked() { void DialogSyntaxPatterns::buttonHighlightStyle_clicked() { QString style = ui.comboHighlightStyle->currentText(); if (!style.isEmpty()) { - auto DrawingStyles = std::make_unique(this, Highlight::HighlightStyles, this); - DrawingStyles->setStyleByName(style); - DrawingStyles->exec(); + + if (!dialogDrawingStyles_) { + dialogDrawingStyles_ = new DialogDrawingStyles(this, Highlight::HighlightStyles, this); + } + + dialogDrawingStyles_->setStyleByName(style); + dialogDrawingStyles_->show(); } } diff --git a/src/DialogSyntaxPatterns.h b/src/DialogSyntaxPatterns.h index cf40e1ba..f67f143a 100644 --- a/src/DialogSyntaxPatterns.h +++ b/src/DialogSyntaxPatterns.h @@ -6,19 +6,21 @@ #include "Verbosity.h" #include "ui_DialogSyntaxPatterns.h" +#include + #include #include class HighlightPattern; class HighlightPatternModel; -class MainWindow; class PatternSet; +class DialogDrawingStyles; class DialogSyntaxPatterns final : public Dialog { Q_OBJECT public: - explicit DialogSyntaxPatterns(MainWindow *window, Qt::WindowFlags f = Qt::WindowFlags()); + explicit DialogSyntaxPatterns(QWidget *parent = nullptr, Qt::WindowFlags f = Qt::WindowFlags()); ~DialogSyntaxPatterns() override = default; public: @@ -71,7 +73,7 @@ private Q_SLOTS: HighlightPatternModel *model_; QModelIndex deleted_; QString previousLanguage_; - MainWindow *window_; + QPointer dialogDrawingStyles_; }; #endif diff --git a/src/MainWindow.cpp b/src/MainWindow.cpp index 4d304541..3a05e90e 100644 --- a/src/MainWindow.cpp +++ b/src/MainWindow.cpp @@ -6120,9 +6120,15 @@ MainWindow *MainWindow::fromDocument(const DocumentWidget *document) { */ void MainWindow::editHighlightStyles(const QString &initialStyle) { - auto DrawingStyles = std::make_unique(nullptr, Highlight::HighlightStyles, this); - DrawingStyles->setStyleByName(initialStyle); - DrawingStyles->exec(); + if (!dialogDrawingStyles_) { + dialogDrawingStyles_ = new DialogDrawingStyles(nullptr, Highlight::HighlightStyles, this); + } + + dialogDrawingStyles_->setStyleByName(initialStyle); + + // TODO(eteran): do we want to take any measures to prevent + // more than one of these being shown? + dialogDrawingStyles_->show(); } /* diff --git a/src/MainWindow.h b/src/MainWindow.h index 603e0dec..c6338c83 100644 --- a/src/MainWindow.h +++ b/src/MainWindow.h @@ -32,6 +32,7 @@ class DialogReplace; class DialogShellMenu; class DialogWindowBackgroundMenu; class DialogSyntaxPatterns; +class DialogDrawingStyles; class DocumentWidget; class TextArea; struct MenuData; @@ -444,6 +445,7 @@ public Q_SLOTS: QPointer dialogColors_; QPointer dialogWindowBackgroundMenu_; QPointer dialogSyntaxPatterns_; + QPointer dialogDrawingStyles_; QPointer