From: konrad Date: Fri, 31 Dec 2010 15:48:37 +0000 (+0000) Subject: size grip for login; X-Git-Url: http://git.silmor.de/gitweb/?a=commitdiff_plain;h=d854ff9bd118ac79e5c53cd46767940dd2bcfdbc;p=web%2Fkonrad%2Fsmoke.git size grip for login; configurable help menu git-svn-id: https://silmor.de/svn/softmagic/smoke/trunk@699 6e3c4bff-ac9f-4ac1-96c5-d2ea494d3e33 --- diff --git a/src/dialogs/login.cpp b/src/dialogs/login.cpp index 2dfada3..f389c51 100644 --- a/src/dialogs/login.cpp +++ b/src/dialogs/login.cpp @@ -28,6 +28,7 @@ #include #include #include +#include MLogin::MLogin() { @@ -68,6 +69,8 @@ MLogin::MLogin() QPushButton*p; hl->addStretch(10); hl->addWidget(p=new QPushButton(tr("Login")),0); + vl->addLayout(hl=new QHBoxLayout); + resizer=new QSizeGrip(this); connect(p,SIGNAL(clicked()),this,SLOT(startLogin())); initProfiles(); loadProfile(); @@ -140,3 +143,13 @@ void MLogin::configwin() initProfiles(); loadProfile(); } + +void MLogin::resizeEvent(QResizeEvent* ) +{ + resizer->resize(resizer->sizeHint()); + if (isRightToLeft()) + resizer->move(rect().bottomLeft() -resizer->rect().bottomLeft()); + else + resizer->move(rect().bottomRight() -resizer->rect().bottomRight()); + resizer->raise(); +} diff --git a/src/dialogs/login.h b/src/dialogs/login.h index 5929ac2..04d9d66 100644 --- a/src/dialogs/login.h +++ b/src/dialogs/login.h @@ -17,6 +17,7 @@ class QComboBox; class QLineEdit; +class QSizeGrip; /**login and profile configuration window*/ class MLogin:public QWidget @@ -29,6 +30,10 @@ class MLogin:public QWidget QString sessionid; QLineEdit*username,*password; QComboBox*profiles; + QSizeGrip*resizer; + + protected: + void resizeEvent(QResizeEvent *); private slots: void initProfiles(); diff --git a/src/main.cpp b/src/main.cpp index c05c65e..f7ded2d 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -12,6 +12,8 @@ #include #include +#include +#include #include #include #include @@ -19,6 +21,7 @@ #include #include #include +#include #include #include @@ -62,7 +65,7 @@ QString dataDir; #include -void initDataDir() +static void initDataDir() { #ifdef Q_OS_WIN32 dataDir=getenv("APPDATA"); @@ -74,15 +77,7 @@ void initDataDir() dataDir+="/.magicSmoke2"; } -QMenu* MApplication::helpMenu() -{ - QMenu*m=new QMenu(tr("&Help")); - m->addAction("&Help",qApp,SLOT(help())); - m->addSeparator(); - m->addAction("About &MagicSmoke",qApp,SLOT(aboutMS())); - m->addAction("About &Qt",qApp,SLOT(aboutQt())); - return m; -} +#define HOMEPAGE_BASEURL "http://smoke.silmor.de" void MApplication::aboutMS() { @@ -90,10 +85,10 @@ void MApplication::aboutMS() mb.setIconPixmap(QPixmap(":/icon.png")); mb.setWindowTitle(tr("About MagicSmoke")); mb.setText(tr( "

MagicSmoke %3

" - "© Konrad Rosenbaum, 2007-2010
" + "© Konrad Rosenbaum, 2007-2011
" "© Peter Keller, 2007-2008
" "protected under the GNU GPL v.3 or at your option any newer

" - "See also the MagicSmoke Homepage.

" + "See also the MagicSmoke Homepage.

" "This version was compiled from repository '%1' revision '%2'."). arg(MSInterface::repoPart()). // %1 arg(MInterface::svnVersion()). //%2 @@ -103,18 +98,74 @@ void MApplication::aboutMS() mb.exec(); } +static QList > helpUrl; + +static void initHelpUrl() +{ + //check file exists, if not initialize it + QFile fd(dataDir+"/helpMenu.xml"); + if(!fd.exists()){ + fd.open(QIODevice::WriteOnly); + fd.write(QByteArray("\n\tdefault://\n")); + fd.close(); + }; + //try to open + if(fd.open(QIODevice::ReadOnly)){ + //read config + QDomDocument doc; + doc.setContent(&fd); + QDomNodeList nl=doc.elementsByTagName("Item"); + for(int i=0;i(el.attribute("label").trimmed(), el.text().trimmed())); + } + } + //fallback + if(helpUrl.size()<1) + helpUrl<("&Help","default://"); +} + +QMenu* MApplication::helpMenu() +{ + QMenu*m=new QMenu(tr("&Help")); + QSignalMapper *map=new QSignalMapper(m); + connect(map,SIGNAL(mapped(int)),qApp,SLOT(help(int))); + for(int i=0;iaddAction(helpUrl[i].first,map,SLOT(map())); + map->setMapping(a,i); + } + m->addSeparator(); + m->addAction("About &MagicSmoke",qApp,SLOT(aboutMS())); + m->addAction("About &Qt",qApp,SLOT(aboutQt())); + return m; +} + void MApplication::help() { QString d=QApplication::applicationDirPath()+"/doc/index.html"; if(!QFile(d).exists()){ - d="http://smoke.silmor.de/doc/"+MSInterface::repoPart()+"/index.html"; + d=HOMEPAGE_BASEURL "/doc/"+MSInterface::repoPart()+"/index.html"; }else d="file:///"+d; QDesktopServices::openUrl(QUrl(d)); } +void MApplication::help(int idx) +{ + if(idx<0 || idx>=helpUrl.size()){ + help(); + return; + } + QString url=helpUrl[idx].second; + if(url=="default://" || url=="") + help(); + else + QDesktopServices::openUrl(QUrl(url)); +} + MApplication::MApplication(int&ac,char**av) :QApplication(ac,av) -{} +{ +} void MApplication::setMyStyle() { @@ -173,6 +224,9 @@ int main(int argc,char**argv) //initialize log file initDebug(); + //init help menu layout + initHelpUrl(); + //check/generate profile if(!QSettings().childGroups().contains("profiles")){ QMessageBox::warning(0,app.translate("initprofile","Initial Profile Warning"), app.translate("initprofile","You need a profile to work with Magic Smoke. Please create one now.")); diff --git a/src/main.h b/src/main.h index d22bfcc..488a35f 100644 --- a/src/main.h +++ b/src/main.h @@ -37,6 +37,7 @@ class MApplication:public QApplication //help menu void aboutMS(); void help(); + void help(int); }; #endif