diff --git a/include/RoomInfoListItem.h b/include/RoomInfoListItem.h index a137b37f26952f31c30e17a5dcbbf431a63e541e..acb1ab84bb271c0c2166d3d9380744a16e48f31d 100644 --- a/include/RoomInfoListItem.h +++ b/include/RoomInfoListItem.h @@ -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_; }; diff --git a/include/TextInputWidget.h b/include/TextInputWidget.h index 70b1c2137a19b8c4dee42233cab2f9c35e0df050..88706e4a375deb64d6a64097d5424b0b5738f1a5 100644 --- a/include/TextInputWidget.h +++ b/include/TextInputWidget.h @@ -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(); diff --git a/include/TimelineItem.h b/include/TimelineItem.h index 1adf574c5562f40812f9e3504af3b9a3bd5b9a9f..d90810d5a2eeb63f0739d2f157732c1167f152a7 100644 --- a/include/TimelineItem.h +++ b/include/TimelineItem.h @@ -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(); diff --git a/include/TimelineView.h b/include/TimelineView.h index bc7c41e69eaecff1320b65c0dd20dc744b254869..78c31e8ee5240f81209b7b33ff8f3b361317a4cb 100644 --- a/include/TimelineView.h +++ b/include/TimelineView.h @@ -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); diff --git a/include/TopRoomBar.h b/include/TopRoomBar.h index f1e93d9d29a1456324de15e7dd8e48bc2bdf121f..2f65428d3131801e2db22e1b8a4b70d3eb32f9dd 100644 --- a/include/TopRoomBar.h +++ b/include/TopRoomBar.h @@ -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 diff --git a/include/UserInfoWidget.h b/include/UserInfoWidget.h index 111f580817edbbe0f55d1e2aa2f5c77847805e08..2acfedb8e8b76d0f17f89386350f55886bbd6b7e 100644 --- a/include/UserInfoWidget.h +++ b/include/UserInfoWidget.h @@ -44,6 +44,7 @@ signals: protected: void resizeEvent(QResizeEvent *event) override; + void paintEvent(QPaintEvent *event) override; private slots: void closeLogoutDialog(bool isLoggingOut); diff --git a/include/ui/LoadingIndicator.h b/include/ui/LoadingIndicator.h index 75920dd88093922c4a21b7a0dd9daded7550add8..bb33fe6c9318cd1bc79394e1b57afac6c6a65bc1 100644 --- a/include/ui/LoadingIndicator.h +++ b/include/ui/LoadingIndicator.h @@ -9,6 +9,7 @@ class LoadingIndicator : public QWidget { Q_OBJECT + Q_PROPERTY(QColor color READ color WRITE setColor) public: LoadingIndicator(QWidget *parent = 0); diff --git a/include/ui/OverlayWidget.h b/include/ui/OverlayWidget.h index 2984e469803c86bba866580b85ec559afe25da83..6662479d51c92e79c7cf6a937a1c51336eb4e3c2 100644 --- a/include/ui/OverlayWidget.h +++ b/include/ui/OverlayWidget.h @@ -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; }; diff --git a/resources/res.qrc b/resources/res.qrc index 55962275cf143021e9c5af4d7364eb34600837f5..9bd977a29c1dabf6684c3ed66b55afabf7104fc4 100644 --- a/resources/res.qrc +++ b/resources/res.qrc @@ -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> diff --git a/resources/styles/nheko.qss b/resources/styles/nheko.qss new file mode 100644 index 0000000000000000000000000000000000000000..caaac6b95b0da30e6e10590873352e06c2f32576 --- /dev/null +++ b/resources/styles/nheko.qss @@ -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; +} diff --git a/resources/styles/system.qss b/resources/styles/system.qss new file mode 100644 index 0000000000000000000000000000000000000000..2f15271fdbd24739ef60363a9f83b093e39b9821 --- /dev/null +++ b/resources/styles/system.qss @@ -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); +} diff --git a/src/ChatPage.cc b/src/ChatPage.cc index 8dd509be996fc2494e565b462ac802e2a27abcbe..acc60c03c28a71adf0aec5b30af7faf25f2bdf74 100644 --- a/src/ChatPage.cc +++ b/src/ChatPage.cc @@ -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; diff --git a/src/EmojiPanel.cc b/src/EmojiPanel.cc index 3f5f83698388ce02cfb5fc11e0ddbc777c9bb163..82eb8afc1c21158c95db79db284c3f8ceb984d79 100644 --- a/src/EmojiPanel.cc +++ b/src/EmojiPanel.cc @@ -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 diff --git a/src/LoginPage.cc b/src/LoginPage.cc index 0b65f8bc6a038b781854ae23f5205bae6a842dba..5c766b785a15c9a7d4788e6c89d6a9ced6ce2fa1 100644 --- a/src/LoginPage.cc +++ b/src/LoginPage.cc @@ -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); diff --git a/src/LogoutDialog.cc b/src/LogoutDialog.cc index 7f2cdbd3d07a6dbcf8e254f6a1fc5e3e2bdfee93..c0db1270c20b8173d20b5373c2e285a59fdd0285 100644 --- a/src/LogoutDialog.cc +++ b/src/LogoutDialog.cc @@ -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); diff --git a/src/MainWindow.cc b/src/MainWindow.cc index c5735b68e0d337011d7416db3eb5c7d9ef016452..04b0e8e3c8d46cec31ef33fd23de9b4dcf1db2b9 100644 --- a/src/MainWindow.cc +++ b/src/MainWindow.cc @@ -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(); } diff --git a/src/RegisterPage.cc b/src/RegisterPage.cc index 304a7dc0d1c093e69eabf4216ea342fdd3dfa647..01f3b28fcf96eaed69f0cf50aa727832ed8d9b28 100644 --- a/src/RegisterPage.cc +++ b/src/RegisterPage.cc @@ -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); diff --git a/src/RoomInfoListItem.cc b/src/RoomInfoListItem.cc index 49b24b5878d202072f2c9180d6da390cd2726084..875bb506dab4a04897f3d5a823d9a203b59d2661 100644 --- a/src/RoomInfoListItem.cc +++ b/src/RoomInfoListItem.cc @@ -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); } diff --git a/src/RoomList.cc b/src/RoomList.cc index 5b10d1c51747df87e18bfd79d7c6970a2ef362e0..b1d3a9ca925b21ae73dc1c2d696d76cca4ca7874 100644 --- a/src/RoomList.cc +++ b/src/RoomList.cc @@ -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); diff --git a/src/TextInputWidget.cc b/src/TextInputWidget.cc index c086db8551fbc5091f05a86e8031b2c23af1563d..829784fd902d9d43346cc3de0ad8e302e26ce941 100644 --- a/src/TextInputWidget.cc +++ b/src/TextInputWidget.cc @@ -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); +} diff --git a/src/TimelineItem.cc b/src/TimelineItem.cc index efc12d42ad2503ab22de457261086ccb8e1e8c21..8c21e61dffd6b80814306858b27626e9de3ce724 100644 --- a/src/TimelineItem.cc +++ b/src/TimelineItem.cc @@ -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); +} diff --git a/src/TimelineView.cc b/src/TimelineView.cc index b1fb2ad0c430a9931cde7ab6e5f670515b05705f..267fbbffc54102c6f7ff1a7c39aa095cf6bb97ee 100644 --- a/src/TimelineView.cc +++ b/src/TimelineView.cc @@ -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); +} diff --git a/src/TopRoomBar.cc b/src/TopRoomBar.cc index 7bec888d912fe96512e1e7a3e1786d2a0c2df6c4..d852ae32b1680a20e31caf3ea3199c432f000900 100644 --- a/src/TopRoomBar.cc +++ b/src/TopRoomBar.cc @@ -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(); diff --git a/src/UserInfoWidget.cc b/src/UserInfoWidget.cc index f5f3db744bc101699b669e0a9bbed2913d8ac419..27d6cbbe312bf89a61f58330429f8ad351c0dfee 100644 --- a/src/UserInfoWidget.cc +++ b/src/UserInfoWidget.cc @@ -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); +} diff --git a/src/UserSettingsPage.cc b/src/UserSettingsPage.cc index 10754cfdcb2923ceccaac8180cc42e628e76f26a..e53ad668470dd300b8ba04012d2270b18b62115e 100644 --- a/src/UserSettingsPage.cc +++ b/src/UserSettingsPage.cc @@ -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); diff --git a/src/main.cc b/src/main.cc index 8bd772545e84a369d6f1a34a040e422f33dfaa0a..9ca1d5de00f7779fe82f7da592587456cc72e98b 100644 --- a/src/main.cc +++ b/src/main.cc @@ -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); diff --git a/src/ui/Badge.cc b/src/ui/Badge.cc index 6e73eca0366c74075007f774787d5915e8f4d8bc..016ed64fa2ce152ee729bace762598e2ae3d4967 100644 --- a/src/ui/Badge.cc +++ b/src/ui/Badge.cc @@ -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); diff --git a/src/ui/OverlayWidget.cc b/src/ui/OverlayWidget.cc index c69f81f7dcfeb191f8a7e4cc606909b2897e0ec9..ccac011664f54efd5b6e9ca56b2c3e03fdbeeb62 100644 --- a/src/ui/OverlayWidget.cc +++ b/src/ui/OverlayWidget.cc @@ -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); +} diff --git a/src/ui/TextField.cc b/src/ui/TextField.cc index e038f2ddd98ea7cc0f39410530754caf78ed1896..d80d6466ba0e5f963f633b88896f573d8628b8d7 100644 --- a/src/ui/TextField.cc +++ b/src/ui/TextField.cc @@ -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()); }