Added document tree and log widgets
This commit is contained in:
@@ -44,10 +44,7 @@ def generate_ui() -> None:
|
|||||||
str(destination),
|
str(destination),
|
||||||
)
|
)
|
||||||
generated = destination.read_text(encoding="utf-8")
|
generated = destination.read_text(encoding="utf-8")
|
||||||
if RESOURCE_IMPORT not in generated:
|
if RESOURCE_IMPORT in generated:
|
||||||
raise RuntimeError(
|
|
||||||
f"could not find the generated resource import in {destination}"
|
|
||||||
)
|
|
||||||
destination.write_text(
|
destination.write_text(
|
||||||
generated.replace(
|
generated.replace(
|
||||||
RESOURCE_IMPORT,
|
RESOURCE_IMPORT,
|
||||||
|
|||||||
@@ -1,13 +1,12 @@
|
|||||||
from __future__ import annotations
|
from __future__ import annotations
|
||||||
|
|
||||||
import sys
|
import sys
|
||||||
|
|
||||||
from PySide6.QtWidgets import QApplication
|
from PySide6.QtWidgets import QApplication
|
||||||
|
|
||||||
from bedit_gui.controllers.document_controller import DocumentController
|
from bedit_gui.controllers.document_controller import DocumentController
|
||||||
from bedit_gui.controllers.undo_controller import UndoController
|
from bedit_gui.controllers.undo_controller import UndoController
|
||||||
|
from bedit_gui.controllers.window_state_controller import WindowStateController
|
||||||
from bedit_gui.documents import Document
|
from bedit_gui.documents import Document
|
||||||
from bedit_gui.resources.generated import resources_rc # noqa: F401
|
|
||||||
from bedit_gui.views.main_window import MainWindow
|
from bedit_gui.views.main_window import MainWindow
|
||||||
|
|
||||||
|
|
||||||
@@ -21,6 +20,8 @@ def main() -> int:
|
|||||||
window = MainWindow()
|
window = MainWindow()
|
||||||
DocumentController(document, window)
|
DocumentController(document, window)
|
||||||
UndoController(document, window)
|
UndoController(document, window)
|
||||||
window.show()
|
window_state_controller = WindowStateController(app, window)
|
||||||
|
window_state_controller.restore()
|
||||||
|
window.showMaximized()
|
||||||
|
|
||||||
return app.exec()
|
return app.exec()
|
||||||
|
|||||||
37
src/bedit_gui/controllers/window_state_controller.py
Normal file
37
src/bedit_gui/controllers/window_state_controller.py
Normal file
@@ -0,0 +1,37 @@
|
|||||||
|
from PySide6.QtCore import QObject, QSettings, QByteArray
|
||||||
|
from PySide6.QtWidgets import QApplication
|
||||||
|
|
||||||
|
from bedit_gui.views.main_window import MainWindow
|
||||||
|
|
||||||
|
|
||||||
|
class WindowStateController(QObject):
|
||||||
|
def __init__(self,app: QApplication,window: MainWindow) -> None:
|
||||||
|
super().__init__(window)
|
||||||
|
|
||||||
|
self.window = window
|
||||||
|
self.settings = QSettings()
|
||||||
|
|
||||||
|
# Capture the layout created by Designer.
|
||||||
|
self._default_geometry = QByteArray(window.saveGeometry())
|
||||||
|
self._default_state = QByteArray(window.saveState())
|
||||||
|
|
||||||
|
app.aboutToQuit.connect(self.save)
|
||||||
|
window.ui.actionReset_Layout.triggered.connect(self.reset)
|
||||||
|
|
||||||
|
def restore(self) -> None:
|
||||||
|
if self.settings.contains("main_window/geometry"):
|
||||||
|
self.window.restoreGeometry(self.settings.value("main_window/geometry"))
|
||||||
|
|
||||||
|
if self.settings.contains("main_window/state"):
|
||||||
|
self.window.restoreState(self.settings.value("main_window/state"))
|
||||||
|
|
||||||
|
def save(self) -> None:
|
||||||
|
self.settings.setValue("main_window/geometry",self.window.saveGeometry())
|
||||||
|
self.settings.setValue("main_window/state",self.window.saveState())
|
||||||
|
|
||||||
|
def reset(self) -> None:
|
||||||
|
self.settings.remove("main_window/geometry")
|
||||||
|
self.settings.remove("main_window/state")
|
||||||
|
self.window.restoreGeometry(self._default_geometry)
|
||||||
|
self.window.restoreState(self._default_state)
|
||||||
|
self.window.showMaximized()
|
||||||
@@ -6,20 +6,30 @@
|
|||||||
<rect>
|
<rect>
|
||||||
<x>0</x>
|
<x>0</x>
|
||||||
<y>0</y>
|
<y>0</y>
|
||||||
<width>800</width>
|
<width>940</width>
|
||||||
<height>600</height>
|
<height>729</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<property name="windowTitle">
|
<property name="windowTitle">
|
||||||
<string>MainWindow</string>
|
<string>MainWindow</string>
|
||||||
</property>
|
</property>
|
||||||
|
<property name="windowIcon">
|
||||||
|
<iconset resource="../../resources/resources.qrc">
|
||||||
|
<normaloff>:/icons/icons/office-chart-line.png</normaloff>:/icons/icons/office-chart-line.png</iconset>
|
||||||
|
</property>
|
||||||
|
<property name="documentMode">
|
||||||
|
<bool>false</bool>
|
||||||
|
</property>
|
||||||
|
<property name="tabShape">
|
||||||
|
<enum>QTabWidget::TabShape::Triangular</enum>
|
||||||
|
</property>
|
||||||
<widget class="QWidget" name="centralwidget"/>
|
<widget class="QWidget" name="centralwidget"/>
|
||||||
<widget class="QMenuBar" name="menubar">
|
<widget class="QMenuBar" name="menubar">
|
||||||
<property name="geometry">
|
<property name="geometry">
|
||||||
<rect>
|
<rect>
|
||||||
<x>0</x>
|
<x>0</x>
|
||||||
<y>0</y>
|
<y>0</y>
|
||||||
<width>800</width>
|
<width>940</width>
|
||||||
<height>22</height>
|
<height>22</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
@@ -46,6 +56,9 @@
|
|||||||
<property name="title">
|
<property name="title">
|
||||||
<string>View</string>
|
<string>View</string>
|
||||||
</property>
|
</property>
|
||||||
|
<addaction name="actionReset_Layout"/>
|
||||||
|
<addaction name="actionPanels"/>
|
||||||
|
<addaction name="actionToolbars"/>
|
||||||
</widget>
|
</widget>
|
||||||
<widget class="QMenu" name="menuHelp">
|
<widget class="QMenu" name="menuHelp">
|
||||||
<property name="title">
|
<property name="title">
|
||||||
@@ -87,6 +100,48 @@
|
|||||||
<addaction name="actionUndo"/>
|
<addaction name="actionUndo"/>
|
||||||
<addaction name="actionRedo"/>
|
<addaction name="actionRedo"/>
|
||||||
</widget>
|
</widget>
|
||||||
|
<widget class="QDockWidget" name="documentTreeWidget">
|
||||||
|
<property name="minimumSize">
|
||||||
|
<size>
|
||||||
|
<width>150</width>
|
||||||
|
<height>533</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
<property name="windowTitle">
|
||||||
|
<string>Document Tree</string>
|
||||||
|
</property>
|
||||||
|
<attribute name="dockWidgetArea">
|
||||||
|
<number>1</number>
|
||||||
|
</attribute>
|
||||||
|
<widget class="QWidget" name="dockWidgetContents">
|
||||||
|
<layout class="QVBoxLayout" name="verticalLayout">
|
||||||
|
<item>
|
||||||
|
<widget class="QTreeView" name="documentTree"/>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</widget>
|
||||||
|
</widget>
|
||||||
|
<widget class="QDockWidget" name="logWidget">
|
||||||
|
<property name="minimumSize">
|
||||||
|
<size>
|
||||||
|
<width>150</width>
|
||||||
|
<height>107</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
<property name="windowTitle">
|
||||||
|
<string>Log</string>
|
||||||
|
</property>
|
||||||
|
<attribute name="dockWidgetArea">
|
||||||
|
<number>8</number>
|
||||||
|
</attribute>
|
||||||
|
<widget class="QWidget" name="dockWidgetContents_5">
|
||||||
|
<layout class="QVBoxLayout" name="verticalLayout_2">
|
||||||
|
<item>
|
||||||
|
<widget class="QListView" name="listView"/>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</widget>
|
||||||
|
</widget>
|
||||||
<action name="actionOpen_File">
|
<action name="actionOpen_File">
|
||||||
<property name="icon">
|
<property name="icon">
|
||||||
<iconset resource="../../resources/resources.qrc">
|
<iconset resource="../../resources/resources.qrc">
|
||||||
@@ -211,6 +266,27 @@
|
|||||||
<enum>QAction::MenuRole::NoRole</enum>
|
<enum>QAction::MenuRole::NoRole</enum>
|
||||||
</property>
|
</property>
|
||||||
</action>
|
</action>
|
||||||
|
<action name="actionReset_Layout">
|
||||||
|
<property name="text">
|
||||||
|
<string>Reset Layout</string>
|
||||||
|
</property>
|
||||||
|
<property name="toolTip">
|
||||||
|
<string>Reset window layout to default</string>
|
||||||
|
</property>
|
||||||
|
<property name="menuRole">
|
||||||
|
<enum>QAction::MenuRole::NoRole</enum>
|
||||||
|
</property>
|
||||||
|
</action>
|
||||||
|
<action name="actionPanels">
|
||||||
|
<property name="text">
|
||||||
|
<string>Panels</string>
|
||||||
|
</property>
|
||||||
|
</action>
|
||||||
|
<action name="actionToolbars">
|
||||||
|
<property name="text">
|
||||||
|
<string>Toolbars</string>
|
||||||
|
</property>
|
||||||
|
</action>
|
||||||
</widget>
|
</widget>
|
||||||
<resources>
|
<resources>
|
||||||
<include location="../../resources/resources.qrc"/>
|
<include location="../../resources/resources.qrc"/>
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
from PySide6.QtWidgets import QMainWindow
|
from PySide6.QtCore import Qt
|
||||||
|
from PySide6.QtWidgets import QMainWindow, QTabWidget
|
||||||
|
|
||||||
from bedit_gui.ui.generated.ui_main_window import Ui_MainWindow
|
from bedit_gui.ui.generated.ui_main_window import Ui_MainWindow
|
||||||
|
|
||||||
@@ -9,3 +10,7 @@ class MainWindow(QMainWindow):
|
|||||||
|
|
||||||
self.ui = Ui_MainWindow()
|
self.ui = Ui_MainWindow()
|
||||||
self.ui.setupUi(self)
|
self.ui.setupUi(self)
|
||||||
|
|
||||||
|
self.setTabPosition(Qt.AllDockWidgetAreas, QTabWidget.North)
|
||||||
|
self.setCorner(Qt.Corner.BottomLeftCorner, Qt.DockWidgetArea.LeftDockWidgetArea)
|
||||||
|
self.setCorner(Qt.Corner.BottomRightCorner, Qt.DockWidgetArea.RightDockWidgetArea)
|
||||||
|
|||||||
Reference in New Issue
Block a user