From ccb69544950110bc1d738162ed008444340ee0aa Mon Sep 17 00:00:00 2001 From: Peter Burgess Date: Tue, 15 May 2018 17:55:13 +0100 Subject: Remove remants of non-netbook mode related code This includes removing the class QtChatTabsShortcutOnlySubstitute, passing around QtChatTabs instead of QtChatTabsBase, removing checks and casts relating to the possible use of either QtChatTabs or QtChatTabsShortcutOnlySubstitute, checks to see if the splitter exists as the splitter should now always exist. Test-Information: Program still builds and runs fine. Both login and main windows open and work correctly. Chat tabs open and close without fault. Unit tests still pass. Removing loginWindowGeometry from the config file causes no issues. Change-Id: Iab58ab7fd23571f4aeeb7c8a9a988bdb1500ba5b diff --git a/Swift/QtUI/QtChatTabs.cpp b/Swift/QtUI/QtChatTabs.cpp index bdbbe01..edd0b87 100644 --- a/Swift/QtUI/QtChatTabs.cpp +++ b/Swift/QtUI/QtChatTabs.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2010-2017 Isode Limited. + * Copyright (c) 2010-2018 Isode Limited. * All rights reserved. * See the COPYING file for more information. */ @@ -34,7 +34,7 @@ #include namespace Swift { -QtChatTabs::QtChatTabs(bool singleWindow, SettingsProvider* settingsProvider, bool trellisMode) : QWidget(), singleWindow_(singleWindow), settingsProvider_(settingsProvider), trellisMode_(trellisMode), dynamicGrid_(nullptr), gridSelectionDialog_(nullptr) { +QtChatTabs::QtChatTabs(SettingsProvider* settingsProvider, bool trellisMode) : QWidget(), settingsProvider_(settingsProvider), trellisMode_(trellisMode), dynamicGrid_(nullptr), gridSelectionDialog_(nullptr) { #ifndef Q_OS_MAC setWindowIcon(QIcon(":/logo-chat-16.png")); #else @@ -200,13 +200,8 @@ void QtChatTabs::handleTabClosing() { if (widget && ((index = dynamicGrid_->indexOf(widget)) >= 0)) { dynamicGrid_->removeTab(index); if (dynamicGrid_->count() == 0) { - if (!singleWindow_) { - hide(); - } - else { - setWindowTitle(""); - onTitleChanged(""); - } + setWindowTitle(""); + onTitleChanged(""); } else { handleTabTitleUpdated(dynamicGrid_->currentWidget()); diff --git a/Swift/QtUI/QtChatTabs.h b/Swift/QtUI/QtChatTabs.h index 3e36ebf..6a758ca 100644 --- a/Swift/QtUI/QtChatTabs.h +++ b/Swift/QtUI/QtChatTabs.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2010-2016 Isode Limited. + * Copyright (c) 2010-2018 Isode Limited. * All rights reserved. * See the COPYING file for more information. */ @@ -26,7 +26,7 @@ namespace Swift { class QtChatTabs : public QWidget, public QtChatTabsBase { Q_OBJECT public: - QtChatTabs(bool singleWindow, SettingsProvider* settingsProvider, bool trellisMode); + QtChatTabs(SettingsProvider* settingsProvider, bool trellisMode); virtual ~QtChatTabs(); virtual void addTab(QtTabbable* tab); @@ -66,7 +66,6 @@ namespace Swift { void checkForFirstShow(); private: - bool singleWindow_; SettingsProvider* settingsProvider_; bool trellisMode_; QtDynamicGridLayout* dynamicGrid_; diff --git a/Swift/QtUI/QtChatTabsShortcutOnlySubstitute.cpp b/Swift/QtUI/QtChatTabsShortcutOnlySubstitute.cpp deleted file mode 100644 index 40ab17f..0000000 --- a/Swift/QtUI/QtChatTabsShortcutOnlySubstitute.cpp +++ /dev/null @@ -1,108 +0,0 @@ -/* - * Copyright (c) 2015-2016 Isode Limited. - * All rights reserved. - * See the COPYING file for more information. - */ - -#include - -#include - -#include -#include - -#include - -#include - -namespace Swift { - -QtChatTabsShortcutOnlySubstitute::QtChatTabsShortcutOnlySubstitute() : QWidget() { - -} - -QtChatTabsShortcutOnlySubstitute::~QtChatTabsShortcutOnlySubstitute() { - -} - -void QtChatTabsShortcutOnlySubstitute::addTab(QtTabbable* tab) { - connect(tab, SIGNAL(requestNextTab()), this, SLOT(handleRequestedNextTab()), Qt::UniqueConnection); - connect(tab, SIGNAL(requestActiveTab()), this, SLOT(handleRequestedActiveTab()), Qt::UniqueConnection); - connect(tab, SIGNAL(requestPreviousTab()), this, SLOT(handleRequestedPreviousTab()), Qt::UniqueConnection); - - connect(new QShortcut(QKeySequence(tr("CTRL+W", "Close chat tab.")), tab), SIGNAL(activated()), this, SLOT(handleCloseTabShortcut())); - connect(new QShortcut(QKeySequence(Qt::CTRL + Qt::Key_PageUp), tab), SIGNAL(activated()), tab, SIGNAL(requestPreviousTab())); - connect(new QShortcut(QKeySequence(Qt::CTRL + Qt::Key_PageDown), tab), SIGNAL(activated()), tab, SIGNAL(requestNextTab())); - connect(new QShortcut(QKeySequence(Qt::ALT + Qt::Key_A), tab), SIGNAL(activated()), tab, SIGNAL(requestActiveTab())); -} - -void QtChatTabsShortcutOnlySubstitute::handleCloseTabShortcut() { - QtTabbable* senderTab = dynamic_cast(sender()->parent()); - SWIFT_LOG_ASSERT(senderTab, debug) << "No window to close." << std::endl; - if (senderTab) { - senderTab->close(); - } -} - -void QtChatTabsShortcutOnlySubstitute::handleRequestedNextTab() { - QtTabbable* senderTab = dynamic_cast(sender()); - - QList tabs = tabbableWindows(); - - int currentIndex = tabs.indexOf(senderTab); - assert(currentIndex >= 0); - - QtTabbable* nextTab = tabs.at((currentIndex + 1) % tabs.size()); - nextTab->activateWindow(); -} - -void QtChatTabsShortcutOnlySubstitute::handleRequestedActiveTab() { - QtTabbable* senderTab = dynamic_cast(sender()); - - QtTabbable::AlertType types[] = {QtTabbable::WaitingActivity, QtTabbable::ImpendingActivity}; - - QList tabs = tabbableWindows(); - - for (auto& type : types) { - int startIndex = tabs.indexOf(senderTab); - int currentIndex = startIndex; - - do { - currentIndex = (currentIndex + 1) % tabs.size(); - QtTabbable* currentTab = tabs.at(currentIndex); - if (currentTab->getWidgetAlertState() == type) { - currentTab->activateWindow(); - return; - } - } while (startIndex != currentIndex); - } -} - -void QtChatTabsShortcutOnlySubstitute::handleRequestedPreviousTab() { - QtTabbable* senderTab = dynamic_cast(sender()); - - QList tabs = tabbableWindows(); - - int currentIndex = tabs.indexOf(senderTab); - assert(currentIndex >= 0); - - QtTabbable* previousTab = tabs.at((currentIndex + tabs.size() - 1) % tabs.size()); - previousTab->activateWindow(); -} - -QList QtChatTabsShortcutOnlySubstitute::tabbableWindows() const { - QList windows = qApp->topLevelWidgets(); - - QList tabbables; - for (auto topLevelWidget : windows) { - QtTabbable* tabbable = dynamic_cast(topLevelWidget); - if (tabbable) { - tabbables << tabbable; - } - } - - return tabbables; -} - -} - diff --git a/Swift/QtUI/QtChatTabsShortcutOnlySubstitute.h b/Swift/QtUI/QtChatTabsShortcutOnlySubstitute.h deleted file mode 100644 index b330fe7..0000000 --- a/Swift/QtUI/QtChatTabsShortcutOnlySubstitute.h +++ /dev/null @@ -1,40 +0,0 @@ -/* - * Copyright (c) 2015-2016 Isode Limited. - * All rights reserved. - * See the COPYING file for more information. - */ - -#pragma once - -#include -#include - -#include - -class QShortcut; - -namespace Swift { - -class QtChatTabsShortcutOnlySubstitute : public QWidget, public QtChatTabsBase { - Q_OBJECT - - public: - QtChatTabsShortcutOnlySubstitute(); - virtual ~QtChatTabsShortcutOnlySubstitute(); - - virtual void addTab(QtTabbable* tab); - - private slots: - void handleCloseTabShortcut(); - void handleRequestedNextTab(); - void handleRequestedActiveTab(); - void handleRequestedPreviousTab(); - - private: - QList tabbableWindows() const; - - private: - QList shortcuts_; -}; - -} diff --git a/Swift/QtUI/QtChatWindowFactory.cpp b/Swift/QtUI/QtChatWindowFactory.cpp index 49cfe4d..33c8b94 100644 --- a/Swift/QtUI/QtChatWindowFactory.cpp +++ b/Swift/QtUI/QtChatWindowFactory.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2010-2017 Isode Limited. + * Copyright (c) 2010-2018 Isode Limited. * All rights reserved. * See the COPYING file for more information. */ @@ -11,7 +11,6 @@ #include #include -#include #include #include #include @@ -23,22 +22,17 @@ namespace Swift { static const QString SPLITTER_STATE = "mucSplitterState"; static const QString CHAT_TABS_GEOMETRY = "chatTabsGeometry"; -QtChatWindowFactory::QtChatWindowFactory(QtSingleWindow* splitter, SettingsProvider* settings, QtSettingsProvider* qtSettings, QtChatTabsBase* tabs, const QString& themePath, const std::map& emoticonsMap) : themePath_(themePath), emoticonsMap_(emoticonsMap) { +QtChatWindowFactory::QtChatWindowFactory(QtSingleWindow* splitter, SettingsProvider* settings, QtSettingsProvider* qtSettings, QtChatTabs* tabs, const QString& themePath, const std::map& emoticonsMap) : themePath_(themePath), emoticonsMap_(emoticonsMap) { qtOnlySettings_ = qtSettings; settings_ = settings; tabs_ = tabs; theme_ = nullptr; - QtChatTabs* fullTabs = dynamic_cast(tabs_); - if (splitter) { - assert(fullTabs && "Netbook mode and no-tabs interface is not supported!"); - splitter->addWidget(fullTabs); - } else if (fullTabs) { - QVariant chatTabsGeometryVariant = qtOnlySettings_->getQSettings()->value(CHAT_TABS_GEOMETRY); - if (chatTabsGeometryVariant.isValid()) { - fullTabs->restoreGeometry(chatTabsGeometryVariant.toByteArray()); - } - connect(fullTabs, SIGNAL(geometryChanged()), this, SLOT(handleWindowGeometryChanged())); + splitter->addWidget(tabs_); + QVariant chatTabsGeometryVariant = qtOnlySettings_->getQSettings()->value(CHAT_TABS_GEOMETRY); + if (chatTabsGeometryVariant.isValid()) { + tabs_->restoreGeometry(chatTabsGeometryVariant.toByteArray()); } + connect(tabs_, SIGNAL(geometryChanged()), this, SLOT(handleWindowGeometryChanged())); } QtChatWindowFactory::~QtChatWindowFactory() { @@ -60,7 +54,7 @@ ChatWindow* QtChatWindowFactory::createChatWindow(const JID &contact,UIEventStre connect(this, SIGNAL(changeSplitterState(QByteArray)), chatWindow, SLOT(handleChangeSplitterState(QByteArray))); QVariant splitterState = qtOnlySettings_->getQSettings()->value(SPLITTER_STATE); - if(splitterState.isValid()) { + if (splitterState.isValid()) { chatWindow->handleChangeSplitterState(splitterState.toByteArray()); } diff --git a/Swift/QtUI/QtChatWindowFactory.h b/Swift/QtUI/QtChatWindowFactory.h index 2bb6a90..3e4dca3 100644 --- a/Swift/QtUI/QtChatWindowFactory.h +++ b/Swift/QtUI/QtChatWindowFactory.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2010-2017 Isode Limited. + * Copyright (c) 2010-2018 Isode Limited. * All rights reserved. * See the COPYING file for more information. */ @@ -24,7 +24,7 @@ #include namespace Swift { - class QtChatTabsBase; + class QtChatTabs; class QtChatTheme; class UIEventStream; class QtUIPreferences; @@ -32,7 +32,7 @@ namespace Swift { class QtChatWindowFactory : public QObject, public ChatWindowFactory { Q_OBJECT public: - QtChatWindowFactory(QtSingleWindow* splitter, SettingsProvider* settings, QtSettingsProvider* qtSettings, QtChatTabsBase* tabs, const QString& themePath, const std::map& emoticonsMap); + QtChatWindowFactory(QtSingleWindow* splitter, SettingsProvider* settings, QtSettingsProvider* qtSettings, QtChatTabs* tabs, const QString& themePath, const std::map& emoticonsMap); ~QtChatWindowFactory(); ChatWindow* createChatWindow(const JID &contact, UIEventStream* eventStream); signals: @@ -44,7 +44,7 @@ namespace Swift { QString themePath_; SettingsProvider* settings_; QtSettingsProvider* qtOnlySettings_; - QtChatTabsBase* tabs_; + QtChatTabs* tabs_; QtChatTheme* theme_; std::map emoticonsMap_; }; diff --git a/Swift/QtUI/QtSwift.cpp b/Swift/QtUI/QtSwift.cpp index 2d75565..2aa8492 100644 --- a/Swift/QtUI/QtSwift.cpp +++ b/Swift/QtUI/QtSwift.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2010-2017 Isode Limited. + * Copyright (c) 2010-2018 Isode Limited. * All rights reserved. * See the COPYING file for more information. */ @@ -42,8 +42,6 @@ #include #include -#include -#include #include #include #include @@ -243,13 +241,7 @@ QtSwift::QtSwift(const po::variables_map& options) : networkFactories_(&clientMa QFont::insertSubstitution(QApplication::font().family(), "Segoe UI Emoji"); #endif bool enableAdHocCommandOnJID = options.count("enable-jid-adhocs") > 0; - tabs_ = nullptr; - if (options.count("no-tabs") && !splitter_) { - tabs_ = new QtChatTabsShortcutOnlySubstitute(); - } - else { - tabs_ = new QtChatTabs(splitter_ != nullptr, settingsHierachy_, true); - } + tabs_ = new QtChatTabs(settingsHierachy_, true); bool startMinimized = options.count("start-minimized") > 0; applicationPathProvider_ = new PlatformApplicationPathProvider(SWIFT_APPLICATION_NAME); storagesFactory_ = new FileStoragesFactory(applicationPathProvider_->getDataDir(), networkFactories_.getCryptoProvider()); @@ -290,9 +282,7 @@ QtSwift::QtSwift(const po::variables_map& options) : networkFactories_(&clientMa statusCache_ = new StatusCache(applicationPathProvider_); - if (splitter_) { - splitter_->show(); - } + splitter_->show(); PlatformAutoUpdaterFactory autoUpdaterFactory; if (autoUpdaterFactory.isSupported() && settingsHierachy_->getSetting(QtUISettingConstants::ENABLE_SOFTWARE_UPDATES) diff --git a/Swift/QtUI/QtSwift.h b/Swift/QtUI/QtSwift.h index a7dc3cf..1d5c5ed 100644 --- a/Swift/QtUI/QtSwift.h +++ b/Swift/QtUI/QtSwift.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2010-2017 Isode Limited. + * Copyright (c) 2010-2018 Isode Limited. * All rights reserved. * See the COPYING file for more information. */ @@ -45,7 +45,7 @@ namespace Swift { class CapsStorage; class MainController; class QtSystemTray; - class QtChatTabsBase; + class QtChatTabs; class QtChatWindowFactory; class QtSoundPlayer; class QtMUCSearchWindowFactory; @@ -88,7 +88,7 @@ namespace Swift { QtSoundPlayer* soundPlayer_; Dock* dock_; URIHandler* uriHandler_; - QtChatTabsBase* tabs_; + QtChatTabs* tabs_; ApplicationPathProvider* applicationPathProvider_; StoragesFactory* storagesFactory_; CertificateStorageFactory* certificateStorageFactory_; diff --git a/Swift/QtUI/QtUIFactory.cpp b/Swift/QtUI/QtUIFactory.cpp index 15619c7..0b19f63 100644 --- a/Swift/QtUI/QtUIFactory.cpp +++ b/Swift/QtUI/QtUIFactory.cpp @@ -19,7 +19,6 @@ #include #include #include -#include #include #include #include @@ -41,10 +40,9 @@ namespace Swift { -QtUIFactory::QtUIFactory(SettingsProviderHierachy* settings, QtSettingsProvider* qtOnlySettings, QtChatTabsBase* tabs, QtSingleWindow* netbookSplitter, QtSystemTray* systemTray, QtChatWindowFactory* chatWindowFactory, TimerFactory* timerFactory, StatusCache* statusCache, AutoUpdater* autoUpdater, bool startMinimized, bool emoticonsExist, bool enableAdHocCommandOnJID) : settings_(settings), qtOnlySettings_(qtOnlySettings), tabsBase_(tabs), netbookSplitter_(netbookSplitter), systemTray_(systemTray), chatWindowFactory_(chatWindowFactory), timerFactory_(timerFactory), lastMainWindow_(nullptr), loginWindow_(nullptr), statusCache_(statusCache), autoUpdater_(autoUpdater), startMinimized_(startMinimized), emoticonsExist_(emoticonsExist), enableAdHocCommandOnJID_(enableAdHocCommandOnJID) { +QtUIFactory::QtUIFactory(SettingsProviderHierachy* settings, QtSettingsProvider* qtOnlySettings, QtChatTabs* tabs, QtSingleWindow* netbookSplitter, QtSystemTray* systemTray, QtChatWindowFactory* chatWindowFactory, TimerFactory* timerFactory, StatusCache* statusCache, AutoUpdater* autoUpdater, bool startMinimized, bool emoticonsExist, bool enableAdHocCommandOnJID) : settings_(settings), qtOnlySettings_(qtOnlySettings), tabs_(tabs), netbookSplitter_(netbookSplitter), systemTray_(systemTray), chatWindowFactory_(chatWindowFactory), timerFactory_(timerFactory), lastMainWindow_(nullptr), loginWindow_(nullptr), statusCache_(statusCache), autoUpdater_(autoUpdater), startMinimized_(startMinimized), emoticonsExist_(emoticonsExist), enableAdHocCommandOnJID_(enableAdHocCommandOnJID) { chatFontSize_ = settings_->getSetting(QtUISettingConstants::CHATWINDOW_FONT_SIZE); historyFontSize_ = settings_->getSetting(QtUISettingConstants::HISTORYWINDOW_FONT_SIZE); - this->tabs_ = dynamic_cast(tabsBase_); } QtUIFactory::~QtUIFactory() { @@ -56,7 +54,7 @@ QtUIFactory::~QtUIFactory() { XMLConsoleWidget* QtUIFactory::createXMLConsoleWidget() { QtXMLConsoleWidget* widget = new QtXMLConsoleWidget(); - tabsBase_->addTab(widget); + tabs_->addTab(widget); showTabs(); widget->show(); return widget; @@ -64,7 +62,7 @@ XMLConsoleWidget* QtUIFactory::createXMLConsoleWidget() { HistoryWindow* QtUIFactory::createHistoryWindow(UIEventStream* uiEventStream) { QtHistoryWindow* window = new QtHistoryWindow(settings_, uiEventStream); - tabsBase_->addTab(window); + tabs_->addTab(window); showTabs(); connect(window, SIGNAL(fontResized(int)), this, SLOT(handleHistoryWindowFontResized(int))); @@ -80,7 +78,7 @@ void QtUIFactory::handleHistoryWindowFontResized(int size) { FileTransferListWidget* QtUIFactory::createFileTransferListWidget() { QtFileTransferListWidget* widget = new QtFileTransferListWidget(); - tabsBase_->addTab(widget); + tabs_->addTab(widget); showTabs(); widget->show(); return widget; @@ -88,9 +86,7 @@ FileTransferListWidget* QtUIFactory::createFileTransferListWidget() { MainWindow* QtUIFactory::createMainWindow(Chattables& chattables, UIEventStream* eventStream) { lastMainWindow_ = new QtMainWindow(chattables, settings_, eventStream, loginWindow_->getMenus(), statusCache_, emoticonsExist_, enableAdHocCommandOnJID_); - if (tabs_) { - tabs_->setViewMenu(lastMainWindow_->getMenus()[0]); - } + tabs_->setViewMenu(lastMainWindow_->getMenus()[0]); return lastMainWindow_; } @@ -177,10 +173,8 @@ AdHocCommandWindow* QtUIFactory::createAdHocCommandWindow(std::shared_ptrisVisible()) { - tabs_->show(); - } + if (!tabs_->isVisible()) { + tabs_->show(); } } diff --git a/Swift/QtUI/QtUIFactory.h b/Swift/QtUI/QtUIFactory.h index 0b9ee3c..4013668 100644 --- a/Swift/QtUI/QtUIFactory.h +++ b/Swift/QtUI/QtUIFactory.h @@ -19,7 +19,6 @@ namespace Swift { class AutoUpdater; class Chattables; class QtChatTabs; - class QtChatTabsBase; class QtChatTheme; class QtChatWindow; class QtChatWindowFactory; @@ -36,7 +35,7 @@ namespace Swift { class QtUIFactory : public QObject, public UIFactory { Q_OBJECT public: - QtUIFactory(SettingsProviderHierachy* settings, QtSettingsProvider* qtOnlySettings, QtChatTabsBase* tabs, QtSingleWindow* netbookSplitter, QtSystemTray* systemTray, QtChatWindowFactory* chatWindowFactory, TimerFactory* timerFactory, StatusCache* statusCache, AutoUpdater* autoUpdater, bool startMinimized, bool emoticonsExist, bool enableAdHocCommandOnJID); + QtUIFactory(SettingsProviderHierachy* settings, QtSettingsProvider* qtOnlySettings, QtChatTabs* tabs, QtSingleWindow* netbookSplitter, QtSystemTray* systemTray, QtChatWindowFactory* chatWindowFactory, TimerFactory* timerFactory, StatusCache* statusCache, AutoUpdater* autoUpdater, bool startMinimized, bool emoticonsExist, bool enableAdHocCommandOnJID); ~QtUIFactory(); virtual XMLConsoleWidget* createXMLConsoleWidget(); virtual HistoryWindow* createHistoryWindow(UIEventStream*); @@ -66,7 +65,6 @@ namespace Swift { private: SettingsProviderHierachy* settings_; QtSettingsProvider* qtOnlySettings_; - QtChatTabsBase* tabsBase_; QtChatTabs* tabs_; QtSingleWindow* netbookSplitter_; QtSystemTray* systemTray_; diff --git a/Swift/QtUI/SConscript b/Swift/QtUI/SConscript index 09860ed..3cd3228 100644 --- a/Swift/QtUI/SConscript +++ b/Swift/QtUI/SConscript @@ -151,7 +151,6 @@ sources = [ "QtChatOverviewDelegate.cpp", "QtChatTabs.cpp", "QtChatTabsBase.cpp", - "QtChatTabsShortcutOnlySubstitute.cpp", "QtChatTheme.cpp", "QtChatView.cpp", "QtChatWindow.cpp", -- cgit v0.10.2-6-g49f6