Skip to content
This repository has been archived by the owner on Oct 17, 2019. It is now read-only.

Commit

Permalink
Remove pixel values from modals, use pointSize instead
Browse files Browse the repository at this point in the history
  • Loading branch information
mujx committed Jul 22, 2018
1 parent 24bad93 commit 3d2e29b
Show file tree
Hide file tree
Showing 12 changed files with 154 additions and 99 deletions.
18 changes: 18 additions & 0 deletions src/Config.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,24 @@ namespace dialogs {
constexpr int labelSize = 15;
}

namespace modals {
constexpr int MIN_WIDGET_WIDTH = 400;
constexpr int MIN_WIDGET_HEIGHT = 400;

constexpr int WIDGET_MARGIN = 20;
constexpr int WIDGET_SPACING = 15;
constexpr int WIDGET_TOP_MARGiN = 2 * WIDGET_MARGIN;

constexpr int TEXT_SPACING = 4;

constexpr int BUTTON_SIZE = 36;
constexpr int BUTTON_RADIUS = BUTTON_SIZE / 2;

constexpr float BUTTON_TEXT_SIZE_RATIO = 1.3;
constexpr float LABEL_MEDIUM_SIZE_RATIO = 1.3;
constexpr float LABEL_BIG_SIZE_RATIO = 2;
}

namespace strings {
const QString url_html = "<a href=\"\\1\">\\1</a>";
const QRegExp url_regex(
Expand Down
36 changes: 18 additions & 18 deletions src/UserSettingsPage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -118,8 +118,8 @@ UserSettingsPage::UserSettingsPage(QSharedPointer<UserSettings> settings, QWidge
backBtn_->setIcon(icon);
backBtn_->setIconSize(QSize(24, 24));

auto heading_ = new QLabel(tr("User Settings"));
heading_->setStyleSheet("font-weight: bold; font-size: 22px;");
QFont font;
font.setPointSizeF(font.pointSizeF() * 1.1);

auto versionInfo = new QLabel(QString("%1 | %2").arg(nheko::version).arg(nheko::build_os));
versionInfo->setTextInteractionFlags(Qt::TextBrowserInteraction);
Expand All @@ -128,80 +128,80 @@ UserSettingsPage::UserSettingsPage(QSharedPointer<UserSettings> settings, QWidge
topBarLayout_->setSpacing(0);
topBarLayout_->setMargin(0);
topBarLayout_->addWidget(backBtn_, 1, Qt::AlignLeft | Qt::AlignVCenter);
topBarLayout_->addWidget(heading_, 0, Qt::AlignBottom);
topBarLayout_->addStretch(1);

auto trayOptionLayout_ = new QHBoxLayout;
trayOptionLayout_->setContentsMargins(0, OptionMargin, 0, OptionMargin);
auto trayLabel = new QLabel(tr("Minimize to tray"), this);
trayToggle_ = new Toggle(this);
trayLabel->setStyleSheet("font-size: 15px;");
trayLabel->setFont(font);
trayToggle_ = new Toggle(this);

trayOptionLayout_->addWidget(trayLabel);
trayOptionLayout_->addWidget(trayToggle_, 0, Qt::AlignBottom | Qt::AlignRight);

auto startInTrayOptionLayout_ = new QHBoxLayout;
startInTrayOptionLayout_->setContentsMargins(0, OptionMargin, 0, OptionMargin);
auto startInTrayLabel = new QLabel(tr("Start in tray"), this);
startInTrayToggle_ = new Toggle(this);
startInTrayLabel->setFont(font);
startInTrayToggle_ = new Toggle(this);
if (!settings_->isTrayEnabled())
startInTrayToggle_->setDisabled(true);
startInTrayLabel->setStyleSheet("font-size: 15px;");

startInTrayOptionLayout_->addWidget(startInTrayLabel);
startInTrayOptionLayout_->addWidget(
startInTrayToggle_, 0, Qt::AlignBottom | Qt::AlignRight);

auto orderRoomLayout = new QHBoxLayout;
orderRoomLayout->setContentsMargins(0, OptionMargin, 0, OptionMargin);
auto orderLabel = new QLabel(tr("Re-order rooms based on activity"), this);
auto orderLabel = new QLabel(tr("Re-order rooms based on activity"), this);
orderLabel->setFont(font);
roomOrderToggle_ = new Toggle(this);
orderLabel->setStyleSheet("font-size: 15px;");

orderRoomLayout->addWidget(orderLabel);
orderRoomLayout->addWidget(roomOrderToggle_, 0, Qt::AlignBottom | Qt::AlignRight);

auto groupViewLayout = new QHBoxLayout;
groupViewLayout->setContentsMargins(0, OptionMargin, 0, OptionMargin);
auto groupViewLabel = new QLabel(tr("Group's sidebar"), this);
groupViewToggle_ = new Toggle(this);
groupViewLabel->setStyleSheet("font-size: 15px;");
groupViewLabel->setFont(font);
groupViewToggle_ = new Toggle(this);

groupViewLayout->addWidget(groupViewLabel);
groupViewLayout->addWidget(groupViewToggle_, 0, Qt::AlignBottom | Qt::AlignRight);

auto typingLayout = new QHBoxLayout;
typingLayout->setContentsMargins(0, OptionMargin, 0, OptionMargin);
auto typingLabel = new QLabel(tr("Typing notifications"), this);
auto typingLabel = new QLabel(tr("Typing notifications"), this);
typingLabel->setFont(font);
typingNotifications_ = new Toggle(this);
typingLabel->setStyleSheet("font-size: 15px;");

typingLayout->addWidget(typingLabel);
typingLayout->addWidget(typingNotifications_, 0, Qt::AlignBottom | Qt::AlignRight);

auto receiptsLayout = new QHBoxLayout;
receiptsLayout->setContentsMargins(0, OptionMargin, 0, OptionMargin);
auto receiptsLabel = new QLabel(tr("Read receipts"), this);
readReceipts_ = new Toggle(this);
receiptsLabel->setStyleSheet("font-size: 15px;");
receiptsLabel->setFont(font);
readReceipts_ = new Toggle(this);

receiptsLayout->addWidget(receiptsLabel);
receiptsLayout->addWidget(readReceipts_, 0, Qt::AlignBottom | Qt::AlignRight);

auto themeOptionLayout_ = new QHBoxLayout;
themeOptionLayout_->setContentsMargins(0, OptionMargin, 0, OptionMargin);
auto themeLabel_ = new QLabel(tr("Theme"), this);
themeCombo_ = new QComboBox(this);
themeLabel_->setFont(font);
themeCombo_ = new QComboBox(this);
themeCombo_->addItem("Light");
themeCombo_->addItem("Dark");
themeCombo_->addItem("System");
themeLabel_->setStyleSheet("font-size: 15px;");

themeOptionLayout_->addWidget(themeLabel_);
themeOptionLayout_->addWidget(themeCombo_, 0, Qt::AlignBottom | Qt::AlignRight);

font.setWeight(65);
auto general_ = new QLabel(tr("GENERAL"), this);
general_->setStyleSheet("font-size: 17px");
general_->setFont(font);

mainLayout_ = new QVBoxLayout;
mainLayout_->setSpacing(7);
Expand Down
23 changes: 12 additions & 11 deletions src/dialogs/CreateRoom.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,21 +16,25 @@ using namespace dialogs;
CreateRoom::CreateRoom(QWidget *parent)
: QFrame(parent)
{
setMaximumSize(520, 600);
setMinimumSize(conf::modals::MIN_WIDGET_WIDTH, conf::modals::MIN_WIDGET_HEIGHT);
setSizePolicy(QSizePolicy::Maximum, QSizePolicy::Maximum);

auto layout = new QVBoxLayout(this);
layout->setSpacing(30);
layout->setMargin(20);
layout->setSpacing(conf::modals::WIDGET_SPACING);
layout->setMargin(conf::modals::WIDGET_MARGIN);

auto buttonLayout = new QHBoxLayout();
buttonLayout->setSpacing(0);
buttonLayout->setMargin(0);

QFont buttonFont;
buttonFont.setPointSizeF(buttonFont.pointSizeF() * conf::modals::BUTTON_TEXT_SIZE_RATIO);

confirmBtn_ = new FlatButton("CREATE", this);
confirmBtn_->setFontSize(conf::btn::fontSize);
confirmBtn_->setFont(buttonFont);

cancelBtn_ = new FlatButton(tr("CANCEL"), this);
cancelBtn_->setFontSize(conf::btn::fontSize);
cancelBtn_->setFont(buttonFont);

buttonLayout->addStretch(1);
buttonLayout->addWidget(confirmBtn_);
Expand All @@ -55,17 +59,15 @@ CreateRoom::CreateRoom(QWidget *parent)
presetLayout->setContentsMargins(0, 10, 0, 10);

auto visibilityLabel = new QLabel(tr("Room Visibility"), this);
visibilityLabel->setStyleSheet(QString("font-size: %1px;").arg(conf::dialogs::labelSize));
visibilityCombo_ = new QComboBox(this);
visibilityCombo_ = new QComboBox(this);
visibilityCombo_->addItem("Private");
visibilityCombo_->addItem("Public");

visibilityLayout->addWidget(visibilityLabel);
visibilityLayout->addWidget(visibilityCombo_, 0, Qt::AlignBottom | Qt::AlignRight);

auto presetLabel = new QLabel(tr("Room Preset"), this);
presetLabel->setStyleSheet(QString("font-size: %1px;").arg(conf::dialogs::labelSize));
presetCombo_ = new QComboBox(this);
presetCombo_ = new QComboBox(this);
presetCombo_->addItem("Private Chat");
presetCombo_->addItem("Public Chat");
presetCombo_->addItem("Trusted Private Chat");
Expand All @@ -74,8 +76,7 @@ CreateRoom::CreateRoom(QWidget *parent)
presetLayout->addWidget(presetCombo_, 0, Qt::AlignBottom | Qt::AlignRight);

auto directLabel_ = new QLabel(tr("Direct Chat"), this);
directLabel_->setStyleSheet(QString("font-size: %1px;").arg(conf::dialogs::labelSize));
directToggle_ = new Toggle(this);
directToggle_ = new Toggle(this);
directToggle_->setActiveColor(QColor("#38A3D8"));
directToggle_->setInactiveColor(QColor("gray"));
directToggle_->setState(true);
Expand Down
19 changes: 9 additions & 10 deletions src/dialogs/InviteUsers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,29 +20,30 @@ using namespace dialogs;
InviteUsers::InviteUsers(QWidget *parent)
: QFrame(parent)
{
setMaximumSize(400, 350);
setMinimumWidth(conf::modals::MIN_WIDGET_WIDTH);
setSizePolicy(QSizePolicy::Maximum, QSizePolicy::Maximum);

auto layout = new QVBoxLayout(this);
layout->setSpacing(30);
layout->setMargin(20);
layout->setSpacing(conf::modals::WIDGET_SPACING);
layout->setMargin(conf::modals::WIDGET_MARGIN);

auto buttonLayout = new QHBoxLayout();
buttonLayout->setSpacing(0);
buttonLayout->setMargin(0);

QFont buttonFont;
buttonFont.setPointSizeF(buttonFont.pointSizeF() * conf::modals::BUTTON_TEXT_SIZE_RATIO);

confirmBtn_ = new FlatButton("INVITE", this);
confirmBtn_->setFontSize(conf::btn::fontSize);
confirmBtn_->setFont(buttonFont);

cancelBtn_ = new FlatButton(tr("CANCEL"), this);
cancelBtn_->setFontSize(conf::btn::fontSize);
cancelBtn_->setFont(buttonFont);

buttonLayout->addStretch(1);
buttonLayout->addWidget(confirmBtn_);
buttonLayout->addWidget(cancelBtn_);

QFont font;
font.setPixelSize(conf::headerFontSize);

inviteeInput_ = new TextField(this);
inviteeInput_->setLabel(tr("User ID to invite"));

Expand All @@ -54,8 +55,6 @@ InviteUsers::InviteUsers(QWidget *parent)

errorLabel_ = new QLabel(this);
errorLabel_->setAlignment(Qt::AlignCenter);
font.setPixelSize(12);
errorLabel_->setFont(font);

layout->addWidget(inviteeInput_);
layout->addWidget(errorLabel_);
Expand Down
36 changes: 23 additions & 13 deletions src/dialogs/JoinRoom.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,43 +14,53 @@ using namespace dialogs;
JoinRoom::JoinRoom(QWidget *parent)
: QFrame(parent)
{
setMaximumSize(400, 400);
setMinimumWidth(conf::modals::MIN_WIDGET_WIDTH);
setSizePolicy(QSizePolicy::Maximum, QSizePolicy::Maximum);

auto layout = new QVBoxLayout(this);
layout->setSpacing(30);
layout->setMargin(20);
layout->setSpacing(conf::modals::WIDGET_SPACING);
layout->setMargin(conf::modals::WIDGET_MARGIN);

auto buttonLayout = new QHBoxLayout();
buttonLayout->setSpacing(0);
buttonLayout->setMargin(0);

QFont buttonFont;
buttonFont.setPointSizeF(buttonFont.pointSizeF() * conf::modals::BUTTON_TEXT_SIZE_RATIO);

confirmBtn_ = new FlatButton("JOIN", this);
confirmBtn_->setFontSize(conf::btn::fontSize);
confirmBtn_->setFont(buttonFont);

cancelBtn_ = new FlatButton(tr("CANCEL"), this);
cancelBtn_->setFontSize(conf::btn::fontSize);
cancelBtn_->setFont(buttonFont);

buttonLayout->addStretch(1);
buttonLayout->addWidget(confirmBtn_);
buttonLayout->addWidget(cancelBtn_);

QFont font;
font.setPixelSize(conf::headerFontSize);

roomInput_ = new TextField(this);
roomInput_->setLabel(tr("Room ID or alias"));

layout->addWidget(roomInput_);
layout->addLayout(buttonLayout);
layout->addStretch(1);

// TODO: input validation with error messages.
connect(confirmBtn_, &QPushButton::clicked, [this]() {
emit closing(true, roomInput_->text());
roomInput_->clear();
});
connect(roomInput_, &QLineEdit::returnPressed, this, &JoinRoom::handleInput);
connect(confirmBtn_, &QPushButton::clicked, this, &JoinRoom::handleInput);
connect(cancelBtn_, &QPushButton::clicked, [this]() { emit closing(false, ""); });
}

void
JoinRoom::handleInput()
{
if (roomInput_->text().isEmpty())
return;

// TODO: input validation with error messages.
emit closing(true, roomInput_->text());
roomInput_->clear();
}

void
JoinRoom::paintEvent(QPaintEvent *)
{
Expand Down
3 changes: 3 additions & 0 deletions src/dialogs/JoinRoom.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@ class JoinRoom : public QFrame
void paintEvent(QPaintEvent *event) override;
void showEvent(QShowEvent *event) override;

private slots:
void handleInput();

private:
FlatButton *confirmBtn_;
FlatButton *cancelBtn_;
Expand Down
16 changes: 10 additions & 6 deletions src/dialogs/LeaveRoom.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,28 +13,32 @@ using namespace dialogs;
LeaveRoom::LeaveRoom(QWidget *parent)
: QFrame(parent)
{
setMaximumSize(400, 400);
setMinimumWidth(conf::modals::MIN_WIDGET_WIDTH);
setSizePolicy(QSizePolicy::Maximum, QSizePolicy::Maximum);

auto layout = new QVBoxLayout(this);
layout->setSpacing(30);
layout->setMargin(20);
layout->setSpacing(conf::modals::WIDGET_SPACING);
layout->setMargin(conf::modals::WIDGET_MARGIN);

auto buttonLayout = new QHBoxLayout();
buttonLayout->setSpacing(0);
buttonLayout->setMargin(0);

QFont buttonFont;
buttonFont.setPointSizeF(buttonFont.pointSizeF() * conf::modals::BUTTON_TEXT_SIZE_RATIO);

confirmBtn_ = new FlatButton("LEAVE", this);
confirmBtn_->setFontSize(conf::btn::fontSize);
confirmBtn_->setFont(buttonFont);

cancelBtn_ = new FlatButton(tr("CANCEL"), this);
cancelBtn_->setFontSize(conf::btn::fontSize);
cancelBtn_->setFont(buttonFont);

buttonLayout->addStretch(1);
buttonLayout->addWidget(confirmBtn_);
buttonLayout->addWidget(cancelBtn_);

QFont font;
font.setPixelSize(conf::headerFontSize);
font.setPointSizeF(font.pointSizeF() * conf::modals::LABEL_MEDIUM_SIZE_RATIO);

auto label = new QLabel(tr("Are you sure you want to leave?"), this);
label->setFont(font);
Expand Down
Loading

0 comments on commit 3d2e29b

Please sign in to comment.