Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
aboutsummaryrefslogtreecommitdiffstats
blob: ce00b66f5b402be07c1bbecfb8ebb910288ea986 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# Copyright (C) 2023 The Qt Company Ltd.
# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
from __future__ import annotations

from PySide6.QtCore import Slot, Qt
from PySide6.QtGui import QKeySequence
from PySide6.QtWidgets import QMainWindow, QMessageBox

from window import Window


class MainWindow(QMainWindow):

    def __init__(self):
        super().__init__()
        menuWindow = self.menuBar().addMenu("Window")
        menuWindow.addAction("Add new", QKeySequence(Qt.Modifier.CTRL | Qt.Key.Key_N),
                             self.onAddNew)
        menuWindow.addAction("Quit", QKeySequence(Qt.Modifier.CTRL | Qt.Key.Key_Q),
                             qApp.closeAllWindows)  # noqa: F821

        self.onAddNew()

    @Slot()
    def onAddNew(self):
        if not self.centralWidget():
            self.setCentralWidget(Window(self))
        else:
            QMessageBox.information(self, "Cannot Add Window()",
                                    "Already occupied. Undock first.")