Skip to content

Commit

Permalink
Darkmode is now forced
Browse files Browse the repository at this point in the history
  • Loading branch information
YourBoyRory committed Dec 16, 2024
1 parent e5da648 commit d88d347
Show file tree
Hide file tree
Showing 5 changed files with 93 additions and 20 deletions.
2 changes: 1 addition & 1 deletion FrameDialog.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from PyQt5.QtCore import Qt, QUrl, QSize, QTimer, QStringListModel, pyqtSignal
from PyQt5.QtGui import QPixmap, QImage, QIcon, QColor, QFont
from PyQt5.QtWidgets import QScrollArea, QSlider, QMainWindow, QMessageBox, QMenuBar, QDialog, QColorDialog, QFormLayout, QLineEdit, QMenu, QAction, QListWidgetItem, QListWidget, QTabWidget, QApplication, QWidget, QVBoxLayout, QComboBox, QLabel, QFrame, QHBoxLayout, QFileDialog, QSizePolicy, QSpinBox, QPushButton
from PyQt5.QtWidgets import QApplication, QStyleFactory, QProgressBar
from PyQt5.QtWidgets import QApplication, QStyleFactory, QProgressBar, QSpacerItem

class HelpDialog(QDialog):
def __init__(self, parent):
Expand Down
5 changes: 4 additions & 1 deletion FrameWidgets.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,13 +66,14 @@ def displayText(self, text):
text_item = QGraphicsTextItem(text)
font = QFont("Sans", 16)
text_item.setFont(font)
#text_item.setDefaultTextColor(Qt.black)
text_item.setDefaultTextColor(Qt.white)

# Center the text in the scene
text_item.setPos(200, 250) # Adjust the position to suit your needs

# Add the text item to the scene
scene = QGraphicsScene(self)
scene.setObjectName("IgnoreMin")
scene.addItem(text_item)
self.setScene(scene)

Expand Down Expand Up @@ -117,6 +118,7 @@ def __init__(self, parent):
combine_OptionsViewport = QHBoxLayout()
"""Options Pane"""
PaintingOptions = QWidget()
PaintingOptions.setObjectName("Frame")
PaintingOptions_layout = QVBoxLayout()

lable_width = 120
Expand Down Expand Up @@ -196,6 +198,7 @@ def __init__(self, parent):

"""Tool Bar"""
ToolBar = QWidget()
ToolBar.setObjectName("Frame")
ToolBar_layout = QVBoxLayout()
# View Port Tools
tools_layout = QHBoxLayout()
Expand Down
34 changes: 17 additions & 17 deletions PaintingStudio.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,9 @@ class PaintingStudio(QMainWindow):

def __init__(self):
super().__init__()
self.setObjectName("Frame")
self.central_widget = QWidget()
self.central_widget.setObjectName("Frame")
self.setCentralWidget(self.central_widget)
layout = QHBoxLayout(self)
self.central_widget.setLayout(layout)
Expand Down Expand Up @@ -135,6 +137,12 @@ def addToComboBox(self, item):
else:
print(item, "Exists")

def resource_path(file):
if getattr(sys, 'frozen', False):
base_path = sys._MEIPASS
else:
base_path = os.path.dirname(__file__)
return os.path.join(base_path, 'styles', file)

def set_theme(app):
desktop = ""
Expand All @@ -145,26 +153,18 @@ def set_theme(app):
]
desktop = os.environ.get('DESKTOP_SESSION')
if any(sub in desktop for sub in gtk_based):
try:
import subprocess
result = subprocess.run(
['gsettings', 'get', 'org.gnome.desktop.interface', 'color-scheme'],
stdout=subprocess.PIPE,
stderr=subprocess.PIPE,
text=True
)
theme = result.stdout.strip().lower()
print(theme)
if 'dark' in theme:
app.setStyle("Adwaita-Dark")
else:
app.setStyle("Adwaita")
except:
print("Failed to get theme satus")
app.setStyle("Adwaita")
app.setStyle("Adwaita-Dark")
except:
pass
current_style = app.style().objectName()
if desktop == "" or current_style == "windowsvista":
desktop = "windows"
try:
with open(resource_path("Adwaita-Dark.qss"), "r") as f:
app.setStyleSheet(f.read())
except:
print("Failed to load darkmode")
pass
print(f"Loaded Theme: {current_style} on {desktop}")

if __name__ == "__main__":
Expand Down
2 changes: 1 addition & 1 deletion build-windows.cmd
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
python -m venv ./venv-windows
source ./venv-windows/Scripts/activate.bat
pip install -r requirements.txt
pyinstaller --onefile --windowed --name "MCPaintingStudio" --add-data "assets:assets/" ./PaintingStudio.py
pyinstaller --onefile --windowed --name "MCPaintingStudio" --add-data "assets:assets/" --add-data "styles:styles/" ./PaintingStudio.py
echo.
echo Build Done
echo.
Expand Down
70 changes: 70 additions & 0 deletions styles/Adwaita-Dark.qss
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
/* General QWidget styling */

QWidget {
border: 1px solid #393939;
background-color: #393939;
color: #f9fafa;
}

QWidget#IgnoreMin {
min-height: 1px;
}

QWidget:disabled {
border: 1px solid #2d2d2d;
background-color: #2d2d2d;
color: #999999;
}
QWidget:focus {
border: 2px solid #587392;
}

QWidget#Frame {
background-color: #242424;
border: none;
}

QLabel {
background-color: #242424;
border: none;
}

QCheckBox {
background-color: #242424;
border: none;
}

QSlider {
background-color: #242424;
border: none;
}

QSlider:disabled {
background-color: #242424;
border: none;
}

QLineEdit {
min-height: 25px;
}

QSpinBox {
min-height: 25px;
}

QComboBox {
min-height: 25px;
}

QPushButton {
min-height: 25px;
min-width: 100px;
}

QPushButton:hover {
background-color: #454545;
}

QPushButton:pressed {
background-color: #707070;
}

0 comments on commit d88d347

Please sign in to comment.