Skip to content

Commit

Permalink
Fix cancel change colour fails to revert colour (close #3)
Browse files Browse the repository at this point in the history
  • Loading branch information
odest committed Jun 8, 2024
1 parent b31c759 commit 8f59afe
Show file tree
Hide file tree
Showing 2 changed files with 75 additions and 25 deletions.
38 changes: 31 additions & 7 deletions src/menu/backgroundPage.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ def initWidgets(self):
self.filePickerMiniButton.setMaximumSize(32, 32)
self.HBoxLayout1.addWidget(self.filePickerMiniButton)
self.colorPickerMiniButton = PushButton(self)
self.colorPickerMiniButton.clicked.connect(lambda: self.showColorDialog(self.updateBackgroundColor, self.parent.backgroundColor))
self.colorPickerMiniButton.clicked.connect(lambda: self.showColorDialog("background color", self.parent.backgroundColor))
self.colorPickerMiniButton.setStyleSheet("PushButton {background: rgba%s; border-radius: 5px;}" % str(self.parent.backgroundColor))
self.colorPickerMiniButton.setMaximumSize(32, 32)
if self.parent.backgroundType == "Color":
Expand All @@ -54,7 +54,7 @@ def initWidgets(self):
self.borderColorPickerButton.clicked.connect(lambda: self.showColorDialog(self.updateBorderColor, self.parent.backgroundBorderColor))
self.HBoxLayout2.addWidget(self.borderColorPickerButton)
self.borderColorPickerMiniButton = PushButton(self)
self.borderColorPickerMiniButton.clicked.connect(lambda: self.showColorDialog(self.updateBorderColor, self.parent.backgroundBorderColor))
self.borderColorPickerMiniButton.clicked.connect(lambda: self.showColorDialog("border color", self.parent.backgroundBorderColor))
self.borderColorPickerMiniButton.setStyleSheet("PushButton {background: rgba%s; border-radius: 5px;}" % str(self.parent.backgroundBorderColor))
self.borderColorPickerMiniButton.setMaximumSize(32, 32)
self.HBoxLayout2.addWidget(self.borderColorPickerMiniButton)
Expand Down Expand Up @@ -178,11 +178,35 @@ def comboBoxSelect(self, text):
self.parent.beforeRestart()


def showColorDialog(self, callback, currentColor):
color_dialog = QColorDialog(QColor(*currentColor), self)
color_dialog.setStyleSheet("QColorDialog {background: QLinearGradient( x1: 0, y1: 0,x2: 1, y2: 0, stop: 0 rgb(7,43,71), stop: 1 rgb(12,76,125)); color: black;}")
color_dialog.currentColorChanged.connect(callback)
color_dialog.exec_()
def showColorDialog(self, type, currentColor):
colorDialog = QColorDialog(QColor(*currentColor), self)
colorDialog.setStyleSheet("QColorDialog {background: QLinearGradient( x1: 0, y1: 0,x2: 1, y2: 0, stop: 0 rgb(7,43,71), stop: 1 rgb(12,76,125)); color: black;}")
self.currentBackgroundColor = self.parent.backgroundColor
self.currentBorderColor = self.parent.backgroundBorderColor

if type == "background color":
colorDialog.currentColorChanged.connect(self.updateBackgroundColor)

if colorDialog.exec_() == QColorDialog.Accepted:
self.tempBackgroundColor = colorDialog.selectedColor()
self.currentBackgroundColor = self.tempBackgroundColor
self.updateBackgroundColor(self.tempBackgroundColor)
else:
self.parent.backgroundColor = self.currentBackgroundColor
self.parent.backgroundLayer.setStyleSheet(f"background-color: rgba{self.parent.backgroundColor}; border-radius:{self.parent.backgroundBorderRadius}px;")
self.colorPickerMiniButton.setStyleSheet("PushButton {background: rgba%s; border-radius: 5px;}" % str(self.parent.backgroundColor))

elif type == "border color":
colorDialog.currentColorChanged.connect(self.updateBorderColor)

if colorDialog.exec_() == QColorDialog.Accepted:
self.tempBorderColor = colorDialog.selectedColor()
self.currentBorderColor = self.tempBorderColor
self.updateBorderColor(self.tempBorderColor)
else:
self.parent.backgroundBorderColor = self.currentBorderColor
self.parent.borderLayer.setStyleSheet(f'background-color: transparent; border: {self.parent.backgroundBorderSize}px solid rgba{self.parent.backgroundBorderColor}; border-radius: {self.parent.backgroundBorderRadius}')
self.borderColorPickerMiniButton.setStyleSheet("PushButton {background: rgba%s; border-radius: 5px;}" % str(self.parent.backgroundBorderColor))


def showFileDialog(self):
Expand Down
62 changes: 44 additions & 18 deletions src/menu/textPage.py
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ def updateToolTips(self):


def updateTextColor(self, color):
r, g, b, a = color.getRgb()
r, g, b, _ = color.getRgb()
self.parent.textColor = (r, g, b, self.parent.textColor[3])
self.parent.hourText.setStyleSheet(f"background-color: transparent; color: rgba{self.parent.textColor};")
self.parent.minuteText.setStyleSheet(f"background-color: transparent; color: rgba{self.parent.textColor};")
Expand All @@ -169,13 +169,13 @@ def updateTextColor(self, color):

def updateNormalIconColor(self, color):
r, g, b, _ = color.getRgb()
self.__tempIconNormalColor = (r, g, b)
self.tempIconNormalColor = (r, g, b)
self.iconsNormalColorPickerMiniButton.setStyleSheet("PushButton {background: rgb%s; border-radius: 5px;}" % str((r, g, b)))


def updateHoverIconColor(self, color):
r, g, b, _ = color.getRgb()
self.parent.iconHoverColor = (r, g, b)
self.tempIconHoverColor = (r, g, b)
self.iconsHoverColorPickerMiniButton.setStyleSheet("PushButton {background: rgb%s; border-radius: 5px;}" % str((r, g, b)))


Expand Down Expand Up @@ -243,26 +243,52 @@ def sliderEvent(self, whichWidget, slider, label):


def showColorDialog(self, type, currentColor):
color_dialog = QColorDialog(QColor(*currentColor), self)
color_dialog.setStyleSheet("QColorDialog {background: QLinearGradient( x1: 0, y1: 0,x2: 1, y2: 0, stop: 0 rgb(7,43,71), stop: 1 rgb(12,76,125)); color: black;}")
colorDialog = QColorDialog(QColor(*currentColor), self)
colorDialog.setStyleSheet("QColorDialog {background: QLinearGradient( x1: 0, y1: 0,x2: 1, y2: 0, stop: 0 rgb(7,43,71), stop: 1 rgb(12,76,125)); color: black;}")
self.currentTextColor = self.parent.textColor
self.currentIconNormalColor = self.parent.iconNormalColor
self.currentIconHoverColor = self.parent.iconHoverColor
self.tempTextColor = self.currentTextColor
self.tempIconNormalColor = self.currentIconNormalColor
self.tempIconHoverColor = self.currentIconHoverColor
self.oldNormalIconColor = self.parent.iconNormalColor
self.oldHoverIconColor = self.parent.iconHoverColor

if type == "text":
color_dialog.currentColorChanged.connect(self.updateTextColor)
colorDialog.currentColorChanged.connect(self.updateTextColor)

if colorDialog.exec_() == QColorDialog.Accepted:
self.tempTextColor = colorDialog.selectedColor()
self.currentTextColor = self.tempTextColor
self.updateTextColor(self.tempTextColor)
else:
self.parent.textColor = self.currentTextColor
self.parent.hourText.setStyleSheet(f"background-color: transparent; color: rgba{self.parent.textColor};")
self.parent.minuteText.setStyleSheet(f"background-color: transparent; color: rgba{self.parent.textColor};")
self.parent.secondText.setStyleSheet(f"background-color: transparent; color: rgba{self.parent.textColor};")
self.parent.blinkingColonText.setStyleSheet(f'background-color: transparent; color: rgba{self.parent.textColor};')
self.parent.dateText.setStyleSheet(f'background-color: transparent; color: rgba{self.parent.textColor};')
self.colorPickerMiniButton.setStyleSheet("PushButton {background: rgba%s; border-radius: 5px;}" % str(self.parent.textColor))

elif type == "normal icon":
__oldNormalIconColor = self.parent.iconNormalColor
self.__tempIconNormalColor = None
color_dialog.currentColorChanged.connect(self.updateNormalIconColor)
colorDialog.currentColorChanged.connect(self.updateNormalIconColor)

elif type == "hover icon":
color_dialog.currentColorChanged.connect(self.updateHoverIconColor)
if colorDialog.exec_() == QColorDialog.Accepted:
self.parent.iconNormalColor = self.tempIconNormalColor
self.parent.updateSVG(self.oldNormalIconColor, self.parent.iconNormalColor)
else:
self.parent.iconNormalColor = self.currentIconNormalColor
self.iconsNormalColorPickerMiniButton.setStyleSheet("PushButton {background: rgb%s; border-radius: 5px;}" % str(self.parent.iconNormalColor))

if color_dialog.exec_():
if type == "normal icon":
self.parent.iconNormalColor = self.__tempIconNormalColor
self.parent.updateSVG(__oldNormalIconColor, self.parent.iconNormalColor)
else:
if type == "normal icon":
self.iconsNormalColorPickerMiniButton.setStyleSheet("PushButton {background: rgb%s; border-radius: 5px;}" % str(__oldNormalIconColor))
elif type == "hover icon":
colorDialog.currentColorChanged.connect(self.updateHoverIconColor)

if colorDialog.exec_() == QColorDialog.Accepted:
self.parent.iconHoverColor = self.tempIconHoverColor
self.parent.updateSVG(self.oldHoverIconColor, self.parent.iconHoverColor)
else:
self.parent.iconHoverColor = self.currentIconHoverColor
self.iconsHoverColorPickerMiniButton.setStyleSheet("PushButton {background: rgb%s; border-radius: 5px;}" % str((self.parent.iconHoverColor)))


def showFileDialog(self):
Expand Down

0 comments on commit 8f59afe

Please sign in to comment.