mirror of
https://github.com/qTox/qTox.git
synced 2024-03-22 14:00:36 +08:00
Add mouse hover effect for friends
This commit is contained in:
parent
03e3a8428e
commit
a54bb37700
|
@ -940,7 +940,7 @@
|
|||
<property name="autoFillBackground">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<widget class="QLabel" name="label">
|
||||
<widget class="QLabel" name="profilePicture">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>10</x>
|
||||
|
|
|
@ -16,6 +16,7 @@ FriendWidget::FriendWidget(int FriendId, QString id)
|
|||
|
||||
avatar.setPixmap(QPixmap("img/contact list icons/contact.png"));
|
||||
name.setText(id);
|
||||
//statusPic.setAlignment(Qt::AlignHCenter);
|
||||
statusPic.setPixmap(QPixmap("img/status/dot_away.png"));
|
||||
QFont small;
|
||||
small.setPixelSize(10);
|
||||
|
@ -37,6 +38,9 @@ FriendWidget::FriendWidget(int FriendId, QString id)
|
|||
layout.addSpacing(5);
|
||||
layout.addWidget(&statusPic);
|
||||
layout.addSpacing(5);
|
||||
|
||||
int isActiveWidget = 0;
|
||||
int isCursorOver = 0;
|
||||
}
|
||||
|
||||
void FriendWidget::mouseReleaseEvent (QMouseEvent*)
|
||||
|
@ -62,8 +66,43 @@ void FriendWidget::contextMenuEvent(QContextMenuEvent * event)
|
|||
}
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
void FriendWidget::enterEvent(QEvent*)
|
||||
{
|
||||
isCursorOver = 1;
|
||||
if (isActiveWidget != 1)
|
||||
{
|
||||
QPalette pal;
|
||||
pal.setColor(QPalette::Background, QColor(75,75,75,255));
|
||||
lastColor = this->palette().background().color();
|
||||
this->setPalette(pal);
|
||||
}
|
||||
}
|
||||
|
||||
void FriendWidget::leaveEvent(QEvent*)
|
||||
{
|
||||
if (isActiveWidget != 1)
|
||||
{
|
||||
QPalette pal;
|
||||
pal.setColor(QPalette::Background, lastColor);
|
||||
this->setPalette(pal);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void FriendWidget::setAsActiveChatroom()
|
||||
{
|
||||
isActiveWidget = 1;
|
||||
|
||||
QFont small;
|
||||
small.setPixelSize(10);
|
||||
statusMessage.setFont(small);
|
||||
|
@ -81,6 +120,8 @@ void FriendWidget::setAsActiveChatroom()
|
|||
|
||||
void FriendWidget::setAsInactiveChatroom()
|
||||
{
|
||||
isActiveWidget = 0;
|
||||
|
||||
QFont small;
|
||||
small.setPixelSize(10);
|
||||
statusMessage.setFont(small);
|
||||
|
|
|
@ -13,6 +13,8 @@ public:
|
|||
FriendWidget(int FriendId, QString id);
|
||||
void mouseReleaseEvent (QMouseEvent* event);
|
||||
void contextMenuEvent(QContextMenuEvent * event);
|
||||
void enterEvent(QEvent* event);
|
||||
void leaveEvent(QEvent* event);
|
||||
void setAsActiveChatroom();
|
||||
void setAsInactiveChatroom();
|
||||
|
||||
|
@ -25,6 +27,10 @@ public:
|
|||
QLabel avatar, name, statusMessage, statusPic;
|
||||
QHBoxLayout layout;
|
||||
QVBoxLayout textLayout;
|
||||
|
||||
private:
|
||||
void mousePressEvent(QMouseEvent *event);
|
||||
int isActiveWidget, isCursorOver;
|
||||
};
|
||||
|
||||
#endif // FRIENDWIDGET_H
|
||||
|
|
Loading…
Reference in New Issue
Block a user