diff --git a/widget/friendwidget.cpp b/widget/friendwidget.cpp index 36113677b..265cde30c 100644 --- a/widget/friendwidget.cpp +++ b/widget/friendwidget.cpp @@ -5,6 +5,7 @@ FriendWidget::FriendWidget(int FriendId, QString id) : friendId(FriendId) { + this->setAutoFillBackground(true); this->setLayout(&layout); this->setFixedWidth(225); this->setFixedHeight(55); @@ -60,3 +61,35 @@ void FriendWidget::contextMenuEvent(QContextMenuEvent * event) } } } + +void FriendWidget::setAsActiveFriend() +{ + QFont small; + small.setPixelSize(10); + statusMessage.setFont(small); + QPalette pal; + pal.setColor(QPalette::WindowText,Qt::darkGray); + statusMessage.setPalette(pal); + QPalette pal2; + pal2.setColor(QPalette::WindowText,Qt::black); + name.setPalette(pal2); + QPalette pal3; + pal3.setColor(QPalette::Background, Qt::white); + this->setPalette(pal3); +} + +void FriendWidget::setAsInactiveFriend() +{ + QFont small; + small.setPixelSize(10); + statusMessage.setFont(small); + QPalette pal; + pal.setColor(QPalette::WindowText,Qt::gray); + statusMessage.setPalette(pal); + QPalette pal2; + pal2.setColor(QPalette::WindowText,Qt::white); + name.setPalette(pal2); + QPalette pal3; + pal3.setColor(QPalette::Background, QColor(63,63,63,255)); + this->setPalette(pal3); +} diff --git a/widget/friendwidget.h b/widget/friendwidget.h index a37a8987d..f5d0f4f6a 100644 --- a/widget/friendwidget.h +++ b/widget/friendwidget.h @@ -13,6 +13,8 @@ public: FriendWidget(int FriendId, QString id); void mouseReleaseEvent (QMouseEvent* event); void contextMenuEvent(QContextMenuEvent * event); + void setAsActiveFriend(); + void setAsInactiveFriend(); signals: void friendWidgetClicked(FriendWidget* widget); diff --git a/widget/widget.cpp b/widget/widget.cpp index fa7d12d54..ecaab43a0 100644 --- a/widget/widget.cpp +++ b/widget/widget.cpp @@ -289,6 +289,12 @@ void Widget::onFriendUsernameLoaded(int friendId, const QString& username) void Widget::onFriendWidgetClicked(FriendWidget *widget) { + if (activeFriendWidget != 0) + { + activeFriendWidget->setAsInactiveFriend(); + } + activeFriendWidget = widget; + widget->setAsActiveFriend(); Friend* f = FriendList::findFriend(widget->friendId); if (!f) return; diff --git a/widget/widget.h b/widget/widget.h index 18e66b228..b12657fab 100644 --- a/widget/widget.h +++ b/widget/widget.h @@ -80,6 +80,7 @@ private: AddFriendForm friendForm; SettingsForm settingsForm; static Widget* instance; + FriendWidget* activeFriendWidget; }; #endif // WIDGET_H