Skip to content
Snippets Groups Projects
Commit be91490d authored by inso's avatar inso
Browse files

Enhance community tile style and behaviour

parent 7974ce4d
Branches
Tags
No related merge requests found
......@@ -23,9 +23,25 @@ class CommunityState(enum.Enum):
class CommunityTile(QFrame):
clicked = pyqtSignal()
_hover_stylesheet = """QFrame#CommunityTile {
border-radius: 5px;
background-color: palette(midlight);
}
"""
_pressed_stylesheet = """QFrame#CommunityTile {
border-radius: 5px;
background-color: palette(dark);
}
"""
_standard_stylesheet = """QFrame#CommunityTile {
border-radius: 5px;
background-color: palette(base);
}
"""
def __init__(self, parent, app, community):
super().__init__(parent)
self.setObjectName("CommunityTile")
self.app = app
self.community = community
self.community.network.nodes_changed.connect(self.handle_nodes_change)
......@@ -35,6 +51,7 @@ class CommunityTile(QFrame):
self.layout().addWidget(self.text_label)
self.setFrameShape(QFrame.StyledPanel)
self.setFrameShadow(QFrame.Raised)
self.setStyleSheet(CommunityTile._standard_stylesheet)
self.busy = Busy(self)
self.busy.hide()
self._state = CommunityState.NOT_INIT
......@@ -130,17 +147,24 @@ class CommunityTile(QFrame):
self.busy.hide()
def mousePressEvent(self, event):
self.clicked.emit()
self.grabMouse()
self.setStyleSheet(CommunityTile._pressed_stylesheet)
return super().mousePressEvent(event)
def mouseReleaseEvent(self, event):
self.releaseMouse()
self.setStyleSheet(CommunityTile._hover_stylesheet)
self.clicked.emit()
return super().mouseReleaseEvent(event)
def resizeEvent(self, event):
self.busy.resize(event.size())
super().resizeEvent(event)
def enterEvent(self, event):
self.setStyleSheet("color: rgb(0, 115, 173);")
self.setStyleSheet(CommunityTile._hover_stylesheet)
return super().enterEvent(event)
def leaveEvent(self, event):
self.setStyleSheet("")
self.setStyleSheet(CommunityTile._standard_stylesheet)
return super().leaveEvent(event)
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment