81 lines
2.6 KiB
Python
81 lines
2.6 KiB
Python
|
from registry import Registry
|
||
|
from drives import Drives
|
||
|
from PyQt6.QtWidgets import QPushButton
|
||
|
from PyQt6.QtWidgets import QLabel
|
||
|
from PyQt6.QtWidgets import QLineEdit
|
||
|
from PyQt6.QtWidgets import QComboBox
|
||
|
from PyQt6.QtWidgets import QStyle
|
||
|
from PyQt6.QtWidgets import QDialog
|
||
|
from PyQt6 import QtCore
|
||
|
|
||
|
|
||
|
class wConfig(QDialog):
|
||
|
def __init__(self):
|
||
|
super().__init__()
|
||
|
|
||
|
self.reg = Registry()
|
||
|
self.drives = Drives()
|
||
|
|
||
|
self.setWindowTitle("Konfiguration")
|
||
|
self.setFixedSize(300, 120)
|
||
|
|
||
|
pixmap = QStyle.StandardPixmap.SP_DriveNetIcon
|
||
|
icon = self.style().standardIcon(pixmap)
|
||
|
self.setWindowIcon(icon)
|
||
|
|
||
|
# Window should stay on top and only close button is visible
|
||
|
self.setWindowFlags(QtCore.Qt.WindowType.WindowStaysOnTopHint | QtCore.Qt.WindowType.WindowCloseButtonHint)
|
||
|
|
||
|
# ArchivePath label and input field
|
||
|
self.lArchivePath = QLabel("Pfad zum Archiv:", self)
|
||
|
self.lArchivePath.setGeometry(10, 10, 100, 20)
|
||
|
|
||
|
self.leArchivePath = QLineEdit(self)
|
||
|
self.leArchivePath.setText(self.reg.ArchivePath)
|
||
|
self.leArchivePath.setGeometry(155, 10, 135, 20)
|
||
|
|
||
|
# CDRomPath label and drop down menu
|
||
|
self.lCDRomPath = QLabel("CD-Rom-Laufwerk:", self)
|
||
|
self.lCDRomPath.setGeometry(10, 40, 100, 20)
|
||
|
|
||
|
self.ddCDRomPath = QComboBox(self)
|
||
|
self.ddCDRomPath.addItems(self.drives.list)
|
||
|
self.ddCDRomPath.setCurrentText(self.reg.CDRomPath)
|
||
|
self.ddCDRomPath.setGeometry(155, 40, 135, 20)
|
||
|
|
||
|
# Apply
|
||
|
self.bApply = QPushButton("Übernehmen", self)
|
||
|
self.bApply.setGeometry(10, 70, 135, 40)
|
||
|
self.bApply.clicked.connect(self.bApplyFunction)
|
||
|
|
||
|
# Cancel / Close
|
||
|
self.bClose = QPushButton("Schließen", self)
|
||
|
self.bClose.setGeometry(155, 70, 135, 40)
|
||
|
self.bClose.clicked.connect(self.bCloseFunction)
|
||
|
|
||
|
self.exec()
|
||
|
|
||
|
def bApplyFunction(self):
|
||
|
# Get text from ArchivePath input field
|
||
|
ArchivePath = self.leArchivePath.text()
|
||
|
|
||
|
# Remove all backslashes from the end of the string
|
||
|
while ArchivePath[-1] == "\\":
|
||
|
ArchivePath = ArchivePath[:-1]
|
||
|
|
||
|
# Get selected item from CDRomPath drop down menu
|
||
|
CDRomPath = self.ddCDRomPath.currentText()
|
||
|
|
||
|
# Set both variables in the running app
|
||
|
self.reg.ArchivePath = ArchivePath
|
||
|
self.reg.CDRomPath = CDRomPath
|
||
|
|
||
|
# Write both variables to the registry
|
||
|
self.reg.regWrite(ArchivePath, CDRomPath)
|
||
|
|
||
|
def bCloseFunction(self):
|
||
|
self.close()
|
||
|
|
||
|
def closeEvent(self, event):
|
||
|
self.close()
|