Added 'auto connect' checkbox to connect dialog. When the main window becomes active for the first time and auto connect is set to true, it will call connectToServer at that point.

This commit is contained in:
Antony Woods 2014-08-27 21:25:11 +01:00
parent 6f319c8b63
commit b381298981
6 changed files with 66 additions and 3 deletions

View file

@ -359,7 +359,7 @@ void MainWindow::createMenus()
}
MainWindow::MainWindow(QWidget *parent)
: QMainWindow(parent), localServer(0)
: QMainWindow(parent), localServer(0), bHasActivated(false)
{
QPixmapCache::setCacheLimit(200000);
@ -417,5 +417,16 @@ void MainWindow::changeEvent(QEvent *event)
{
if (event->type() == QEvent::LanguageChange)
retranslateUi();
else if(event->type() == QEvent::ActivationChange) {
if(isActiveWindow() && !bHasActivated){
bHasActivated = true;
if(settingsCache->getAutoConnect()) {
qDebug() << "Attempting auto-connect...";
DlgConnect dlg(this);
client->connectToServer(dlg.getHost(), dlg.getPort(), dlg.getPlayerName(), dlg.getPassword());
}
}
}
QMainWindow::changeEvent(event);
}