Skip to content

Commit

Permalink
Enhance community tile style and behaviour
Browse files Browse the repository at this point in the history
  • Loading branch information
Insoleet committed Feb 11, 2016
1 parent 7974ce4 commit be91490
Showing 1 changed file with 27 additions and 3 deletions.
30 changes: 27 additions & 3 deletions src/sakia/gui/community_tile.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -35,6 +51,7 @@ def __init__(self, parent, app, community):
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
Expand Down Expand Up @@ -130,17 +147,24 @@ async def refresh(self):
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 comments on commit be91490

Please sign in to comment.