From 786930292ad80f295557420b98f2d3de2d30e303 Mon Sep 17 00:00:00 2001 From: Brett Weir Date: Tue, 26 Jul 2016 15:46:53 -0700 Subject: [PATCH] Remove ugly dependency of editorview on preferences dialog --- src/propelleride/filemanager.cpp | 13 +++++++++---- src/propelleride/filemanager.h | 3 +++ src/propelleride/mainwindow.cpp | 12 ++++++++---- src/propelleride/mainwindow.h | 4 ++-- src/propelleride/views/editorview.cpp | 5 ----- src/propelleride/views/editorview.h | 4 +--- 6 files changed, 23 insertions(+), 18 deletions(-) diff --git a/src/propelleride/filemanager.cpp b/src/propelleride/filemanager.cpp index 0246703..0c0943e 100644 --- a/src/propelleride/filemanager.cpp +++ b/src/propelleride/filemanager.cpp @@ -1,5 +1,6 @@ #include "filemanager.h" +#include #include #include #include @@ -74,10 +75,14 @@ int FileManager::newFile() setTabToolTip(index,""); - connect(editor,SIGNAL(textChanged()),this,SLOT(fileChanged())); - connect(editor,SIGNAL(undoAvailable(bool)),this,SLOT(setUndo(bool))); - connect(editor,SIGNAL(redoAvailable(bool)),this,SLOT(setRedo(bool))); - connect(editor,SIGNAL(copyAvailable(bool)),this,SLOT(setCopy(bool))); + connect(editor, SIGNAL(textChanged()), this, SLOT(fileChanged())); + connect(editor, SIGNAL(undoAvailable(bool)), this, SLOT(setUndo(bool))); + connect(editor, SIGNAL(redoAvailable(bool)), this, SLOT(setRedo(bool))); + connect(editor, SIGNAL(copyAvailable(bool)), this, SLOT(setCopy(bool))); + + connect(this, SIGNAL(accepted()), editor, SLOT(loadPreferences())); + connect(this, SIGNAL(updateColors()), editor, SLOT(updateColors())); + connect(this, SIGNAL(updateFonts(const QFont &)), editor, SLOT(updateFonts())); emit closeAvailable(true); setCurrentIndex(index); diff --git a/src/propelleride/filemanager.h b/src/propelleride/filemanager.h index 94b7557..a20cff6 100644 --- a/src/propelleride/filemanager.h +++ b/src/propelleride/filemanager.h @@ -75,4 +75,7 @@ public slots: void closeAvailable(bool available); void sendMessage(const QString & message); + void accepted(); + void updateColors(); + void updateFonts(const QFont &); }; diff --git a/src/propelleride/mainwindow.cpp b/src/propelleride/mainwindow.cpp index b3c2163..53bcdb2 100644 --- a/src/propelleride/mainwindow.cpp +++ b/src/propelleride/mainwindow.cpp @@ -39,15 +39,19 @@ MainWindow::MainWindow(QWidget *parent) connect(&builder, SIGNAL(buildError()), &preferences, SLOT(showPreferences())); parser = language.parser(); - connect(&preferences,SIGNAL(updateColors()),this,SLOT(recolorProjectView())); - connect(&preferences,SIGNAL(updateFonts(const QFont &)),this,SLOT(recolorProjectView())); - connect(&preferences,SIGNAL(updateFonts(const QFont &)),this,SLOT(recolorBuildManager())); + connect(&preferences, SIGNAL(updateColors()), this, SLOT(recolorProjectView())); + connect(&preferences, SIGNAL(updateFonts(const QFont &)), this, SLOT(recolorProjectView())); + + connect(&preferences, SIGNAL(updateFonts(const QFont &)), this, SLOT(recolorBuildManager())); + + connect(&preferences, SIGNAL(accepted()), ui.editorTabs, SIGNAL(accepted())); + connect(&preferences, SIGNAL(updateColors()), ui.editorTabs, SIGNAL(updateColors())); + connect(&preferences, SIGNAL(updateFonts(const QFont &)), ui.editorTabs, SIGNAL(updateFonts(const QFont &))); recolorProjectView(); recolorBuildManager(); - // project editor tabs ui.finder->connectFileManager(ui.editorTabs); QSplitterHandle *hndl = ui.splitter->handle(1); diff --git a/src/propelleride/mainwindow.h b/src/propelleride/mainwindow.h index 2a5191d..75fbe8a 100644 --- a/src/propelleride/mainwindow.h +++ b/src/propelleride/mainwindow.h @@ -31,6 +31,8 @@ class MainWindow : public QMainWindow PropellerManager manager; Zipper zipper; + Preferences preferences; + BuildManager builder; Language language; @@ -55,8 +57,6 @@ class MainWindow : public QMainWindow public: MainWindow(QWidget * parent = 0); - Preferences preferences; - public slots: void showMessage(const QString & message); diff --git a/src/propelleride/views/editorview.cpp b/src/propelleride/views/editorview.cpp index 46166ef..d5a9743 100644 --- a/src/propelleride/views/editorview.cpp +++ b/src/propelleride/views/editorview.cpp @@ -36,7 +36,6 @@ EditorView::EditorView(QWidget *parent) : QPlainTextEdit(parent) { highlighter = 0; setExtension("spin"); - propDialog = &((MainWindow *) parent)->preferences; canUndo = false; canRedo = false; @@ -60,10 +59,6 @@ EditorView::EditorView(QWidget *parent) : QPlainTextEdit(parent) updateFonts(); saveContent(); - connect(propDialog, SIGNAL(accepted()), this, SLOT(loadPreferences())); - connect(propDialog, SIGNAL(updateColors()), this, SLOT(updateColors())); - connect(propDialog, SIGNAL(updateFonts(const QFont &)), this, SLOT(updateFonts())); - connect(this, SIGNAL(undoAvailable(bool)), this, SLOT(setUndo(bool))); connect(this, SIGNAL(redoAvailable(bool)), this, SLOT(setRedo(bool))); connect(this, SIGNAL(copyAvailable(bool)), this, SLOT(setCopy(bool))); diff --git a/src/propelleride/views/editorview.h b/src/propelleride/views/editorview.h index 98aa4a1..e08fb26 100644 --- a/src/propelleride/views/editorview.h +++ b/src/propelleride/views/editorview.h @@ -1,5 +1,6 @@ #pragma once +#include #include #include #include @@ -9,8 +10,6 @@ #include "highlighter.h" #include "language.h" -#include "preferences.h" - class EditorView : public QPlainTextEdit { @@ -22,7 +21,6 @@ class EditorView : public QPlainTextEdit Highlighter * highlighter; QComboBox * cbAuto; - Preferences * propDialog; QStringList blocks; QRegularExpression re_blocks;