Refactor the welcome page

pull/1/head
Konstantinos Sideris 7 years ago
parent b9521b0809
commit ff1bc797de
  1. 23
      include/WelcomePage.h
  2. 117
      src/WelcomePage.cc

@ -17,12 +17,6 @@
#pragma once #pragma once
#include <QHBoxLayout>
#include <QLabel>
#include <QSpacerItem>
#include <QVBoxLayout>
#include <QWidget>
#include "RaisedButton.h" #include "RaisedButton.h"
class WelcomePage : public QWidget class WelcomePage : public QWidget
@ -31,7 +25,6 @@ class WelcomePage : public QWidget
public: public:
explicit WelcomePage(QWidget *parent = 0); explicit WelcomePage(QWidget *parent = 0);
~WelcomePage();
signals: signals:
// Notify that the user wants to login in. // Notify that the user wants to login in.
@ -40,19 +33,7 @@ signals:
// Notify that the user wants to register. // Notify that the user wants to register.
void userRegister(); void userRegister();
private slots:
void onLoginButtonClicked();
void onRegisterButtonClicked();
private: private:
QVBoxLayout *top_layout_; RaisedButton *registerBtn_;
QHBoxLayout *button_layout_; RaisedButton *loginBtn_;
QLabel *intro_banner_;
QLabel *intro_text_;
QSpacerItem *button_spacer_;
RaisedButton *register_button_;
RaisedButton *login_button_;
}; };

@ -15,7 +15,7 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>. * along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
#include <QApplication> #include <QLabel>
#include <QLayout> #include <QLayout>
#include "Config.h" #include "Config.h"
@ -26,79 +26,56 @@ WelcomePage::WelcomePage(QWidget *parent)
{ {
setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
top_layout_ = new QVBoxLayout(this); auto topLayout_ = new QVBoxLayout(this);
top_layout_->setSpacing(0); topLayout_->setSpacing(20);
top_layout_->setMargin(0);
intro_banner_ = new QLabel(this); QFont headingFont("Open Sans", 23);
intro_banner_->setPixmap(QPixmap(":/logos/nheko-256.png")); QFont subTitleFont("Open Sans", 22);
intro_banner_->setAlignment(Qt::AlignCenter);
intro_text_ = new QLabel(this); auto logo_ = new QLabel(this);
logo_->setPixmap(QPixmap(":/logos/nheko-256.png"));
logo_->setAlignment(Qt::AlignCenter);
QString heading(tr("Welcome to nheko! The desktop client for the Matrix protocol.")); QString heading(tr("Welcome to nheko! The desktop client for the Matrix protocol."));
QString main(tr("Enjoy your stay!")); QString main(tr("Enjoy your stay!"));
intro_text_->setText(QString("<p align=\"center\" style=\"margin: 0; line-height: 2pt\">" auto intoTxt_ = new QLabel(heading, this);
" <span style=\" font-size:18px; color:#515151;\"> %1 </span>" intoTxt_->setFont(headingFont);
"</p>" intoTxt_->setContentsMargins(0, 20, 0, 0);
"<p align=\"center\" style=\"margin: 1pt; line-height: 2pt;\">"
" <span style=\" font-size:18px; color:#515151;\"> %2 </span>" auto subTitle = new QLabel(main, this);
"</p>") subTitle->setFont(subTitleFont);
.arg(heading) subTitle->setContentsMargins(0, 0, 0, 0);
.arg(main));
topLayout_->addStretch(1);
top_layout_->addStretch(1); topLayout_->addWidget(logo_);
top_layout_->addWidget(intro_banner_); topLayout_->addWidget(intoTxt_, 0, Qt::AlignCenter);
top_layout_->addStretch(1); topLayout_->addWidget(subTitle, 0, Qt::AlignCenter);
top_layout_->addWidget(intro_text_, 0, Qt::AlignCenter);
top_layout_->addStretch(1); auto btnLayout_ = new QHBoxLayout();
btnLayout_->setSpacing(20);
button_layout_ = new QHBoxLayout(); btnLayout_->setContentsMargins(0, 20, 0, 20);
button_layout_->setSpacing(0);
button_layout_->setContentsMargins(0, 20, 0, 80); registerBtn_ = new RaisedButton(tr("REGISTER"), this);
registerBtn_->setBackgroundColor(QColor("#333333"));
register_button_ = new RaisedButton(tr("REGISTER"), this); registerBtn_->setMinimumSize(240, 65);
register_button_->setBackgroundColor(QColor("#333333")); registerBtn_->setFontSize(conf::btn::fontSize);
register_button_->setForegroundColor(QColor("white")); registerBtn_->setCornerRadius(conf::btn::cornerRadius);
register_button_->setMinimumSize(240, 60);
register_button_->setFontSize(conf::btn::fontSize); loginBtn_ = new RaisedButton(tr("LOGIN"), this);
register_button_->setCornerRadius(conf::btn::cornerRadius); loginBtn_->setBackgroundColor(QColor("#333333"));
loginBtn_->setMinimumSize(240, 65);
login_button_ = new RaisedButton(tr("LOGIN"), this); loginBtn_->setFontSize(conf::btn::fontSize);
login_button_->setBackgroundColor(QColor("#333333")); loginBtn_->setCornerRadius(conf::btn::cornerRadius);
login_button_->setForegroundColor(QColor("white"));
login_button_->setMinimumSize(240, 60); btnLayout_->addStretch(1);
login_button_->setFontSize(conf::btn::fontSize); btnLayout_->addWidget(registerBtn_);
login_button_->setCornerRadius(conf::btn::cornerRadius); btnLayout_->addWidget(loginBtn_);
btnLayout_->addStretch(1);
button_spacer_ =
new QSpacerItem(20, 20, QSizePolicy::MinimumExpanding, QSizePolicy::Minimum); topLayout_->addLayout(btnLayout_);
topLayout_->addStretch(1);
button_layout_->addStretch(1);
button_layout_->addWidget(register_button_); connect(registerBtn_, &QPushButton::clicked, this, &WelcomePage::userRegister);
button_layout_->addItem(button_spacer_); connect(loginBtn_, &QPushButton::clicked, this, &WelcomePage::userLogin);
button_layout_->addWidget(login_button_);
button_layout_->addStretch(1);
top_layout_->addLayout(button_layout_);
connect(register_button_, SIGNAL(clicked()), this, SLOT(onRegisterButtonClicked()));
connect(login_button_, SIGNAL(clicked()), this, SLOT(onLoginButtonClicked()));
}
void
WelcomePage::onLoginButtonClicked()
{
emit userLogin();
}
void
WelcomePage::onRegisterButtonClicked()
{
emit userRegister();
}
WelcomePage::~WelcomePage()
{
} }

Loading…
Cancel
Save