--- a/QTfrontend/hwform.cpp Sat Jan 19 21:51:41 2013 +0400
+++ b/QTfrontend/hwform.cpp Mon Jan 21 00:07:26 2013 +0400
@@ -1336,75 +1336,77 @@
QString nickname = config->value("net/nick", "").toString();
QString password;
- if (nickname.isEmpty() || hash.isEmpty()) { //if something from login is missing, start dialog loop
-
+ //if something from login is missing, start dialog loop
+ if (nickname.isEmpty() || hash.isEmpty())
+ {
while (nickname.isEmpty() || (hash.isEmpty() && temphash.isEmpty())) //while a nickname, or both hashes are missing
{
- //open dialog
+ //open dialog
HWPasswordDialog * pwDialog = new HWPasswordDialog(this);
// make the "new account" button dialog open a browser with the registration page
connect(pwDialog->pbNewAccount, SIGNAL(clicked()), this, SLOT(openRegistrationPage()));
pwDialog->cbSave->setChecked(config->value("net/savepassword", true).toBool());
- //if nickname is present, put it into the field
- if (!nickname.isEmpty()) {
- pwDialog->leNickname->setText(nickname);
- pwDialog->lePassword->setFocus();
- }
+ //if nickname is present, put it into the field
+ if (!nickname.isEmpty()) {
+ pwDialog->leNickname->setText(nickname);
+ pwDialog->lePassword->setFocus();
+ }
+
+ //if dialog close, create an error message
+ if (pwDialog->exec() != QDialog::Accepted) {
+ delete pwDialog;
+ GoBack();
+ return;
+ }
+
+ //set nick and pass from the dialog
+ nickname = pwDialog->leNickname->text();
+ password = pwDialog->lePassword->text();
- //if dialog close, create an error message
- if (pwDialog->exec() != QDialog::Accepted) {
- delete pwDialog;
- GoBack();
- return;
- }
+ //check the nickname variable
+ if (nickname.isEmpty()) {
+ int retry = RetryDialog(tr("Hedgewars - Empty nickname"), tr("No nickname supplied."));
+ GoBack();
+ delete pwDialog;
+ if (retry) {
+ NetConnectOfficialServer();
+ }
+ return;
+ }
+
+ if (!password.isEmpty()) {
+ //calculate temphash and set it into config
+ temphash = QCryptographicHash::hash(password.toUtf8(), QCryptographicHash::Md5).toHex();
+ config->setTempHash(temphash);
- //set nick and pass from the dialog
- nickname = pwDialog->leNickname->text();
- password = pwDialog->lePassword->text();
+ //if user wants to save password
+ bool save = pwDialog->cbSave->isChecked();
+ config->setValue("net/savepassword", save);
+ if (save) // user wants to save password
+ {
+ ui.pageOptions->CBSavePassword->setChecked(true);
+ config->setPasswordHash(temphash);
+ }
+ }
+ else {
+ delete pwDialog;
+ config->setValue("net/nick", nickname);
+ config->updNetNick();
+ config->clearPasswordHash();
+ break;
+ }
- //check the nickname variable
- if (nickname.isEmpty()) {
- int retry = RetryDialog(tr("Hedgewars - Empty nickname"), tr("No nickname supplied."));
- GoBack();
delete pwDialog;
- if (retry) {
- NetConnectOfficialServer();
- }
- return;
- }
- if (!password.isEmpty()) {
- //calculate temphash and set it into config
- temphash = QCryptographicHash::hash(password.toUtf8(), QCryptographicHash::Md5).toHex();
- config->setTempHash(temphash);
-
- //if user wants to save password
- bool save = pwDialog->cbSave->isChecked();
- config->setValue("net/savepassword", save);
- if (save) // user wants to save password
- {
- config->setPasswordHash(temphash);
- }
- }
- else {
- delete pwDialog;
+ //update nickname
config->setValue("net/nick", nickname);
config->updNetNick();
- config->clearPasswordHash();
- break;
- }
- delete pwDialog;
-
- //update nickname
- config->setValue("net/nick", nickname);
- config->updNetNick();
-
- //and all the variables
- hash = config->passwordHash();
- temphash = config->tempHash();
- nickname = config->value("net/nick", "").toString();
+ //and all the variables
+ hash = config->passwordHash();
+ temphash = config->tempHash();
+ nickname = config->value("net/nick", "").toString();
}
}
--- a/QTfrontend/main.cpp Sat Jan 19 21:51:41 2013 +0400
+++ b/QTfrontend/main.cpp Mon Jan 21 00:07:26 2013 +0400
@@ -46,6 +46,11 @@
#include <signal.h>
#endif
+// Program resources
+#ifdef __APPLE__
+static CocoaInitializer * cocoaInit = NULL;
+#endif
+static FileEngineHandler * engine = NULL;
//Determines the day of easter in year
//from http://aa.usno.navy.mil/faq/docs/easter.php,adapted to C/C++
@@ -124,26 +129,31 @@
return true;
}
+// Guaranteed to be the last thing ran in the application's life time.
+// Closes resources that need to exist as long as possible.
+void closeResources(void)
+{
#ifdef __APPLE__
-static CocoaInitializer *cocoaInit = NULL;
-// Function to be called at end of program's termination on OS X to release
-// the NSAutoReleasePool contained within the CocoaInitializer.
-void releaseCocoaPool(void)
-{
if (cocoaInit != NULL)
{
delete cocoaInit;
cocoaInit = NULL;
}
+#endif
+ if (engine != NULL)
+ {
+ delete engine;
+ engine = NULL;
+ }
}
-#endif
int main(int argc, char *argv[])
{
+ // Since we're calling this first, closeResources() will be the last thing called after main() returns.
+ atexit(closeResources);
+
#ifdef __APPLE__
- // This creates the autoreleasepool that prevents leaking, and destroys it only on exit
- cocoaInit = new CocoaInitializer();
- atexit(releaseCocoaPool);
+ cocoaInit = new CocoaInitializer(); // Creates the autoreleasepool preventing cocoa object leaks on OS X.
#endif
#ifndef _WIN32
@@ -165,7 +175,7 @@
splash->show();
#endif
- FileEngineHandler engine(argv[0]);
+ engine = new FileEngineHandler(argv[0]);
app.setAttribute(Qt::AA_DontShowIconsInMenus,false);
@@ -280,11 +290,11 @@
}
// setup PhysFS
- engine.mount(datadir->absolutePath());
- engine.mount(cfgdir->absolutePath() + "/Data");
- engine.mount(cfgdir->absolutePath());
- engine.setWriteDir(cfgdir->absolutePath());
- engine.mountPacks();
+ engine->mount(datadir->absolutePath());
+ engine->mount(cfgdir->absolutePath() + "/Data");
+ engine->mount(cfgdir->absolutePath());
+ engine->setWriteDir(cfgdir->absolutePath());
+ engine->mountPacks();
checkForFile("physfs://hedgewars.ini");
--- a/QTfrontend/res/css/qt.css Sat Jan 19 21:51:41 2013 +0400
+++ b/QTfrontend/res/css/qt.css Mon Jan 21 00:07:26 2013 +0400
@@ -309,4 +309,8 @@
#hatList::item:selected {
background-color: #150A61;
+}
+
+QDialogButtonBox QPushButton {
+padding: 3px 5px;
}
\ No newline at end of file
--- a/QTfrontend/res/html/about.html Sat Jan 19 21:51:41 2013 +0400
+++ b/QTfrontend/res/html/about.html Mon Jan 21 00:07:26 2013 +0400
@@ -90,13 +90,5 @@
Natasha Korotaeva <<a href="mailto:layout@pisem.net">layout@pisem.net</a>><br>
Adam Higerd (aka ahigerd at FreeNode)
</p>
-
- <h2>What we use:</h2><p>
- %COMPILER_A_OPEN%Compiler%COMPILER_A_CLOSE%: %COMPILER%<br>
- <a href="http://www.libsdl.org/">SDL</a>: %SDL%<br>
- <a href="http://qt-project.org/">Qt</a> version: %QT%<br>
- <a href="http://icculus.org/physfs/">PhysicsFS</a> %PHYSFS%<br>
- %LIBAV%
- </p>
</body>
</html>
--- a/QTfrontend/ui/page/AbstractPage.cpp Sat Jan 19 21:51:41 2013 +0400
+++ b/QTfrontend/ui/page/AbstractPage.cpp Mon Jan 21 00:07:26 2013 +0400
@@ -40,27 +40,28 @@
void AbstractPage::initPage()
{
QGridLayout * pageLayout = new QGridLayout(this);
+ QHBoxLayout * bottomLeftLayout = new QHBoxLayout();
+ pageLayout->addLayout(bottomLeftLayout, 1, 0);
// stretch grid space for body and footer
- pageLayout->setColumnStretch(0,0);
- pageLayout->setColumnStretch(1,0);
+ pageLayout->setColumnStretch(0,1);
+ pageLayout->setColumnStretch(1,2);
pageLayout->setColumnStretch(2,1);
- pageLayout->setColumnStretch(3,0);
pageLayout->setRowStretch(0,1);
pageLayout->setRowStretch(1,0);
// add back/exit button
btnBack = formattedButton(":/res/Exit.png", true);
btnBack->setWhatsThis(tr("Go back"));
- pageLayout->addWidget(btnBack, 1, 0, 1, 1, Qt::AlignLeft | Qt::AlignBottom);
+ bottomLeftLayout->addWidget(btnBack, 0);
// add body layout as defined by the subclass
- pageLayout->addLayout(bodyLayoutDefinition(), 0, 0, 1, 4);
+ pageLayout->addLayout(bodyLayoutDefinition(), 0, 0, 1, 3);
// add left footer layout
QLayout * flld = footerLayoutLeftDefinition();
if (flld != NULL)
- pageLayout->addLayout(flld, 1, 1);
+ bottomLeftLayout->addLayout(flld, 0);
descLabel = new QLabel();
descLabel->setAlignment(Qt::AlignCenter);
@@ -68,12 +69,15 @@
descLabel->setOpenExternalLinks(true);
descLabel->setFixedHeight(50);
descLabel->setStyleSheet("font-size: 16px");
- pageLayout->addWidget(descLabel, 1, 2);
+ bottomLeftLayout->addWidget(descLabel);
+ pageLayout->addWidget(descLabel, 1, 1);
// add footer layout
QLayout * fld = footerLayoutDefinition();
if (fld != NULL)
- pageLayout->addLayout(fld, 1, 3);
+ pageLayout->addLayout(fld, 1, 2);
+
+ bottomLeftLayout->addStretch(1);
// connect signals
connect(btnBack, SIGNAL(clicked()), this, SIGNAL(goBack()));
--- a/QTfrontend/ui/widget/about.cpp Sat Jan 19 21:51:41 2013 +0400
+++ b/QTfrontend/ui/widget/about.cpp Mon Jan 21 00:07:26 2013 +0400
@@ -46,6 +46,9 @@
{
QGridLayout *mainLayout = new QGridLayout(this);
+ QVBoxLayout * leftLayout = new QVBoxLayout();
+ mainLayout->addLayout(leftLayout, 0, 0, 2, 1);
+
QLabel *imageLabel = new QLabel;
QImage image(":/res/Hedgehog.png");
imageLabel->setPixmap(QPixmap::fromImage(image));
@@ -55,7 +58,7 @@
imageLabel->setMinimumHeight(30);
imageLabel->setMaximumHeight(300);
- mainLayout->addWidget(imageLabel, 0, 0, 2, 1);
+ leftLayout->addWidget(imageLabel, 0, Qt::AlignHCenter);
QLabel *lbl1 = new QLabel(this);
lbl1->setOpenExternalLinks(true);
@@ -66,63 +69,55 @@
"</style>"
"<div align=\"center\"><h1>Hedgewars</h1>"
"<h3>" + QLabel::tr("Version") + " " + *cVersionString + "</h3>"
- "<p><a href=\"http://www.hedgewars.org/\">http://www.hedgewars.org/</a></p><br>" +
+ "<p><a href=\"http://www.hedgewars.org/\">http://www.hedgewars.org/</a></p>" +
QLabel::tr("This program is distributed under the GNU General Public License v2") +
"</div>"
);
lbl1->setWordWrap(true);
mainLayout->addWidget(lbl1, 0, 1);
- QString html;
- QFile file(":/res/html/about.html");
- if(!file.open(QIODevice::ReadOnly))
- QMessageBox::information(0, "Error loading about page", file.errorString());
-
- QTextStream in(&file);
+ lbl2 = new QTextBrowser(this);
+ lbl2->setOpenExternalLinks(true);
+ QUrl localpage = QUrl::fromLocalFile(":/res/html/about.html");
+ lbl2->setSource(localpage); //sets the source of the label from the file above
+ mainLayout->addWidget(lbl2, 1, 1);
- while(!in.atEnd())
- html.append(in.readLine());
-
- file.close();
-
- /* Get information */
+ /* Library information */
- QString compilerText, compilerOpen, compilerClose;
- #ifdef __GNUC__
- compilerText = "GCC " + QString(__VERSION__) + "\n";
- compilerOpen = "<a href=\"http://gcc.gnu.org\">";
- compilerClose = "</a>";
- #else
- compilerText = "Unknown\n";
- compilerOpen = compilerClose = "";
- #endif
+ QString libinfo = "<style type=text/css>a:link { color: #FFFF6E; }</style>";
- /* Add information */
+#ifdef __GNUC__
+ libinfo.append(QString("Compiler: <a href=\"http://gcc.gnu.org\">GCC</a> %1<br>").arg(__VERSION__));
+#else
+ libinfo.append(QString("Compiler: Unknown<br>").arg(__VERSION__));
+#endif
- html.replace("%COMPILER_A_OPEN%", compilerOpen);
- html.replace("%COMPILER_A_CLOSE%", compilerClose);
- html.replace("%COMPILER%", compilerText);
- html.replace("%SDL%", QString("version: %1.%2.%3")
+ libinfo.append(QString("<a href=\"http://www.libsdl.org/\">SDL</a> version: %1.%2.%3<br>")
.arg(SDL_MAJOR_VERSION)
.arg(SDL_MINOR_VERSION)
.arg(SDL_PATCHLEVEL));
- html.replace("%QT%", QT_VERSION_STR);
+
+ libinfo.append(QString("<a href=\"http://qt-project.org/\">Qt</a> version: %1<br>").arg(QT_VERSION_STR));
+
#ifdef VIDEOREC
- html.replace("%LIBAV%", QString("<a href=\"http://libav.org\">Libav</a> version: %1.%2.%3")
+ libinfo.append(QString("<a href=\"http://libav.org\">Libav</a> version: %1.%2.%3<br>")
.arg(LIBAVUTIL_VERSION_MAJOR)
.arg(LIBAVUTIL_VERSION_MINOR)
.arg(LIBAVUTIL_VERSION_MICRO));
#endif
- html.replace("%PHYSFS%", QString("version: %1.%2.%3")
+
+ libinfo.append(QString("<a href=\"http://icculus.org/physfs/\">PhysFS</a> version: %1.%2.%3<br>")
.arg(PHYSFS_VER_MAJOR)
.arg(PHYSFS_VER_MINOR)
.arg(PHYSFS_VER_PATCH));
- lbl2 = new QTextBrowser(this);
- lbl2->setOpenExternalLinks(true);
- lbl2->setHtml(html);
- mainLayout->addWidget(lbl2, 1, 1);
-
+ QLabel * lblLibInfo = new QLabel();
+ lblLibInfo->setText(libinfo);
+ lblLibInfo->setWordWrap(true);
+ lblLibInfo->setMaximumWidth(280);
+ leftLayout->addWidget(lblLibInfo, 0, Qt::AlignTop | Qt::AlignHCenter);
+ leftLayout->addStretch(1);
+
setAcceptDrops(true);
}