X-Git-Url: https://git.quassel-irc.org/?a=blobdiff_plain;f=src%2Fqtui%2Fmainpage.cpp;h=15f83a89e7c0d12c4494e489f05e8b714831d179;hb=ba4218e0fc6775c96b76100712e6d705b197154e;hp=702e60ef1f8335fd5942c94603ce2ef0da178538;hpb=5b686746c880e5cda6d5de3e08180ea4332ff222;p=quassel.git diff --git a/src/qtui/mainpage.cpp b/src/qtui/mainpage.cpp index 702e60ef..15f83a89 100644 --- a/src/qtui/mainpage.cpp +++ b/src/qtui/mainpage.cpp @@ -1,5 +1,5 @@ /*************************************************************************** - * Copyright (C) 2005-2012 by the Quassel Project * + * Copyright (C) 2005-2015 by the Quassel Project * * devel@quassel-irc.org * * * * This program is free software; you can redistribute it and/or modify * @@ -18,28 +18,43 @@ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * ***************************************************************************/ +#include #include +#include +#include #include #include "mainpage.h" +#include "coreconnectdlg.h" +#include "client.h" MainPage::MainPage(QWidget *parent) : QWidget(parent) { -} - - -void MainPage::paintEvent(QPaintEvent *event) -{ - Q_UNUSED(event); - - QPainter painter(this); - QImage img(":/pics/quassel-logo.png"); // FIXME load externally - - if (img.height() > height() || img.width() > width()) - img = img.scaled(width(), height(), Qt::KeepAspectRatio, Qt::SmoothTransformation); - - int xmargin = (width() - img.width()) / 2; - int ymargin = (height() - img.height()) / 2; - - painter.drawImage(xmargin, ymargin, img); + QVBoxLayout *layout = new QVBoxLayout(this); + layout->setAlignment(Qt::AlignCenter); + QLabel *label = new QLabel(this); + label->setPixmap(QPixmap(":/pics/quassel-logo.png")); + layout->addWidget(label); + + if (Quassel::runMode() != Quassel::Monolithic) { + QPushButton *connectButton = new QPushButton(QIcon::fromTheme("network-connect"), tr("Connect to Core...")); + connectButton->setEnabled(Client::coreConnection()->state() == CoreConnection::Disconnected); + + connect(Client::coreConnection(), &CoreConnection::stateChanged, [connectButton](CoreConnection::ConnectionState state){ + if (state == CoreConnection::Disconnected) { + connectButton->setEnabled(true); + } else { + connectButton->setDisabled(true); + } + }); + connect(connectButton, &QPushButton::clicked, [this](){ + CoreConnectDlg dlg(this); + if (dlg.exec() == QDialog::Accepted) { + AccountId accId = dlg.selectedAccount(); + if (accId.isValid()) + Client::coreConnection()->connectToCore(accId); + } + }); + layout->addWidget(connectButton); + } }