Sampled Instrument Player with static and monolithic design. All instruments are built-in.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

174 lines
7.2 KiB

#! /usr/bin/env python3
# -*- coding: utf-8 -*-
Copyright 2022, Nils Hilbricht, Germany ( )
This file is part of the Laborejo Software Suite ( ),
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
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 <>.
import logging; logger = logging.getLogger(__name__);"import")
#Standard Lib
from random import choice
from typing import List
#System Wide Modules
from PyQt5 import QtCore, QtWidgets, QtGui
#Template Moduiles
from .designer.about import Ui_TemplateAbout
#Client Modules
from engine.config import * #imports METADATA
from qtgui.resources import * #Has the logo
import engine.api as api #Already loaded, will not change anything
class About(QtWidgets.QDialog):
"""A help window with useful tips.
Also the nagscreen for Donations.
The didYouKnow sentences stay here to be edited and not in engine/
They are GUI only and need to be translated
The About dialog depends on a set key guiSharedDataToSave["showAboutDialog"]. That is usually
created in the mainWindow for a new instance, never saved, and intial value depends on
didYouKnow:List[str] = [] #Will be filled by the non-template part of the program
def __init__(self, mainWindow):
#super(DidYouKnow, self).__init__(parent, QtCore.Qt.WindowStaysOnTopHint|QtCore.Qt.CustomizeWindowHint|QtCore.Qt.X11BypassWindowManagerHint)
#super(DidYouKnow, self).__init__(parent, QtCore.Qt.FramelessWindowHint)
self.setModal(True) #block until closed
self.ui = Ui_TemplateAbout()
self.mainWindow = mainWindow
self.index = self.tricks().index(self.ui.didyouknowLabel.text())
self.ui.numberLabel.setText("Tip " + str(self.index+1) + "/" + str(len(self.tricks())))
copyright = f"""{METADATA["author"]} ({METADATA["year"]})"""
name = f"""{METADATA["name"]} ver. {METADATA["version"]}"""
aboutText = "\n".join([name, copyright, METADATA["url"]])
#Image: 300x151
aboutLogoPixmap = QtGui.QPixmap(":aboutlogo.png")
#pixmap_scaled = aboutLogoPixmap.scaled(self.ui.goldenratioLabel.size(), QtCore.Qt.KeepAspectRatio)
#We don't want the user to get bombarded with information on the first start.
#Only show us the second time.
if not "showAboutDialog" in api.session.guiSharedDataToSave:
api.session.guiSharedDataToSave["showAboutDialog"] = True
QAbstractSlider.SliderNoAction 0
QAbstractSlider.SliderSingleStepAdd 1
QAbstractSlider.SliderSingleStepSub 2
QAbstractSlider.SliderPageStepAdd 3
QAbstractSlider.SliderPageStepSub 4
QAbstractSlider.SliderToMinimum 5
QAbstractSlider.SliderToMaximum 6
QAbstractSlider.SliderMove 7
self.shortcut("right", lambda: self.ui.numberSlider.triggerAction(1))
self.shortcut("left", lambda: self.ui.numberSlider.triggerAction(2))
self.shortcut("up", lambda: self.ui.numberSlider.triggerAction(1))
self.shortcut("down", lambda: self.ui.numberSlider.triggerAction(2))
self.ui.numberSlider.wheelEvent = self.mouseWheelEventCustom #Deactivate the normal number slider wheel event
self.wheelEvent = self.mouseWheelEventCustom #Use a window wide one that is easier to control
settings = QtCore.QSettings("LaborejoSoftwareSuite", METADATA["shortName"])
self.ui.showOnStartup.setChecked(settings.value("showAboutDialog", type=bool))
def tricks(self):
"""For some reason translations do not work if saved as class variable.
A getter function works"""
return About.didYouKnow + [
#Make the first three words matter!
#Do not start them all with "You can..." or "...that you can", in response to the Did you know? title.
QtCore.QCoreApplication.translate("TemplateAbout", "Help can be found through the <a href=''>Laborejo Community</a>"),
QtCore.QCoreApplication.translate("TemplateAbout", "Temporary Shortcuts can be created by hovering the mouse cursor over a menu entry (with no shortcut) and pressing a numpad key"),
QtCore.QCoreApplication.translate("TemplateAbout", "Closing the program with the [X] icon or shortcuts like Alt+F4 will only hide the window. This state will be saved, so you don't need to see the window each time you load your session."),
def reject(self):
def showEvent(self, event):
"""The qt main loop is slow. We can't show the about dialog, or any other sub-dialog,
right after becauer the event loop is not ready and the screen positions
will be wrong.
Instead we wait that the showEvent actually arrives.
And even then we wait a few ms, to be on the safe side. That was actually needed on the
devs system.
Also the dialog is sometimes not closed but hidden.
Also we had reports of not correctly parented and centered dialogs.
Make sure everything is where it should be"""
parentCenter = self.mainWindow.geometry().center()
aboutCenter = self.geometry().center()
self.move(parentCenter - aboutCenter)
def mouseWheelEventCustom(self, event):
if event.angleDelta().y() > 0:
def shortcut(self, key, function):
act = QtWidgets.QAction('')
def saveStartupState(self):
settings = QtCore.QSettings("LaborejoSoftwareSuite", METADATA["shortName"])
settings.setValue("showAboutDialog", bool(self.ui.showOnStartup.checkState()))
def moveSlider(self):
nowIdx = self.ui.numberSlider.value()
self.ui.numberLabel.setText("Trick " + str(nowIdx+1) + "/" + str(len(self.tricks())))