diff --git a/src/dialogs/CreateRoom.cpp b/src/dialogs/CreateRoom.cpp
index 3c538b49..27407d45 100644
--- a/src/dialogs/CreateRoom.cpp
+++ b/src/dialogs/CreateRoom.cpp
@@ -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_);
@@ -55,8 +59,7 @@ 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");
@@ -64,8 +67,7 @@ CreateRoom::CreateRoom(QWidget *parent)
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");
@@ -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);
diff --git a/src/dialogs/InviteUsers.cpp b/src/dialogs/InviteUsers.cpp
index bcd163b0..8361468a 100644
--- a/src/dialogs/InviteUsers.cpp
+++ b/src/dialogs/InviteUsers.cpp
@@ -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"));
@@ -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_);
diff --git a/src/dialogs/JoinRoom.cpp b/src/dialogs/JoinRoom.cpp
index 05c0f455..1ff6bba1 100644
--- a/src/dialogs/JoinRoom.cpp
+++ b/src/dialogs/JoinRoom.cpp
@@ -14,44 +14,54 @@ 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 *)
{
QStyleOption opt;
diff --git a/src/dialogs/JoinRoom.h b/src/dialogs/JoinRoom.h
index 5919f08f..0c2f47d7 100644
--- a/src/dialogs/JoinRoom.h
+++ b/src/dialogs/JoinRoom.h
@@ -20,6 +20,9 @@ protected:
void paintEvent(QPaintEvent *event) override;
void showEvent(QShowEvent *event) override;
+private slots:
+ void handleInput();
+
private:
FlatButton *confirmBtn_;
FlatButton *cancelBtn_;
diff --git a/src/dialogs/LeaveRoom.cpp b/src/dialogs/LeaveRoom.cpp
index 9647d19f..30f8dace 100644
--- a/src/dialogs/LeaveRoom.cpp
+++ b/src/dialogs/LeaveRoom.cpp
@@ -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);
diff --git a/src/dialogs/Logout.cpp b/src/dialogs/Logout.cpp
index e2449817..f790eb92 100644
--- a/src/dialogs/Logout.cpp
+++ b/src/dialogs/Logout.cpp
@@ -31,34 +31,39 @@ using namespace dialogs;
Logout::Logout(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("OK", 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("Logout. Are you sure?"), this);
label->setFont(font);
layout->addWidget(label);
layout->addLayout(buttonLayout);
+ layout->addStretch(1);
connect(confirmBtn_, &QPushButton::clicked, [this]() { emit closing(true); });
connect(cancelBtn_, &QPushButton::clicked, [this]() { emit closing(false); });
diff --git a/src/dialogs/MemberList.cpp b/src/dialogs/MemberList.cpp
index 60c2eb0a..9757b8af 100644
--- a/src/dialogs/MemberList.cpp
+++ b/src/dialogs/MemberList.cpp
@@ -26,7 +26,7 @@ MemberItem::MemberItem(const RoomMember &member, QWidget *parent)
textLayout_->setSpacing(0);
avatar_ = new Avatar(this);
- avatar_->setSize(44);
+ avatar_->setSize(46);
avatar_->setLetter(utils::firstChar(member.display_name));
if (!member.avatar.isNull())
@@ -37,18 +37,14 @@ MemberItem::MemberItem(const RoomMember &member, QWidget *parent)
this,
[this](const QImage &img) { avatar_->setImage(img); });
- QFont nameFont, idFont;
+ QFont nameFont;
nameFont.setWeight(65);
- nameFont.setPixelSize(conf::receipts::font + 1);
- idFont.setWeight(50);
- idFont.setPixelSize(conf::receipts::font);
+ nameFont.setPointSizeF(nameFont.pointSizeF() * 1.1);
+ userId_ = new QLabel(member.user_id, this);
userName_ = new QLabel(member.display_name, this);
userName_->setFont(nameFont);
- userId_ = new QLabel(member.user_id, this);
- userId_->setFont(idFont);
-
textLayout_->addWidget(userName_);
textLayout_->addWidget(userId_);
@@ -60,12 +56,17 @@ MemberList::MemberList(const QString &room_id, QWidget *parent)
: QFrame(parent)
, room_id_{room_id}
{
- setMaximumSize(420, 380);
+ QFont doubleFont;
+ doubleFont.setPointSizeF(doubleFont.pointSizeF() * 2);
+ setMinimumWidth(QFontMetrics(doubleFont).averageCharWidth() * 30);
+ setMinimumHeight(conf::modals::MIN_WIDGET_HEIGHT);
+
+ setSizePolicy(QSizePolicy::Maximum, QSizePolicy::Maximum);
setAttribute(Qt::WA_DeleteOnClose, true);
auto layout = new QVBoxLayout(this);
- layout->setSpacing(30);
- layout->setMargin(20);
+ layout->setSpacing(conf::modals::WIDGET_SPACING);
+ layout->setMargin(conf::modals::WIDGET_MARGIN);
list_ = new QListWidget;
list_->setFrameStyle(QFrame::NoFrame);
@@ -74,7 +75,7 @@ MemberList::MemberList(const QString &room_id, QWidget *parent)
list_->setSpacing(5);
QFont font;
- font.setPixelSize(conf::headerFontSize);
+ font.setPointSizeF(font.pointSizeF() * conf::modals::LABEL_BIG_SIZE_RATIO);
topLabel_ = new QLabel(tr("Room members"), this);
topLabel_->setAlignment(Qt::AlignCenter);
diff --git a/src/dialogs/PreviewUploadOverlay.cpp b/src/dialogs/PreviewUploadOverlay.cpp
index 7e54ba4e..31167727 100644
--- a/src/dialogs/PreviewUploadOverlay.cpp
+++ b/src/dialogs/PreviewUploadOverlay.cpp
@@ -39,18 +39,23 @@ PreviewUploadOverlay::PreviewUploadOverlay(QWidget *parent)
: QWidget{parent}
, titleLabel_{this}
, fileName_{this}
- , upload_{tr("Upload"), this}
- , cancel_{tr("Cancel"), this}
+ , upload_{tr("Upload").toUpper(), this}
+ , cancel_{tr("Cancel").toUpper(), this}
{
auto hlayout = new QHBoxLayout;
+ hlayout->addStretch(1);
hlayout->addWidget(&upload_);
hlayout->addWidget(&cancel_);
+ hlayout->setSpacing(0);
+ hlayout->setMargin(0);
auto vlayout = new QVBoxLayout{this};
vlayout->addWidget(&titleLabel_);
vlayout->addWidget(&infoLabel_);
vlayout->addWidget(&fileName_);
vlayout->addLayout(hlayout);
+ vlayout->setSpacing(conf::modals::WIDGET_SPACING);
+ vlayout->setMargin(conf::modals::WIDGET_MARGIN);
connect(&upload_, &QPushButton::clicked, [this]() {
emit confirmUpload(data_, mediaType_, fileName_.text());
@@ -79,8 +84,10 @@ PreviewUploadOverlay::init()
setWindowFlags(Qt::Tool | Qt::WindowStaysOnTopHint);
setWindowModality(Qt::WindowModal);
- titleLabel_.setStyleSheet(
- QString{"font-weight: bold; font-size: %1px;"}.arg(conf::headerFontSize));
+ QFont font;
+ font.setPointSizeF(font.pointSizeF() * conf::modals::LABEL_MEDIUM_SIZE_RATIO);
+
+ titleLabel_.setFont(font);
titleLabel_.setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
titleLabel_.setAlignment(Qt::AlignCenter);
infoLabel_.setSizePolicy(QSizePolicy::Maximum, QSizePolicy::Maximum);
@@ -88,8 +95,11 @@ PreviewUploadOverlay::init()
fileName_.setAlignment(Qt::AlignCenter);
upload_.setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);
cancel_.setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);
- upload_.setFontSize(conf::btn::fontSize);
- cancel_.setFontSize(conf::btn::fontSize);
+
+ QFont buttonFont;
+ buttonFont.setPointSizeF(buttonFont.pointSizeF() * conf::modals::BUTTON_TEXT_SIZE_RATIO);
+ upload_.setFont(buttonFont);
+ cancel_.setFont(buttonFont);
if (isImage_) {
infoLabel_.setAlignment(Qt::AlignCenter);
diff --git a/src/dialogs/ReCaptcha.cpp b/src/dialogs/ReCaptcha.cpp
index 9181d588..0995e955 100644
--- a/src/dialogs/ReCaptcha.cpp
+++ b/src/dialogs/ReCaptcha.cpp
@@ -22,21 +22,24 @@ ReCaptcha::ReCaptcha(const QString &session, QWidget *parent)
setWindowModality(Qt::WindowModal);
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(8);
buttonLayout->setMargin(0);
+ QFont buttonFont;
+ buttonFont.setPointSizeF(buttonFont.pointSizeF() * conf::modals::BUTTON_TEXT_SIZE_RATIO);
+
openCaptchaBtn_ = new FlatButton("OPEN reCAPTCHA", this);
- openCaptchaBtn_->setFontSize(conf::btn::fontSize);
+ openCaptchaBtn_->setFont(buttonFont);
confirmBtn_ = new RaisedButton(tr("CONFIRM"), this);
- confirmBtn_->setFontSize(conf::btn::fontSize);
+ confirmBtn_->setFont(buttonFont);
cancelBtn_ = new RaisedButton(tr("CANCEL"), this);
- cancelBtn_->setFontSize(conf::btn::fontSize);
+ cancelBtn_->setFont(buttonFont);
buttonLayout->addStretch(1);
buttonLayout->addWidget(openCaptchaBtn_);
@@ -44,7 +47,7 @@ ReCaptcha::ReCaptcha(const QString &session, QWidget *parent)
buttonLayout->addWidget(cancelBtn_);
QFont font;
- font.setPixelSize(conf::headerFontSize);
+ font.setPointSizeF(font.pointSizeF() * conf::modals::LABEL_MEDIUM_SIZE_RATIO);
auto label = new QLabel(tr("Solve the reCAPTCHA and press the confirm button"), this);
label->setFont(font);
diff --git a/src/dialogs/ReadReceipts.cpp b/src/dialogs/ReadReceipts.cpp
index c27146ac..f3201de5 100644
--- a/src/dialogs/ReadReceipts.cpp
+++ b/src/dialogs/ReadReceipts.cpp
@@ -28,15 +28,16 @@ ReceiptItem::ReceiptItem(QWidget *parent,
textLayout_ = new QVBoxLayout;
textLayout_->setMargin(0);
- textLayout_->setSpacing(5);
+ textLayout_->setSpacing(conf::modals::TEXT_SPACING);
- QFont font;
- font.setPixelSize(conf::receipts::font);
+ QFont nameFont;
+ nameFont.setWeight(65);
+ nameFont.setPointSizeF(nameFont.pointSizeF() * 1.1);
auto displayName = Cache::displayName(room_id, user_id);
avatar_ = new Avatar(this);
- avatar_->setSize(40);
+ avatar_->setSize(44);
avatar_->setLetter(utils::firstChar(displayName));
// If it's a matrix id we use the second letter.
@@ -44,10 +45,9 @@ ReceiptItem::ReceiptItem(QWidget *parent,
avatar_->setLetter(QChar(displayName.at(1)));
userName_ = new QLabel(displayName, this);
- userName_->setFont(font);
+ userName_->setFont(nameFont);
timestamp_ = new QLabel(dateFormat(QDateTime::fromMSecsSinceEpoch(timestamp)), this);
- timestamp_->setFont(font);
textLayout_->addWidget(userName_);
textLayout_->addWidget(timestamp_);
@@ -80,20 +80,21 @@ ReceiptItem::dateFormat(const QDateTime &then) const
ReadReceipts::ReadReceipts(QWidget *parent)
: QFrame(parent)
{
- setMaximumSize(400, 350);
+ 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);
userList_ = new QListWidget;
userList_->setFrameStyle(QFrame::NoFrame);
userList_->setSelectionMode(QAbstractItemView::NoSelection);
userList_->setAttribute(Qt::WA_MacShowFocusRect, 0);
- userList_->setSpacing(5);
+ userList_->setSpacing(conf::modals::TEXT_SPACING);
QFont font;
- font.setPixelSize(conf::headerFontSize);
+ font.setPointSizeF(font.pointSizeF() * conf::modals::LABEL_MEDIUM_SIZE_RATIO);
topLabel_ = new QLabel(tr("Read receipts"), this);
topLabel_->setAlignment(Qt::AlignCenter);
|