From 4a3b9f10bcc90875980557c1535b3ff803083b56 Mon Sep 17 00:00:00 2001 From: konrad Date: Sat, 24 Jan 2009 15:14:17 +0000 Subject: [PATCH] first steps towards singleton git-svn-id: https://silmor.de/svn/softmagic/smoke/trunk@248 6e3c4bff-ac9f-4ac1-96c5-d2ea494d3e33 --- src/main.cpp | 2 +- src/mainwindow.cpp | 11 +++++++++-- src/webrequest.cpp | 5 +++++ src/webrequest.h | 4 +++- 4 files changed, 18 insertions(+), 4 deletions(-) diff --git a/src/main.cpp b/src/main.cpp index e61d9d2..f6d1972 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -163,7 +163,7 @@ int main(int argc,char**argv) //open main window MMainWindow mmw; - mmw.showMaximized(); + mmw.show(); return app.exec(); } diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index bcfea4d..35cfae5 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -17,6 +17,7 @@ #include "overview.h" #include "webrequest.h" +#include #include #include #include @@ -222,9 +223,15 @@ void MMainWindow::startLogin() MOverview *mo=new MOverview(mw,profiles->itemData(profiles->currentIndex()).toString()); mo->show(); + //make sure the application exits after everything is cleaned up + qApp->setQuitOnLastWindowClosed(false); + connect(mw,SIGNAL(destroyed(QObject*)),qApp,SLOT(quit())); + //reset main window - password->setText(""); - setEnabled(true); +// password->setText(""); +// setEnabled(true); +// deleteLater(); + hide(); } void MMainWindow::changeLang() diff --git a/src/webrequest.cpp b/src/webrequest.cpp index 0fa9e14..2156e87 100644 --- a/src/webrequest.cpp +++ b/src/webrequest.cpp @@ -27,9 +27,12 @@ #include +static QPointersinst; + MWebRequest::MWebRequest(QString pid) :temp(this,pid) { + sinst=this; profileid=pid; webtimeout=QSettings().value("profiles/"+pid+"/webtimeout",30).toInt()*1000; loglvl=LogLevel(QSettings().value("profiles/"+pid+"/webloglevel",LogOnError).toInt()); @@ -44,6 +47,8 @@ MWebRequest::MWebRequest(QString pid) } MWebRequest::~MWebRequest(){} +MWebRequest* MWebRequest::instance(){return sinst;} + QString MWebRequest::dataDir()const { QString dd="profile."+profileid; diff --git a/src/webrequest.h b/src/webrequest.h index d71643b..39500e5 100644 --- a/src/webrequest.h +++ b/src/webrequest.h @@ -31,7 +31,7 @@ #include "templates.h" #include "user.h" -/**abstraction of requests to the web server, handles sessions and all data transfer*/ +/**abstraction of requests to the web server, handles sessions and all data transfer; singleton*/ class MWebRequest:public QObject { Q_OBJECT @@ -39,6 +39,8 @@ class MWebRequest:public QObject MWebRequest(QString profileid); ~MWebRequest(); + static MWebRequest* instance(); + /**returns the data directory of this profile; it makes sure the directory exists*/ QString dataDir()const; -- 1.7.2.5