From 299541db5d6586c0b09e036816dfd28477ebc249 Mon Sep 17 00:00:00 2001 From: Marcus Eggenberger Date: Tue, 21 Oct 2008 14:45:48 +0200 Subject: [PATCH 1/1] fixing dependencies to core. MonolithicApplication is now a proper QObject --- src/CMakeLists.txt | 3 ++- src/client/client.h | 3 +++ src/client/clientsyncer.cpp | 1 + src/client/clientsyncer.h | 1 + src/qtui/coreconnectdlg.cpp | 18 ++++++++++-------- src/qtui/coreconnectdlg.h | 8 +++++--- src/qtui/monoapplication.cpp | 13 ++++++++----- src/qtui/monoapplication.h | 7 +++++-- src/qtui/qtuiapplication.cpp | 1 - 9 files changed, 35 insertions(+), 20 deletions(-) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 33374dbf..da979d59 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -56,7 +56,8 @@ endif(WANT_QTCLIENT) if(WANT_MONO) setup_qt4_variables(${LINK_DBUS} GUI NETWORK SCRIPT SQL ${LINK_WEBKIT}) - add_executable(quassel WIN32 common/main.cpp qtui/monoapplication.cpp ${COMMON_DEPS} ${CLIENT_DEPS} ${CORE_DEPS}) + qt4_wrap_cpp(MOC qtui/monoapplication.h) + add_executable(quassel WIN32 common/main.cpp qtui/monoapplication.cpp ${MOC} ${COMMON_DEPS} ${CLIENT_DEPS} ${CORE_DEPS}) add_dependencies(quassel icons genversion_run) set_target_properties(quassel PROPERTIES COMPILE_FLAGS "-DQT_GUI_LIB -DQT_NETWORK_LIB -DQT_SCRIPT_LIB -DQT_SQL_LIB -DBUILD_MONO" diff --git a/src/client/client.h b/src/client/client.h index 62ad9b09..2d073c5f 100644 --- a/src/client/client.h +++ b/src/client/client.h @@ -43,6 +43,7 @@ class BufferModel; class BufferSyncer; class ClientBacklogManager; class ClientIrcListHelper; +class ClientSyncer; class BufferViewManager; class IrcUser; class IrcChannel; @@ -146,6 +147,8 @@ signals: void requestCreateNetwork(const NetworkInfo &info); void requestRemoveNetwork(NetworkId); + void newClientSyncer(ClientSyncer *); + public slots: //void selectBuffer(Buffer *); diff --git a/src/client/clientsyncer.cpp b/src/client/clientsyncer.cpp index 655875ff..a9d59727 100644 --- a/src/client/clientsyncer.cpp +++ b/src/client/clientsyncer.cpp @@ -170,6 +170,7 @@ void ClientSyncer::coreSocketConnected() { } void ClientSyncer::useInternalCore() { + emit startInternalCore(); emit connectToInternalCore(Client::instance()->signalProxy()); } diff --git a/src/client/clientsyncer.h b/src/client/clientsyncer.h index 16c516d7..d321451a 100644 --- a/src/client/clientsyncer.h +++ b/src/client/clientsyncer.h @@ -61,6 +61,7 @@ signals: void encrypted(bool); + void startInternalCore(); void connectToInternalCore(SignalProxy *proxy); public slots: diff --git a/src/qtui/coreconnectdlg.cpp b/src/qtui/coreconnectdlg.cpp index 6903d937..d61a0211 100644 --- a/src/qtui/coreconnectdlg.cpp +++ b/src/qtui/coreconnectdlg.cpp @@ -24,11 +24,11 @@ #include "coreconnectdlg.h" +#include "client.h" #include "clientsettings.h" #include "clientsyncer.h" #include "coreconfigwizard.h" #include "iconloader.h" -#include "monoapplication.h" CoreConnectDlg::CoreConnectDlg(bool autoconnect, QWidget *parent) : QDialog(parent) @@ -44,6 +44,8 @@ CoreConnectDlg::CoreConnectDlg(bool autoconnect, QWidget *parent) setWindowFlags(Qt::Sheet); clientSyncer = new ClientSyncer(this); + connect(this, SIGNAL(newClientSyncer(ClientSyncer *)), Client::instance(), SIGNAL(newClientSyncer(ClientSyncer *))); + emit newClientSyncer(clientSyncer); // announce the new client syncer via the client. wizard = 0; @@ -214,13 +216,13 @@ void CoreConnectDlg::on_accountButtonBox_accepted() { } void CoreConnectDlg::on_useInternalCore_clicked() { - // FIXME: this needs to be a qobject_cast - therefore MonolithicApplication needs to be a proper QObject... :/ - MonolithicApplication *monoApp = static_cast(QApplication::instance()); - if(monoApp) { - qDebug() << "starting core..."; - monoApp->startInternalCore(); - monoApp->connectClientSyncer(clientSyncer); - } +// // FIXME: this needs to be a qobject_cast - therefore MonolithicApplication needs to be a proper QObject... :/ +// MonolithicApplication *monoApp = qobject_cast(QApplication::instance()); +// if(monoApp) { +// qDebug() << "starting core..."; +// monoApp->startInternalCore(); +// monoApp->connectClientSyncer(clientSyncer); +// } clientSyncer->useInternalCore(); startSync(); } diff --git a/src/qtui/coreconnectdlg.h b/src/qtui/coreconnectdlg.h index ff980d32..ae3d5b76 100644 --- a/src/qtui/coreconnectdlg.h +++ b/src/qtui/coreconnectdlg.h @@ -18,8 +18,8 @@ * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * ***************************************************************************/ -#ifndef _CORECONNECTDLG_H_ -#define _CORECONNECTDLG_H_ +#ifndef CORECONNECTDLG_H +#define CORECONNECTDLG_H #include @@ -38,8 +38,10 @@ public: CoreConnectDlg(bool = false, QWidget *parent = 0); ~CoreConnectDlg(); -private slots: +signals: + void newClientSyncer(ClientSyncer *); +private slots: /*** Phase Null: Accounts ***/ void restartPhaseNull(); diff --git a/src/qtui/monoapplication.cpp b/src/qtui/monoapplication.cpp index 97688f2a..7b05c734 100644 --- a/src/qtui/monoapplication.cpp +++ b/src/qtui/monoapplication.cpp @@ -33,8 +33,9 @@ MonolithicApplication::MonolithicApplication(int &argc, char **argv) } bool MonolithicApplication::init() { - if(Quassel::init()) { - return QtUiApplication::init(); + connect(Client::instance(), SIGNAL(newClientSyncer(ClientSyncer *)), this, SLOT(newClientSyncer(ClientSyncer *))); + if(QtUiApplication::init()) { + return true; } return false; } @@ -45,12 +46,14 @@ MonolithicApplication::~MonolithicApplication() { delete _internal; } -bool MonolithicApplication::startInternalCore() { - return _internal->init(); +void MonolithicApplication::newClientSyncer(ClientSyncer *syncer) { + connect(syncer, SIGNAL(startInternalCore()), this, SLOT(startInternalCore())); } -void MonolithicApplication::connectClientSyncer(ClientSyncer *syncer) { +void MonolithicApplication::startInternalCore() { + _internal->init(); Core *core = Core::instance(); + ClientSyncer *syncer = static_cast(sender()); connect(syncer, SIGNAL(connectToInternalCore(SignalProxy *)), core, SLOT(setupInternalClientSession(SignalProxy *))); connect(core, SIGNAL(sessionState(const QVariant &)), syncer, SLOT(internalSessionStateReceived(const QVariant &))); } diff --git a/src/qtui/monoapplication.h b/src/qtui/monoapplication.h index 40503424..ff35ddd1 100644 --- a/src/qtui/monoapplication.h +++ b/src/qtui/monoapplication.h @@ -27,13 +27,16 @@ class ClientSyncer; class CoreApplicationInternal; class MonolithicApplication : public QtUiApplication { + Q_OBJECT public: MonolithicApplication(int &, char **); ~MonolithicApplication(); bool init(); - bool startInternalCore(); - void connectClientSyncer(ClientSyncer *syncer); + +private slots: + void newClientSyncer(ClientSyncer *syncer); + void startInternalCore(); private: CoreApplicationInternal *_internal; diff --git a/src/qtui/qtuiapplication.cpp b/src/qtui/qtuiapplication.cpp index 6ae09c94..7a6f0977 100644 --- a/src/qtui/qtuiapplication.cpp +++ b/src/qtui/qtuiapplication.cpp @@ -45,7 +45,6 @@ bool QtUiApplication::init() { // QTimer::singleShot(0, gui, SLOT(init())); gui->init(); resumeSessionIfPossible(); - return true; } return false; -- 2.20.1