diff --git a/README.md b/README.md
index 30e7cae..58d455e 100644
--- a/README.md
+++ b/README.md
@@ -12,6 +12,11 @@
[![Build Status](https://travis-ci.org/Trilarion/imperialism-remake.svg?branch=master)](https://travis-ci.org/Trilarion/imperialism-remake)
+## Requirements
+
+- Minimal screen size: 1024 x 768
+- Python (with some modules (see below) or included in a package)
+
## Getting Started
### Access the source code
diff --git a/source/imperialism_remake/base/constants.py b/source/imperialism_remake/base/constants.py
index 3401715..c08ca1a 100644
--- a/source/imperialism_remake/base/constants.py
+++ b/source/imperialism_remake/base/constants.py
@@ -82,7 +82,7 @@ def extend(path, *parts):
@unique
class Option(utils.AutoNumberedEnum):
"""
- Options as automatically numbered enum. The members of it are then the Options.
+ Options as automatically numbered enum. The members of it are then the Options.
"""
LOCALSERVER_OPEN = ()
# local server accepts outside connections
diff --git a/source/imperialism_remake/base/tools.py b/source/imperialism_remake/base/tools.py
index d3c51fd..1e16d54 100644
--- a/source/imperialism_remake/base/tools.py
+++ b/source/imperialism_remake/base/tools.py
@@ -15,8 +15,8 @@
# along with this program. If not, see
"""
- Non-specific independent helper functions. Do not depend on any other part of the project except on package lib
- and base.constants and is specifically used by the project.
+Non-specific independent helper functions. Do not depend on any other part of the project except on package lib
+and base.constants and is specifically used by the project.
"""
import PyQt5.QtGui as QtGui
diff --git a/source/imperialism_remake/client/client.py b/source/imperialism_remake/client/client.py
index 56ef030..c13ffc3 100644
--- a/source/imperialism_remake/client/client.py
+++ b/source/imperialism_remake/client/client.py
@@ -47,10 +47,10 @@
class MapItem(QtCore.QObject):
"""
- Holds together a clickable QPixmapItem, a description text and a reference to a label that
- shows the text
+ Holds together a clickable QPixmapItem, a description text and a reference to a label that
+ shows the text
- TODO use signals to show the text instead
+ TODO use signals to show the text instead
"""
description_change = QtCore.pyqtSignal(str)
@@ -75,22 +75,21 @@ def __init__(self, parent, pixmap, label, description):
def show_description(self):
"""
- Shows the description in the label.
+ Shows the description in the label.
"""
self.label.setText('{}'.format(self.description))
def hide_description(self):
"""
- Hides the description from the label.
+ Hides the description from the label.
"""
self.label.setText('')
+# TODO convert to simple method which does it, no need to be a class
class StartScreen(QtWidgets.QWidget):
"""
- Creates the start screen
-
- TODO convert to simple method which does it, no need to be a class
+ Creates the start screen
"""
frame_pen = QtGui.QPen(QtGui.QBrush(QtGui.QColor(255, 255, 255, 64)), 6)
@@ -103,8 +102,8 @@ def __init__(self, client):
layout = qt.RelativeLayout(self)
- start_image = QtGui.QPixmap(constants.extend(constants.GRAPHICS_UI_FOLDER,
- 'start.background.jpg'))
+ path = constants.extend(constants.GRAPHICS_UI_FOLDER, 'start.background.jpg')
+ start_image = QtGui.QPixmap(path)
start_image_item = QtWidgets.QGraphicsPixmapItem(start_image)
start_image_item.setZValue(1)
@@ -121,6 +120,8 @@ def __init__(self, client):
layout.addWidget(view)
subtitle = QtWidgets.QLabel('')
+ subtitle.resize(0,0)
+ # TODO this is below the main image but collides with screens only 768 px high
subtitle.layout_constraint = qt.RelativeLayoutConstraint(
(0.5, -0.5, 0), (0.5, -0.5, start_image.height() / 2 + 20))
layout.addWidget(subtitle)
@@ -142,7 +143,7 @@ def __init__(self, client):
for k, v in image_map.items():
# add action from our predefined action dictionary
pixmap = QtGui.QPixmap(constants.extend(constants.GRAPHICS_UI_FOLDER, v['overlay']))
- map_item = MapItem(view, pixmap, label=subtitle, description=v['label'])
+ map_item = MapItem(scene, pixmap, label=subtitle, description=v['label'])
map_item.item.setZValue(3)
offset = v['offset']
map_item.item.setOffset(QtCore.QPointF(offset[0], offset[1]))
@@ -156,6 +157,7 @@ def __init__(self, client):
version_label = QtWidgets.QLabel('{}'
.format(version.__version_full__))
+ version_label.resize(version_label.sizeHint())
version_label.layout_constraint = qt.RelativeLayoutConstraint().east(20).south(20)
layout.addWidget(version_label)
@@ -400,7 +402,7 @@ def local_network_connect():
def start_client():
"""
- Creates the Qt application and shows the main window.
+ Creates the Qt application and shows the main window.
"""
# create app
@@ -445,8 +447,8 @@ def start_client():
client = Client()
client.switch_to_start_screen()
+ # start Qt app execution and immediately try to connect to local server
logger.info('client initialized, start Qt app execution')
- # TODO is this necessary to run as event?
# noinspection PyCallByClass
QtCore.QTimer.singleShot(0, local_network_connect)
app.exec_()
diff --git a/source/imperialism_remake/client/editor.py b/source/imperialism_remake/client/editor.py
index 5390e8b..f5e250a 100644
--- a/source/imperialism_remake/client/editor.py
+++ b/source/imperialism_remake/client/editor.py
@@ -612,7 +612,10 @@ class NewScenarioWidget(QtWidgets.QWidget):
"""
#: signal, emitted if this dialog finishes successfully and transmits parameters in the dictionary
- finished = QtCore.pyqtSignal(dict)
+ finished = QtCore.pyqtSignal(object)
+ # see also: https://stackoverflow.com/questions/43964766/pyqt-emit-signal-with-dict
+ # and https://www.riverbankcomputing.com/pipermail/pyqt/2017-May/039175.html
+ # may be changed back to dict with a later PyQt5 version
def __init__(self, *args, **kwargs):
"""
diff --git a/source/imperialism_remake/lib/qt.py b/source/imperialism_remake/lib/qt.py
index ae1a880..082dab2 100644
--- a/source/imperialism_remake/lib/qt.py
+++ b/source/imperialism_remake/lib/qt.py
@@ -15,9 +15,9 @@
# along with this program. If not, see
"""
- Graphics (PyQt5) based objects and algorithms that do not depend specifically on the project but only on PyQt5.
+Graphics (PyQt5) based objects and algorithms that do not depend specifically on the project but only on PyQt5.
- Abstraction of the used elements in the project to achieve an intermediate layer and to minimize dependencies.
+Abstraction of the used elements in the project to achieve an intermediate layer and to minimize dependencies.
"""
from datetime import datetime
@@ -147,7 +147,7 @@ class RelativeLayout(QtWidgets.QLayout):
An implementation of QLayout working with RelativeLayoutConstraints so the position can be estimated by
method calculate_relative_position()
- Note: No margins in this layout.
+ Note: No margins in this layout. The elements must have been set to their target size.
"""
def __init__(self, *args):
@@ -174,12 +174,14 @@ def sizeHint(self): # noqa: N802
def setGeometry(self, rect: QtCore.QRect): # noqa: N802
"""
- Layout the elements by calculating their relative position inside the parent, given the parents coordinates.
+ Layout the elements by calculating their relative position inside the parent, given the parents coordinates
+ and the sizes of the elements. The width and height are not changed but the offset is computed according to
+ the layout constraint and the parent size.
:param rect: Position and size of the parent.
"""
for item in self.items:
- o_size = item.sizeHint()
+ o_size = item.widget().size()
c = item.widget().layout_constraint
@@ -217,7 +219,7 @@ def minimumSize(self): # noqa: N802
min_height = 0
for item in self.items:
- o_size = item.sizeHint()
+ o_size = item.widget().size()
c = item.widget().layout_constraint
gap_x = abs(c.x[2])