aboutsummaryrefslogtreecommitdiff
path: root/src/__main__.py
blob: e6416722844efd00c1f4c8d9e3c2dd05c5485147 (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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
"""
Maid RPG character generator
'maid' by Wazul

2017.06.08.
"""
import sys
from PyQt5 import QtWidgets, QtGui, QtCore, Qt
from .modules.maidWidget import CMaidWidget
from .modules.helpWidget import CHelpWidget
from .modules.masterWidget import CMasterWidget
from .modules.butlerWidget import CButlerWidget
from .modules.data_reader import MaidDataReader

class ApplicationWindow(QtWidgets.QMainWindow):
    """ Main window for the application. """
    def __init__(self, data_reader):
        QtWidgets.QMainWindow.__init__(self)
        self.setAttribute(QtCore.Qt.WA_DeleteOnClose)
        self.setWindowTitle('RMG - MaidRPG random generator')

        self.icon = QtGui.QIcon('icon.ico')
        self.setWindowIcon(self.icon)

        self.setTabPosition(QtCore.Qt.TopDockWidgetArea, QtWidgets.QTabWidget.North)

       # self.setFixedWidth(550)
       # self.setFixedHeight(650)

        self.statusbarMessage = QtWidgets.QLabel("Version number 1.1 - 'maid' by Wazul (2017)")
        self.statusBar().addWidget(self.statusbarMessage)


        self.maidDock = QtWidgets.QDockWidget('Random maid')
        self.maidDock.parent = self

        self.maidDock.setFeatures(QtWidgets.QDockWidget.NoDockWidgetFeatures)
        titleWidget = QtWidgets.QWidget()
        self.maidDock.setTitleBarWidget(titleWidget)

        self.maidWidget = CMaidWidget(data_reader, self.maidDock)
        self.maidDock.setWidget(self.maidWidget)
        self.addDockWidget(QtCore.Qt.TopDockWidgetArea, self.maidDock)


        self.butlerDock = QtWidgets.QDockWidget('Random butler')
        self.butlerDock.parent = self

        self.butlerDock.setFeatures(QtWidgets.QDockWidget.NoDockWidgetFeatures)
        titleWidget = QtWidgets.QWidget()
        self.butlerDock.setTitleBarWidget(titleWidget)

        self.butlerWidget = CButlerWidget(data_reader, self.butlerDock)
        self.butlerDock.setWidget(self.butlerWidget)
        self.addDockWidget(QtCore.Qt.TopDockWidgetArea, self.butlerDock)


        self.masterDock = QtWidgets.QDockWidget('Random master')
        self.masterDock.parent = self

        self.masterDock.setFeatures(QtWidgets.QDockWidget.NoDockWidgetFeatures)
        titleWidgetMaster = QtWidgets.QWidget()
        self.masterDock.setTitleBarWidget(titleWidgetMaster)

        self.masterWidget = CMasterWidget(data_reader, self.masterDock)
        self.masterDock.setWidget(self.masterWidget)
        self.addDockWidget(QtCore.Qt.TopDockWidgetArea, self.masterDock)


        self.helpDock = QtWidgets.QDockWidget('Help')
        self.helpDock.parent = self

        self.helpDock.setFeatures(QtWidgets.QDockWidget.NoDockWidgetFeatures)
        titleWidgetHelp = QtWidgets.QWidget()
        self.helpDock.setTitleBarWidget(titleWidgetHelp)

        self.helpWidget = CHelpWidget(self.helpDock)
        self.helpDock.setWidget(self.helpWidget)
        self.addDockWidget(QtCore.Qt.TopDockWidgetArea, self.helpDock)


        self.tabifyDockWidget(self.maidDock, self.butlerDock)
        self.tabifyDockWidget(self.butlerDock, self.masterDock)
        self.tabifyDockWidget(self.masterDock, self.helpDock)
        self.maidDock.raise_()
        self.seq = 0

    def keyPressEvent(self, event):
        if self.seq == 0 and event.key() == QtCore.Qt.Key_Up:
            self.seq += 1
        elif self.seq == 1 and event.key() == QtCore.Qt.Key_Up:
            self.seq += 1
            self.helpDock.setFocus()
        elif self.seq == 2 and event.key() == QtCore.Qt.Key_Down:
            self.seq += 1
        elif self.seq == 3 and event.key() == QtCore.Qt.Key_Down:
            self.seq += 1
        elif self.seq == 4 and event.key() == QtCore.Qt.Key_Left:
            self.seq += 1
        elif self.seq == 5 and event.key() == QtCore.Qt.Key_Right:
            self.seq += 1
        elif self.seq == 6 and event.key() == QtCore.Qt.Key_Left:
            self.seq += 1
        elif self.seq == 7 and event.key() == QtCore.Qt.Key_Right:
            self.seq += 1
        elif self.seq == 8 and event.key() == QtCore.Qt.Key_B:
            self.seq += 1
        elif self.seq == 9 and event.key() == QtCore.Qt.Key_A:
            self.helpWidget.easterEgg()
        else:
            self.seq = 0


def main(argv):
    data_reader = MaidDataReader()
    qt_args = [argv[0], '-style', 'Fusion'] + argv[1:]
    app = QtWidgets.QApplication(qt_args)
    main_window = ApplicationWindow(data_reader)
    main_window.show()
    sys.exit(app.exec_())


if __name__ == '__main__':
    main(sys.argv)