Example #1
0
    def __init__(self, *args, **kwargs):
        super().__init__(*args, **kwargs)
        widget_layout = QtWidgets.QVBoxLayout(self)

        # title
        # TODO validator for title, no empty string
        self.title_edit = QtWidgets.QLineEdit()
        self.title_edit.setFixedWidth(300)
        self.title_edit.setText(editor_scenario.scenario[constants.ScenarioProperty.TITLE])
        widget_layout.addLayout(qt.wrap_in_boxlayout((QtWidgets.QLabel('Title'), self.title_edit)))

        # description
        self.description_edit = QtWidgets.QLineEdit()
        self.description_edit.setFixedWidth(300)
        self.description_edit.setText(editor_scenario.scenario[constants.ScenarioProperty.DESCRIPTION])
        widget_layout.addLayout(qt.wrap_in_boxlayout((QtWidgets.QLabel('Description'), self.description_edit)))

        # game years
        game_range = editor_scenario.scenario[constants.ScenarioProperty.GAME_YEAR_RANGE]
        self.game_year_from = QtWidgets.QLineEdit()
        self.game_year_from.setFixedWidth(100)
        self.game_year_from.setText(str(game_range[0]))
        self.game_year_to = QtWidgets.QLineEdit()
        self.game_year_to.setFixedWidth(100)
        self.game_year_to.setText(str(game_range[1]))
        widget_layout.addLayout(qt.wrap_in_boxlayout((QtWidgets.QLabel('Time range from'), self.game_year_from, QtWidgets.QLabel('to'), self.game_year_to)))

        # vertical stretch
        widget_layout.addStretch()
Example #2
0
    def __init__(self, scenario, initial_province=None):
        super().__init__()

        self.scenario = scenario

        widget_layout = QtWidgets.QVBoxLayout(self)

        # toolbar
        toolbar = QtWidgets.QToolBar()
        a = qt.create_action(tools.load_ui_icon('icon.add.png'),
                             'Add province', toolbar, self.add_province)
        toolbar.addAction(a)
        a = qt.create_action(tools.load_ui_icon('icon.delete.png'),
                             'Remove province', toolbar, self.remove_province)
        toolbar.addAction(a)
        widget_layout.addLayout(qt.wrap_in_boxlayout(toolbar))

        # provinces selection combo box
        label = QtWidgets.QLabel('Choose')
        self.provinces_combobox = QtWidgets.QComboBox()
        self.provinces_combobox.setFixedWidth(200)
        self.provinces_combobox.currentIndexChanged.connect(
            self.province_combobox_index_changed)
        widget_layout.addWidget(
            qt.wrap_in_groupbox(
                qt.wrap_in_boxlayout((label, self.provinces_combobox)),
                constants.SCENARIO_FILE_PROVINCES))

        # province info panel
        layout = QtWidgets.QVBoxLayout()

        # nation
        self.nation_label = QtWidgets.QLabel('Nation')
        layout.addWidget(self.nation_label)

        widget_layout.addWidget(qt.wrap_in_groupbox(layout, 'Info'))

        # vertical stretch
        widget_layout.addStretch()

        # reset content
        self.reset_content()

        # if province is given, select it
        if initial_province:
            index = utils.index_of_element(self.provinces, initial_province)
            self.provinces_combobox.setCurrentIndex(index)
Example #3
0
    def __init__(self, initial_province=None):
        super().__init__()

        widget_layout = QtWidgets.QVBoxLayout(self)

        # toolbar
        toolbar = QtWidgets.QToolBar()
        a = qt.create_action(tools.load_ui_icon('icon.add.png'), 'Add province', toolbar, self.add_province)
        toolbar.addAction(a)
        a = qt.create_action(tools.load_ui_icon('icon.delete.png'), 'Remove province', toolbar, self.remove_province)
        toolbar.addAction(a)
        widget_layout.addLayout(qt.wrap_in_boxlayout(toolbar))

        # provinces selection combo box
        label = QtWidgets.QLabel('Choose')
        self.provinces_combobox = QtWidgets.QComboBox()
        self.provinces_combobox.setFixedWidth(200)
        self.provinces_combobox.currentIndexChanged.connect(self.province_combobox_index_changed)
        widget_layout.addWidget(qt.wrap_in_groupbox(qt.wrap_in_boxlayout((label, self.provinces_combobox)), 'provinces'))

        # province info panel
        layout = QtWidgets.QVBoxLayout()

        # nation
        self.nation_label = QtWidgets.QLabel('Nation')
        layout.addWidget(self.nation_label)

        widget_layout.addWidget(qt.wrap_in_groupbox(layout, 'Info'))

        # vertical stretch
        widget_layout.addStretch()

        # reset content
        self.reset_content()

        # if province is given, select it
        if initial_province:
            index = utils.index_of_element(self.provinces, initial_province)
            self.provinces_combobox.setCurrentIndex(index)
Example #4
0
    def __init__(self, initial_nation=None):
        super().__init__()

        widget_layout = QtWidgets.QVBoxLayout(self)

        # toolbar
        toolbar = QtWidgets.QToolBar()
        a = qt.create_action(tools.load_ui_icon('icon.add.png'), 'Add nation', toolbar, self.add_nation)
        toolbar.addAction(a)
        a = qt.create_action(tools.load_ui_icon('icon.delete.png'), 'Remove nation', toolbar, self.remove_nation)
        toolbar.addAction(a)
        widget_layout.addLayout(qt.wrap_in_boxlayout(toolbar))

        # nation selection combo box
        label = QtWidgets.QLabel('Choose')
        self.nation_combobox = QtWidgets.QComboBox()
        self.nation_combobox.setFixedWidth(200)
        self.nation_combobox.currentIndexChanged.connect(self.nation_selected)
        widget_layout.addWidget(qt.wrap_in_groupbox(qt.wrap_in_boxlayout((label, self.nation_combobox)), 'Nations'))

        # nation info panel
        layout = QtWidgets.QVBoxLayout()

        # description
        self.description_edit = QtWidgets.QLineEdit()
        self.description_edit.setFixedWidth(300)
        self.description_edit.setText('Test')
        layout.addLayout(qt.wrap_in_boxlayout((QtWidgets.QLabel('Description'), self.description_edit)))

        # color
        self.color_picker = QtWidgets.QPushButton()
        self.color_picker.setFixedSize(24, 24)
        self.color_picker.clicked.connect(self.show_color_picker)
        layout.addLayout(qt.wrap_in_boxlayout((QtWidgets.QLabel('Color'), self.color_picker)))

        # capital province
        self.capital_province_edit = QtWidgets.QLineEdit()
        self.capital_province_edit.setFixedWidth(300)
        layout.addLayout(qt.wrap_in_boxlayout((QtWidgets.QLabel('Capital'), self.capital_province_edit)))

        # all provinces
        self.provinces_combobox = QtWidgets.QComboBox()
        self.provinces_combobox.setFixedWidth(300)
        self.number_provinces_label = QtWidgets.QLabel()
        layout.addLayout(qt.wrap_in_boxlayout((self.number_provinces_label, self.provinces_combobox)))

        widget_layout.addWidget(qt.wrap_in_groupbox(layout, 'Info'))

        # vertical stretch
        widget_layout.addStretch()

        # reset content
        self.reset_content()

        # select initial nation if given
        if initial_nation:
            index = utils.index_of_element(self.nations, initial_nation)
            self.nation_combobox.setCurrentIndex(index)
Example #5
0
    def __init__(self, *args, **kwargs):
        super().__init__(*args, **kwargs)

        layout = QtWidgets.QHBoxLayout(self)

        self.client_list_widget = QtWidgets.QListWidget()
        #       list.itemSelectionChanged.connect(self.selection_changed)
        #       list.setSelectionMode(QtGui.QAbstractItemView.SingleSelection)
        self.client_list_widget.setHorizontalScrollBarPolicy(
            QtCore.Qt.ScrollBarAlwaysOff)
        self.client_list_widget.setVerticalScrollBarPolicy(
            QtCore.Qt.ScrollBarAsNeeded)
        self.client_list_widget.setFixedWidth(200)
        layout.addWidget(
            qt.wrap_in_groupbox(self.client_list_widget, 'Players'))

        self.chat_log_text_edit = QtWidgets.QTextEdit()
        self.chat_log_text_edit.setEnabled(False)
        chat_log_group = qt.wrap_in_groupbox(self.chat_log_text_edit,
                                             'Chat log')

        self.chat_input_edit = QtWidgets.QLineEdit()
        self.chat_input_edit.returnPressed.connect(self.send_chat_message)
        chat_input_group = qt.wrap_in_groupbox(self.chat_input_edit,
                                               'Chat input')
        layout.addLayout(qt.wrap_in_boxlayout(
            (chat_log_group, chat_input_group),
            horizontal=False,
            add_stretch=False),
                         stretch=1)

        # connection to server

        # chat messages
        local_network_client.connect_to_channel(constants.C.CHAT,
                                                self.receive_chat_messages)
        local_network_client.send(constants.C.CHAT, constants.M.CHAT_SUBSCRIBE)

        # LOBBY
        local_network_client.connect_to_channel(constants.C.LOBBY,
                                                self.receive_lobby_messages)
        self.request_updated_client_list()

        # set timer for connected client updates
        self.timer = QtCore.QTimer()
        self.timer.timeout.connect(self.request_updated_client_list)
        self.timer.setInterval(5000)
        self.timer.start()
    def _layout_widget_preferences_general(self):
        """
        Create general options widget.
        """
        tab = QtWidgets.QWidget()
        tab_layout = QtWidgets.QVBoxLayout(tab)

        # language
        label = QtWidgets.QLabel('Choose')
        combobox = QtWidgets.QComboBox()
        tab_layout.addWidget(qt.wrap_in_groupbox(qt.wrap_in_boxlayout((label, combobox)), 'User Interface Language'))

        # vertical stretch
        tab_layout.addStretch()

        # add tab
        self.tab_general = tab
        self.stacked_layout.addWidget(tab)
Example #7
0
    def _layout_widget_preferences_general(self):
        """
        Create general options widget.
        """
        tab = QtWidgets.QWidget()
        tab_layout = QtWidgets.QVBoxLayout(tab)

        # language
        label = QtWidgets.QLabel('Choose')
        combobox = QtWidgets.QComboBox()
        tab_layout.addWidget(
            qt.wrap_in_groupbox(qt.wrap_in_boxlayout((label, combobox)),
                                'User Interface Language'))

        # vertical stretch
        tab_layout.addStretch()

        # add tab
        self.tab_general = tab
        self.stacked_layout.addWidget(tab)
Example #8
0
    def __init__(self, *args, **kwargs):
        super().__init__(*args, **kwargs)

        layout = QtWidgets.QHBoxLayout(self)

        self.client_list_widget = QtWidgets.QListWidget()
#       list.itemSelectionChanged.connect(self.selection_changed)
#       list.setSelectionMode(QtGui.QAbstractItemView.SingleSelection)
        self.client_list_widget.setHorizontalScrollBarPolicy(QtCore.Qt.ScrollBarAlwaysOff)
        self.client_list_widget.setVerticalScrollBarPolicy(QtCore.Qt.ScrollBarAsNeeded)
        self.client_list_widget.setFixedWidth(200)
        layout.addWidget(qt.wrap_in_groupbox(self.client_list_widget, 'Players'))

        self.chat_log_text_edit = QtWidgets.QTextEdit()
        self.chat_log_text_edit.setEnabled(False)
        chat_log_group = qt.wrap_in_groupbox(self.chat_log_text_edit, 'Chat log')

        self.chat_input_edit = QtWidgets.QLineEdit()
        self.chat_input_edit.returnPressed.connect(self.send_chat_message)
        chat_input_group = qt.wrap_in_groupbox(self.chat_input_edit, 'Chat input')
        layout.addLayout(qt.wrap_in_boxlayout((chat_log_group, chat_input_group), horizontal=False, add_stretch=False),
                         stretch=1)

        # connection to server

        # chat messages
        local_network_client.connect_to_channel(constants.C.CHAT, self.receive_chat_messages)
        local_network_client.send(constants.C.CHAT, constants.M.CHAT_SUBSCRIBE)

        # LOBBY
        local_network_client.connect_to_channel(constants.C.LOBBY, self.receive_lobby_messages)
        self.request_updated_client_list()

        # set timer for connected client updates
        self.timer = QtCore.QTimer()
        self.timer.timeout.connect(self.request_updated_client_list)
        self.timer.setInterval(5000)
        self.timer.start()
    def _layout_widget_preferences_network(self):
        """
        Create network options widget.
        """
        tab = QtWidgets.QWidget()
        tab_layout = QtWidgets.QVBoxLayout(tab)

        # client
        layout = QtWidgets.QVBoxLayout()
        if local_network_client.is_connected():
            peer_address, peer_port = local_network_client.peer_address()
            status = 'Connected to {}:{}'.format(peer_address.toString(), peer_port)
        else:
            status = 'Disconnected'
        layout.addWidget(QtWidgets.QLabel(status))
        tab_layout.addWidget(qt.wrap_in_groupbox(layout, 'Client'))
        # alias name edit box
        label = QtWidgets.QLabel('Alias')
        edit = QtWidgets.QLineEdit()
        edit.setFixedWidth(300)
        self._register_line_edit(edit, constants.Option.LOCALCLIENT_NAME)
        layout.addLayout(qt.wrap_in_boxlayout((label, edit)))

        # local server group box
        layout = QtWidgets.QVBoxLayout()
        import ipgetter
        local_ip = ipgetter.myip()
        layout.addWidget(QtWidgets.QLabel('Local public IP address: {}'.format(local_ip)))
        # accepts incoming connections checkbox
        checkbox = QtWidgets.QCheckBox('Accepts incoming connections')
        self._register_check_box(checkbox, constants.Option.LOCALSERVER_OPEN)
        layout.addWidget(checkbox)
        # alias name edit box
        label = QtWidgets.QLabel('Alias')
        edit = QtWidgets.QLineEdit()
        edit.setFixedWidth(300)
        self._register_line_edit(edit, constants.Option.LOCALSERVER_NAME)
        layout.addLayout(qt.wrap_in_boxlayout((label, edit)))
        # actions toolbar
        toolbar = QtWidgets.QToolBar()
        toolbar.setIconSize(QtCore.QSize(24, 24))
        # show local server monitor
        toolbar.addAction(
            qt.create_action(tools.load_ui_icon('icon.preferences.network.png'), 'Show local server monitor', toolbar))
        layout.addLayout(qt.wrap_in_boxlayout(toolbar))
        tab_layout.addWidget(qt.wrap_in_groupbox(layout, 'Local Server'))

        # remote server group box
        layout = QtWidgets.QVBoxLayout()
        # remote server address
        label = QtWidgets.QLabel('Remote IP address')
        edit = QtWidgets.QLineEdit()
        edit.setFixedWidth(300)
        layout.addLayout(qt.wrap_in_boxlayout((label, edit)))
        # actions toolbar
        toolbar = QtWidgets.QToolBar()
        toolbar.setIconSize(QtCore.QSize(24, 24))
        # connect to remote server
        a = qt.create_action(tools.load_ui_icon('icon.preferences.network.png'), 'Connect/Disconnect to remote server',
                             toolbar, checkable=True)
        toolbar.addAction(a)
        layout.addLayout(qt.wrap_in_boxlayout(toolbar))
        tab_layout.addWidget(qt.wrap_in_groupbox(layout, 'Remote Server'))

        # vertical stretch
        tab_layout.addStretch()

        # add tab
        self.tab_network = tab
        self.stacked_layout.addWidget(tab)
Example #10
0
    def _layout_widget_preferences_network(self):
        """
        Create network options widget.
        """
        tab = QtWidgets.QWidget()
        tab_layout = QtWidgets.QVBoxLayout(tab)

        # client
        layout = QtWidgets.QVBoxLayout()
        if local_network_client.is_connected():
            peer_address, peer_port = local_network_client.peer_address()
            status = 'Connected to {}:{}'.format(peer_address.toString(),
                                                 peer_port)
        else:
            status = 'Disconnected'
        layout.addWidget(QtWidgets.QLabel(status))
        tab_layout.addWidget(qt.wrap_in_groupbox(layout, 'Client'))
        # alias name edit box
        label = QtWidgets.QLabel('Alias')
        edit = QtWidgets.QLineEdit()
        edit.setFixedWidth(300)
        self._register_line_edit(edit, constants.Option.LOCALCLIENT_NAME)
        layout.addLayout(qt.wrap_in_boxlayout((label, edit)))

        # local server group box
        layout = QtWidgets.QVBoxLayout()
        import ipgetter
        local_ip = ipgetter.myip()
        layout.addWidget(
            QtWidgets.QLabel('Local public IP address: {}'.format(local_ip)))
        # accepts incoming connections checkbox
        checkbox = QtWidgets.QCheckBox('Accepts incoming connections')
        self._register_check_box(checkbox, constants.Option.LOCALSERVER_OPEN)
        layout.addWidget(checkbox)
        # alias name edit box
        label = QtWidgets.QLabel('Alias')
        edit = QtWidgets.QLineEdit()
        edit.setFixedWidth(300)
        self._register_line_edit(edit, constants.Option.LOCALSERVER_NAME)
        layout.addLayout(qt.wrap_in_boxlayout((label, edit)))
        # actions toolbar
        toolbar = QtWidgets.QToolBar()
        toolbar.setIconSize(QtCore.QSize(24, 24))
        # show local server monitor
        toolbar.addAction(
            qt.create_action(
                tools.load_ui_icon('icon.preferences.network.png'),
                'Show local server monitor', toolbar))
        layout.addLayout(qt.wrap_in_boxlayout(toolbar))
        tab_layout.addWidget(qt.wrap_in_groupbox(layout, 'Local Server'))

        # remote server group box
        layout = QtWidgets.QVBoxLayout()
        # remote server address
        label = QtWidgets.QLabel('Remote IP address')
        edit = QtWidgets.QLineEdit()
        edit.setFixedWidth(300)
        layout.addLayout(qt.wrap_in_boxlayout((label, edit)))
        # actions toolbar
        toolbar = QtWidgets.QToolBar()
        toolbar.setIconSize(QtCore.QSize(24, 24))
        # connect to remote server
        a = qt.create_action(
            tools.load_ui_icon('icon.preferences.network.png'),
            'Connect/Disconnect to remote server',
            toolbar,
            checkable=True)
        toolbar.addAction(a)
        layout.addLayout(qt.wrap_in_boxlayout(toolbar))
        tab_layout.addWidget(qt.wrap_in_groupbox(layout, 'Remote Server'))

        # vertical stretch
        tab_layout.addStretch()

        # add tab
        self.tab_network = tab
        self.stacked_layout.addWidget(tab)