summary refs log tree commit diff
path: root/src/dialogs
diff options
context:
space:
mode:
authorKonstantinos Sideris <sideris.konstantin@gmail.com>2018-09-19 22:42:26 +0300
committerKonstantinos Sideris <sideris.konstantin@gmail.com>2018-09-19 22:42:26 +0300
commit1716502eff3e5108f05aba8acbabd5c9287d624c (patch)
treefe16cfce143a3350c1b1453edf47adbb5e13f665 /src/dialogs
parentci: Don't count errors during brew upgrade (diff)
downloadnheko-1716502eff3e5108f05aba8acbabd5c9287d624c.tar.xz
Improvements on the system theme
Diffstat (limited to 'src/dialogs')
-rw-r--r--src/dialogs/CreateRoom.cpp38
-rw-r--r--src/dialogs/CreateRoom.h9
-rw-r--r--src/dialogs/InviteUsers.cpp37
-rw-r--r--src/dialogs/InviteUsers.h9
-rw-r--r--src/dialogs/JoinRoom.cpp36
-rw-r--r--src/dialogs/JoinRoom.h9
-rw-r--r--src/dialogs/LeaveRoom.cpp38
-rw-r--r--src/dialogs/LeaveRoom.h11
-rw-r--r--src/dialogs/Logout.cpp41
-rw-r--r--src/dialogs/Logout.h11
-rw-r--r--src/dialogs/MemberList.cpp33
-rw-r--r--src/dialogs/MemberList.h8
-rw-r--r--src/dialogs/ReadReceipts.cpp19
-rw-r--r--src/dialogs/ReadReceipts.h3
-rw-r--r--src/dialogs/RoomSettings.cpp41
-rw-r--r--src/dialogs/RoomSettings.h7
-rw-r--r--src/dialogs/UserProfile.cpp19
-rw-r--r--src/dialogs/UserProfile.h3
18 files changed, 163 insertions, 209 deletions
diff --git a/src/dialogs/CreateRoom.cpp b/src/dialogs/CreateRoom.cpp

index 51f38fa8..bfd1e751 100644 --- a/src/dialogs/CreateRoom.cpp +++ b/src/dialogs/CreateRoom.cpp
@@ -1,12 +1,11 @@ #include <QComboBox> #include <QLabel> -#include <QStyleOption> +#include <QPushButton> #include <QVBoxLayout> #include "dialogs/CreateRoom.h" #include "Config.h" -#include "ui/FlatButton.h" #include "ui/TextField.h" #include "ui/Theme.h" #include "ui/ToggleButton.h" @@ -16,6 +15,11 @@ using namespace dialogs; CreateRoom::CreateRoom(QWidget *parent) : QFrame(parent) { + setAutoFillBackground(true); + setWindowFlags(Qt::Tool | Qt::WindowStaysOnTopHint); + setWindowModality(Qt::WindowModal); + setAttribute(Qt::WA_DeleteOnClose, true); + QFont doubleFont; doubleFont.setPointSizeF(doubleFont.pointSizeF() * 2); @@ -29,21 +33,15 @@ CreateRoom::CreateRoom(QWidget *parent) 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_->setFont(buttonFont); + buttonLayout->setSpacing(15); - cancelBtn_ = new FlatButton(tr("CANCEL"), this); - cancelBtn_->setFont(buttonFont); + confirmBtn_ = new QPushButton(tr("Create room"), this); + cancelBtn_ = new QPushButton(tr("Cancel"), this); + cancelBtn_->setDefault(true); buttonLayout->addStretch(1); - buttonLayout->addWidget(confirmBtn_); buttonLayout->addWidget(cancelBtn_); + buttonLayout->addWidget(confirmBtn_); QFont font; font.setPixelSize(conf::headerFontSize); @@ -104,15 +102,14 @@ CreateRoom::CreateRoom(QWidget *parent) request_.topic = topicInput_->text().toStdString(); request_.room_alias_name = aliasInput_->text().toStdString(); - emit closing(true, request_); + emit createRoom(request_); clearFields(); }); connect(cancelBtn_, &QPushButton::clicked, this, [this]() { - emit closing(false, request_); - clearFields(); + emit close(); }); connect(visibilityCombo_, @@ -151,15 +148,6 @@ CreateRoom::clearFields() } void -CreateRoom::paintEvent(QPaintEvent *) -{ - QStyleOption opt; - opt.init(this); - QPainter p(this); - style()->drawPrimitive(QStyle::PE_Widget, &opt, &p, this); -} - -void CreateRoom::showEvent(QShowEvent *event) { nameInput_->setFocus(); diff --git a/src/dialogs/CreateRoom.h b/src/dialogs/CreateRoom.h
index 46edebdc..22ac6a43 100644 --- a/src/dialogs/CreateRoom.h +++ b/src/dialogs/CreateRoom.h
@@ -4,7 +4,7 @@ #include <mtx.hpp> -class FlatButton; +class QPushButton; class TextField; class QComboBox; class Toggle; @@ -18,10 +18,9 @@ public: CreateRoom(QWidget *parent = nullptr); signals: - void closing(bool isCreating, const mtx::requests::CreateRoom &request); + void createRoom(const mtx::requests::CreateRoom &request); protected: - void paintEvent(QPaintEvent *event) override; void showEvent(QShowEvent *event) override; private: @@ -32,8 +31,8 @@ private: Toggle *directToggle_; - FlatButton *confirmBtn_; - FlatButton *cancelBtn_; + QPushButton *confirmBtn_; + QPushButton *cancelBtn_; TextField *nameInput_; TextField *topicInput_; diff --git a/src/dialogs/InviteUsers.cpp b/src/dialogs/InviteUsers.cpp
index 8361468a..635a205e 100644 --- a/src/dialogs/InviteUsers.cpp +++ b/src/dialogs/InviteUsers.cpp
@@ -2,6 +2,7 @@ #include <QIcon> #include <QListWidget> #include <QListWidgetItem> +#include <QPushButton> #include <QStyleOption> #include <QTimer> #include <QVBoxLayout> @@ -10,7 +11,6 @@ #include "Config.h" #include "InviteeItem.h" -#include "ui/FlatButton.h" #include "ui/TextField.h" #include "mtx.hpp" @@ -20,6 +20,11 @@ using namespace dialogs; InviteUsers::InviteUsers(QWidget *parent) : QFrame(parent) { + setAutoFillBackground(true); + setWindowFlags(Qt::Tool | Qt::WindowStaysOnTopHint); + setWindowModality(Qt::WindowModal); + setAttribute(Qt::WA_DeleteOnClose, true); + setMinimumWidth(conf::modals::MIN_WIDGET_WIDTH); setSizePolicy(QSizePolicy::Maximum, QSizePolicy::Maximum); @@ -31,18 +36,14 @@ InviteUsers::InviteUsers(QWidget *parent) buttonLayout->setSpacing(0); buttonLayout->setMargin(0); - QFont buttonFont; - buttonFont.setPointSizeF(buttonFont.pointSizeF() * conf::modals::BUTTON_TEXT_SIZE_RATIO); - - confirmBtn_ = new FlatButton("INVITE", this); - confirmBtn_->setFont(buttonFont); - - cancelBtn_ = new FlatButton(tr("CANCEL"), this); - cancelBtn_->setFont(buttonFont); + confirmBtn_ = new QPushButton("Invite", this); + cancelBtn_ = new QPushButton(tr("Cancel"), this); + cancelBtn_->setDefault(true); buttonLayout->addStretch(1); - buttonLayout->addWidget(confirmBtn_); + buttonLayout->setSpacing(15); buttonLayout->addWidget(cancelBtn_); + buttonLayout->addWidget(confirmBtn_); inviteeInput_ = new TextField(this); inviteeInput_->setLabel(tr("User ID to invite")); @@ -63,7 +64,7 @@ InviteUsers::InviteUsers(QWidget *parent) connect(inviteeInput_, &TextField::returnPressed, this, &InviteUsers::addUser); connect(confirmBtn_, &QPushButton::clicked, [this]() { - emit closing(true, invitedUsers()); + emit sendInvites(invitedUsers()); inviteeInput_->clear(); inviteeList_->clear(); @@ -71,12 +72,11 @@ InviteUsers::InviteUsers(QWidget *parent) }); connect(cancelBtn_, &QPushButton::clicked, [this]() { - QStringList emptyList; - emit closing(false, emptyList); - inviteeInput_->clear(); inviteeList_->clear(); errorLabel_->hide(); + + emit close(); }); } @@ -119,15 +119,6 @@ InviteUsers::removeInvitee(QListWidgetItem *item) inviteeList_->removeItemWidget(widget); } -void -InviteUsers::paintEvent(QPaintEvent *) -{ - QStyleOption opt; - opt.init(this); - QPainter p(this); - style()->drawPrimitive(QStyle::PE_Widget, &opt, &p, this); -} - QStringList InviteUsers::invitedUsers() const { diff --git a/src/dialogs/InviteUsers.h b/src/dialogs/InviteUsers.h
index 41e6236a..952c97a5 100644 --- a/src/dialogs/InviteUsers.h +++ b/src/dialogs/InviteUsers.h
@@ -5,7 +5,7 @@ #include <QListWidgetItem> #include <QStringList> -class FlatButton; +class QPushButton; class TextField; class QListWidget; @@ -18,11 +18,10 @@ public: explicit InviteUsers(QWidget *parent = nullptr); protected: - void paintEvent(QPaintEvent *event) override; void showEvent(QShowEvent *event) override; signals: - void closing(bool isLeaving, QStringList invitees); + void sendInvites(QStringList invitees); private slots: void removeInvitee(QListWidgetItem *item); @@ -31,8 +30,8 @@ private: void addUser(); QStringList invitedUsers() const; - FlatButton *confirmBtn_; - FlatButton *cancelBtn_; + QPushButton *confirmBtn_; + QPushButton *cancelBtn_; TextField *inviteeInput_; QLabel *errorLabel_; diff --git a/src/dialogs/JoinRoom.cpp b/src/dialogs/JoinRoom.cpp
index 1ff6bba1..135cb4f5 100644 --- a/src/dialogs/JoinRoom.cpp +++ b/src/dialogs/JoinRoom.cpp
@@ -1,11 +1,11 @@ #include <QLabel> +#include <QPushButton> #include <QStyleOption> #include <QVBoxLayout> #include "dialogs/JoinRoom.h" #include "Config.h" -#include "ui/FlatButton.h" #include "ui/TextField.h" #include "ui/Theme.h" @@ -14,6 +14,11 @@ using namespace dialogs; JoinRoom::JoinRoom(QWidget *parent) : QFrame(parent) { + setAutoFillBackground(true); + setWindowFlags(Qt::Tool | Qt::WindowStaysOnTopHint); + setWindowModality(Qt::WindowModal); + setAttribute(Qt::WA_DeleteOnClose, true); + setMinimumWidth(conf::modals::MIN_WIDGET_WIDTH); setSizePolicy(QSizePolicy::Maximum, QSizePolicy::Maximum); @@ -22,21 +27,15 @@ JoinRoom::JoinRoom(QWidget *parent) 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_->setFont(buttonFont); + buttonLayout->setSpacing(15); - cancelBtn_ = new FlatButton(tr("CANCEL"), this); - cancelBtn_->setFont(buttonFont); + confirmBtn_ = new QPushButton(tr("Join"), this); + cancelBtn_ = new QPushButton(tr("Cancel"), this); + cancelBtn_->setDefault(true); buttonLayout->addStretch(1); - buttonLayout->addWidget(confirmBtn_); buttonLayout->addWidget(cancelBtn_); + buttonLayout->addWidget(confirmBtn_); roomInput_ = new TextField(this); roomInput_->setLabel(tr("Room ID or alias")); @@ -47,7 +46,7 @@ JoinRoom::JoinRoom(QWidget *parent) connect(roomInput_, &QLineEdit::returnPressed, this, &JoinRoom::handleInput); connect(confirmBtn_, &QPushButton::clicked, this, &JoinRoom::handleInput); - connect(cancelBtn_, &QPushButton::clicked, [this]() { emit closing(false, ""); }); + connect(cancelBtn_, &QPushButton::clicked, this, &JoinRoom::close); } void @@ -57,20 +56,11 @@ JoinRoom::handleInput() return; // TODO: input validation with error messages. - emit closing(true, roomInput_->text()); + emit joinRoom(roomInput_->text()); roomInput_->clear(); } void -JoinRoom::paintEvent(QPaintEvent *) -{ - QStyleOption opt; - opt.init(this); - QPainter p(this); - style()->drawPrimitive(QStyle::PE_Widget, &opt, &p, this); -} - -void JoinRoom::showEvent(QShowEvent *event) { roomInput_->setFocus(); diff --git a/src/dialogs/JoinRoom.h b/src/dialogs/JoinRoom.h
index 0c2f47d7..257cb950 100644 --- a/src/dialogs/JoinRoom.h +++ b/src/dialogs/JoinRoom.h
@@ -2,7 +2,7 @@ #include <QFrame> -class FlatButton; +class QPushButton; class TextField; namespace dialogs { @@ -14,18 +14,17 @@ public: JoinRoom(QWidget *parent = nullptr); signals: - void closing(bool isJoining, const QString &room); + void joinRoom(const QString &room); protected: - void paintEvent(QPaintEvent *event) override; void showEvent(QShowEvent *event) override; private slots: void handleInput(); private: - FlatButton *confirmBtn_; - FlatButton *cancelBtn_; + QPushButton *confirmBtn_; + QPushButton *cancelBtn_; TextField *roomInput_; }; diff --git a/src/dialogs/LeaveRoom.cpp b/src/dialogs/LeaveRoom.cpp
index 30f8dace..5ac62615 100644 --- a/src/dialogs/LeaveRoom.cpp +++ b/src/dialogs/LeaveRoom.cpp
@@ -1,11 +1,11 @@ #include <QLabel> +#include <QPushButton> #include <QStyleOption> #include <QVBoxLayout> #include "dialogs/LeaveRoom.h" #include "Config.h" -#include "ui/FlatButton.h" #include "ui/Theme.h" using namespace dialogs; @@ -13,6 +13,11 @@ using namespace dialogs; LeaveRoom::LeaveRoom(QWidget *parent) : QFrame(parent) { + setAutoFillBackground(true); + setWindowFlags(Qt::Tool | Qt::WindowStaysOnTopHint); + setWindowModality(Qt::WindowModal); + setAttribute(Qt::WA_DeleteOnClose, true); + setMinimumWidth(conf::modals::MIN_WIDGET_WIDTH); setSizePolicy(QSizePolicy::Maximum, QSizePolicy::Maximum); @@ -24,37 +29,20 @@ LeaveRoom::LeaveRoom(QWidget *parent) buttonLayout->setSpacing(0); buttonLayout->setMargin(0); - QFont buttonFont; - buttonFont.setPointSizeF(buttonFont.pointSizeF() * conf::modals::BUTTON_TEXT_SIZE_RATIO); - - confirmBtn_ = new FlatButton("LEAVE", this); - confirmBtn_->setFont(buttonFont); - - cancelBtn_ = new FlatButton(tr("CANCEL"), this); - cancelBtn_->setFont(buttonFont); + confirmBtn_ = new QPushButton("Leave", this); + cancelBtn_ = new QPushButton(tr("Cancel"), this); + cancelBtn_->setDefault(true); buttonLayout->addStretch(1); - buttonLayout->addWidget(confirmBtn_); + buttonLayout->setSpacing(15); buttonLayout->addWidget(cancelBtn_); - - QFont font; - font.setPointSizeF(font.pointSizeF() * conf::modals::LABEL_MEDIUM_SIZE_RATIO); + buttonLayout->addWidget(confirmBtn_); auto label = new QLabel(tr("Are you sure you want to leave?"), this); - label->setFont(font); layout->addWidget(label); layout->addLayout(buttonLayout); - connect(confirmBtn_, &QPushButton::clicked, [this]() { emit closing(true); }); - connect(cancelBtn_, &QPushButton::clicked, [this]() { emit closing(false); }); -} - -void -LeaveRoom::paintEvent(QPaintEvent *) -{ - QStyleOption opt; - opt.init(this); - QPainter p(this); - style()->drawPrimitive(QStyle::PE_Widget, &opt, &p, this); + connect(confirmBtn_, &QPushButton::clicked, this, &LeaveRoom::leaving); + connect(cancelBtn_, &QPushButton::clicked, this, &LeaveRoom::close); } diff --git a/src/dialogs/LeaveRoom.h b/src/dialogs/LeaveRoom.h
index 98e4938d..a35cf04d 100644 --- a/src/dialogs/LeaveRoom.h +++ b/src/dialogs/LeaveRoom.h
@@ -2,7 +2,7 @@ #include <QFrame> -class FlatButton; +class QPushButton; namespace dialogs { @@ -12,14 +12,11 @@ class LeaveRoom : public QFrame public: explicit LeaveRoom(QWidget *parent = nullptr); -protected: - void paintEvent(QPaintEvent *event) override; - signals: - void closing(bool isLeaving); + void leaving(); private: - FlatButton *confirmBtn_; - FlatButton *cancelBtn_; + QPushButton *confirmBtn_; + QPushButton *cancelBtn_; }; } // dialogs diff --git a/src/dialogs/Logout.cpp b/src/dialogs/Logout.cpp
index 54ccb7c6..882ef915 100644 --- a/src/dialogs/Logout.cpp +++ b/src/dialogs/Logout.cpp
@@ -17,13 +17,14 @@ #include <QLabel> #include <QPaintEvent> +#include <QPainter> +#include <QPushButton> #include <QStyleOption> #include <QVBoxLayout> #include "dialogs/Logout.h" #include "Config.h" -#include "ui/FlatButton.h" #include "ui/Theme.h" using namespace dialogs; @@ -31,6 +32,11 @@ using namespace dialogs; Logout::Logout(QWidget *parent) : QFrame(parent) { + setAutoFillBackground(true); + setWindowFlags(Qt::Tool | Qt::WindowStaysOnTopHint); + setWindowModality(Qt::WindowModal); + setAttribute(Qt::WA_DeleteOnClose, true); + setMinimumWidth(conf::modals::MIN_WIDGET_WIDTH); setSizePolicy(QSizePolicy::Maximum, QSizePolicy::Maximum); @@ -42,40 +48,21 @@ Logout::Logout(QWidget *parent) buttonLayout->setSpacing(0); buttonLayout->setMargin(0); - QFont buttonFont; - buttonFont.setPointSizeF(buttonFont.pointSizeF() * conf::modals::BUTTON_TEXT_SIZE_RATIO); - - confirmBtn_ = new FlatButton("OK", this); - confirmBtn_->setFont(buttonFont); - confirmBtn_->setRippleStyle(ui::RippleStyle::NoRipple); - - cancelBtn_ = new FlatButton(tr("CANCEL"), this); - cancelBtn_->setFont(buttonFont); - cancelBtn_->setRippleStyle(ui::RippleStyle::NoRipple); + confirmBtn_ = new QPushButton("Logout", this); + cancelBtn_ = new QPushButton(tr("Cancel"), this); + cancelBtn_->setDefault(true); buttonLayout->addStretch(1); - buttonLayout->addWidget(confirmBtn_); + buttonLayout->setSpacing(15); buttonLayout->addWidget(cancelBtn_); - - QFont font; - font.setPointSizeF(font.pointSizeF() * conf::modals::LABEL_MEDIUM_SIZE_RATIO); + buttonLayout->addWidget(confirmBtn_); 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); }); -} - -void -Logout::paintEvent(QPaintEvent *) -{ - QStyleOption opt; - opt.init(this); - QPainter p(this); - style()->drawPrimitive(QStyle::PE_Widget, &opt, &p, this); + connect(confirmBtn_, &QPushButton::clicked, this, &Logout::loggingOut); + connect(cancelBtn_, &QPushButton::clicked, this, &Logout::close); } diff --git a/src/dialogs/Logout.h b/src/dialogs/Logout.h
index cfefb970..b7e962eb 100644 --- a/src/dialogs/Logout.h +++ b/src/dialogs/Logout.h
@@ -19,7 +19,7 @@ #include <QFrame> -class FlatButton; +class QPushButton; namespace dialogs { @@ -29,14 +29,11 @@ class Logout : public QFrame public: explicit Logout(QWidget *parent = nullptr); -protected: - void paintEvent(QPaintEvent *event) override; - signals: - void closing(bool isLoggingOut); + void loggingOut(); private: - FlatButton *confirmBtn_; - FlatButton *cancelBtn_; + QPushButton *confirmBtn_; + QPushButton *cancelBtn_; }; } // dialogs diff --git a/src/dialogs/MemberList.cpp b/src/dialogs/MemberList.cpp
index b353229f..bd9b1edf 100644 --- a/src/dialogs/MemberList.cpp +++ b/src/dialogs/MemberList.cpp
@@ -1,5 +1,7 @@ #include <QListWidgetItem> #include <QPainter> +#include <QPushButton> +#include <QShortcut> #include <QStyleOption> #include <QVBoxLayout> @@ -11,7 +13,6 @@ #include "Config.h" #include "Utils.h" #include "ui/Avatar.h" -#include "ui/FlatButton.h" using namespace dialogs; @@ -51,10 +52,22 @@ MemberItem::MemberItem(const RoomMember &member, QWidget *parent) topLayout_->addLayout(textLayout_, 1); } +void +MemberItem::paintEvent(QPaintEvent *) +{ + QStyleOption opt; + opt.init(this); + QPainter p(this); + style()->drawPrimitive(QStyle::PE_Widget, &opt, &p, this); +} + MemberList::MemberList(const QString &room_id, QWidget *parent) : QFrame(parent) , room_id_{room_id} { + setAutoFillBackground(true); + setWindowFlags(Qt::Tool | Qt::WindowStaysOnTopHint); + setWindowModality(Qt::WindowModal); setAttribute(Qt::WA_DeleteOnClose, true); auto layout = new QVBoxLayout(this); @@ -64,7 +77,6 @@ MemberList::MemberList(const QString &room_id, QWidget *parent) list_ = new QListWidget; list_->setFrameStyle(QFrame::NoFrame); list_->setSelectionMode(QAbstractItemView::NoSelection); - list_->setAttribute(Qt::WA_MacShowFocusRect, 0); list_->setSpacing(5); QFont doubleFont; @@ -89,7 +101,8 @@ MemberList::MemberList(const QString &room_id, QWidget *parent) list_->clear(); // Add button at the bottom. - moreBtn_ = new FlatButton(tr("SHOW MORE"), this); + moreBtn_ = new QPushButton(tr("Show more"), this); + moreBtn_->setFlat(true); auto item = new QListWidgetItem; item->setSizeHint(moreBtn_->minimumSizeHint()); item->setFlags(Qt::NoItemFlags); @@ -97,7 +110,7 @@ MemberList::MemberList(const QString &room_id, QWidget *parent) list_->insertItem(0, item); list_->setItemWidget(item, moreBtn_); - connect(moreBtn_, &FlatButton::clicked, this, [this]() { + connect(moreBtn_, &QPushButton::clicked, this, [this]() { const size_t numMembers = list_->count() - 1; if (numMembers > 0) @@ -109,6 +122,9 @@ MemberList::MemberList(const QString &room_id, QWidget *parent) } catch (const lmdb::error &e) { qCritical() << e.what(); } + + auto closeShortcut = new QShortcut(QKeySequence(tr("ESC")), this); + connect(closeShortcut, &QShortcut::activated, this, &MemberList::close); } void @@ -143,12 +159,3 @@ MemberList::addUsers(const std::vector<RoomMember> &members) list_->setItemWidget(item, user); } } - -void -MemberList::paintEvent(QPaintEvent *) -{ - QStyleOption opt; - opt.init(this); - QPainter p(this); - style()->drawPrimitive(QStyle::PE_Widget, &opt, &p, this); -} diff --git a/src/dialogs/MemberList.h b/src/dialogs/MemberList.h
index 9c3dc5dc..ac7fe94e 100644 --- a/src/dialogs/MemberList.h +++ b/src/dialogs/MemberList.h
@@ -4,7 +4,7 @@ #include <QListWidget> class Avatar; -class FlatButton; +class QPushButton; class QHBoxLayout; class QLabel; class QVBoxLayout; @@ -23,6 +23,9 @@ class MemberItem : public QWidget public: MemberItem(const RoomMember &member, QWidget *parent); +protected: + void paintEvent(QPaintEvent *) override; + private: QHBoxLayout *topLayout_; QVBoxLayout *textLayout_; @@ -43,7 +46,6 @@ public slots: void addUsers(const std::vector<RoomMember> &users); protected: - void paintEvent(QPaintEvent *event) override; void hideEvent(QHideEvent *event) override { list_->clear(); @@ -56,6 +58,6 @@ private: QString room_id_; QLabel *topLabel_; QListWidget *list_; - FlatButton *moreBtn_; + QPushButton *moreBtn_; }; } // dialogs diff --git a/src/dialogs/ReadReceipts.cpp b/src/dialogs/ReadReceipts.cpp
index 400963b5..5a36bd89 100644 --- a/src/dialogs/ReadReceipts.cpp +++ b/src/dialogs/ReadReceipts.cpp
@@ -2,6 +2,7 @@ #include <QIcon> #include <QListWidgetItem> #include <QPainter> +#include <QShortcut> #include <QStyleOption> #include <QTimer> #include <QVBoxLayout> @@ -60,6 +61,15 @@ ReceiptItem::ReceiptItem(QWidget *parent, [this](const QImage &img) { avatar_->setImage(img); }); } +void +ReceiptItem::paintEvent(QPaintEvent *) +{ + QStyleOption opt; + opt.init(this); + QPainter p(this); + style()->drawPrimitive(QStyle::PE_Widget, &opt, &p, this); +} + QString ReceiptItem::dateFormat(const QDateTime &then) const { @@ -79,6 +89,11 @@ ReceiptItem::dateFormat(const QDateTime &then) const ReadReceipts::ReadReceipts(QWidget *parent) : QFrame(parent) { + setAutoFillBackground(true); + setWindowFlags(Qt::Tool | Qt::WindowStaysOnTopHint); + setWindowModality(Qt::WindowModal); + setAttribute(Qt::WA_DeleteOnClose, true); + auto layout = new QVBoxLayout(this); layout->setSpacing(conf::modals::WIDGET_SPACING); layout->setMargin(conf::modals::WIDGET_MARGIN); @@ -86,7 +101,6 @@ ReadReceipts::ReadReceipts(QWidget *parent) userList_ = new QListWidget; userList_->setFrameStyle(QFrame::NoFrame); userList_->setSelectionMode(QAbstractItemView::NoSelection); - userList_->setAttribute(Qt::WA_MacShowFocusRect, 0); userList_->setSpacing(conf::modals::TEXT_SPACING); QFont doubleFont; @@ -107,6 +121,9 @@ ReadReceipts::ReadReceipts(QWidget *parent) layout->addWidget(topLabel_); layout->addWidget(userList_); + + auto closeShortcut = new QShortcut(QKeySequence(tr("ESC")), this); + connect(closeShortcut, &QShortcut::activated, this, &ReadReceipts::close); } void diff --git a/src/dialogs/ReadReceipts.h b/src/dialogs/ReadReceipts.h
index 5e5615df..8e1b6b75 100644 --- a/src/dialogs/ReadReceipts.h +++ b/src/dialogs/ReadReceipts.h
@@ -21,6 +21,9 @@ public: uint64_t timestamp, const QString &room_id); +protected: + void paintEvent(QPaintEvent *); + private: QString dateFormat(const QDateTime &then) const; diff --git a/src/dialogs/RoomSettings.cpp b/src/dialogs/RoomSettings.cpp
index 7409c5bd..21ddc079 100644 --- a/src/dialogs/RoomSettings.cpp +++ b/src/dialogs/RoomSettings.cpp
@@ -8,6 +8,8 @@ #include <QMimeDatabase> #include <QPainter> #include <QPixmap> +#include <QPushButton> +#include <QShortcut> #include <QShowEvent> #include <QStyleOption> #include <QVBoxLayout> @@ -54,24 +56,15 @@ EditModal::EditModal(const QString &roomId, QWidget *parent) auto layout = new QVBoxLayout(this); - QFont buttonFont; - buttonFont.setPointSizeF(buttonFont.pointSizeF() * 1.3); - - applyBtn_ = new FlatButton(tr("APPLY"), this); - applyBtn_->setFont(buttonFont); - applyBtn_->setRippleStyle(ui::RippleStyle::NoRipple); - applyBtn_->setSizePolicy(QSizePolicy::Maximum, QSizePolicy::Maximum); - - cancelBtn_ = new FlatButton(tr("CANCEL"), this); - cancelBtn_->setFont(buttonFont); - cancelBtn_->setRippleStyle(ui::RippleStyle::NoRipple); - cancelBtn_->setSizePolicy(QSizePolicy::Maximum, QSizePolicy::Maximum); + applyBtn_ = new QPushButton(tr("Apply"), this); + cancelBtn_ = new QPushButton(tr("Cancel"), this); + cancelBtn_->setDefault(true); auto btnLayout = new QHBoxLayout; - btnLayout->setMargin(5); btnLayout->addStretch(1); - btnLayout->addWidget(applyBtn_); + btnLayout->setSpacing(15); btnLayout->addWidget(cancelBtn_); + btnLayout->addWidget(applyBtn_); nameInput_ = new TextField(this); nameInput_->setLabel(tr("Name").toUpper()); @@ -172,6 +165,11 @@ RoomSettings::RoomSettings(const QString &room_id, QWidget *parent) { retrieveRoomInfo(); + setAutoFillBackground(true); + setWindowFlags(Qt::Tool | Qt::WindowStaysOnTopHint); + setWindowModality(Qt::WindowModal); + setAttribute(Qt::WA_DeleteOnClose, true); + QFont doubleFont; doubleFont.setPointSizeF(doubleFont.pointSizeF() * 2); @@ -422,6 +420,9 @@ RoomSettings::RoomSettings(const QString &room_id, QWidget *parent) stopLoadingSpinner(); resetErrorLabel(); }); + + auto closeShortcut = new QShortcut(QKeySequence(tr("ESC")), this); + connect(closeShortcut, &QShortcut::activated, this, &RoomSettings::close); } void @@ -446,9 +447,10 @@ RoomSettings::setupEditButton() connect(editFieldsBtn_, &QPushButton::clicked, this, [this]() { retrieveRoomInfo(); - auto modal = new EditModal(room_id_, this->parentWidget()); + auto modal = new EditModal(room_id_, this); modal->setFields(QString::fromStdString(info_.name), QString::fromStdString(info_.topic)); + modal->raise(); modal->show(); connect(modal, &EditModal::nameChanged, this, [this](const QString &newName) { if (roomNameLabel_) @@ -505,15 +507,6 @@ RoomSettings::showEvent(QShowEvent *event) QWidget::showEvent(event); } -void -RoomSettings::paintEvent(QPaintEvent *) -{ - QStyleOption opt; - opt.init(this); - QPainter p(this); - style()->drawPrimitive(QStyle::PE_Widget, &opt, &p, this); -} - bool RoomSettings::canChangeJoinRules(const std::string &room_id, const std::string &user_id) const { diff --git a/src/dialogs/RoomSettings.h b/src/dialogs/RoomSettings.h
index c2c81cdb..6667b68b 100644 --- a/src/dialogs/RoomSettings.h +++ b/src/dialogs/RoomSettings.h
@@ -9,6 +9,7 @@ class Avatar; class FlatButton; +class QPushButton; class QComboBox; class QHBoxLayout; class QShowEvent; @@ -100,8 +101,8 @@ private: TextField *nameInput_; TextField *topicInput_; - FlatButton *applyBtn_; - FlatButton *cancelBtn_; + QPushButton *applyBtn_; + QPushButton *cancelBtn_; }; namespace dialogs { @@ -113,13 +114,11 @@ public: RoomSettings(const QString &room_id, QWidget *parent = nullptr); signals: - void closing(); void enableEncryptionError(const QString &msg); void showErrorMessage(const QString &msg); void accessRulesUpdated(); protected: - void paintEvent(QPaintEvent *event) override; void showEvent(QShowEvent *event) override; private slots: diff --git a/src/dialogs/UserProfile.cpp b/src/dialogs/UserProfile.cpp
index 15e0a46c..54929e03 100644 --- a/src/dialogs/UserProfile.cpp +++ b/src/dialogs/UserProfile.cpp
@@ -3,6 +3,7 @@ #include <QListWidget> #include <QPaintEvent> #include <QSettings> +#include <QShortcut> #include <QStyleOption> #include <QVBoxLayout> @@ -48,6 +49,11 @@ DeviceItem::DeviceItem(DeviceInfo device, QWidget *parent) UserProfile::UserProfile(QWidget *parent) : QWidget(parent) { + setAutoFillBackground(true); + setWindowFlags(Qt::Tool | Qt::WindowStaysOnTopHint); + setWindowModality(Qt::WindowModal); + setAttribute(Qt::WA_DeleteOnClose, true); + QIcon banIcon, kickIcon, ignoreIcon, startChatIcon; banIcon.addFile(":/icons/icons/ui/do-not-disturb-rounded-sign.png"); @@ -134,6 +140,7 @@ UserProfile::UserProfile(QWidget *parent) devices_->setSelectionMode(QAbstractItemView::NoSelection); devices_->setAttribute(Qt::WA_MacShowFocusRect, 0); devices_->setSpacing(DEVICE_SPACING); + devices_->setMinimumHeight(devices_->sizeHint().height() * 1.2); devices_->hide(); QFont descriptionLabelFont; @@ -170,6 +177,9 @@ UserProfile::UserProfile(QWidget *parent) vlayout->setContentsMargins(WIDGET_MARGIN, TOP_WIDGET_MARGIN, WIDGET_MARGIN, WIDGET_MARGIN); qRegisterMetaType<std::vector<DeviceInfo>>(); + + auto closeShortcut = new QShortcut(QKeySequence(tr("ESC")), this); + connect(closeShortcut, &QShortcut::activated, this, &UserProfile::close); } void @@ -292,12 +302,3 @@ UserProfile::updateDeviceList(const QString &user_id, const std::vector<DeviceIn devicesLabel_->show(); devices_->show(); } - -void -UserProfile::paintEvent(QPaintEvent *) -{ - QStyleOption opt; - opt.init(this); - QPainter p(this); - style()->drawPrimitive(QStyle::PE_Widget, &opt, &p, this); -} diff --git a/src/dialogs/UserProfile.h b/src/dialogs/UserProfile.h
index 7dc1c0c8..0f684cda 100644 --- a/src/dialogs/UserProfile.h +++ b/src/dialogs/UserProfile.h
@@ -48,9 +48,6 @@ public: void init(const QString &userId, const QString &roomId); -protected: - void paintEvent(QPaintEvent *) override; - private slots: void updateDeviceList(const QString &user_id, const std::vector<DeviceInfo> &devices);