Skip to content

Commit

Permalink
Remove ugly dependency of editorview on preferences dialog
Browse files Browse the repository at this point in the history
  • Loading branch information
bweir committed Jul 26, 2016
1 parent 1130ba6 commit 7869302
Show file tree
Hide file tree
Showing 6 changed files with 23 additions and 18 deletions.
13 changes: 9 additions & 4 deletions src/propelleride/filemanager.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#include "filemanager.h"

#include <QDebug>
#include <QFileDialog>
#include <QRegularExpression>
#include <QStandardPaths>
Expand Down Expand Up @@ -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);
Expand Down
3 changes: 3 additions & 0 deletions src/propelleride/filemanager.h
Original file line number Diff line number Diff line change
Expand Up @@ -75,4 +75,7 @@ public slots:
void closeAvailable(bool available);
void sendMessage(const QString & message);

void accepted();
void updateColors();
void updateFonts(const QFont &);
};
12 changes: 8 additions & 4 deletions src/propelleride/mainwindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
4 changes: 2 additions & 2 deletions src/propelleride/mainwindow.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ class MainWindow : public QMainWindow
PropellerManager manager;
Zipper zipper;

Preferences preferences;

BuildManager builder;
Language language;

Expand All @@ -55,8 +57,6 @@ class MainWindow : public QMainWindow
public:
MainWindow(QWidget * parent = 0);

Preferences preferences;

public slots:
void showMessage(const QString & message);

Expand Down
5 changes: 0 additions & 5 deletions src/propelleride/views/editorview.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ EditorView::EditorView(QWidget *parent) : QPlainTextEdit(parent)
{
highlighter = 0;
setExtension("spin");
propDialog = &((MainWindow *) parent)->preferences;

canUndo = false;
canRedo = false;
Expand All @@ -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)));
Expand Down
4 changes: 1 addition & 3 deletions src/propelleride/views/editorview.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#pragma once

#include <QComboBox>
#include <QCompleter>
#include <QPlainTextEdit>
#include <QString>
Expand All @@ -9,8 +10,6 @@

#include "highlighter.h"
#include "language.h"
#include "preferences.h"


class EditorView : public QPlainTextEdit
{
Expand All @@ -22,7 +21,6 @@ class EditorView : public QPlainTextEdit

Highlighter * highlighter;
QComboBox * cbAuto;
Preferences * propDialog;

QStringList blocks;
QRegularExpression re_blocks;
Expand Down

0 comments on commit 7869302

Please sign in to comment.