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">
|
<property name="autoFillBackground">
|
||||||
<bool>true</bool>
|
<bool>true</bool>
|
||||||
</property>
|
</property>
|
||||||
<widget class="QLabel" name="label">
|
<widget class="QLabel" name="profilePicture">
|
||||||
<property name="geometry">
|
<property name="geometry">
|
||||||
<rect>
|
<rect>
|
||||||
<x>10</x>
|
<x>10</x>
|
||||||
|
|
|
@ -16,6 +16,7 @@ FriendWidget::FriendWidget(int FriendId, QString id)
|
||||||
|
|
||||||
avatar.setPixmap(QPixmap("img/contact list icons/contact.png"));
|
avatar.setPixmap(QPixmap("img/contact list icons/contact.png"));
|
||||||
name.setText(id);
|
name.setText(id);
|
||||||
|
//statusPic.setAlignment(Qt::AlignHCenter);
|
||||||
statusPic.setPixmap(QPixmap("img/status/dot_away.png"));
|
statusPic.setPixmap(QPixmap("img/status/dot_away.png"));
|
||||||
QFont small;
|
QFont small;
|
||||||
small.setPixelSize(10);
|
small.setPixelSize(10);
|
||||||
|
@ -37,6 +38,9 @@ FriendWidget::FriendWidget(int FriendId, QString id)
|
||||||
layout.addSpacing(5);
|
layout.addSpacing(5);
|
||||||
layout.addWidget(&statusPic);
|
layout.addWidget(&statusPic);
|
||||||
layout.addSpacing(5);
|
layout.addSpacing(5);
|
||||||
|
|
||||||
|
int isActiveWidget = 0;
|
||||||
|
int isCursorOver = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void FriendWidget::mouseReleaseEvent (QMouseEvent*)
|
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()
|
void FriendWidget::setAsActiveChatroom()
|
||||||
{
|
{
|
||||||
|
isActiveWidget = 1;
|
||||||
|
|
||||||
QFont small;
|
QFont small;
|
||||||
small.setPixelSize(10);
|
small.setPixelSize(10);
|
||||||
statusMessage.setFont(small);
|
statusMessage.setFont(small);
|
||||||
|
@ -81,6 +120,8 @@ void FriendWidget::setAsActiveChatroom()
|
||||||
|
|
||||||
void FriendWidget::setAsInactiveChatroom()
|
void FriendWidget::setAsInactiveChatroom()
|
||||||
{
|
{
|
||||||
|
isActiveWidget = 0;
|
||||||
|
|
||||||
QFont small;
|
QFont small;
|
||||||
small.setPixelSize(10);
|
small.setPixelSize(10);
|
||||||
statusMessage.setFont(small);
|
statusMessage.setFont(small);
|
||||||
|
|
|
@ -13,6 +13,8 @@ public:
|
||||||
FriendWidget(int FriendId, QString id);
|
FriendWidget(int FriendId, QString id);
|
||||||
void mouseReleaseEvent (QMouseEvent* event);
|
void mouseReleaseEvent (QMouseEvent* event);
|
||||||
void contextMenuEvent(QContextMenuEvent * event);
|
void contextMenuEvent(QContextMenuEvent * event);
|
||||||
|
void enterEvent(QEvent* event);
|
||||||
|
void leaveEvent(QEvent* event);
|
||||||
void setAsActiveChatroom();
|
void setAsActiveChatroom();
|
||||||
void setAsInactiveChatroom();
|
void setAsInactiveChatroom();
|
||||||
|
|
||||||
|
@ -25,6 +27,10 @@ public:
|
||||||
QLabel avatar, name, statusMessage, statusPic;
|
QLabel avatar, name, statusMessage, statusPic;
|
||||||
QHBoxLayout layout;
|
QHBoxLayout layout;
|
||||||
QVBoxLayout textLayout;
|
QVBoxLayout textLayout;
|
||||||
|
|
||||||
|
private:
|
||||||
|
void mousePressEvent(QMouseEvent *event);
|
||||||
|
int isActiveWidget, isCursorOver;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // FRIENDWIDGET_H
|
#endif // FRIENDWIDGET_H
|
||||||
|
|
Loading…
Reference in New Issue
Block a user