mirror of
https://github.com/dcs-liberation/dcs_liberation.git
synced 2025-11-10 14:22:26 +00:00
Basics for QT UI
This commit is contained in:
parent
a30d4a4514
commit
4652e7d188
24
qt_ui/main.py
Normal file
24
qt_ui/main.py
Normal file
@ -0,0 +1,24 @@
|
||||
import sys
|
||||
from time import sleep
|
||||
|
||||
from PySide2.QtGui import QPixmap
|
||||
from PySide2.QtWidgets import QApplication, QLabel, QSplashScreen
|
||||
|
||||
from qt_ui.windows.QLiberationWindow import QLiberationWindow
|
||||
|
||||
if __name__ == "__main__":
|
||||
|
||||
app = QApplication(sys.argv)
|
||||
|
||||
pixmap = QPixmap("../resources/ui/splash_screen.png")
|
||||
splash = QSplashScreen(pixmap)
|
||||
splash.show()
|
||||
|
||||
sleep(2)
|
||||
app.processEvents()
|
||||
|
||||
window = QLiberationWindow()
|
||||
window.show()
|
||||
|
||||
splash.finish(window)
|
||||
sys.exit(app.exec_())
|
||||
10
qt_ui/uiconstants.py
Normal file
10
qt_ui/uiconstants.py
Normal file
@ -0,0 +1,10 @@
|
||||
# URL for UI links
|
||||
|
||||
URLS = {
|
||||
"Manual": "https://github.com/shdwp/dcs_liberation/wiki/Manual",
|
||||
"Troubleshooting": "https://github.com/shdwp/dcs_liberation/wiki/Troubleshooting",
|
||||
"Modding": "https://github.com/shdwp/dcs_liberation/wiki/Modding-tutorial",
|
||||
"Repository": "https://github.com/shdwp/dcs_liberation",
|
||||
"ForumThread": "https://forums.eagle.ru/showthread.php?t=214834",
|
||||
"Issues": "https://github.com/shdwp/dcs_liberation/issues"
|
||||
}
|
||||
18
qt_ui/windows/QLiberationMap.py
Normal file
18
qt_ui/windows/QLiberationMap.py
Normal file
@ -0,0 +1,18 @@
|
||||
from PySide2.QtGui import QPixmap
|
||||
from PySide2.QtWidgets import QWidget, QGraphicsWidget, QGraphicsView
|
||||
|
||||
from qt_ui.windows.QLiberationScene import QLiberationScene
|
||||
|
||||
|
||||
class QLiberationMap(QGraphicsView):
|
||||
|
||||
def __init__(self):
|
||||
super(QLiberationMap, self).__init__()
|
||||
self.setMinimumSize(800,600)
|
||||
self.init_scene()
|
||||
|
||||
def init_scene(self):
|
||||
scene = QLiberationScene(self)
|
||||
scene.addText("Hello World")
|
||||
scene.addPixmap(QPixmap("../resources/caumap.gif"))
|
||||
self.setScene(scene)
|
||||
8
qt_ui/windows/QLiberationScene.py
Normal file
8
qt_ui/windows/QLiberationScene.py
Normal file
@ -0,0 +1,8 @@
|
||||
from PySide2.QtWidgets import QWidget, QGraphicsScene
|
||||
|
||||
|
||||
class QLiberationScene(QGraphicsScene):
|
||||
|
||||
def __init__(self, parent):
|
||||
super().__init__(parent)
|
||||
self.addText("Hello Liberation Map")
|
||||
60
qt_ui/windows/QLiberationWindow.py
Normal file
60
qt_ui/windows/QLiberationWindow.py
Normal file
@ -0,0 +1,60 @@
|
||||
from PySide2.QtGui import QIcon
|
||||
from PySide2.QtWidgets import QWidget, QPushButton, QHBoxLayout, QVBoxLayout, QMenuBar, QMainWindow
|
||||
import webbrowser
|
||||
|
||||
from qt_ui.uiconstants import URLS
|
||||
from qt_ui.windows.QLiberationMap import QLiberationMap
|
||||
|
||||
|
||||
class QLiberationWindow(QMainWindow):
|
||||
|
||||
def __init__(self):
|
||||
super(QLiberationWindow, self).__init__()
|
||||
self.init_ui()
|
||||
|
||||
def init_ui(self):
|
||||
|
||||
self.setGeometry(300, 100, 270, 100)
|
||||
self.setWindowTitle("DCS Liberation")
|
||||
self.setWindowIcon(QIcon("../resources/icon.png"))
|
||||
self.statusBar().showMessage('Ready')
|
||||
self.init_menubar()
|
||||
|
||||
okButton = QPushButton("OK")
|
||||
cancelButton = QPushButton("Cancel")
|
||||
|
||||
hbox = QHBoxLayout()
|
||||
hbox.addStretch(1)
|
||||
hbox.addWidget(okButton)
|
||||
hbox.addWidget(cancelButton)
|
||||
|
||||
self.liberationMap = QLiberationMap()
|
||||
hbox.addWidget(self.liberationMap)
|
||||
|
||||
vbox = QVBoxLayout()
|
||||
vbox.addStretch(1)
|
||||
vbox.addLayout(hbox)
|
||||
|
||||
|
||||
central_widget = QWidget()
|
||||
central_widget.setLayout(vbox)
|
||||
self.setCentralWidget(central_widget)
|
||||
|
||||
|
||||
def init_menubar(self):
|
||||
self.menu = self.menuBar()
|
||||
|
||||
file_menu = self.menu.addMenu("File")
|
||||
file_menu.addAction("New Game")
|
||||
file_menu.addAction("Open")
|
||||
file_menu.addAction("Save")
|
||||
file_menu.addAction("Save As")
|
||||
|
||||
help_menu = self.menu.addMenu("Help")
|
||||
help_menu.addAction("Online Manual", lambda: webbrowser.open_new_tab(URLS["Manual"]))
|
||||
help_menu.addAction("Troubleshooting Guide", lambda: webbrowser.open_new_tab(URLS["Troubleshooting"]))
|
||||
help_menu.addAction("Modding Guide", lambda: webbrowser.open_new_tab(URLS["Modding"]))
|
||||
help_menu.addSeparator()
|
||||
help_menu.addAction("Contribute", lambda: webbrowser.open_new_tab(URLS["Repository"]))
|
||||
help_menu.addAction("Forum Thread", lambda: webbrowser.open_new_tab(URLS["ForumThread"]))
|
||||
help_menu.addAction("Report an issue", lambda: webbrowser.open_new_tab(URLS["Issues"]))
|
||||
BIN
resources/ui/splash_screen.png
Normal file
BIN
resources/ui/splash_screen.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 465 KiB |
Loading…
x
Reference in New Issue
Block a user