diff --git a/res.qrc b/res.qrc
index 220dd9fd5..74ce71c24 100644
--- a/res.qrc
+++ b/res.qrc
@@ -72,7 +72,6 @@
ui/chatArea/scrollBarDownArrow.svg
ui/chatArea/scrollBarLeftArrow.svg
ui/chatArea/scrollBarRightArrow.svg
- ui/chatroomWidgets/genericChatroomWidget.css
ui/emoteButton/emoteButton.css
ui/emoteButton/emoteButton.svg
ui/emoticonWidget/dot_page.svg
diff --git a/src/widget/friendwidget.cpp b/src/widget/friendwidget.cpp
index d2a78e4ae..7540b91e4 100644
--- a/src/widget/friendwidget.cpp
+++ b/src/widget/friendwidget.cpp
@@ -223,6 +223,8 @@ void FriendWidget::mousePressEvent(QMouseEvent *ev)
{
if (ev->button() == Qt::LeftButton)
dragStartPos = ev->pos();
+
+ GenericChatroomWidget::mousePressEvent(ev);
}
void FriendWidget::mouseMoveEvent(QMouseEvent *ev)
diff --git a/src/widget/genericchatroomwidget.cpp b/src/widget/genericchatroomwidget.cpp
index 1ef455c1a..7cdddaa2e 100644
--- a/src/widget/genericchatroomwidget.cpp
+++ b/src/widget/genericchatroomwidget.cpp
@@ -23,45 +23,40 @@
#include "maskablepixmapwidget.h"
#include "src/widget/tool/croppinglabel.h"
#include
-#include
GenericChatroomWidget::GenericChatroomWidget(QWidget *parent)
- : QFrame(parent)
+ : QFrame(parent), compact{Settings::getInstance().getCompactLayout()},
+ active{false}
{
- setProperty("compact", Settings::getInstance().getCompactLayout());
-
// avatar
- if (property("compact").toBool())
- {
+ if (compact)
avatar = new MaskablePixmapWidget(this, QSize(20,20), ":/img/avatar_mask.svg");
- }
else
- {
avatar = new MaskablePixmapWidget(this, QSize(40,40), ":/img/avatar_mask.svg");
- }
// status text
statusMessageLabel = new CroppingLabel(this);
- statusMessageLabel->setObjectName("status");
+ statusMessageLabel->setTextFormat(Qt::PlainText);
+ statusMessageLabel->setForegroundRole(QPalette::WindowText);
// name text
nameLabel = new CroppingLabel(this);
- nameLabel->setObjectName("name");
nameLabel->setTextFormat(Qt::PlainText);
- statusMessageLabel->setTextFormat(Qt::PlainText);
+ nameLabel->setForegroundRole(QPalette::WindowText);
- onCompactChanged(property("compact").toBool());
-
- setProperty("active", false);
- setStyleSheet(Style::getStylesheet(":/ui/chatroomWidgets/genericChatroomWidget.css"));
+ setAutoFillBackground(true);
+ reloadTheme();
+ setCompact(compact);
}
-void GenericChatroomWidget::onCompactChanged(bool _compact)
+void GenericChatroomWidget::setCompact(bool _compact)
{
+ compact = _compact;
+
delete textLayout; // has to be first, deleted by layout
delete layout;
- setProperty("compact", _compact);
+ compact = _compact;
layout = new QHBoxLayout;
textLayout = new QVBoxLayout;
@@ -74,7 +69,7 @@ void GenericChatroomWidget::onCompactChanged(bool _compact)
setLayoutDirection(Qt::LeftToRight); // parent might have set Qt::RightToLeft
// avatar
- if (property("compact").toBool())
+ if (compact)
{
setFixedHeight(25);
avatar->setSize(QSize(20,20));
@@ -105,19 +100,28 @@ void GenericChatroomWidget::onCompactChanged(bool _compact)
layout->addSpacing(10);
layout->activate();
}
-
- Style::repolish(this);
}
bool GenericChatroomWidget::isActive()
{
- return property("active").toBool();
+ return active;
}
-void GenericChatroomWidget::setActive(bool active)
+void GenericChatroomWidget::setActive(bool _active)
{
- setProperty("active", active);
- Style::repolish(this);
+ active = _active;
+ if (active)
+ {
+ setBackgroundRole(QPalette::Light);
+ statusMessageLabel->setForegroundRole(QPalette::HighlightedText);
+ nameLabel->setForegroundRole(QPalette::HighlightedText);
+ }
+ else
+ {
+ setBackgroundRole(QPalette::Window);
+ statusMessageLabel->setForegroundRole(QPalette::WindowText);
+ nameLabel->setForegroundRole(QPalette::WindowText);
+ }
}
void GenericChatroomWidget::setName(const QString &name)
@@ -140,14 +144,25 @@ QString GenericChatroomWidget::getStatusMsg() const
return statusMessageLabel->text();
}
-void GenericChatroomWidget::mouseReleaseEvent(QMouseEvent*)
-{
- emit chatroomWidgetClicked(this);
-}
-
void GenericChatroomWidget::reloadTheme()
{
- setStyleSheet(Style::getStylesheet(":/ui/chatroomWidgets/genericChatroomWidget.css"));
+ QPalette p;
+
+ p = statusMessageLabel->palette();
+ p.setColor(QPalette::WindowText, Style::getColor(Style::LightGrey)); // Base color
+ p.setColor(QPalette::HighlightedText, Style::getColor(Style::MediumGrey)); // Color when active
+ statusMessageLabel->setPalette(p);
+
+ p = nameLabel->palette();
+ p.setColor(QPalette::WindowText, Style::getColor(Style::White)); // Base color
+ p.setColor(QPalette::HighlightedText, Style::getColor(Style::DarkGrey)); // Color when active
+ nameLabel->setPalette(p);
+
+ p = palette();
+ p.setColor(QPalette::Window, Style::getColor(Style::ThemeMedium)); // Base background color
+ p.setColor(QPalette::Highlight, Style::getColor(Style::ThemeLight)); // On mouse over
+ p.setColor(QPalette::Light, Style::getColor(Style::White)); // When active
+ setPalette(p);
}
bool GenericChatroomWidget::isCompact() const
@@ -155,8 +170,25 @@ bool GenericChatroomWidget::isCompact() const
return compact;
}
-void GenericChatroomWidget::setCompact(bool compact)
+void GenericChatroomWidget::mousePressEvent(QMouseEvent* event)
{
- this->compact = compact;
- Style::repolish(this);
+ if (!active && event->button() == Qt::RightButton)
+ setBackgroundRole(QPalette::Window);
+}
+
+void GenericChatroomWidget::mouseReleaseEvent(QMouseEvent*)
+{
+ emit chatroomWidgetClicked(this);
+}
+
+void GenericChatroomWidget::enterEvent(QEvent*)
+{
+ if (!active)
+ setBackgroundRole(QPalette::Highlight);
+}
+
+void GenericChatroomWidget::leaveEvent(QEvent*)
+{
+ if (!active)
+ setBackgroundRole(QPalette::Window);
}
diff --git a/src/widget/genericchatroomwidget.h b/src/widget/genericchatroomwidget.h
index 3742811f3..83ca617b7 100644
--- a/src/widget/genericchatroomwidget.h
+++ b/src/widget/genericchatroomwidget.h
@@ -37,7 +37,6 @@ class GenericChatroomWidget : public QFrame
Q_OBJECT
public:
GenericChatroomWidget(QWidget *parent = 0);
- void mouseReleaseEvent (QMouseEvent* event);
virtual void setAsActiveChatroom(){;}
virtual void setAsInactiveChatroom(){;}
@@ -58,15 +57,18 @@ public:
void reloadTheme();
bool isCompact() const;
- void setCompact(bool compact);
- Q_PROPERTY(bool compact READ isCompact WRITE setCompact)
+public slots:
+ void setCompact(bool compact);
signals:
void chatroomWidgetClicked(GenericChatroomWidget* widget);
-public slots:
- void onCompactChanged(bool compact);
+protected:
+ virtual void mousePressEvent(QMouseEvent* event);
+ virtual void mouseReleaseEvent (QMouseEvent* event);
+ virtual void enterEvent(QEvent* e);
+ virtual void leaveEvent(QEvent* e);
protected:
QColor lastColor;
@@ -74,10 +76,8 @@ protected:
QVBoxLayout* textLayout = nullptr;
MaskablePixmapWidget* avatar;
QLabel statusPic;
- CroppingLabel* nameLabel, * statusMessageLabel;
- bool compact;
-
- friend class Style; ///< To update our stylesheets
+ CroppingLabel* nameLabel, *statusMessageLabel;
+ bool compact, active;
};
#endif // GENERICCHATROOMWIDGET_H
diff --git a/src/widget/widget.cpp b/src/widget/widget.cpp
index 2942ce49b..009240f67 100644
--- a/src/widget/widget.cpp
+++ b/src/widget/widget.cpp
@@ -575,7 +575,7 @@ void Widget::addFriend(int friendId, const QString &userId)
Core* core = Nexus::getCore();
connect(newfriend, &Friend::displayedNameChanged, contactListWidget, &FriendListWidget::moveWidget);
- connect(settingsWidget, &SettingsWidget::compactToggled, newfriend->getFriendWidget(), &GenericChatroomWidget::onCompactChanged);
+ connect(settingsWidget, &SettingsWidget::compactToggled, newfriend->getFriendWidget(), &GenericChatroomWidget::setCompact);
connect(newfriend->getFriendWidget(), SIGNAL(chatroomWidgetClicked(GenericChatroomWidget*)), this, SLOT(onChatroomWidgetClicked(GenericChatroomWidget*)));
connect(newfriend->getFriendWidget(), SIGNAL(removeFriend(int)), this, SLOT(removeFriend(int)));
connect(newfriend->getFriendWidget(), SIGNAL(copyFriendIdToClipboard(int)), this, SLOT(copyFriendIdToClipboard(int)));
@@ -1031,7 +1031,7 @@ Group *Widget::createGroup(int groupId)
layout->addWidget(newgroup->getGroupWidget());
newgroup->getGroupWidget()->updateStatusLight();
- connect(settingsWidget, &SettingsWidget::compactToggled, newgroup->getGroupWidget(), &GenericChatroomWidget::onCompactChanged);
+ connect(settingsWidget, &SettingsWidget::compactToggled, newgroup->getGroupWidget(), &GenericChatroomWidget::setCompact);
connect(newgroup->getGroupWidget(), SIGNAL(chatroomWidgetClicked(GenericChatroomWidget*)), this, SLOT(onChatroomWidgetClicked(GenericChatroomWidget*)));
connect(newgroup->getGroupWidget(), SIGNAL(removeGroup(int)), this, SLOT(removeGroup(int)));
connect(newgroup->getGroupWidget(), SIGNAL(chatroomWidgetClicked(GenericChatroomWidget*)), newgroup->getChatForm(), SLOT(focusInput()));
diff --git a/ui/chatroomWidgets/genericChatroomWidget.css b/ui/chatroomWidgets/genericChatroomWidget.css
deleted file mode 100644
index 09feb23c1..000000000
--- a/ui/chatroomWidgets/genericChatroomWidget.css
+++ /dev/null
@@ -1,62 +0,0 @@
-GenericChatroomWidget
-{
- background-color: @themeMedium;
-}
-
-GenericChatroomWidget[active="true"]
-{
- background-color: @white;
-}
-
-GenericChatroomWidget[active="false"]:hover
-{
- background-color: @themeLight;
-}
-
-GenericChatroomWidget[active="true"][compact="true"] > QLabel#status
-{
- font: @small;
- color: @mediumGrey;
-}
-
-GenericChatroomWidget[active="false"][compact="true"] > QLabel#status
-{
- font: @small;
- color: @lightGrey;
-}
-
-GenericChatroomWidget[active="true"][compact="true"] > QLabel#name
-{
- font: @medium;
- color: @darkGrey;
-}
-
-GenericChatroomWidget[active="false"][compact="true"] > QLabel#name
-{
- font: @medium;
- color: @white;
-}
-
-GenericChatroomWidget[active="true"][compact="false"] > QLabel#status
-{
- font: @medium;
- color: @mediumGrey;
-}
-
-GenericChatroomWidget[active="false"][compact="false"] > QLabel#status
-{
- font: @medium;
- color: @lightGrey;
-}
-
-GenericChatroomWidget[active="true"][compact="false"] > QLabel#name
-{
- font: @big;
- color: @darkGrey;
-}
-
-GenericChatroomWidget[active="false"][compact="false"] > QLabel#name
-{
- font: @big;
- color: @white;
-}