mirror of
https://github.com/dcs-liberation/dcs_liberation.git
synced 2025-11-10 14:22:26 +00:00
UI Theme switcher working
This commit is contained in:
@@ -1,11 +1,16 @@
|
||||
import os
|
||||
|
||||
from PySide2 import QtWidgets
|
||||
from PySide2.QtCore import QFile
|
||||
from PySide2.QtGui import Qt
|
||||
from PySide2.QtWidgets import QFrame, QLineEdit, QGridLayout, QVBoxLayout, QLabel, QPushButton, \
|
||||
QFileDialog, QMessageBox, QDialog
|
||||
QFileDialog, QMessageBox, QDialog, QComboBox, QApplication
|
||||
import qt_ui.uiconstants as CONST
|
||||
import sys
|
||||
|
||||
from userdata import liberation_install
|
||||
import userdata
|
||||
from userdata import liberation_install, liberation_theme
|
||||
from userdata.liberation_theme import get_theme_file, set_theme_name, get_theme_index, set_theme_index
|
||||
|
||||
|
||||
class QLiberationPreferences(QFrame):
|
||||
@@ -28,9 +33,14 @@ class QLiberationPreferences(QFrame):
|
||||
self.browse_saved_game.clicked.connect(self.on_browse_saved_games)
|
||||
self.browse_install_dir = QPushButton("Browse...")
|
||||
self.browse_install_dir.clicked.connect(self.on_browse_installation_dir)
|
||||
self.themeSelect = QComboBox()
|
||||
|
||||
for x, y in CONST.THEMES.items():
|
||||
self.themeSelect.addItem(y['themeName'])
|
||||
|
||||
self.initUi()
|
||||
|
||||
|
||||
def initUi(self):
|
||||
main_layout = QVBoxLayout()
|
||||
layout = QGridLayout()
|
||||
@@ -40,6 +50,9 @@ class QLiberationPreferences(QFrame):
|
||||
layout.addWidget(QLabel("<strong>DCS installation directory:</strong>"), 2, 0, alignment=Qt.AlignLeft)
|
||||
layout.addWidget(self.edit_dcs_install_dir, 3, 0, alignment=Qt.AlignRight)
|
||||
layout.addWidget(self.browse_install_dir, 3, 1, alignment=Qt.AlignRight)
|
||||
layout.addWidget(QLabel("<strong>Theme (Requires Restart)</strong>"), 4, 0)
|
||||
layout.addWidget(self.themeSelect, 4, 1, alignment=Qt.AlignRight)
|
||||
self.themeSelect.setCurrentIndex(get_theme_index())
|
||||
|
||||
main_layout.addLayout(layout)
|
||||
main_layout.addStretch()
|
||||
@@ -63,6 +76,7 @@ class QLiberationPreferences(QFrame):
|
||||
print("Applying changes")
|
||||
self.saved_game_dir = self.edit_saved_game_dir.text()
|
||||
self.dcs_install_dir = self.edit_dcs_install_dir.text()
|
||||
set_theme_index(self.themeSelect.currentIndex())
|
||||
|
||||
if not os.path.isdir(self.saved_game_dir):
|
||||
error_dialog = QMessageBox.critical(self, "Wrong DCS Saved Games directory.",
|
||||
@@ -87,6 +101,7 @@ class QLiberationPreferences(QFrame):
|
||||
|
||||
liberation_install.setup(self.saved_game_dir, self.dcs_install_dir)
|
||||
liberation_install.save_config()
|
||||
liberation_theme.set_theme_file()
|
||||
return True
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user