summary refs log tree commit diff
diff options
context:
space:
mode:
authorKonstantinos Sideris <sideris.konstantin@gmail.com>2018-09-21 10:55:24 +0300
committerKonstantinos Sideris <sideris.konstantin@gmail.com>2018-09-21 10:55:24 +0300
commitce26f041adf49d8281cf2248ef840313bc532dc5 (patch)
tree6657272e90457f46304c6958dcb8ac751fc3cb4a
parentClose dialogs on confirmation (diff)
downloadnheko-ce26f041adf49d8281cf2248ef840313bc532dc5.tar.xz
Add method to center widgets & clean up unused headers
-rw-r--r--src/InviteeItem.cpp24
-rw-r--r--src/InviteeItem.h4
-rw-r--r--src/Utils.cpp15
-rw-r--r--src/Utils.h5
-rw-r--r--src/dialogs/CreateRoom.cpp1
-rw-r--r--src/dialogs/JoinRoom.cpp2
-rw-r--r--src/dialogs/LeaveRoom.cpp2
-rw-r--r--src/dialogs/Logout.cpp7
-rw-r--r--src/dialogs/ReCaptcha.cpp1
-rw-r--r--src/dialogs/RoomSettings.cpp1
-rw-r--r--src/dialogs/UserProfile.cpp2
11 files changed, 28 insertions, 36 deletions
diff --git a/src/InviteeItem.cpp b/src/InviteeItem.cpp

index 6e9be0d5..906a3bfe 100644 --- a/src/InviteeItem.cpp +++ b/src/InviteeItem.cpp
@@ -1,11 +1,9 @@ #include <QHBoxLayout> +#include <QPushButton> #include "InviteeItem.h" -#include "ui/FlatButton.h" -#include "ui/Theme.h" constexpr int SidePadding = 10; -constexpr int IconSize = 13; InviteeItem::InviteeItem(mtx::identifiers::User user, QWidget *parent) : QWidget{parent} @@ -15,23 +13,11 @@ InviteeItem::InviteeItem(mtx::identifiers::User user, QWidget *parent) topLayout_->setSpacing(0); topLayout_->setContentsMargins(SidePadding, 0, 3 * SidePadding, 0); - QFont font; - font.setPixelSize(15); - - name_ = new QLabel(user_, this); - name_->setFont(font); - - QIcon removeUserIcon; - removeUserIcon.addFile(":/icons/icons/ui/remove-symbol.png"); - - removeUserBtn_ = new FlatButton(this); - removeUserBtn_->setIcon(removeUserIcon); - removeUserBtn_->setIconSize(QSize(IconSize, IconSize)); - removeUserBtn_->setFixedSize(QSize(IconSize, IconSize)); - removeUserBtn_->setRippleStyle(ui::RippleStyle::NoRipple); + name_ = new QLabel(user_, this); + removeUserBtn_ = new QPushButton(tr("Remove"), this); topLayout_->addWidget(name_); - topLayout_->addWidget(removeUserBtn_); + topLayout_->addWidget(removeUserBtn_, 0, Qt::AlignRight); - connect(removeUserBtn_, &FlatButton::clicked, this, &InviteeItem::removeItem); + connect(removeUserBtn_, &QPushButton::clicked, this, &InviteeItem::removeItem); } diff --git a/src/InviteeItem.h b/src/InviteeItem.h
index f0bdbdf0..85ff7a63 100644 --- a/src/InviteeItem.h +++ b/src/InviteeItem.h
@@ -5,7 +5,7 @@ #include "mtx.hpp" -class FlatButton; +class QPushButton; class InviteeItem : public QWidget { @@ -23,5 +23,5 @@ private: QString user_; QLabel *name_; - FlatButton *removeUserBtn_; + QPushButton *removeUserBtn_; }; diff --git a/src/Utils.cpp b/src/Utils.cpp
index 41be9e08..5feb5608 100644 --- a/src/Utils.cpp +++ b/src/Utils.cpp
@@ -384,3 +384,18 @@ utils::linkColor() return QPalette().color(QPalette::Link).name(); } + +void +utils::centerWidget(QWidget *widget, QWidget *parent) +{ + if (parent) { + widget->move(parent->geometry().center() - widget->rect().center()); + return; + } + + const QRect screenGeometry = QApplication::desktop()->screenGeometry(); + const int x = (screenGeometry.width() - widget->width()) / 2; + const int y = (screenGeometry.height() - widget->height()) / 2; + + widget->move(x, y); +} diff --git a/src/Utils.h b/src/Utils.h
index f0973a8a..bb032a1c 100644 --- a/src/Utils.h +++ b/src/Utils.h
@@ -221,6 +221,11 @@ linkifyMessage(const QString &body); QString markdownToHtml(const QString &text); +//! Retrieve the color of the links based on the current theme. QString linkColor(); + +//! Center a widget in relation to another widget. +void +centerWidget(QWidget *widget, QWidget *parent); } diff --git a/src/dialogs/CreateRoom.cpp b/src/dialogs/CreateRoom.cpp
index 7fddc3a5..46ba5a35 100644 --- a/src/dialogs/CreateRoom.cpp +++ b/src/dialogs/CreateRoom.cpp
@@ -7,7 +7,6 @@ #include "Config.h" #include "ui/TextField.h" -#include "ui/Theme.h" #include "ui/ToggleButton.h" using namespace dialogs; diff --git a/src/dialogs/JoinRoom.cpp b/src/dialogs/JoinRoom.cpp
index 284897dd..b5c26e69 100644 --- a/src/dialogs/JoinRoom.cpp +++ b/src/dialogs/JoinRoom.cpp
@@ -1,13 +1,11 @@ #include <QLabel> #include <QPushButton> -#include <QStyleOption> #include <QVBoxLayout> #include "dialogs/JoinRoom.h" #include "Config.h" #include "ui/TextField.h" -#include "ui/Theme.h" using namespace dialogs; diff --git a/src/dialogs/LeaveRoom.cpp b/src/dialogs/LeaveRoom.cpp
index 283c9025..e3aea439 100644 --- a/src/dialogs/LeaveRoom.cpp +++ b/src/dialogs/LeaveRoom.cpp
@@ -1,12 +1,10 @@ #include <QLabel> #include <QPushButton> -#include <QStyleOption> #include <QVBoxLayout> #include "dialogs/LeaveRoom.h" #include "Config.h" -#include "ui/Theme.h" using namespace dialogs; diff --git a/src/dialogs/Logout.cpp b/src/dialogs/Logout.cpp
index cf4d5587..7c44b23c 100644 --- a/src/dialogs/Logout.cpp +++ b/src/dialogs/Logout.cpp
@@ -16,16 +16,11 @@ */ #include <QLabel> -#include <QPaintEvent> -#include <QPainter> #include <QPushButton> -#include <QStyleOption> #include <QVBoxLayout> -#include "dialogs/Logout.h" - #include "Config.h" -#include "ui/Theme.h" +#include "dialogs/Logout.h" using namespace dialogs; diff --git a/src/dialogs/ReCaptcha.cpp b/src/dialogs/ReCaptcha.cpp
index 4aaa58a3..7849aa4f 100644 --- a/src/dialogs/ReCaptcha.cpp +++ b/src/dialogs/ReCaptcha.cpp
@@ -8,7 +8,6 @@ #include "Config.h" #include "MatrixClient.h" -#include "ui/Theme.h" using namespace dialogs; diff --git a/src/dialogs/RoomSettings.cpp b/src/dialogs/RoomSettings.cpp
index 21ddc079..5e285064 100644 --- a/src/dialogs/RoomSettings.cpp +++ b/src/dialogs/RoomSettings.cpp
@@ -26,7 +26,6 @@ #include "ui/LoadingIndicator.h" #include "ui/Painter.h" #include "ui/TextField.h" -#include "ui/Theme.h" #include "ui/ToggleButton.h" using namespace dialogs; diff --git a/src/dialogs/UserProfile.cpp b/src/dialogs/UserProfile.cpp
index 54929e03..5b8280f2 100644 --- a/src/dialogs/UserProfile.cpp +++ b/src/dialogs/UserProfile.cpp
@@ -1,10 +1,8 @@ #include <QHBoxLayout> #include <QLabel> #include <QListWidget> -#include <QPaintEvent> #include <QSettings> #include <QShortcut> -#include <QStyleOption> #include <QVBoxLayout> #include "AvatarProvider.h"