Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
alexpdev committed Dec 11, 2023
1 parent 3e74560 commit 12f8b52
Show file tree
Hide file tree
Showing 5 changed files with 2,409 additions and 2 deletions.
9 changes: 7 additions & 2 deletions QStyler/styler.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
from PySide6.QtWidgets import (QApplication, QComboBox, QFileDialog,
QHBoxLayout, QLabel, QListWidget,
QListWidgetItem, QSlider, QTextEdit, QToolBar,
QVBoxLayout, QWidget)
QVBoxLayout, QWidget, QLineEdit)

from QStyler.dialog import NewDialog, RenameDialog
from QStyler.utils import (ParsingError, QssParser, apply_stylesheet, get_icon,
Expand Down Expand Up @@ -57,6 +57,7 @@ def __init__(self, parent=None):
self.red_layout = QHBoxLayout()
self.green_layout = QHBoxLayout()
self.blue_layout = QHBoxLayout()
self.line_edit = QLineEdit()
self.red_label = QLabel("R")
self.green_label = QLabel("G")
self.blue_label = QLabel("B")
Expand All @@ -74,12 +75,14 @@ def __init__(self, parent=None):
self.blue_layout.addWidget(self.blue_label)
self.blue_layout.addWidget(self.blue_slider)
self.layout.addWidget(self.label)
self.layout.addWidget(self.line_edit)
self.layout.addLayout(self.red_layout)
self.layout.addLayout(self.green_layout)
self.layout.addLayout(self.blue_layout)
self.blue_slider.setRange(0, 255)
self.green_slider.setRange(0, 255)
self.red_slider.setRange(0, 255)
self.line_edit.setReadOnly(True)
self.blue_slider.valueChanged.connect(self.change_color)
self.red_slider.valueChanged.connect(self.change_color)
self.green_slider.valueChanged.connect(self.change_color)
Expand All @@ -98,6 +101,7 @@ def change_color(self, _):
red_value = self.red_slider.value()
color_val = [f"{i:02x}" for i in [red_value, green_value, blue_value]]
color_string = "#" + "".join(color_val)
self.line_edit.setText(color_string)
self.label.setStyleSheet(f"background-color: {color_string};")
self.colorChanged.emit(color_string)

Expand Down Expand Up @@ -495,13 +499,14 @@ def insert_color(self, color):
cursor.MoveOperation.Left, cursor.MoveMode.KeepAnchor, e - s
)
cursor.deleteChar()
self.editor.insertPlainText(color + ";")
elif result2: # pragma: nocover
s, e = second + result2.start(), pos
cursor.movePosition(
cursor.MoveOperation.Left, cursor.MoveMode.KeepAnchor, e - s
)
cursor.deleteChar()
self.editor.insertPlainText(color + ";")
self.editor.insertPlainText(color + ";")

def live_update(self):
"""Update theme in real time."""
Expand Down
Loading

0 comments on commit 12f8b52

Please sign in to comment.