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.
83 lines
3.7 KiB
83 lines
3.7 KiB
6 years ago
|
#! /usr/bin/env python3
|
||
|
# -*- coding: utf-8 -*-
|
||
|
"""
|
||
|
Copyright 2018, Nils Hilbricht, Germany ( https://www.hilbricht.net )
|
||
|
|
||
|
This file is part of the Laborejo Software Suite ( https://www.laborejo.org ),
|
||
|
more specifically its template base application.
|
||
|
|
||
|
The Template Base 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; logging.info("import {}".format(__file__))
|
||
|
|
||
|
#Standard Library Modules
|
||
|
import os.path
|
||
|
#Third Party Modules
|
||
|
from PyQt5 import QtWidgets, QtCore, QtGui
|
||
|
#Template Modules
|
||
|
from template.qtgui.mainwindow import MainWindow as TemplateMainWindow
|
||
|
from template.qtgui.menu import Menu
|
||
|
from template.qtgui.about import About
|
||
|
|
||
|
#User modules
|
||
|
import engine.api as api
|
||
|
|
||
|
class MainWindow(TemplateMainWindow):
|
||
|
|
||
|
def __init__(self):
|
||
|
"""The order of calls is very important.
|
||
|
The split ploint is calling the super.__init. Some functions need to be called before,
|
||
|
some after.
|
||
|
For example:
|
||
|
|
||
|
The about dialog is created in the template main window init. So we need to set additional
|
||
|
help texts before that init.
|
||
|
"""
|
||
|
|
||
|
#Inject more help texts in the templates About "Did You Know" field.
|
||
|
#About.didYouKnow is a class variable.
|
||
|
#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.
|
||
|
#We use injection into the class and not a parameter because this dialog gets shown by creating an object. We can't give the parameters when this is shown via the mainWindow menu.
|
||
|
About.didYouKnow = [
|
||
|
QtCore.QCoreApplication.translate("About", "This is an example application. Extend it to your liking. Start by editing config.py")
|
||
|
] + About.didYouKnow
|
||
|
|
||
|
super().__init__()
|
||
|
|
||
|
#New menu entries and template-menu overrides
|
||
|
self.menu.connectMenuEntry("actionAbout", lambda: print("About Dialog Menu deactivated")) #deactivates the original function
|
||
|
self.menu.addMenuEntry("menuEdit", "actionNils", "Nils", lambda: print("Merle"))
|
||
|
self.menu.connectMenuEntry("actionNils", lambda: print("Perle"))
|
||
|
|
||
|
self.start() #This shows the GUI, or not, depends on the NSM gui save setting. We need to call that after the menu, otherwise the about dialog will block and then we get new menu entries, which looks strange.
|
||
|
|
||
|
def dropEvent(self, event):
|
||
|
"""This function does not exist in the template.
|
||
|
It is easiest to edit it directly than to create another abstraction layer.
|
||
|
|
||
|
Having that function in the mainWindow will not make drops available for subwindows
|
||
|
like About or UserManual. """
|
||
|
if True: # remove if you want to handle file drops
|
||
|
for url in event.mimeData().urls():
|
||
|
print ("TODO: Enable this function", url)
|
||
|
|
||
|
|
||
|
for url in event.mimeData().urls():
|
||
|
filePath = url.toLocalFile()
|
||
|
#Decide here if you want only files, only directories, both etc.
|
||
|
if os.path.isfile(filePath) and filePath.lower().endswith(".sf2"):
|
||
|
linkedPath = self.nsmClient.importResource(filePath)
|
||
|
print ("linked sf2 into", linkedPath)
|