diff options
Diffstat (limited to 'Swift/QtUI')
-rw-r--r-- | Swift/QtUI/QtUIFactory.cpp | 29 | ||||
-rw-r--r-- | Swift/QtUI/QtUIFactory.h | 21 |
2 files changed, 28 insertions, 22 deletions
diff --git a/Swift/QtUI/QtUIFactory.cpp b/Swift/QtUI/QtUIFactory.cpp index a9e0e8f..9eed822 100644 --- a/Swift/QtUI/QtUIFactory.cpp +++ b/Swift/QtUI/QtUIFactory.cpp @@ -6,6 +6,8 @@ #include <Swift/QtUI/QtUIFactory.h> +#include <algorithm> + #include <QSplitter> #include <Swiften/Whiteboard/WhiteboardSession.h> @@ -120,19 +122,15 @@ MUCSearchWindow* QtUIFactory::createMUCSearchWindow() { ChatWindow* QtUIFactory::createChatWindow(const JID& contact, UIEventStream* eventStream) { QtChatWindow* window = dynamic_cast<QtChatWindow*>(chatWindowFactory->createChatWindow(contact, eventStream)); + + // remove already closed and thereby deleted chat windows + chatWindows.erase(std::remove_if(chatWindows.begin(), chatWindows.end(), + [](QPointer<QtChatWindow>& window) { + return window.isNull(); + }), chatWindows.end()); + chatWindows.push_back(window); - std::vector<QPointer<QtChatWindow> > deletions; - foreach (QPointer<QtChatWindow> existingWindow, chatWindows) { - if (existingWindow.isNull()) { - deletions.push_back(existingWindow); - } else { - connect(window, SIGNAL(fontResized(int)), existingWindow, SLOT(handleFontResized(int))); - connect(existingWindow, SIGNAL(fontResized(int)), window, SLOT(handleFontResized(int))); - } - } - foreach (QPointer<QtChatWindow> deletedWindow, deletions) { - chatWindows.erase(std::remove(chatWindows.begin(), chatWindows.end(), deletedWindow), chatWindows.end()); - } + connect(window, SIGNAL(fontResized(int)), this, SLOT(handleChatWindowFontResized(int))); window->handleFontResized(chatFontSize); return window; @@ -141,6 +139,13 @@ ChatWindow* QtUIFactory::createChatWindow(const JID& contact, UIEventStream* eve void QtUIFactory::handleChatWindowFontResized(int size) { chatFontSize = size; settings->storeSetting(QtUISettingConstants::CHATWINDOW_FONT_SIZE, size); + + // resize font in other chat windows + for (auto&& existingWindow : chatWindows) { + if (!existingWindow.isNull()) { + existingWindow->handleFontResized(size); + } + } } UserSearchWindow* QtUIFactory::createUserSearchWindow(UserSearchWindow::Type type, UIEventStream* eventStream, const std::set<std::string>& groups) { diff --git a/Swift/QtUI/QtUIFactory.h b/Swift/QtUI/QtUIFactory.h index a57d509..ce3b533 100644 --- a/Swift/QtUI/QtUIFactory.h +++ b/Swift/QtUI/QtUIFactory.h @@ -6,6 +6,8 @@ #pragma once +#include <vector> + #include <QObject> #include <QPointer> @@ -14,21 +16,20 @@ class QSplitter; namespace Swift { - class QtSettingsProvider; - class SettingsProviderHierachy; - class QtChatTabsBase; class QtChatTabs; - class QtSystemTray; - class QtLoginWindow; - class QtMainWindow; + class QtChatTabsBase; class QtChatTheme; - class QtChatWindowFactory; class QtChatWindow; + class QtChatWindowFactory; + class QtLoginWindow; + class QtMainWindow; + class QtSettingsProvider; + class QtSingleWindow; + class QtSystemTray; + class SettingsProviderHierachy; + class StatusCache; class TimerFactory; - class historyWindow_; class WhiteboardSession; - class StatusCache; - class QtSingleWindow; class QtUIFactory : public QObject, public UIFactory { Q_OBJECT |