From 09f28a9b66c80a08744ba83123e4caecbf8f45e0 Mon Sep 17 00:00:00 2001
From: Paolo Capriotti
Date: Fri, 17 Aug 2007 12:08:33 +0200
Subject: [PATCH] When settings change, all tabs are notified. Fixes ticket
#32.
---
src/controllers/abstract.h | 2 ++
src/controllers/editgame.cpp | 4 ++++
src/controllers/editgame.h | 2 ++
src/graphicalsystem.cpp | 2 +-
src/graphicalsystem.h | 2 +-
src/mainwindow.cpp | 6 ++++++
src/mainwindow.h | 1 +
src/ui.cpp | 9 +++++++++
src/ui.h | 1 +
9 files changed, 27 insertions(+), 2 deletions(-)
diff --git a/src/controllers/abstract.h b/src/controllers/abstract.h
index 5a102e9..06986da 100644
--- a/src/controllers/abstract.h
+++ b/src/controllers/abstract.h
@@ -169,6 +169,8 @@ public:
* Remove an entity from the controller list.
*/
virtual void removeEntity(const EntityToken&) { }
+
+ virtual void reloadSettings() = 0;
};
diff --git a/src/controllers/editgame.cpp b/src/controllers/editgame.cpp
index 2bc8255..19cb853 100644
--- a/src/controllers/editgame.cpp
+++ b/src/controllers/editgame.cpp
@@ -314,3 +314,7 @@ shared_ptr EditGameController::end() {
return Controller::end();
}
+
+void EditGameController::reloadSettings() {
+ m_graphical->settingsChanged();
+}
diff --git a/src/controllers/editgame.h b/src/controllers/editgame.h
index f709339..a6d7ab4 100644
--- a/src/controllers/editgame.h
+++ b/src/controllers/editgame.h
@@ -71,6 +71,8 @@ public:
virtual boost::shared_ptr end();
virtual void detach();
+
+ virtual void reloadSettings();
};
diff --git a/src/graphicalsystem.cpp b/src/graphicalsystem.cpp
index 7dcfc3c..5b8fcd0 100644
--- a/src/graphicalsystem.cpp
+++ b/src/graphicalsystem.cpp
@@ -46,7 +46,7 @@ GraphicalSystem::GraphicalSystem(ChessTable* view,
m_animator = m_variant->createAnimator(this);
- settings().onChange(this, "settingsChanged", "Loader::Theme");
+// settings().onChange(this, "settingsChanged", "Loader::Theme");
settingsChanged();
if (startingPosition)
diff --git a/src/graphicalsystem.h b/src/graphicalsystem.h
index 5355eda..ba85529 100644
--- a/src/graphicalsystem.h
+++ b/src/graphicalsystem.h
@@ -50,7 +50,7 @@ public:
// Point p3 = Point::invalid(), Point p4 = Point::invalid(),
// Point p5 = Point::invalid(), Point p6 = Point::invalid() );
-private Q_SLOTS:
+public Q_SLOTS:
/** internal function to listen at setting changes */
void settingsChanged();
diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp
index 9375c09..ce8a325 100644
--- a/src/mainwindow.cpp
+++ b/src/mainwindow.cpp
@@ -90,6 +90,8 @@ MainWindow::MainWindow(const QString& variant)
addDockWidget(Qt::BottomDockWidgetArea, console_dock, Qt::Horizontal);
console_dock->setWindowFlags(console_dock->windowFlags() & ~Qt::WindowStaysOnTopHint);
console_dock->show();
+
+ settings().onChange(this, "settingsChanged");
connect(board, SIGNAL(error(ErrorCode)), this, SLOT(displayErrorMessage(ErrorCode)));
//BROKEN connect(board->clock(), SIGNAL(labelClicked(int)), &ui(), SLOT(setTurn(int)));
@@ -656,5 +658,9 @@ void MainWindow::preferences() {
dialog.apply();
}
+void MainWindow::settingsChanged() {
+ ui().reloadSettings();
+}
+
diff --git a/src/mainwindow.h b/src/mainwindow.h
index d93a81d..4d18dd8 100644
--- a/src/mainwindow.h
+++ b/src/mainwindow.h
@@ -128,6 +128,7 @@ public Q_SLOTS:
// void prefHighlight();
void preferences();
+ void settingsChanged();
};
diff --git a/src/ui.cpp b/src/ui.cpp
index 3d4f381..f4d61bb 100644
--- a/src/ui.cpp
+++ b/src/ui.cpp
@@ -169,3 +169,12 @@ QString UI::currentVariant() const {
return controller()->variant();
}
+void UI::reloadSettings() {
+ for (ControllerMap::iterator it = m_controller.begin(),
+ end = m_controller.end();
+ it != end;
+ ++it) {
+ it->second->reloadSettings();
+ }
+}
+
diff --git a/src/ui.h b/src/ui.h
index 8542c61..f1d2c4a 100644
--- a/src/ui.h
+++ b/src/ui.h
@@ -69,6 +69,7 @@ public Q_SLOTS:
void detach();
QString currentVariant() const;
+ void reloadSettings();
};
#endif
--
2.11.4.GIT