Nils
4 years ago
13 changed files with 457 additions and 105 deletions
@ -0,0 +1,82 @@ |
|||||
|
# -*- coding: utf-8 -*- |
||||
|
|
||||
|
# Form implementation generated from reading ui file 'settings.ui' |
||||
|
# |
||||
|
# Created by: PyQt5 UI code generator 5.15.0 |
||||
|
# |
||||
|
# WARNING: Any manual changes made to this file will be lost when pyuic5 is |
||||
|
# run again. Do not edit this file unless you know what you are doing. |
||||
|
|
||||
|
|
||||
|
from PyQt5 import QtCore, QtGui, QtWidgets |
||||
|
|
||||
|
|
||||
|
class Ui_Dialog(object): |
||||
|
def setupUi(self, Dialog): |
||||
|
Dialog.setObjectName("Dialog") |
||||
|
Dialog.resize(626, 387) |
||||
|
self.verticalLayout = QtWidgets.QVBoxLayout(Dialog) |
||||
|
self.verticalLayout.setObjectName("verticalLayout") |
||||
|
self.SettingsTab = QtWidgets.QTabWidget(Dialog) |
||||
|
self.SettingsTab.setTabPosition(QtWidgets.QTabWidget.North) |
||||
|
self.SettingsTab.setTabShape(QtWidgets.QTabWidget.Rounded) |
||||
|
self.SettingsTab.setObjectName("SettingsTab") |
||||
|
self.tab_2 = QtWidgets.QWidget() |
||||
|
self.tab_2.setObjectName("tab_2") |
||||
|
self.verticalLayout_3 = QtWidgets.QVBoxLayout(self.tab_2) |
||||
|
self.verticalLayout_3.setObjectName("verticalLayout_3") |
||||
|
self.label_help_launcher_whitelist = QtWidgets.QLabel(self.tab_2) |
||||
|
self.label_help_launcher_whitelist.setWordWrap(True) |
||||
|
self.label_help_launcher_whitelist.setObjectName("label_help_launcher_whitelist") |
||||
|
self.verticalLayout_3.addWidget(self.label_help_launcher_whitelist) |
||||
|
self.launcherWhitelistPlainTextEdit = QtWidgets.QPlainTextEdit(self.tab_2) |
||||
|
self.launcherWhitelistPlainTextEdit.setObjectName("launcherWhitelistPlainTextEdit") |
||||
|
self.verticalLayout_3.addWidget(self.launcherWhitelistPlainTextEdit) |
||||
|
self.label_help_launcher_blacklist = QtWidgets.QLabel(self.tab_2) |
||||
|
self.label_help_launcher_blacklist.setWordWrap(True) |
||||
|
self.label_help_launcher_blacklist.setObjectName("label_help_launcher_blacklist") |
||||
|
self.verticalLayout_3.addWidget(self.label_help_launcher_blacklist) |
||||
|
self.launcherBlacklistPlainTextEdit = QtWidgets.QPlainTextEdit(self.tab_2) |
||||
|
self.launcherBlacklistPlainTextEdit.setObjectName("launcherBlacklistPlainTextEdit") |
||||
|
self.verticalLayout_3.addWidget(self.launcherBlacklistPlainTextEdit) |
||||
|
self.SettingsTab.addTab(self.tab_2, "") |
||||
|
self.tab = QtWidgets.QWidget() |
||||
|
self.tab.setObjectName("tab") |
||||
|
self.verticalLayout_2 = QtWidgets.QVBoxLayout(self.tab) |
||||
|
self.verticalLayout_2.setObjectName("verticalLayout_2") |
||||
|
self.label_help_programstart = QtWidgets.QLabel(self.tab) |
||||
|
self.label_help_programstart.setWordWrap(True) |
||||
|
self.label_help_programstart.setObjectName("label_help_programstart") |
||||
|
self.verticalLayout_2.addWidget(self.label_help_programstart) |
||||
|
self.label_help_path_rules = QtWidgets.QLabel(self.tab) |
||||
|
self.label_help_path_rules.setWordWrap(True) |
||||
|
self.label_help_path_rules.setObjectName("label_help_path_rules") |
||||
|
self.verticalLayout_2.addWidget(self.label_help_path_rules) |
||||
|
self.programPathsPlainTextEdit = QtWidgets.QPlainTextEdit(self.tab) |
||||
|
self.programPathsPlainTextEdit.setObjectName("programPathsPlainTextEdit") |
||||
|
self.verticalLayout_2.addWidget(self.programPathsPlainTextEdit) |
||||
|
self.SettingsTab.addTab(self.tab, "") |
||||
|
self.verticalLayout.addWidget(self.SettingsTab) |
||||
|
self.buttonBox = QtWidgets.QDialogButtonBox(Dialog) |
||||
|
self.buttonBox.setOrientation(QtCore.Qt.Horizontal) |
||||
|
self.buttonBox.setStandardButtons(QtWidgets.QDialogButtonBox.Cancel|QtWidgets.QDialogButtonBox.Ok) |
||||
|
self.buttonBox.setObjectName("buttonBox") |
||||
|
self.verticalLayout.addWidget(self.buttonBox) |
||||
|
self.buttonBox.raise_() |
||||
|
self.SettingsTab.raise_() |
||||
|
|
||||
|
self.retranslateUi(Dialog) |
||||
|
self.SettingsTab.setCurrentIndex(0) |
||||
|
self.buttonBox.accepted.connect(Dialog.accept) |
||||
|
self.buttonBox.rejected.connect(Dialog.reject) |
||||
|
QtCore.QMetaObject.connectSlotsByName(Dialog) |
||||
|
|
||||
|
def retranslateUi(self, Dialog): |
||||
|
_translate = QtCore.QCoreApplication.translate |
||||
|
Dialog.setWindowTitle(_translate("Dialog", "Settings")) |
||||
|
self.label_help_launcher_whitelist.setText(_translate("Dialog", "Whitelist - Add executable names (not paths) to the program launcher. One executable per line.")) |
||||
|
self.label_help_launcher_blacklist.setText(_translate("Dialog", "Blacklist - Exclude executable names (not paths) from the program launcher. One executable per line.")) |
||||
|
self.SettingsTab.setTabText(self.SettingsTab.indexOf(self.tab_2), _translate("Dialog", "Launcher")) |
||||
|
self.label_help_programstart.setText(_translate("Dialog", "For advanced users only! Add executable paths to the environment, just for Argodejo and NSM. Changes need a program restart afterwards. If you want your programs in the application launcher use the launcher tab.")) |
||||
|
self.label_help_path_rules.setText(_translate("Dialog", "Add one absolute path to a directory (e.g. /home/user/audio-bin) per line. No wildcards. Trailing slashes/ don\'t matter.")) |
||||
|
self.SettingsTab.setTabText(self.SettingsTab.indexOf(self.tab), _translate("Dialog", "$PATH")) |
@ -0,0 +1,142 @@ |
|||||
|
<?xml version="1.0" encoding="UTF-8"?> |
||||
|
<ui version="4.0"> |
||||
|
<class>Dialog</class> |
||||
|
<widget class="QDialog" name="Dialog"> |
||||
|
<property name="geometry"> |
||||
|
<rect> |
||||
|
<x>0</x> |
||||
|
<y>0</y> |
||||
|
<width>626</width> |
||||
|
<height>387</height> |
||||
|
</rect> |
||||
|
</property> |
||||
|
<property name="windowTitle"> |
||||
|
<string>Settings</string> |
||||
|
</property> |
||||
|
<layout class="QVBoxLayout" name="verticalLayout"> |
||||
|
<item> |
||||
|
<widget class="QTabWidget" name="SettingsTab"> |
||||
|
<property name="tabPosition"> |
||||
|
<enum>QTabWidget::North</enum> |
||||
|
</property> |
||||
|
<property name="tabShape"> |
||||
|
<enum>QTabWidget::Rounded</enum> |
||||
|
</property> |
||||
|
<property name="currentIndex"> |
||||
|
<number>0</number> |
||||
|
</property> |
||||
|
<widget class="QWidget" name="tab_2"> |
||||
|
<attribute name="title"> |
||||
|
<string>Launcher</string> |
||||
|
</attribute> |
||||
|
<layout class="QVBoxLayout" name="verticalLayout_3"> |
||||
|
<item> |
||||
|
<widget class="QLabel" name="label_help_launcher_whitelist"> |
||||
|
<property name="text"> |
||||
|
<string>Whitelist - Add executable names (not paths) to the program launcher. One executable per line.</string> |
||||
|
</property> |
||||
|
<property name="wordWrap"> |
||||
|
<bool>true</bool> |
||||
|
</property> |
||||
|
</widget> |
||||
|
</item> |
||||
|
<item> |
||||
|
<widget class="QPlainTextEdit" name="launcherWhitelistPlainTextEdit"/> |
||||
|
</item> |
||||
|
<item> |
||||
|
<widget class="QLabel" name="label_help_launcher_blacklist"> |
||||
|
<property name="text"> |
||||
|
<string>Blacklist - Exclude executable names (not paths) from the program launcher. One executable per line.</string> |
||||
|
</property> |
||||
|
<property name="wordWrap"> |
||||
|
<bool>true</bool> |
||||
|
</property> |
||||
|
</widget> |
||||
|
</item> |
||||
|
<item> |
||||
|
<widget class="QPlainTextEdit" name="launcherBlacklistPlainTextEdit"/> |
||||
|
</item> |
||||
|
</layout> |
||||
|
</widget> |
||||
|
<widget class="QWidget" name="tab"> |
||||
|
<attribute name="title"> |
||||
|
<string>$PATH</string> |
||||
|
</attribute> |
||||
|
<layout class="QVBoxLayout" name="verticalLayout_2"> |
||||
|
<item> |
||||
|
<widget class="QLabel" name="label_help_programstart"> |
||||
|
<property name="text"> |
||||
|
<string>For advanced users only! Add executable paths to the environment, just for Argodejo and NSM. Changes need a program restart afterwards. If you want your programs in the application launcher use the launcher tab.</string> |
||||
|
</property> |
||||
|
<property name="wordWrap"> |
||||
|
<bool>true</bool> |
||||
|
</property> |
||||
|
</widget> |
||||
|
</item> |
||||
|
<item> |
||||
|
<widget class="QLabel" name="label_help_path_rules"> |
||||
|
<property name="text"> |
||||
|
<string>Add one absolute path to a directory (e.g. /home/user/audio-bin) per line. No wildcards. Trailing slashes/ don't matter.</string> |
||||
|
</property> |
||||
|
<property name="wordWrap"> |
||||
|
<bool>true</bool> |
||||
|
</property> |
||||
|
</widget> |
||||
|
</item> |
||||
|
<item> |
||||
|
<widget class="QPlainTextEdit" name="programPathsPlainTextEdit"/> |
||||
|
</item> |
||||
|
</layout> |
||||
|
</widget> |
||||
|
</widget> |
||||
|
</item> |
||||
|
<item> |
||||
|
<widget class="QDialogButtonBox" name="buttonBox"> |
||||
|
<property name="orientation"> |
||||
|
<enum>Qt::Horizontal</enum> |
||||
|
</property> |
||||
|
<property name="standardButtons"> |
||||
|
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set> |
||||
|
</property> |
||||
|
</widget> |
||||
|
</item> |
||||
|
</layout> |
||||
|
<zorder>buttonBox</zorder> |
||||
|
<zorder>SettingsTab</zorder> |
||||
|
</widget> |
||||
|
<resources/> |
||||
|
<connections> |
||||
|
<connection> |
||||
|
<sender>buttonBox</sender> |
||||
|
<signal>accepted()</signal> |
||||
|
<receiver>Dialog</receiver> |
||||
|
<slot>accept()</slot> |
||||
|
<hints> |
||||
|
<hint type="sourcelabel"> |
||||
|
<x>248</x> |
||||
|
<y>254</y> |
||||
|
</hint> |
||||
|
<hint type="destinationlabel"> |
||||
|
<x>157</x> |
||||
|
<y>274</y> |
||||
|
</hint> |
||||
|
</hints> |
||||
|
</connection> |
||||
|
<connection> |
||||
|
<sender>buttonBox</sender> |
||||
|
<signal>rejected()</signal> |
||||
|
<receiver>Dialog</receiver> |
||||
|
<slot>reject()</slot> |
||||
|
<hints> |
||||
|
<hint type="sourcelabel"> |
||||
|
<x>316</x> |
||||
|
<y>260</y> |
||||
|
</hint> |
||||
|
<hint type="destinationlabel"> |
||||
|
<x>286</x> |
||||
|
<y>274</y> |
||||
|
</hint> |
||||
|
</hints> |
||||
|
</connection> |
||||
|
</connections> |
||||
|
</ui> |
Binary file not shown.
@ -0,0 +1,116 @@ |
|||||
|
#! /usr/bin/env python3 |
||||
|
# -*- coding: utf-8 -*- |
||||
|
""" |
||||
|
Copyright 2020, Nils Hilbricht, Germany ( https://www.hilbricht.net ) |
||||
|
|
||||
|
This file is part of the Laborejo Software Suite ( https://www.laborejo.org ), |
||||
|
|
||||
|
This application is free software: you can redistribute it and/or modify |
||||
|
it under the terms of the GNU General Public License as published by |
||||
|
the Free Software Foundation, either version 3 of the License, or |
||||
|
(at your option) any later version. |
||||
|
|
||||
|
This program is distributed in the hope that it will be useful, |
||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of |
||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
||||
|
GNU General Public License for more details. |
||||
|
|
||||
|
You should have received a copy of the GNU General Public License |
||||
|
along with this program. If not, see <http://www.gnu.org/licenses/>. |
||||
|
""" |
||||
|
|
||||
|
import logging; logger = logging.getLogger(__name__); logger.info("import") |
||||
|
|
||||
|
|
||||
|
#Standard Library |
||||
|
import pathlib |
||||
|
import os |
||||
|
|
||||
|
#Third Party |
||||
|
from PyQt5 import QtCore, QtWidgets |
||||
|
|
||||
|
#Engine |
||||
|
import engine.api as api |
||||
|
from engine.config import METADATA #includes METADATA only. No other environmental setup is executed. |
||||
|
|
||||
|
#QtGui |
||||
|
from .designer.settings import Ui_Dialog |
||||
|
|
||||
|
class SettingsDialog(QtWidgets.QDialog): |
||||
|
|
||||
|
def __init__(self, mainWindow): |
||||
|
super().__init__(mainWindow) |
||||
|
self.ui = Ui_Dialog() |
||||
|
self.ui.setupUi(self) |
||||
|
self.mainWindow = mainWindow |
||||
|
|
||||
|
self.success = False |
||||
|
|
||||
|
settings = QtCore.QSettings("LaborejoSoftwareSuite", METADATA["shortName"]) |
||||
|
if settings.contains("launcherBlacklistPlainTextEdit"): |
||||
|
self.ui.launcherBlacklistPlainTextEdit.setPlainText(settings.value("launcherBlacklistPlainTextEdit", type=str)) |
||||
|
else: |
||||
|
self.ui.launcherBlacklistPlainTextEdit.setPlainText("") |
||||
|
|
||||
|
if settings.contains("launcherWhitelistPlainTextEdit"): |
||||
|
self.ui.launcherWhitelistPlainTextEdit.setPlainText(settings.value("launcherWhitelistPlainTextEdit", type=str)) |
||||
|
else: |
||||
|
self.ui.launcherWhitelistPlainTextEdit.setPlainText("") |
||||
|
|
||||
|
if settings.contains("programPathsPlainTextEdit"): |
||||
|
self.ui.programPathsPlainTextEdit.setPlainText(settings.value("programPathsPlainTextEdit", type=str)) |
||||
|
else: |
||||
|
self.ui.programPathsPlainTextEdit.setPlainText("") |
||||
|
|
||||
|
#self.ui.name.textEdited.connect(self.check) #not called when text is changed programatically |
||||
|
|
||||
|
self.ui.buttonBox.accepted.connect(self.process) |
||||
|
self.ui.buttonBox.rejected.connect(self.reject) |
||||
|
|
||||
|
self.setWindowFlag(QtCore.Qt.Popup, True) |
||||
|
self.setModal(True) |
||||
|
self.setFocus(True) |
||||
|
self.exec_() |
||||
|
|
||||
|
@staticmethod |
||||
|
def loadFromSettingsAndSendToEngine(): |
||||
|
"""Called on program start and in self.process, which has a bit overhead because |
||||
|
it is saving to file and then reloading from file (qsettings)""" |
||||
|
settings = QtCore.QSettings("LaborejoSoftwareSuite", METADATA["shortName"]) |
||||
|
if settings.contains("launcherBlacklistPlainTextEdit"): |
||||
|
bl = settings.value("launcherBlacklistPlainTextEdit", type=str) |
||||
|
else: |
||||
|
bl = None |
||||
|
|
||||
|
if settings.contains("launcherWhitelistPlainTextEdit"): |
||||
|
wl = settings.value("launcherWhitelistPlainTextEdit", type=str) |
||||
|
else: |
||||
|
wl = None |
||||
|
|
||||
|
if settings.contains("programPathsPlainTextEdit"): |
||||
|
pth = settings.value("programPathsPlainTextEdit", type=str) |
||||
|
else: |
||||
|
pth = None |
||||
|
|
||||
|
blacklist = bl.split("\n") if bl else [] |
||||
|
whitelist = wl.split("\n") if wl else [] |
||||
|
|
||||
|
api.systemProgramsSetBlacklist(blacklist) |
||||
|
api.systemProgramsSetWhitelist(whitelist) |
||||
|
|
||||
|
#Depends on SettingsDialog: More executable paths for the engine. We do this in mainwindow because it has access to the qsettings safe file and is started before engine, program-database or nsmd. |
||||
|
additionalExecutablePaths = pth.split("\n") if pth else [] |
||||
|
if additionalExecutablePaths: |
||||
|
os.environ["PATH"] = os.pathsep.join(additionalExecutablePaths) + os.pathsep + os.environ["PATH"] |
||||
|
|
||||
|
def process(self): |
||||
|
settings = QtCore.QSettings("LaborejoSoftwareSuite", METADATA["shortName"]) |
||||
|
|
||||
|
settings.setValue("launcherBlacklistPlainTextEdit", self.ui.launcherBlacklistPlainTextEdit.toPlainText()) |
||||
|
settings.setValue("launcherWhitelistPlainTextEdit", self.ui.launcherWhitelistPlainTextEdit.toPlainText()) |
||||
|
settings.setValue("programPathsPlainTextEdit", self.ui.programPathsPlainTextEdit.toPlainText()) |
||||
|
|
||||
|
SettingsDialog.loadFromSettingsAndSendToEngine() |
||||
|
|
||||
|
self.success = True |
||||
|
self.done(True) |
Loading…
Reference in new issue