mirror of https://github.com/qTox/qTox
Fixed friend hover highlighting
parent
a54bb37700
commit
a52e51e1cb
|
@ -39,8 +39,7 @@ FriendWidget::FriendWidget(int FriendId, QString id)
|
|||
layout.addWidget(&statusPic);
|
||||
layout.addSpacing(5);
|
||||
|
||||
int isActiveWidget = 0;
|
||||
int isCursorOver = 0;
|
||||
isActiveWidget = 0;
|
||||
}
|
||||
|
||||
void FriendWidget::mouseReleaseEvent (QMouseEvent*)
|
||||
|
@ -70,15 +69,23 @@ void FriendWidget::mousePressEvent(QMouseEvent *event)
|
|||
{
|
||||
if ((event->buttons() & Qt::LeftButton) == Qt::LeftButton)
|
||||
{
|
||||
QPalette pal;
|
||||
pal.setColor(QPalette::Background, QColor(85,85,85,255));
|
||||
this->setPalette(pal);
|
||||
if (isActiveWidget)
|
||||
{
|
||||
QPalette pal;
|
||||
pal.setColor(QPalette::Background, QColor(250,250,250,255));
|
||||
this->setPalette(pal);
|
||||
}
|
||||
else
|
||||
{
|
||||
QPalette pal;
|
||||
pal.setColor(QPalette::Background, QColor(85,85,85,255));
|
||||
this->setPalette(pal);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void FriendWidget::enterEvent(QEvent*)
|
||||
{
|
||||
isCursorOver = 1;
|
||||
if (isActiveWidget != 1)
|
||||
{
|
||||
QPalette pal;
|
||||
|
|
|
@ -12,6 +12,7 @@ struct FriendWidget : public QWidget
|
|||
public:
|
||||
FriendWidget(int FriendId, QString id);
|
||||
void mouseReleaseEvent (QMouseEvent* event);
|
||||
void mousePressEvent(QMouseEvent *event);
|
||||
void contextMenuEvent(QContextMenuEvent * event);
|
||||
void enterEvent(QEvent* event);
|
||||
void leaveEvent(QEvent* event);
|
||||
|
@ -29,8 +30,8 @@ public:
|
|||
QVBoxLayout textLayout;
|
||||
|
||||
private:
|
||||
void mousePressEvent(QMouseEvent *event);
|
||||
int isActiveWidget, isCursorOver;
|
||||
QColor lastColor;
|
||||
int isActiveWidget;
|
||||
};
|
||||
|
||||
#endif // FRIENDWIDGET_H
|
||||
|
|
|
@ -41,6 +41,8 @@ GroupWidget::GroupWidget(int GroupId, QString Name)
|
|||
layout.addSpacing(5);
|
||||
layout.addLayout(&textLayout);
|
||||
layout.addStretch();
|
||||
|
||||
isActiveWidget = 0;
|
||||
}
|
||||
|
||||
void GroupWidget::mouseReleaseEvent (QMouseEvent*)
|
||||
|
@ -66,6 +68,37 @@ void GroupWidget::contextMenuEvent(QContextMenuEvent * event)
|
|||
}
|
||||
}
|
||||
|
||||
void GroupWidget::mousePressEvent(QMouseEvent *event)
|
||||
{
|
||||
if ((event->buttons() & Qt::LeftButton) == Qt::LeftButton)
|
||||
{
|
||||
QPalette pal;
|
||||
pal.setColor(QPalette::Background, QColor(85,85,85,255));
|
||||
this->setPalette(pal);
|
||||
}
|
||||
}
|
||||
|
||||
void GroupWidget::enterEvent(QEvent*)
|
||||
{
|
||||
if (isActiveWidget != 1)
|
||||
{
|
||||
QPalette pal;
|
||||
pal.setColor(QPalette::Background, QColor(75,75,75,255));
|
||||
lastColor = this->palette().background().color();
|
||||
this->setPalette(pal);
|
||||
}
|
||||
}
|
||||
|
||||
void GroupWidget::leaveEvent(QEvent*)
|
||||
{
|
||||
if (isActiveWidget != 1)
|
||||
{
|
||||
QPalette pal;
|
||||
pal.setColor(QPalette::Background, lastColor);
|
||||
this->setPalette(pal);
|
||||
}
|
||||
}
|
||||
|
||||
void GroupWidget::onUserListChanged()
|
||||
{
|
||||
Group* g = GroupList::findGroup(groupId);
|
||||
|
@ -77,6 +110,8 @@ void GroupWidget::onUserListChanged()
|
|||
|
||||
void GroupWidget::setAsActiveChatroom()
|
||||
{
|
||||
isActiveWidget = 1;
|
||||
|
||||
QFont small;
|
||||
small.setPixelSize(10);
|
||||
nusers.setFont(small);
|
||||
|
@ -94,6 +129,8 @@ void GroupWidget::setAsActiveChatroom()
|
|||
|
||||
void GroupWidget::setAsInactiveChatroom()
|
||||
{
|
||||
isActiveWidget = 0;
|
||||
|
||||
QFont small;
|
||||
small.setPixelSize(10);
|
||||
nusers.setFont(small);
|
||||
|
|
|
@ -13,7 +13,11 @@ public:
|
|||
GroupWidget(int GroupId, QString Name);
|
||||
void onUserListChanged();
|
||||
void mouseReleaseEvent (QMouseEvent* event);
|
||||
void mousePressEvent(QMouseEvent *event);
|
||||
void contextMenuEvent(QContextMenuEvent * event);
|
||||
void enterEvent(QEvent* event);
|
||||
void leaveEvent(QEvent* event);
|
||||
|
||||
|
||||
signals:
|
||||
void groupWidgetClicked(GroupWidget* widget);
|
||||
|
@ -26,6 +30,10 @@ public:
|
|||
QVBoxLayout textLayout;
|
||||
void setAsInactiveChatroom();
|
||||
void setAsActiveChatroom();
|
||||
|
||||
private:
|
||||
QColor lastColor;
|
||||
int isActiveWidget;
|
||||
};
|
||||
|
||||
#endif // GROUPWIDGET_H
|
||||
|
|
Loading…
Reference in New Issue