Add method to center widgets & clean up unused headers

This commit is contained in:
Konstantinos Sideris 2018-09-21 10:55:24 +03:00
parent ecc346a6da
commit ce26f041ad
11 changed files with 28 additions and 36 deletions

View file

@ -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);
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);
}

View file

@ -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_;
};

View file

@ -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);
}

View file

@ -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);
}

View file

@ -7,7 +7,6 @@
#include "Config.h"
#include "ui/TextField.h"
#include "ui/Theme.h"
#include "ui/ToggleButton.h"
using namespace dialogs;

View file

@ -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;

View file

@ -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;

View file

@ -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;

View file

@ -8,7 +8,6 @@
#include "Config.h"
#include "MatrixClient.h"
#include "ui/Theme.h"
using namespace dialogs;

View file

@ -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;

View file

@ -1,10 +1,8 @@
#include <QHBoxLayout>
#include <QLabel>
#include <QListWidget>
#include <QPaintEvent>
#include <QSettings>
#include <QShortcut>
#include <QStyleOption>
#include <QVBoxLayout>
#include "AvatarProvider.h"