diff options
Diffstat (limited to 'Swift')
-rw-r--r-- | Swift/Controllers/HistoryController.cpp | 33 | ||||
-rw-r--r-- | Swift/Controllers/HistoryController.h | 31 | ||||
-rw-r--r-- | Swift/Controllers/MainController.cpp | 3 | ||||
-rw-r--r-- | Swift/Controllers/MainController.h | 2 | ||||
-rw-r--r-- | Swift/Controllers/SConscript | 1 | ||||
-rw-r--r-- | Swift/Controllers/UIEvents/RequestHistoryUIEvent.h | 14 | ||||
-rw-r--r-- | Swift/Controllers/UIInterfaces/HistoryWindow.h | 17 | ||||
-rw-r--r-- | Swift/Controllers/UIInterfaces/HistoryWindowFactory.h | 18 | ||||
-rw-r--r-- | Swift/Controllers/UIInterfaces/UIFactory.h | 2 | ||||
-rw-r--r-- | Swift/QtUI/QtHistoryWindow.cpp | 65 | ||||
-rw-r--r-- | Swift/QtUI/QtHistoryWindow.h | 31 | ||||
-rw-r--r-- | Swift/QtUI/QtMainWindow.cpp | 8 | ||||
-rw-r--r-- | Swift/QtUI/QtMainWindow.h | 1 | ||||
-rw-r--r-- | Swift/QtUI/QtUIFactory.cpp | 11 | ||||
-rw-r--r-- | Swift/QtUI/QtUIFactory.h | 1 | ||||
-rw-r--r-- | Swift/QtUI/SConscript | 1 |
16 files changed, 239 insertions, 0 deletions
diff --git a/Swift/Controllers/HistoryController.cpp b/Swift/Controllers/HistoryController.cpp new file mode 100644 index 0000000..2aa1b6e --- /dev/null +++ b/Swift/Controllers/HistoryController.cpp @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2012 Catalin Badea + * Licensed under the GNU General Public License v3. + * See Documentation/Licenses/GPLv3.txt for more information. + */ + +#include "Swift/Controllers/HistoryController.h" + +#include "Swift/Controllers/UIInterfaces/HistoryWindowFactory.h" +#include "Swift/Controllers/UIEvents/RequestHistoryUIEvent.h" + +namespace Swift { + +HistoryController::HistoryController(UIEventStream* uiEventStream, HistoryWindowFactory* historyWindowFactory) : historyWindowFactory_(historyWindowFactory), historyWindow_(NULL) { + uiEventStream->onUIEvent.connect(boost::bind(&HistoryController::handleUIEvent, this, _1)); +} + +HistoryController::~HistoryController() { + delete historyWindow_; +} + +void HistoryController::handleUIEvent(boost::shared_ptr<UIEvent> rawEvent) { + boost::shared_ptr<RequestHistoryUIEvent> event = boost::dynamic_pointer_cast<RequestHistoryUIEvent>(rawEvent); + if (event != NULL) { + if (historyWindow_ == NULL) { + historyWindow_ = historyWindowFactory_->createHistoryWindow(); + } + historyWindow_->show(); + historyWindow_->activate(); + } +} + +} diff --git a/Swift/Controllers/HistoryController.h b/Swift/Controllers/HistoryController.h new file mode 100644 index 0000000..465b037 --- /dev/null +++ b/Swift/Controllers/HistoryController.h @@ -0,0 +1,31 @@ +/* + * Copyright (c) 2012 Catalin Badea + * Licensed under the GNU General Public License v3. + * See Documentation/Licenses/GPLv3.txt for more information. + */ + +#pragma once + +#include "Swiften/Base/boost_bsignals.h" +#include <boost/bind.hpp> +#include <boost/shared_ptr.hpp> + +#include "Swift/Controllers/UIEvents/UIEventStream.h" + +namespace Swift { + class HistoryWindowFactory; + class HistoryWindow; + + class HistoryController { + public: + HistoryController(UIEventStream* uiEventStream, HistoryWindowFactory* historyWindowFactory); + ~HistoryController(); + + private: + void handleUIEvent(boost::shared_ptr<UIEvent> event); + + private: + HistoryWindowFactory* historyWindowFactory_; + HistoryWindow* historyWindow_; + }; +} diff --git a/Swift/Controllers/MainController.cpp b/Swift/Controllers/MainController.cpp index 53387ca..dc027d0 100644 --- a/Swift/Controllers/MainController.cpp +++ b/Swift/Controllers/MainController.cpp @@ -37,6 +37,7 @@ #include "Swift/Controllers/SystemTray.h" #include "Swift/Controllers/SystemTrayController.h" #include "Swift/Controllers/XMLConsoleController.h" +#include "Swift/Controllers/HistoryController.h" #include "Swift/Controllers/FileTransferListController.h" #include "Swift/Controllers/UIEvents/UIEventStream.h" #include "Swift/Controllers/PresenceNotifier.h" @@ -169,6 +170,7 @@ MainController::MainController( idleDetector_->onIdleChanged.connect(boost::bind(&MainController::handleInputIdleChanged, this, _1)); xmlConsoleController_ = new XMLConsoleController(uiEventStream_, uiFactory_); + historyController_ = new HistoryController(uiEventStream_, uiFactory_); fileTransferListController_ = new FileTransferListController(uiEventStream_, uiFactory_); @@ -193,6 +195,7 @@ MainController::~MainController() { resetClient(); delete fileTransferListController_; delete xmlConsoleController_; + delete historyController_; delete xmppURIController_; delete soundEventController_; delete systemTrayController_; diff --git a/Swift/Controllers/MainController.h b/Swift/Controllers/MainController.h index eeba9f3..5a767d3 100644 --- a/Swift/Controllers/MainController.h +++ b/Swift/Controllers/MainController.h @@ -52,6 +52,7 @@ namespace Swift { class SoundEventController; class SoundPlayer; class XMLConsoleController; + class HistoryController; class FileTransferListController; class UIEventStream; class EventWindowFactory; @@ -143,6 +144,7 @@ namespace Swift { LoginWindow* loginWindow_; UIEventStream* uiEventStream_; XMLConsoleController* xmlConsoleController_; + HistoryController* historyController_; FileTransferListController* fileTransferListController_; ChatsManager* chatsManager_; ProfileController* profileController_; diff --git a/Swift/Controllers/SConscript b/Swift/Controllers/SConscript index 70085a6..407efde 100644 --- a/Swift/Controllers/SConscript +++ b/Swift/Controllers/SConscript @@ -44,6 +44,7 @@ if env["SCONS_STAGE"] == "build" : "SoundEventController.cpp", "SystemTrayController.cpp", "XMLConsoleController.cpp", + "HistoryController.cpp", "FileTransferListController.cpp", "StatusTracker.cpp", "PresenceNotifier.cpp", diff --git a/Swift/Controllers/UIEvents/RequestHistoryUIEvent.h b/Swift/Controllers/UIEvents/RequestHistoryUIEvent.h new file mode 100644 index 0000000..8562beb --- /dev/null +++ b/Swift/Controllers/UIEvents/RequestHistoryUIEvent.h @@ -0,0 +1,14 @@ +/* + * Copyright (c) 2012 Catalin Badea + * Licensed under the GNU General Public License v3. + * See Documentation/Licenses/GPLv3.txt for more information. + */ + +#pragma once + +#include "Swift/Controllers/UIEvents/UIEvent.h" + +namespace Swift { + class RequestHistoryUIEvent : public UIEvent { + }; +} diff --git a/Swift/Controllers/UIInterfaces/HistoryWindow.h b/Swift/Controllers/UIInterfaces/HistoryWindow.h new file mode 100644 index 0000000..379d4b1 --- /dev/null +++ b/Swift/Controllers/UIInterfaces/HistoryWindow.h @@ -0,0 +1,17 @@ +/* + * Copyright (c) 2012 Catalin Badea + * Licensed under the GNU General Public License v3. + * See Documentation/Licenses/GPLv3.txt for more information. + */ + +#pragma once + +namespace Swift { + class HistoryWindow { + public: + virtual ~HistoryWindow() {}; + + virtual void show() = 0; + virtual void activate() = 0; + }; +} diff --git a/Swift/Controllers/UIInterfaces/HistoryWindowFactory.h b/Swift/Controllers/UIInterfaces/HistoryWindowFactory.h new file mode 100644 index 0000000..c84d8d7 --- /dev/null +++ b/Swift/Controllers/UIInterfaces/HistoryWindowFactory.h @@ -0,0 +1,18 @@ +/* + * Copyright (c) 2012 Catalin Badea + * Licensed under the GNU General Public License v3. + * See Documentation/Licenses/GPLv3.txt for more information. + */ + +#pragma once + +#include "Swift/Controllers/UIInterfaces/HistoryWindow.h" + +namespace Swift { + class UIEventStream; + class HistoryWindowFactory { + public: + virtual ~HistoryWindowFactory() {}; + virtual HistoryWindow* createHistoryWindow() = 0; + }; +} diff --git a/Swift/Controllers/UIInterfaces/UIFactory.h b/Swift/Controllers/UIInterfaces/UIFactory.h index cf89dab..d6bea77 100644 --- a/Swift/Controllers/UIInterfaces/UIFactory.h +++ b/Swift/Controllers/UIInterfaces/UIFactory.h @@ -8,6 +8,7 @@ #include <Swift/Controllers/UIInterfaces/ChatListWindowFactory.h> #include <Swift/Controllers/UIInterfaces/ChatWindowFactory.h> +#include <Swift/Controllers/UIInterfaces/HistoryWindowFactory.h> #include <Swift/Controllers/UIInterfaces/EventWindowFactory.h> #include <Swift/Controllers/UIInterfaces/LoginWindowFactory.h> #include <Swift/Controllers/UIInterfaces/MainWindowFactory.h> @@ -24,6 +25,7 @@ namespace Swift { class UIFactory : public ChatListWindowFactory, public ChatWindowFactory, + public HistoryWindowFactory, public EventWindowFactory, public LoginWindowFactory, public MainWindowFactory, diff --git a/Swift/QtUI/QtHistoryWindow.cpp b/Swift/QtUI/QtHistoryWindow.cpp new file mode 100644 index 0000000..a54fa03 --- /dev/null +++ b/Swift/QtUI/QtHistoryWindow.cpp @@ -0,0 +1,65 @@ +/* + * Copyright (c) 2012 Catalin Badea + * Licensed under the GNU General Public License v3. + * See Documentation/Licenses/GPLv3.txt for more information. + */ + +#include "QtHistoryWindow.h" +#include "QtTabbable.h" + +#include <QCloseEvent> +#include <QTextEdit> +#include <QVBoxLayout> +#include <QPushButton> +#include <QScrollBar> +#include <QCheckBox> + +#include "QtSwiftUtil.h" +#include <string> + +namespace Swift { + +QtHistoryWindow::QtHistoryWindow() { + QVBoxLayout* layout = new QVBoxLayout(this); + layout->setSpacing(0); + layout->setContentsMargins(0,0,0,0); + + QWidget* bottom = new QWidget(this); + layout->addWidget(bottom); + bottom->setAutoFillBackground(true); + + QHBoxLayout* buttonLayout = new QHBoxLayout(bottom); + buttonLayout->setContentsMargins(10,0,20,0); + buttonLayout->setSpacing(0); + + buttonLayout->addStretch(); + + setWindowTitle(tr("History")); + emit titleUpdated(); +} + +QtHistoryWindow::~QtHistoryWindow() { + // do nothing +} + +void QtHistoryWindow::show() { + QWidget::show(); + emit windowOpening(); +} + +void QtHistoryWindow::activate() { + emit wantsToActivate(); +} + +void QtHistoryWindow::showEvent(QShowEvent* event) { + emit windowOpening(); + emit titleUpdated(); + QWidget::showEvent(event); +} + +void QtHistoryWindow::closeEvent(QCloseEvent* event) { + emit windowClosing(); + event->accept(); +} + +} diff --git a/Swift/QtUI/QtHistoryWindow.h b/Swift/QtUI/QtHistoryWindow.h new file mode 100644 index 0000000..f2e5cc0 --- /dev/null +++ b/Swift/QtUI/QtHistoryWindow.h @@ -0,0 +1,31 @@ +/* + * Copyright (c) 2012 Catalin Badea + * Licensed under the GNU General Public License v3. + * See Documentation/Licenses/GPLv3.txt for more information. + */ + +#pragma once + +#include "Swift/Controllers/UIInterfaces/HistoryWindow.h" +#include "QtTabbable.h" + +class QTextEdit; +class QCheckBox; +class QColor; + +namespace Swift { + class QtHistoryWindow : public QtTabbable, public HistoryWindow { + Q_OBJECT + + public: + QtHistoryWindow(); + ~QtHistoryWindow(); + + void show(); + void activate(); + + private: + virtual void closeEvent(QCloseEvent* event); + virtual void showEvent(QShowEvent* event); + }; +} diff --git a/Swift/QtUI/QtMainWindow.cpp b/Swift/QtUI/QtMainWindow.cpp index d312546..7ec0c93 100644 --- a/Swift/QtUI/QtMainWindow.cpp +++ b/Swift/QtUI/QtMainWindow.cpp @@ -27,6 +27,7 @@ #include <Swift/QtUI/QtLoginWindow.h> #include <Roster/QtRosterWidget.h> #include <Swift/Controllers/UIEvents/RequestJoinMUCUIEvent.h> +#include <Swift/Controllers/UIEvents/RequestHistoryUIEvent.h> #include <Swift/Controllers/UIEvents/RequestAddUserDialogUIEvent.h> #include <Swift/Controllers/UIEvents/RequestChatWithUserDialogUIEvent.h> #include <Swift/Controllers/UIEvents/RequestProfileEditorUIEvent.h> @@ -122,6 +123,9 @@ QtMainWindow::QtMainWindow(SettingsProvider* settings, UIEventStream* uiEventStr QAction* joinMUCAction = new QAction(tr("Enter &Room…"), this); connect(joinMUCAction, SIGNAL(triggered()), SLOT(handleJoinMUCAction())); actionsMenu->addAction(joinMUCAction); + QAction* viewLogsAction = new QAction(tr("&View History…"), this); + connect(viewLogsAction, SIGNAL(triggered()), SLOT(handleViewLogsAction())); + actionsMenu->addAction(viewLogsAction); addUserAction_ = new QAction(tr("&Add Contact…"), this); connect(addUserAction_, SIGNAL(triggered(bool)), this, SLOT(handleAddUserActionTriggered(bool))); actionsMenu->addAction(addUserAction_); @@ -235,6 +239,10 @@ void QtMainWindow::handleJoinMUCAction() { uiEventStream_->send(boost::make_shared<RequestJoinMUCUIEvent>()); } +void QtMainWindow::handleViewLogsAction() { + uiEventStream_->send(boost::make_shared<RequestHistoryUIEvent>()); +} + void QtMainWindow::handleStatusChanged(StatusShow::Type showType, const QString &statusMessage) { onChangeStatusRequest(showType, Q2PSTRING(statusMessage)); } diff --git a/Swift/QtUI/QtMainWindow.h b/Swift/QtUI/QtMainWindow.h index 251c346..26d25e1 100644 --- a/Swift/QtUI/QtMainWindow.h +++ b/Swift/QtUI/QtMainWindow.h @@ -58,6 +58,7 @@ namespace Swift { void handleShowOfflineToggled(bool); void handleShowEmoticonsToggled(bool); void handleJoinMUCAction(); + void handleViewLogsAction(); void handleSignOutAction(); void handleEditProfileAction(); void handleAddUserActionTriggered(bool checked); diff --git a/Swift/QtUI/QtUIFactory.cpp b/Swift/QtUI/QtUIFactory.cpp index 78de7aa..e58bbbe 100644 --- a/Swift/QtUI/QtUIFactory.cpp +++ b/Swift/QtUI/QtUIFactory.cpp @@ -9,6 +9,7 @@ #include <QSplitter> #include "QtXMLConsoleWidget.h" +#include "QtHistoryWindow.h" #include "QtChatTabs.h" #include "QtMainWindow.h" #include "QtLoginWindow.h" @@ -44,6 +45,16 @@ XMLConsoleWidget* QtUIFactory::createXMLConsoleWidget() { return widget; } +HistoryWindow* QtUIFactory::createHistoryWindow() { + QtHistoryWindow* window = new QtHistoryWindow(); + tabs->addTab(window); + if (!tabs->isVisible()) { + tabs->show(); + } + window->show(); + return window; +} + FileTransferListWidget* QtUIFactory::createFileTransferListWidget() { QtFileTransferListWidget* widget = new QtFileTransferListWidget(); tabs->addTab(widget); diff --git a/Swift/QtUI/QtUIFactory.h b/Swift/QtUI/QtUIFactory.h index edb89ad..0fa95b8 100644 --- a/Swift/QtUI/QtUIFactory.h +++ b/Swift/QtUI/QtUIFactory.h @@ -31,6 +31,7 @@ namespace Swift { QtUIFactory(SettingsProviderHierachy* settings, QtSettingsProvider* qtOnlySettings, QtChatTabs* tabs, QSplitter* netbookSplitter, QtSystemTray* systemTray, QtChatWindowFactory* chatWindowFactory, TimerFactory* timerFactory, bool startMinimized, bool emoticonsExist); virtual XMLConsoleWidget* createXMLConsoleWidget(); + virtual HistoryWindow* createHistoryWindow(); virtual MainWindow* createMainWindow(UIEventStream* eventStream); virtual LoginWindow* createLoginWindow(UIEventStream* eventStream); virtual EventWindow* createEventWindow(); diff --git a/Swift/QtUI/SConscript b/Swift/QtUI/SConscript index ef05a12..2da5535 100644 --- a/Swift/QtUI/SConscript +++ b/Swift/QtUI/SConscript @@ -93,6 +93,7 @@ sources = [ "QtTabWidget.cpp", "QtTextEdit.cpp", "QtXMLConsoleWidget.cpp", + "QtHistoryWindow.cpp", "QtFileTransferListWidget.cpp", "QtFileTransferListItemModel.cpp", "QtAdHocCommandWindow.cpp", |