From cbc30076b037cafb872310577f83609cc3f88bb0 Mon Sep 17 00:00:00 2001 From: No'am Rosenthal Date: Mon, 10 Aug 2009 00:05:47 -0700 Subject: Fixed loginmvc example to have better notifications --- scc/examples/loginmvc/main.cpp | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'scc/examples/loginmvc/main.cpp') diff --git a/scc/examples/loginmvc/main.cpp b/scc/examples/loginmvc/main.cpp index c01a3be..25b68d1 100644 --- a/scc/examples/loginmvc/main.cpp +++ b/scc/examples/loginmvc/main.cpp @@ -117,6 +117,7 @@ class MyView : public QFrame, public virtual Ui::Frame { Q_OBJECT public: + QString welcomeText; MyView(QWidget* o = NULL) : QFrame(o) { setupUi(this); @@ -139,7 +140,7 @@ class MyView : public QFrame, public virtual Ui::Frame } void notifyWelcome() { - QMessageBox::information(this,"","Welcome!"); + QMessageBox::information(this,"Welcome!",welcomeText); } void notifyError() { @@ -162,14 +163,15 @@ class MyView : public QFrame, public virtual Ui::Frame int main(int argc, char *argv[]) { QApplication a(argc, argv); - - AbstractModel* model = QSslSocket::supportsSsl () ? (AbstractModel*)new GMailModel() : (AbstractModel*)new DummyModel(); + bool use_gmail = QSslSocket::supportsSsl () && !a.arguments().contains("--dummy"); + AbstractModel* model = use_gmail ? (AbstractModel*)new GMailModel() : (AbstractModel*)new DummyModel(); MyView* view = new MyView(); SMClass_controller *controller = new SMClass_controller(); controller->setupStateMachine(); controller->set_loginButton(view->loginButton); controller->set_logoutButton(view->logoutButton); controller->set_cancelButton(view->cancelButton); + view->welcomeText = (use_gmail ?"Please enter your GMail user/password":"Username=user, Password=password"); QObject::connect(controller,SIGNAL(event_login_action(QString,QString)),model,SLOT(login(QString,QString))); QObject::connect(controller,SIGNAL(event_notify_loggedIn()),view,SLOT(notifyLogin())); QObject::connect(controller,SIGNAL(event_notify_error()),view,SLOT(notifyError())); @@ -186,7 +188,6 @@ int main(int argc, char *argv[]) QObject::connect(view->timeoutSlider,SIGNAL(valueChanged(int)),controller,SLOT(set_loginTimeout(int))); controller->start(); view->show(); - QObject::connect(view,SIGNAL(closed()),qApp,SLOT(quit())); return a.exec(); } #include -- cgit v1.2.3