Use system color scheme (using a Qt stylesheet) #104

The color scheme of nheko obeys the default color theme of Qt
(i.e. the system theme). It uses a Qt stylesheet to accomplish this,
which means replacing the color theme with a custom theme would only
be a matter of writing a new style sheet and loading it into the app.
This commit is contained in:
Max Sandholm 2017-11-16 16:33:52 +02:00 committed by Konstantinos Sideris
parent 21fdb26bd4
commit 19b526d453
29 changed files with 328 additions and 97 deletions

View file

@ -38,6 +38,19 @@ struct DescInfo
class RoomInfoListItem : public QWidget
{
Q_OBJECT
Q_PROPERTY(QColor highlightedBackgroundColor READ highlightedBackgroundColor WRITE
setHighlightedBackgroundColor)
Q_PROPERTY(
QColor hoverBackgroundColor READ hoverBackgroundColor WRITE setHoverBackgroundColor)
Q_PROPERTY(QColor backgroundColor READ backgroundColor WRITE setBackgroundColor)
Q_PROPERTY(QColor titleColor READ titleColor WRITE setTitleColor)
Q_PROPERTY(QColor subtitleColor READ subtitleColor WRITE setSubtitleColor)
Q_PROPERTY(
QColor highlightedTitleColor READ highlightedTitleColor WRITE setHighlightedTitleColor)
Q_PROPERTY(QColor highlightedSubtitleColor READ highlightedSubtitleColor WRITE
setHighlightedSubtitleColor)
public:
RoomInfoListItem(QSharedPointer<RoomSettings> settings,
@ -51,13 +64,39 @@ public:
void clearUnreadMessageCount();
void setState(const RoomState &state);
bool isPressed() const { return isPressed_; };
RoomState state() const { return state_; };
int unreadMessageCount() const { return unreadMsgCount_; };
bool isPressed() const { return isPressed_; }
RoomState state() const { return state_; }
int unreadMessageCount() const { return unreadMsgCount_; }
void setAvatar(const QImage &avatar_image);
void setDescriptionMessage(const DescInfo &info);
inline QColor highlightedBackgroundColor() const { return highlightedBackgroundColor_; }
inline QColor hoverBackgroundColor() const { return hoverBackgroundColor_; }
inline QColor backgroundColor() const { return backgroundColor_; }
inline QColor highlightedTitleColor() const { return highlightedTitleColor_; }
inline QColor highlightedSubtitleColor() const { return highlightedSubtitleColor_; }
inline QColor titleColor() const { return titleColor_; }
inline QColor subtitleColor() const { return subtitleColor_; }
inline void setHighlightedBackgroundColor(QColor &color)
{
highlightedBackgroundColor_ = color;
}
inline void setHoverBackgroundColor(QColor &color) { hoverBackgroundColor_ = color; }
inline void setBackgroundColor(QColor &color) { backgroundColor_ = color; }
inline void setHighlightedTitleColor(QColor &color) { highlightedTitleColor_ = color; }
inline void setHighlightedSubtitleColor(QColor &color)
{
highlightedSubtitleColor_ = color;
}
inline void setTitleColor(QColor &color) { titleColor_ = color; }
inline void setSubtitleColor(QColor &color) { subtitleColor_ = color; }
signals:
void clicked(const QString &room_id);
void leaveRoom(const QString &room_id);
@ -98,4 +137,14 @@ private:
int maxHeight_;
int unreadMsgCount_ = 0;
QColor highlightedBackgroundColor_;
QColor hoverBackgroundColor_;
QColor backgroundColor_;
QColor highlightedTitleColor_;
QColor highlightedSubtitleColor_;
QColor titleColor_;
QColor subtitleColor_;
};

View file

@ -76,7 +76,7 @@ public:
public slots:
void openFileSelection();
void hideUploadSpinner();
void focusLineEdit() { input_->setFocus(); };
void focusLineEdit() { input_->setFocus(); }
private slots:
void addSelectedEmoji(const QString &emoji);
@ -91,7 +91,8 @@ signals:
void stoppedTyping();
protected:
void focusInEvent(QFocusEvent *event);
void focusInEvent(QFocusEvent *event) override;
void paintEvent(QPaintEvent *) override;
private:
void showUploadSpinner();

View file

@ -19,6 +19,9 @@
#include <QHBoxLayout>
#include <QLabel>
#include <QPainter>
#include <QStyle>
#include <QStyleOption>
#include "Emote.h"
#include "Image.h"
@ -67,6 +70,9 @@ public:
~TimelineItem();
protected:
void paintEvent(QPaintEvent *event) override;
private:
void init();

View file

@ -21,6 +21,8 @@
#include <QList>
#include <QQueue>
#include <QScrollArea>
#include <QStyle>
#include <QStyleOption>
#include "Emote.h"
#include "Image.h"
@ -110,7 +112,7 @@ public slots:
void addBackwardsEvents(const QString &room_id, const RoomMessages &msgs);
// Whether or not the initial batch has been loaded.
bool hasLoaded() { return scroll_layout_->count() > 1 || isTimelineFinished; };
bool hasLoaded() { return scroll_layout_->count() > 1 || isTimelineFinished; }
void handleFailedMessage(int txnid);
@ -120,6 +122,9 @@ private slots:
signals:
void updateLastTimelineMessage(const QString &user, const DescInfo &info);
protected:
void paintEvent(QPaintEvent *event) override;
private:
void init();
void addTimelineItem(TimelineItem *item, TimelineDirection direction);
@ -133,7 +138,7 @@ private:
bool isPendingMessage(const QString &txnid, const QString &sender, const QString &userid);
void removePendingMessage(const QString &txnid);
bool isDuplicate(const QString &event_id) { return eventIds_.contains(event_id); };
bool isDuplicate(const QString &event_id) { return eventIds_.contains(event_id); }
void handleNewUserMessage(PendingMessage msg);

View file

@ -34,7 +34,7 @@ class Menu;
class OverlayModal;
class RoomSettings;
static const QString URL_HTML = "<a href=\"\\1\" style=\"color: #333333\">\\1</a>";
static const QString URL_HTML = "<a href=\"\\1\">\\1</a>";
static const QRegExp URL_REGEX("((?:https?|ftp)://\\S+)");
class TopRoomBar : public QWidget

View file

@ -44,6 +44,7 @@ signals:
protected:
void resizeEvent(QResizeEvent *event) override;
void paintEvent(QPaintEvent *event) override;
private slots:
void closeLogoutDialog(bool isLoggingOut);

View file

@ -9,6 +9,7 @@
class LoadingIndicator : public QWidget
{
Q_OBJECT
Q_PROPERTY(QColor color READ color WRITE setColor)
public:
LoadingIndicator(QWidget *parent = 0);

View file

@ -1,6 +1,8 @@
#pragma once
#include <QEvent>
#include <QPainter>
#include <QStyleOption>
#include <QWidget>
class OverlayWidget : public QWidget
@ -15,4 +17,5 @@ protected:
bool eventFilter(QObject *obj, QEvent *event) override;
QRect overlayGeometry() const;
void paintEvent(QPaintEvent *event) override;
};

View file

@ -42,7 +42,6 @@
<file>icons/emoji-categories/flags.png</file>
<file>icons/emoji-categories/flags@2x.png</file>
</qresource>
<qresource prefix="/logos">
<file>nheko.png</file>
@ -62,13 +61,15 @@
<file>nheko-32.png</file>
<file>nheko-16.png</file>
</qresource>
<qresource prefix="/fonts">
<file>fonts/OpenSans/OpenSans-Regular.ttf</file>
<file>fonts/OpenSans/OpenSans-Italic.ttf</file>
<file>fonts/OpenSans/OpenSans-Bold.ttf</file>
<file>fonts/OpenSans/OpenSans-Semibold.ttf</file>
<file>fonts/EmojiOne/emojione-android.ttf</file>
</qresource>
<qresource prefix="/styles">
<file>styles/system.qss</file>
<file>styles/nheko.qss</file>
</qresource>
</RCC>

View file

@ -0,0 +1,56 @@
* {
color: #333;
}
QLabel {
color: #333;
}
#chatPage, #chatPage > * { background-color: white; }
TimelineView, TimelineView > * { background-color: white; }
QMenu, QMenu > * { background-color: white; }
FlatButton { qproperty-foregroundColor: #333; }
RaisedButton { qproperty-foregroundColor: white; }
RoomInfoListItem
{
qproperty-highlightedBackgroundColor: #38A3D8;
qproperty-hoverBackgroundColor: rgba(200, 200, 200, 128);
qproperty-backgroundColor: white;
qproperty-titleColor: #333;
qproperty-subtitleColor: #5d6565;
qproperty-highlightedTitleColor: white;
qproperty-highlightedSubtitleColor: white;
}
#ChatPageLoadSpinner {
qproperty-color: #acc7dc;
}
#FileUploadSpinner {
qproperty-color: #333;
}
UserInfoWidget, UserInfoWidget > * {
background-color: #d6dde3;
color: #ebebeb;
}
Avatar {
qproperty-textColor: black;
qproperty-backgroundColor: #eee;
}
#displayNameLabel {
color: #171919;
}
#userIdLabel {
color: #555459;
}

View file

@ -0,0 +1,39 @@
OverlayWidget, OverlayWidget > * {
background-color: palette(window);
}
#mainContent, #mainContent > * {
background-color: palette(base);
}
TimelineView, TimelineView > *, TimelineItem, TimelineItem > * {
background-color: palette(base);
}
FlatButton {
qproperty-foregroundColor: palette(text);
}
RoomInfoListItem {
qproperty-highlightedBackgroundColor: palette(highlight);
qproperty-hoverBackgroundColor: palette(dark);
qproperty-backgroundColor: palette(window);
qproperty-titleColor: palette(text);
qproperty-subtitleColor: palette(text);
qproperty-highlightedTitleColor: palette(text);
qproperty-highlightedSubtitleColor: palette(text);
}
LoadingIndicator {
qproperty-color: palette(text);
}
#ChatPageLoadSpinner {
qproperty-color: #acc7dc;
}
UserInfoWidget, UserInfoWidget > * {
background-color: palette(window);
}

View file

@ -49,7 +49,7 @@ ChatPage::ChatPage(QSharedPointer<MatrixClient> client, QWidget *parent)
: QWidget(parent)
, client_(client)
{
setStyleSheet("background-color: #fff;");
setObjectName("chatPage");
topLayout_ = new QHBoxLayout(this);
topLayout_->setSpacing(0);
@ -79,7 +79,8 @@ ChatPage::ChatPage(QSharedPointer<MatrixClient> client, QWidget *parent)
sideBarLayout_->addWidget(sidebarActions_);
// Content
content_ = new QFrame(this);
content_ = new QFrame(this);
content_->setObjectName("mainContent");
contentLayout_ = new QVBoxLayout(content_);
contentLayout_->setSpacing(0);
contentLayout_->setMargin(0);
@ -544,7 +545,7 @@ ChatPage::showQuickSwitcher()
new OverlayModal(MainWindow::instance(), quickSwitcher_.data()),
[=](OverlayModal *modal) { modal->deleteLater(); });
quickSwitcherModal_->setDuration(0);
quickSwitcherModal_->setColor(QColor(30, 30, 30, 170));
// quickSwitcherModal_->setColor(QColor(30, 30, 30, 170));
}
QMap<QString, QString> rooms;

View file

@ -32,11 +32,9 @@ EmojiPanel::EmojiPanel(QWidget *parent)
, animationDuration_{100}
, categoryIconSize_{20}
{
setStyleSheet("QWidget {background: #fff; color: #e8e8e8; border: none;}"
"QScrollBar:vertical { background-color: #fff; width: 8px; margin: 0px "
"2px 0 2px; }"
"QScrollBar::handle:vertical { background-color: #d6dde3; min-height: "
"20px; }"
setStyleSheet("QWidget {border: none;}"
"QScrollBar:vertical { width: 8px; margin: 0px 2px 0 2px; }"
"QScrollBar::handle:vertical { min-height: 20px; }"
"QScrollBar::add-line:vertical { border: none; background: none; }"
"QScrollBar::sub-line:vertical { border: none; background: none; }");
@ -55,7 +53,7 @@ EmojiPanel::EmojiPanel(QWidget *parent)
contentLayout->setMargin(0);
auto emojiCategories = new QFrame(mainWidget);
emojiCategories->setStyleSheet("background-color: #f2f2f2");
// emojiCategories->setStyleSheet("background-color: #f2f2f2");
auto categoriesLayout = new QHBoxLayout(emojiCategories);
categoriesLayout->setSpacing(6);
@ -250,6 +248,10 @@ EmojiPanel::leaveEvent(QEvent *event)
void
EmojiPanel::paintEvent(QPaintEvent *event)
{
Q_UNUSED(event);
QStyleOption opt;
opt.init(this);
QPainter p(this);
DropShadow::draw(p,
shadowMargin_,
@ -262,7 +264,8 @@ EmojiPanel::paintEvent(QPaintEvent *event)
width(),
height());
QWidget::paintEvent(event);
style()->drawPrimitive(QStyle::PE_Widget, &opt, &p, this);
// QWidget::paintEvent(event);
}
void

View file

@ -30,7 +30,7 @@ LoginPage::LoginPage(QSharedPointer<MatrixClient> client, QWidget *parent)
, inferredServerAddress_()
, client_{client}
{
setStyleSheet("background-color: #fff");
// setStyleSheet("background-color: #fff");
top_layout_ = new QVBoxLayout();
@ -40,7 +40,7 @@ LoginPage::LoginPage(QSharedPointer<MatrixClient> client, QWidget *parent)
back_button_ = new FlatButton(this);
back_button_->setMinimumSize(QSize(30, 30));
back_button_->setForegroundColor("#333333");
// back_button_->setForegroundColor("#333333");
top_bar_layout_->addWidget(back_button_, 0, Qt::AlignLeft | Qt::AlignVCenter);
top_bar_layout_->addStretch(1);
@ -75,10 +75,10 @@ LoginPage::LoginPage(QSharedPointer<MatrixClient> client, QWidget *parent)
form_wrapper_->addStretch(1);
matrixid_input_ = new TextField(this);
matrixid_input_->setTextColor("#333333");
// matrixid_input_->setTextColor("#333333");
matrixid_input_->setLabel(tr("Matrix ID"));
matrixid_input_->setInkColor("#555459");
matrixid_input_->setBackgroundColor("#fff");
// matrixid_input_->setInkColor("#555459");
// matrixid_input_->setBackgroundColor("#fff");
matrixid_input_->setPlaceholderText(tr("e.g @joe:matrix.org"));
spinner_ = new LoadingIndicator(this);
@ -95,17 +95,17 @@ LoginPage::LoginPage(QSharedPointer<MatrixClient> client, QWidget *parent)
matrixidLayout_->addWidget(matrixid_input_, 0, Qt::AlignVCenter);
password_input_ = new TextField(this);
password_input_->setTextColor("#333333");
// password_input_->setTextColor("#333333");
password_input_->setLabel(tr("Password"));
password_input_->setInkColor("#555459");
password_input_->setBackgroundColor("#fff");
// password_input_->setInkColor("#555459");
// password_input_->setBackgroundColor("#fff");
password_input_->setEchoMode(QLineEdit::Password);
serverInput_ = new TextField(this);
serverInput_->setTextColor("#333333");
// serverInput_->setTextColor("#333333");
serverInput_->setLabel("Homeserver address");
serverInput_->setInkColor("#555459");
serverInput_->setBackgroundColor("#fff");
// serverInput_->setInkColor("#555459");
// serverInput_->setBackgroundColor("#fff");
serverInput_->setPlaceholderText("matrix.org");
serverInput_->hide();
@ -121,8 +121,8 @@ LoginPage::LoginPage(QSharedPointer<MatrixClient> client, QWidget *parent)
button_layout_->setContentsMargins(0, 0, 0, 30);
login_button_ = new RaisedButton(tr("LOGIN"), this);
login_button_->setBackgroundColor(QColor("#333333"));
login_button_->setForegroundColor(QColor("white"));
// login_button_->setBackgroundColor(QColor("#333333"));
// login_button_->setForegroundColor(QColor("white"));
login_button_->setMinimumSize(350, 65);
login_button_->setFontSize(20);
login_button_->setCornerRadius(3);
@ -136,7 +136,7 @@ LoginPage::LoginPage(QSharedPointer<MatrixClient> client, QWidget *parent)
error_label_ = new QLabel(this);
error_label_->setFont(font);
error_label_->setStyleSheet("color: #E22826");
// error_label_->setStyleSheet("color: #E22826");
top_layout_->addLayout(top_bar_layout_);
top_layout_->addStretch(1);

View file

@ -27,7 +27,7 @@ LogoutDialog::LogoutDialog(QWidget *parent)
: QFrame(parent)
{
setMaximumSize(400, 400);
setStyleSheet("background-color: #fff");
// setStyleSheet("background-color: #fff");
auto layout = new QVBoxLayout(this);
layout->setSpacing(30);
@ -52,7 +52,7 @@ LogoutDialog::LogoutDialog(QWidget *parent)
auto label = new QLabel(tr("Logout. Are you sure?"), this);
label->setFont(font);
label->setStyleSheet("color: #333333");
// label->setStyleSheet("color: #333333");
layout->addWidget(label);
layout->addLayout(buttonLayout);

View file

@ -43,7 +43,6 @@ MainWindow::MainWindow(QWidget *parent)
{
setWindowTitle("nheko");
setObjectName("MainWindow");
setStyleSheet("QWidget#MainWindow {background-color: #fff}");
restoreWindowSize();
@ -204,9 +203,9 @@ MainWindow::showChatPage(QString userid, QString homeserver, QString token)
spinner_ = QSharedPointer<LoadingIndicator>(
new LoadingIndicator(this),
[=](LoadingIndicator *indicator) { indicator->deleteLater(); });
spinner_->setColor("#acc7dc");
spinner_->setFixedHeight(100);
spinner_->setFixedWidth(100);
spinner_->setObjectName("ChatPageLoadSpinner");
spinner_->start();
}

View file

@ -28,7 +28,7 @@ RegisterPage::RegisterPage(QSharedPointer<MatrixClient> client, QWidget *parent)
: QWidget(parent)
, client_(client)
{
setStyleSheet("background-color: #fff");
// setStyleSheet("background-color: #fff");
top_layout_ = new QVBoxLayout();
@ -73,30 +73,30 @@ RegisterPage::RegisterPage(QSharedPointer<MatrixClient> client, QWidget *parent)
form_wrapper_->addStretch(1);
username_input_ = new TextField();
username_input_->setTextColor("#333333");
// username_input_->setTextColor("#333333");
username_input_->setLabel(tr("Username"));
username_input_->setInkColor("#555459");
username_input_->setBackgroundColor("#fff");
// username_input_->setInkColor("#555459");
// username_input_->setBackgroundColor("#fff");
password_input_ = new TextField();
password_input_->setTextColor("#333333");
// password_input_->setTextColor("#333333");
password_input_->setLabel(tr("Password"));
password_input_->setInkColor("#555459");
password_input_->setBackgroundColor("#fff");
// password_input_->setInkColor("#555459");
// password_input_->setBackgroundColor("#fff");
password_input_->setEchoMode(QLineEdit::Password);
password_confirmation_ = new TextField();
password_confirmation_->setTextColor("#333333");
// password_confirmation_->setTextColor("#333333");
password_confirmation_->setLabel(tr("Password confirmation"));
password_confirmation_->setInkColor("#555459");
password_confirmation_->setBackgroundColor("#fff");
// password_confirmation_->setInkColor("#555459");
// password_confirmation_->setBackgroundColor("#fff");
password_confirmation_->setEchoMode(QLineEdit::Password);
server_input_ = new TextField();
server_input_->setTextColor("#333333");
// server_input_->setTextColor("#333333");
server_input_->setLabel(tr("Home Server"));
server_input_->setInkColor("#555459");
server_input_->setBackgroundColor("#fff");
// server_input_->setInkColor("#555459");
// server_input_->setBackgroundColor("#fff");
form_layout_->addWidget(username_input_, Qt::AlignHCenter, 0);
form_layout_->addWidget(password_input_, Qt::AlignHCenter, 0);
@ -112,11 +112,11 @@ RegisterPage::RegisterPage(QSharedPointer<MatrixClient> client, QWidget *parent)
error_label_ = new QLabel(this);
error_label_->setFont(font);
error_label_->setStyleSheet("color: #E22826");
// error_label_->setStyleSheet("color: #E22826");
register_button_ = new RaisedButton(tr("REGISTER"), this);
register_button_->setBackgroundColor(QColor("#333333"));
register_button_->setForegroundColor(QColor("white"));
// register_button_->setBackgroundColor(QColor("#333333"));
// register_button_->setForegroundColor(QColor("white"));
register_button_->setMinimumSize(350, 65);
register_button_->setFontSize(conf::btn::fontSize);
register_button_->setCornerRadius(conf::btn::cornerRadius);

View file

@ -95,18 +95,19 @@ RoomInfoListItem::paintEvent(QPaintEvent *event)
p.setRenderHint(QPainter::SmoothPixmapTransform);
p.setRenderHint(QPainter::Antialiasing);
if (isPressed_)
p.fillRect(rect(), QColor("#38A3D8"));
else if (underMouse())
p.fillRect(rect(), QColor(200, 200, 200, 128));
else
p.fillRect(rect(), QColor("#FFF"));
QFont font;
font.setPixelSize(conf::fontSize);
QFontMetrics metrics(font);
p.setPen(QColor("#333"));
if (isPressed_) {
p.fillRect(rect(), highlightedBackgroundColor_);
} else if (underMouse()) {
p.fillRect(rect(), hoverBackgroundColor_);
} else {
p.fillRect(rect(), backgroundColor_);
}
// p.setPen(QColor("#333"));
QRect avatarRegion(Padding, Padding, IconSize, IconSize);
@ -115,10 +116,12 @@ RoomInfoListItem::paintEvent(QPaintEvent *event)
if (width() > ui::sidebar::SmallSize) {
if (isPressed_) {
QPen pen(QColor("white"));
QPen pen(highlightedTitleColor_);
p.setPen(pen);
} else {
QPen pen(titleColor_);
p.setPen(pen);
}
font.setPixelSize(conf::roomlist::fonts::heading);
p.setFont(font);
@ -130,8 +133,11 @@ RoomInfoListItem::paintEvent(QPaintEvent *event)
state_.getName(), Qt::ElideRight, (width() - IconSize - 2 * Padding) * 0.8);
p.drawText(QPoint(2 * Padding + IconSize, top_y), name);
if (!isPressed_) {
QPen pen(QColor("#5d6565"));
if (isPressed_) {
QPen pen(highlightedSubtitleColor_);
p.setPen(pen);
} else {
QPen pen(subtitleColor_);
p.setPen(pen);
}

View file

@ -33,9 +33,7 @@ RoomList::RoomList(QSharedPointer<MatrixClient> client, QWidget *parent)
: QWidget(parent)
, client_(client)
{
setStyleSheet(
"border: 1px solid #ccc; border-right: 0px solid #000; border-left: 0px solid #000;");
setStyleSheet("border: none;");
topLayout_ = new QVBoxLayout(this);
topLayout_->setSpacing(0);
topLayout_->setMargin(0);

View file

@ -133,8 +133,8 @@ FilteredTextEdit::minimumSizeHint() const
void
FilteredTextEdit::submit()
{
if (toPlainText().trimmed().isEmpty())
return;
if (toPlainText().trimmed().isEmpty())
return;
if (true_history_.size() == INPUT_HISTORY_SIZE)
true_history_.pop_back();
@ -176,7 +176,6 @@ TextInputWidget::TextInputWidget(QWidget *parent)
setFixedHeight(conf::textInput::height);
setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed);
setCursor(Qt::ArrowCursor);
setStyleSheet("background-color: #fff;");
topLayout_ = new QHBoxLayout();
topLayout_->setSpacing(0);
@ -192,6 +191,7 @@ TextInputWidget::TextInputWidget(QWidget *parent)
spinner_ = new LoadingIndicator(this);
spinner_->setFixedHeight(32);
spinner_->setFixedWidth(32);
spinner_->setObjectName("FileUploadSpinner");
spinner_->hide();
QFont font;
@ -202,7 +202,7 @@ TextInputWidget::TextInputWidget(QWidget *parent)
input_->setFont(font);
input_->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
input_->setPlaceholderText(tr("Write a message..."));
input_->setStyleSheet("color: #333333; border: none; padding-top: 5px; margin: 0 5px");
input_->setStyleSheet("border: none; padding-top: 5px;");
sendMessageBtn_ = new FlatButton(this);
@ -335,3 +335,12 @@ TextInputWidget::focusInEvent(QFocusEvent *event)
{
input_->setFocus(event->reason());
}
void
TextInputWidget::paintEvent(QPaintEvent *)
{
QStyleOption opt;
opt.init(this);
QPainter p(this);
style()->drawPrimitive(QStyle::PE_Widget, &opt, &p, this);
}

View file

@ -30,7 +30,7 @@
#include "TimelineViewManager.h"
static const QRegExp URL_REGEX("((?:https?|ftp)://\\S+)");
static const QString URL_HTML = "<a href=\"\\1\" style=\"color: #333333\">\\1</a>";
static const QString URL_HTML = "<a href=\"\\1\">\\1</a>";
namespace events = matrix::events;
namespace msgs = matrix::events::messages;
@ -205,7 +205,7 @@ TimelineItem::TimelineItem(const events::MessageEvent<msgs::Notice> &event,
body.replace(URL_REGEX, URL_HTML);
body.replace("\n", "<br/>");
body = "<i style=\"color: #565E5E\">" + body + "</i>";
body = "<i>" + body + "</i>";
if (with_sender) {
auto displayName = TimelineViewManager::displayName(event.sender());
@ -308,7 +308,7 @@ TimelineItem::TimelineItem(const events::MessageEvent<msgs::Text> &event,
void
TimelineItem::generateBody(const QString &body)
{
QString content("<span style=\"color: black;\"> %1 </span>");
QString content("<span> %1 </span>");
body_ = new QLabel(this);
body_->setFont(font_);
@ -332,8 +332,8 @@ TimelineItem::generateBody(const QString &userid, const QString &body)
sender = userid.split(":")[0].split("@")[1];
}
QString userContent("<span style=\"color: #171717\"> %1 </span>");
QString bodyContent("<span style=\"color: #171717;\"> %1 </span>");
QString userContent("%1");
QString bodyContent("%1");
QFont usernameFont = font_;
usernameFont.setBold(true);
@ -357,7 +357,7 @@ TimelineItem::generateBody(const QString &userid, const QString &body)
void
TimelineItem::generateTimestamp(const QDateTime &time)
{
QString msg("<span style=\"color: #5d6565;\"> %1 </span>");
QString msg("%1");
QFont timestampFont;
timestampFont.setPixelSize(conf::timeline::fonts::timestamp);
@ -369,6 +369,8 @@ TimelineItem::generateTimestamp(const QDateTime &time)
timestamp_->setFont(timestampFont);
timestamp_->setText(msg.arg(time.toString("HH:mm")));
timestamp_->setContentsMargins(0, topMargin, 0, 0);
timestamp_->setStyleSheet(
QString("font-size: %1px;").arg(conf::timeline::fonts::timestamp));
}
QString
@ -399,8 +401,6 @@ TimelineItem::setupAvatarLayout(const QString &userName)
userAvatar_ = new Avatar(this);
userAvatar_->setLetter(QChar(userName[0]).toUpper());
userAvatar_->setBackgroundColor(QColor("#eee"));
userAvatar_->setTextColor(QColor("black"));
userAvatar_->setSize(conf::timeline::avatarSize);
// TODO: The provided user name should be a UserId class
@ -467,3 +467,12 @@ TimelineItem::descriptiveTime(const QDateTime &then)
}
TimelineItem::~TimelineItem() {}
void
TimelineItem::paintEvent(QPaintEvent *)
{
QStyleOption opt;
opt.init(this);
QPainter p(this);
style()->drawPrimitive(QStyle::PE_Widget, &opt, &p, this);
}

View file

@ -399,7 +399,6 @@ TimelineView::init()
const int max = scroll_area_->verticalScrollBar()->maximum();
scroll_area_->verticalScrollBar()->setValue(max);
});
top_layout_ = new QVBoxLayout(this);
top_layout_->setSpacing(0);
top_layout_->setMargin(0);
@ -416,6 +415,7 @@ TimelineView::init()
scroll_layout_ = new QVBoxLayout(scroll_widget_);
scroll_layout_->addStretch(1);
scroll_layout_->setSpacing(0);
scroll_layout_->setObjectName("timelinescrollarea");
scroll_area_->setWidget(scroll_widget_);
@ -639,3 +639,12 @@ TimelineView::handleFailedMessage(int txnid)
// Note: We do this even if the message has already been echoed.
QTimer::singleShot(500, this, SLOT(sendNextPendingMessage()));
}
void
TimelineView::paintEvent(QPaintEvent *)
{
QStyleOption opt;
opt.init(this);
QPainter p(this);
style()->drawPrimitive(QStyle::PE_Widget, &opt, &p, this);
}

View file

@ -41,8 +41,6 @@ TopRoomBar::TopRoomBar(QWidget *parent)
avatar_ = new Avatar(this);
avatar_->setLetter(QChar('?'));
avatar_->setBackgroundColor(QColor("#d6dde3"));
avatar_->setTextColor(QColor("#555459"));
avatar_->setSize(35);
textLayout_ = new QVBoxLayout();

View file

@ -43,17 +43,19 @@ UserInfoWidget::UserInfoWidget(QWidget *parent)
textLayout_ = new QVBoxLayout();
userAvatar_ = new Avatar(this);
userAvatar_->setObjectName("userAvatar");
userAvatar_->setLetter(QChar('?'));
userAvatar_->setSize(55);
userAvatar_->setBackgroundColor("#fff");
userAvatar_->setTextColor("#333333");
// userAvatar_->setBackgroundColor("#fff");
// userAvatar_->setTextColor("#333333");
QFont nameFont("Open Sans SemiBold");
nameFont.setPixelSize(conf::userInfoWidget::fonts::displayName);
displayNameLabel_ = new QLabel(this);
displayNameLabel_->setFont(nameFont);
displayNameLabel_->setStyleSheet("padding: 0 9px; color: #171919; margin-bottom: -10px;");
displayNameLabel_->setObjectName("displayNameLabel");
displayNameLabel_->setStyleSheet("padding: 0 9px; margin-bottom: -10px;");
displayNameLabel_->setAlignment(Qt::AlignLeading | Qt::AlignLeft | Qt::AlignTop);
QFont useridFont("Open Sans");
@ -61,7 +63,8 @@ UserInfoWidget::UserInfoWidget(QWidget *parent)
userIdLabel_ = new QLabel(this);
userIdLabel_->setFont(useridFont);
userIdLabel_->setStyleSheet("padding: 0 8px 8px 8px; color: #555459;");
userIdLabel_->setObjectName("userIdLabel");
userIdLabel_->setStyleSheet("padding: 0 8px 8px 8px;");
userIdLabel_->setAlignment(Qt::AlignLeading | Qt::AlignLeft | Qt::AlignVCenter);
avatarLayout_->addWidget(userAvatar_);
@ -177,3 +180,14 @@ UserInfoWidget::setUserId(const QString &userid)
user_id_ = userid;
userIdLabel_->setText(userid);
}
void
UserInfoWidget::paintEvent(QPaintEvent *event)
{
Q_UNUSED(event);
QStyleOption opt;
opt.init(this);
QPainter p(this);
style()->drawPrimitive(QStyle::PE_Widget, &opt, &p, this);
}

View file

@ -72,7 +72,7 @@ UserSettingsPage::UserSettingsPage(QSharedPointer<UserSettings> settings, QWidge
backBtn_->setIconSize(QSize(24, 24));
auto heading_ = new QLabel(tr("User Settings"));
heading_->setFont(QFont("Open Sans Bold", 22));
heading_->setStyleSheet("font-weight: bold; font-size: 22px;");
topBarLayout_ = new QHBoxLayout;
topBarLayout_->setSpacing(0);
@ -87,7 +87,7 @@ UserSettingsPage::UserSettingsPage(QSharedPointer<UserSettings> settings, QWidge
trayToggle_ = new Toggle(this);
trayToggle_->setActiveColor(QColor("#38A3D8"));
trayToggle_->setInactiveColor(QColor("gray"));
trayLabel->setFont(QFont("Open Sans", 15));
trayLabel->setStyleSheet("font-size: 15px;");
trayOptionLayout_->addWidget(trayLabel);
trayOptionLayout_->addWidget(trayToggle_, 0, Qt::AlignBottom | Qt::AlignRight);
@ -98,14 +98,13 @@ UserSettingsPage::UserSettingsPage(QSharedPointer<UserSettings> settings, QWidge
themeCombo_ = new QComboBox(this);
themeCombo_->addItem("Default");
themeCombo_->addItem("System");
themeLabel_->setFont(QFont("Open Sans", 15));
themeLabel_->setStyleSheet("font-size: 15px;");
themeOptionLayout_->addWidget(themeLabel_);
themeOptionLayout_->addWidget(themeCombo_, 0, Qt::AlignBottom | Qt::AlignRight);
auto general_ = new QLabel(tr("GENERAL"), this);
general_->setFont(QFont("Open Sans Bold", 17));
general_->setStyleSheet("color: #5d6565");
general_->setStyleSheet("font-size: 17px; color: #5d6565");
mainLayout_ = new QVBoxLayout;
mainLayout_->setSpacing(7);

View file

@ -17,6 +17,7 @@
#include <QApplication>
#include <QDesktopWidget>
#include <QFile>
#include <QFontDatabase>
#include <QLibraryInfo>
#include <QNetworkProxy>
@ -72,6 +73,21 @@ main(int argc, char *argv[])
QSettings settings;
QFile stylefile;
if (!settings.contains("user/theme")) {
settings.setValue("user/theme", "default");
}
if (settings.value("user/theme").toString() == "default") {
stylefile.setFileName(":/styles/styles/nheko.qss");
} else {
stylefile.setFileName(":/styles/styles/system.qss");
}
stylefile.open(QFile::ReadOnly);
QString stylesheet = QString(stylefile.readAll());
app.setStyleSheet(stylesheet);
// Set the default if a value has not been set.
if (settings.value("font/size").toInt() == 0)
settings.setValue("font/size", 12);

View file

@ -176,7 +176,6 @@ Badge::paintEvent(QPaintEvent *)
QBrush brush;
brush.setStyle(Qt::SolidPattern);
brush.setColor(isEnabled() ? backgroundColor() : QColor("#cccccc"));
painter.setBrush(brush);
painter.setPen(Qt::NoPen);

View file

@ -59,3 +59,14 @@ OverlayWidget::overlayGeometry() const
return widget->rect();
}
void
OverlayWidget::paintEvent(QPaintEvent *event)
{
Q_UNUSED(event);
QStyleOption opt;
opt.init(this);
QPainter p(this);
style()->drawPrimitive(QStyle::PE_Widget, &opt, &p, this);
}

View file

@ -197,8 +197,6 @@ TextField::paintEvent(QPaintEvent *event)
if (text().isEmpty()) {
painter.setOpacity(1 - state_machine_->progress());
// painter.fillRect(rect(),
// parentWidget()->palette().color(backgroundRole()));
painter.fillRect(rect(), backgroundColor());
}