From 2b7dda3e2606cf836775cbdf6286493048686a43 Mon Sep 17 00:00:00 2001 From: konrad Date: Mon, 28 Dec 2009 14:04:37 +0000 Subject: [PATCH] moved login dialog to dialogs git-svn-id: https://silmor.de/svn/softmagic/smoke/trunk@362 6e3c4bff-ac9f-4ac1-96c5-d2ea494d3e33 --- src/dialogs/dialogs.pri | 2 + src/dialogs/login.cpp | 135 +++++++++++++++++++++++++++++++++++++++++++++++ src/dialogs/login.h | 40 ++++++++++++++ src/login.cpp | 135 ----------------------------------------------- src/login.h | 40 -------------- src/smoke.pro | 2 - 6 files changed, 177 insertions(+), 177 deletions(-) create mode 100644 src/dialogs/login.cpp create mode 100644 src/dialogs/login.h delete mode 100644 src/login.cpp delete mode 100644 src/login.h diff --git a/src/dialogs/dialogs.pri b/src/dialogs/dialogs.pri index f7aace9..b18df66 100644 --- a/src/dialogs/dialogs.pri +++ b/src/dialogs/dialogs.pri @@ -4,6 +4,7 @@ HEADERS += \ dialogs/eventsummary.h \ dialogs/orderwin.h \ dialogs/moneylog.h \ + dialogs/login.h \ dialogs/passwdchg.h SOURCES += \ @@ -12,6 +13,7 @@ SOURCES += \ dialogs/eventsummary.cpp \ dialogs/orderwin.cpp \ dialogs/moneylog.cpp \ + dialogs/login.cpp \ dialogs/passwdchg.cpp INCLUDEPATH += ./dialogs \ No newline at end of file diff --git a/src/dialogs/login.cpp b/src/dialogs/login.cpp new file mode 100644 index 0000000..363daa3 --- /dev/null +++ b/src/dialogs/login.cpp @@ -0,0 +1,135 @@ +// +// C++ Implementation: mainwindow +// +// Description: +// +// +// Author: Konrad Rosenbaum , (C) 2007 +// +// Copyright: See README/COPYING files that come with this distribution +// +// + +#include "main.h" +#include "login.h" +#include "msinterface.h" +#include "overview.h" +#include "configdialog.h" + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +MLogin::MLogin() +{ + setWindowTitle(tr("Magic Smoke Login")); + QVBoxLayout*vl; + setLayout(vl=new QVBoxLayout); + //create Menu Bar + QMenuBar*mb; + vl->setMenuBar(mb=new QMenuBar); + QMenu*m=mb->addMenu(tr("&File")); + m->addAction(tr("&Exit"),this,SLOT(close())); + m=mb->addMenu(tr("&Configure")); + m->addAction(tr("&Configuration..."),this,SLOT(configwin())); + mb->addMenu(MApplication::helpMenu()); + + //create central widget + QGridLayout*gl; + vl->addLayout(gl=new QGridLayout,10); + QLabel*lab; + int lctr=0; + gl->addWidget(lab=new QLabel(tr("Profile:")),lctr,0); + lab->setAlignment(Qt::AlignRight); + gl->addWidget(profiles=new QComboBox,lctr,1); + connect(profiles,SIGNAL(currentIndexChanged(int)),this,SLOT(loadProfile())); + gl->addWidget(lab=new QLabel(tr("Username:")),++lctr,0); + lab->setAlignment(Qt::AlignRight); + gl->addWidget(username=new QLineEdit,lctr,1); + gl->addWidget(lab=new QLabel(tr("Password:")),++lctr,0); + lab->setAlignment(Qt::AlignRight); + gl->addWidget(password=new QLineEdit,lctr,1); + password->setEchoMode(QLineEdit::Password); + connect(password,SIGNAL(returnPressed()),this,SLOT(startLogin())); + connect(username,SIGNAL(returnPressed()),password,SLOT(setFocus())); + gl->setRowStretch(++lctr,10); + QHBoxLayout *hl=new QHBoxLayout; + gl->addLayout(hl,++lctr,0,1,2); + QPushButton*p; + hl->addStretch(10); + hl->addWidget(p=new QPushButton(tr("Login")),0); + connect(p,SIGNAL(clicked()),this,SLOT(startLogin())); + initProfiles(); + loadProfile(); +} + +void MLogin::initProfiles() +{ + QSettings set; + set.beginGroup("profiles"); + QStringList prf=set.childGroups(); + profiles->clear(); + for(int i=0;iaddItem(set.value(prf[i]+"/name").toString(),prf[i]); + } +} + +void MLogin::loadProfile() +{ + QString key=profiles->itemData(profiles->currentIndex()).toString(); + QSettings set; + set.beginGroup("profiles/"+key); + username->setText(set.value("username").toString()); + password->setText(""); + password->setFocus(); +} + +void MLogin::startLogin() +{ + //make it impossible for the user to interfere + setEnabled(false); + //create request object + MSInterface *mw=new MSInterface(profiles->itemData(profiles->currentIndex()).toString()); + //check server version + if(!mw->checkServer()){ + //no need for messagebox: checkServer displays one if necessary + mw->deleteLater(); + setEnabled(true); + return; + } + //start login request + if(!mw->login(username->text(),password->text())){ + QMessageBox::warning(this,tr("Warning"),tr("Unable to log in.")); + mw->deleteLater(); + setEnabled(true); + return; + } + //initialize + mw->initialize(); + //open window + MOverview *mo=new MOverview(profiles->itemData(profiles->currentIndex()).toString()); + mo->show(); + + //make sure the application exits (only) after everything is cleaned up + qApp->setQuitOnLastWindowClosed(false); + connect(mw,SIGNAL(destroyed(QObject*)),qApp,SLOT(quit())); + + hide(); +} + +void MLogin::configwin() +{ + MConfigDialog cd; + cd.exec(); + initProfiles(); + loadProfile(); +} diff --git a/src/dialogs/login.h b/src/dialogs/login.h new file mode 100644 index 0000000..53c328e --- /dev/null +++ b/src/dialogs/login.h @@ -0,0 +1,40 @@ +// +// C++ Interface: mainwindow +// +// Description: +// +// +// Author: Konrad Rosenbaum , (C) 2007/8/9 +// +// Copyright: See README/COPYING files that come with this distribution +// +// + +#ifndef MAGICSMOKE_LOGIN_H +#define MAGICSMOKE_LOGIN_H + +#include + +class QComboBox; +class QLineEdit; + +/**login and profile configuration window*/ +class MLogin:public QDialog +{ + Q_OBJECT + public: + MLogin(); + + private: + QString sessionid; + QLineEdit*username,*password; + QComboBox*profiles; + + private slots: + void initProfiles(); + void loadProfile(); + void startLogin(); + void configwin(); +}; + +#endif diff --git a/src/login.cpp b/src/login.cpp deleted file mode 100644 index 363daa3..0000000 --- a/src/login.cpp +++ /dev/null @@ -1,135 +0,0 @@ -// -// C++ Implementation: mainwindow -// -// Description: -// -// -// Author: Konrad Rosenbaum , (C) 2007 -// -// Copyright: See README/COPYING files that come with this distribution -// -// - -#include "main.h" -#include "login.h" -#include "msinterface.h" -#include "overview.h" -#include "configdialog.h" - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -MLogin::MLogin() -{ - setWindowTitle(tr("Magic Smoke Login")); - QVBoxLayout*vl; - setLayout(vl=new QVBoxLayout); - //create Menu Bar - QMenuBar*mb; - vl->setMenuBar(mb=new QMenuBar); - QMenu*m=mb->addMenu(tr("&File")); - m->addAction(tr("&Exit"),this,SLOT(close())); - m=mb->addMenu(tr("&Configure")); - m->addAction(tr("&Configuration..."),this,SLOT(configwin())); - mb->addMenu(MApplication::helpMenu()); - - //create central widget - QGridLayout*gl; - vl->addLayout(gl=new QGridLayout,10); - QLabel*lab; - int lctr=0; - gl->addWidget(lab=new QLabel(tr("Profile:")),lctr,0); - lab->setAlignment(Qt::AlignRight); - gl->addWidget(profiles=new QComboBox,lctr,1); - connect(profiles,SIGNAL(currentIndexChanged(int)),this,SLOT(loadProfile())); - gl->addWidget(lab=new QLabel(tr("Username:")),++lctr,0); - lab->setAlignment(Qt::AlignRight); - gl->addWidget(username=new QLineEdit,lctr,1); - gl->addWidget(lab=new QLabel(tr("Password:")),++lctr,0); - lab->setAlignment(Qt::AlignRight); - gl->addWidget(password=new QLineEdit,lctr,1); - password->setEchoMode(QLineEdit::Password); - connect(password,SIGNAL(returnPressed()),this,SLOT(startLogin())); - connect(username,SIGNAL(returnPressed()),password,SLOT(setFocus())); - gl->setRowStretch(++lctr,10); - QHBoxLayout *hl=new QHBoxLayout; - gl->addLayout(hl,++lctr,0,1,2); - QPushButton*p; - hl->addStretch(10); - hl->addWidget(p=new QPushButton(tr("Login")),0); - connect(p,SIGNAL(clicked()),this,SLOT(startLogin())); - initProfiles(); - loadProfile(); -} - -void MLogin::initProfiles() -{ - QSettings set; - set.beginGroup("profiles"); - QStringList prf=set.childGroups(); - profiles->clear(); - for(int i=0;iaddItem(set.value(prf[i]+"/name").toString(),prf[i]); - } -} - -void MLogin::loadProfile() -{ - QString key=profiles->itemData(profiles->currentIndex()).toString(); - QSettings set; - set.beginGroup("profiles/"+key); - username->setText(set.value("username").toString()); - password->setText(""); - password->setFocus(); -} - -void MLogin::startLogin() -{ - //make it impossible for the user to interfere - setEnabled(false); - //create request object - MSInterface *mw=new MSInterface(profiles->itemData(profiles->currentIndex()).toString()); - //check server version - if(!mw->checkServer()){ - //no need for messagebox: checkServer displays one if necessary - mw->deleteLater(); - setEnabled(true); - return; - } - //start login request - if(!mw->login(username->text(),password->text())){ - QMessageBox::warning(this,tr("Warning"),tr("Unable to log in.")); - mw->deleteLater(); - setEnabled(true); - return; - } - //initialize - mw->initialize(); - //open window - MOverview *mo=new MOverview(profiles->itemData(profiles->currentIndex()).toString()); - mo->show(); - - //make sure the application exits (only) after everything is cleaned up - qApp->setQuitOnLastWindowClosed(false); - connect(mw,SIGNAL(destroyed(QObject*)),qApp,SLOT(quit())); - - hide(); -} - -void MLogin::configwin() -{ - MConfigDialog cd; - cd.exec(); - initProfiles(); - loadProfile(); -} diff --git a/src/login.h b/src/login.h deleted file mode 100644 index 53c328e..0000000 --- a/src/login.h +++ /dev/null @@ -1,40 +0,0 @@ -// -// C++ Interface: mainwindow -// -// Description: -// -// -// Author: Konrad Rosenbaum , (C) 2007/8/9 -// -// Copyright: See README/COPYING files that come with this distribution -// -// - -#ifndef MAGICSMOKE_LOGIN_H -#define MAGICSMOKE_LOGIN_H - -#include - -class QComboBox; -class QLineEdit; - -/**login and profile configuration window*/ -class MLogin:public QDialog -{ - Q_OBJECT - public: - MLogin(); - - private: - QString sessionid; - QLineEdit*username,*password; - QComboBox*profiles; - - private slots: - void initProfiles(); - void loadProfile(); - void startLogin(); - void configwin(); -}; - -#endif diff --git a/src/smoke.pro b/src/smoke.pro index ccdba23..f487a77 100644 --- a/src/smoke.pro +++ b/src/smoke.pro @@ -22,7 +22,6 @@ RCC_DIR = .ctmp SOURCES = \ main.cpp \ - login.cpp \ event.cpp \ order.cpp \ shipping.cpp \ @@ -30,7 +29,6 @@ SOURCES = \ HEADERS = \ main.h \ - login.h \ event.h \ order.h \ shipping.h \ -- 1.7.2.5