add context icons + help/about

This commit is contained in:
Maxime Réaux 2026-02-11 13:23:04 +01:00
parent 7f0d86f6dd
commit 4c8086caf4
12 changed files with 143 additions and 38 deletions

View file

@ -18,9 +18,10 @@ from warchron.controller.round_controller import RoundController
class AppController:
def __init__(self, model: Model, view: View) -> None:
def __init__(self, model: Model, view: View, version: str) -> None:
self.model: Model = model
self.view: View = view
self.app_version = version
self.navigation = NavigationController(self)
self.players = PlayerController(self)
self.wars = WarController(self)
@ -43,6 +44,7 @@ class AppController:
self.view.actionOpen.triggered.connect(self.open_file)
self.view.actionSave.triggered.connect(self.save)
self.view.actionSave_as.triggered.connect(self.save_as)
self.view.actionAbout.triggered.connect(self.show_about)
self.view.addPlayerBtn.clicked.connect(self.players.add_player)
self.view.addWarBtn.clicked.connect(self.wars.add_war)
self.view.majorValue.valueChanged.connect(self.wars.set_major_value)
@ -129,6 +131,23 @@ class AppController:
self.is_dirty = False
self.update_window_title()
def show_about(self) -> None:
QMessageBox.about(
self.view,
"About WarChron",
f"""
<h2>WarChron</h2>
<p><b>Version:</b> {self.app_version}</p>
<p>Campaign & War management tool</p>
<p>© 2026 Your Name</p>
<p>Licensed under GNU GPL v3</p>
<hr>
<p>Icons from Fugue Icons 3.5.6<br>
© Yusuke Kamiyamane<br>
Licensed under Creative Commons Attribution 3.0</p>
""",
)
# Display methods
def update_window_title(self) -> None:

View file

@ -12,7 +12,9 @@ class Battle:
self.sector_id: str = sector_id # ref to Campaign.sector
self.player_1_id: str | None = player_1_id # ref to Campaign.participants
self.player_2_id: str | None = player_2_id # ref to Campaign.participants
self.winner_id: str | None = None
self.winner_id: str | None = (
None # ref to Campaign.participants within player_1/2
)
self.score: str | None = None
self.victory_condition: str | None = None
self.comment: str | None = None

View file

@ -0,0 +1,20 @@
<RCC>
<qresource prefix="/icons">
<file>arrow-curve.png</file>
<file>arrow-curve-180-left.png</file>
<file>cross.png</file>
<file>disk.png</file>
<file>disk--pencil.png</file>
<file>document.png</file>
<file>door--arrow.png</file>
<file>folder.png</file>
<file>notebook--arrow.png</file>
<file>pencil.png</file>
<file>plus.png</file>
<file>question.png</file>
<file>swords-small.png</file>
<file>users.png</file>
<file>warchron_logo
.png</file>
</qresource>
</RCC>

View file

@ -52,7 +52,7 @@ class Ui_MainWindow(object):
self.playersTable.setHorizontalHeaderItem(2, item)
item = QtWidgets.QTableWidgetItem()
self.playersTable.setHorizontalHeaderItem(3, item)
self.playersTable.horizontalHeader().setStretchLastSection(True)
self.playersTable.horizontalHeader().setStretchLastSection(False)
self.gridLayout.addWidget(self.playersTable, 1, 0, 1, 1)
icon2 = QtGui.QIcon()
icon2.addPixmap(QtGui.QPixmap(".\\src\\warchron\\view\\ui\\../resources/users.png"), QtGui.QIcon.Mode.Normal, QtGui.QIcon.State.Off)
@ -187,7 +187,7 @@ class Ui_MainWindow(object):
self.objectivesTable.setHorizontalHeaderItem(0, item)
item = QtWidgets.QTableWidgetItem()
self.objectivesTable.setHorizontalHeaderItem(1, item)
self.objectivesTable.horizontalHeader().setStretchLastSection(True)
self.objectivesTable.horizontalHeader().setStretchLastSection(False)
self.verticalLayout.addWidget(self.objectivesTable)
self.verticalLayout_10.addWidget(self.groupBox)
self.groupBox_2 = QtWidgets.QGroupBox(parent=self.pageWar)
@ -220,7 +220,7 @@ class Ui_MainWindow(object):
self.warParticipantsTable.setHorizontalHeaderItem(3, item)
item = QtWidgets.QTableWidgetItem()
self.warParticipantsTable.setHorizontalHeaderItem(4, item)
self.warParticipantsTable.horizontalHeader().setStretchLastSection(True)
self.warParticipantsTable.horizontalHeader().setStretchLastSection(False)
self.verticalLayout_2.addWidget(self.warParticipantsTable)
self.verticalLayout_10.addWidget(self.groupBox_2)
self.horizontalLayout_6 = QtWidgets.QHBoxLayout()
@ -286,7 +286,7 @@ class Ui_MainWindow(object):
self.sectorsTable.setHorizontalHeaderItem(4, item)
item = QtWidgets.QTableWidgetItem()
self.sectorsTable.setHorizontalHeaderItem(5, item)
self.sectorsTable.horizontalHeader().setStretchLastSection(True)
self.sectorsTable.horizontalHeader().setStretchLastSection(False)
self.verticalLayout_5.addWidget(self.sectorsTable)
self.verticalLayout_7.addWidget(self.groupBox_3)
self.groupBox_4 = QtWidgets.QGroupBox(parent=self.pageCampaign)
@ -318,7 +318,7 @@ class Ui_MainWindow(object):
self.campaignParticipantsTable.setHorizontalHeaderItem(3, item)
item = QtWidgets.QTableWidgetItem()
self.campaignParticipantsTable.setHorizontalHeaderItem(4, item)
self.campaignParticipantsTable.horizontalHeader().setStretchLastSection(True)
self.campaignParticipantsTable.horizontalHeader().setStretchLastSection(False)
self.verticalLayout_6.addWidget(self.campaignParticipantsTable)
self.verticalLayout_7.addWidget(self.groupBox_4)
self.horizontalLayout_10 = QtWidgets.QHBoxLayout()
@ -361,7 +361,7 @@ class Ui_MainWindow(object):
self.choicesTable.setHorizontalHeaderItem(1, item)
item = QtWidgets.QTableWidgetItem()
self.choicesTable.setHorizontalHeaderItem(2, item)
self.choicesTable.horizontalHeader().setStretchLastSection(True)
self.choicesTable.horizontalHeader().setStretchLastSection(False)
self.horizontalLayout_4.addWidget(self.choicesTable)
self.verticalLayout_8.addWidget(self.groupBox_5)
self.horizontalLayout_13 = QtWidgets.QHBoxLayout()
@ -389,7 +389,7 @@ class Ui_MainWindow(object):
self.battlesTable.setHorizontalHeaderItem(1, item)
item = QtWidgets.QTableWidgetItem()
self.battlesTable.setHorizontalHeaderItem(2, item)
self.battlesTable.horizontalHeader().setStretchLastSection(True)
self.battlesTable.horizontalHeader().setStretchLastSection(False)
self.horizontalLayout_12.addWidget(self.battlesTable)
self.verticalLayout_8.addWidget(self.groupBox_6)
self.horizontalLayout_9 = QtWidgets.QHBoxLayout()
@ -409,7 +409,7 @@ class Ui_MainWindow(object):
self.verticalLayout_9.addWidget(self.tabWidget)
MainWindow.setCentralWidget(self.centralwidget)
self.menubar = QtWidgets.QMenuBar(parent=MainWindow)
self.menubar.setGeometry(QtCore.QRect(0, 0, 1235, 21))
self.menubar.setGeometry(QtCore.QRect(0, 0, 1235, 22))
self.menubar.setObjectName("menubar")
self.menuFile = QtWidgets.QMenu(parent=self.menubar)
self.menuFile.setObjectName("menuFile")
@ -442,11 +442,13 @@ class Ui_MainWindow(object):
self.actionExit.setIcon(icon7)
self.actionExit.setObjectName("actionExit")
self.actionUndo = QtGui.QAction(parent=MainWindow)
self.actionUndo.setEnabled(False)
icon8 = QtGui.QIcon()
icon8.addPixmap(QtGui.QPixmap(".\\src\\warchron\\view\\ui\\../resources/arrow-curve-180-left.png"), QtGui.QIcon.Mode.Normal, QtGui.QIcon.State.Off)
self.actionUndo.setIcon(icon8)
self.actionUndo.setObjectName("actionUndo")
self.actionRedo = QtGui.QAction(parent=MainWindow)
self.actionRedo.setEnabled(False)
icon9 = QtGui.QIcon()
icon9.addPixmap(QtGui.QPixmap(".\\src\\warchron\\view\\ui\\../resources/arrow-curve.png"), QtGui.QIcon.Mode.Normal, QtGui.QIcon.State.Off)
self.actionRedo.setIcon(icon9)

View file

@ -76,7 +76,7 @@
<bool>true</bool>
</property>
<attribute name="horizontalHeaderStretchLastSection">
<bool>true</bool>
<bool>false</bool>
</attribute>
<column>
<property name="text">
@ -431,7 +431,7 @@
<bool>true</bool>
</property>
<attribute name="horizontalHeaderStretchLastSection">
<bool>true</bool>
<bool>false</bool>
</attribute>
<column>
<property name="text">
@ -497,7 +497,7 @@
<bool>true</bool>
</property>
<attribute name="horizontalHeaderStretchLastSection">
<bool>true</bool>
<bool>false</bool>
</attribute>
<column>
<property name="text">
@ -650,7 +650,7 @@
<bool>true</bool>
</property>
<attribute name="horizontalHeaderStretchLastSection">
<bool>true</bool>
<bool>false</bool>
</attribute>
<column>
<property name="text">
@ -733,7 +733,7 @@
<bool>true</bool>
</property>
<attribute name="horizontalHeaderStretchLastSection">
<bool>true</bool>
<bool>false</bool>
</attribute>
<column>
<property name="text">
@ -833,7 +833,7 @@
<bool>true</bool>
</property>
<attribute name="horizontalHeaderStretchLastSection">
<bool>true</bool>
<bool>false</bool>
</attribute>
<column>
<property name="text">
@ -900,7 +900,7 @@
<bool>true</bool>
</property>
<attribute name="horizontalHeaderStretchLastSection">
<bool>true</bool>
<bool>false</bool>
</attribute>
<column>
<property name="text">
@ -966,7 +966,7 @@
<x>0</x>
<y>0</y>
<width>1235</width>
<height>21</height>
<height>22</height>
</rect>
</property>
<widget class="QMenu" name="menuFile">
@ -1049,6 +1049,9 @@
</property>
</action>
<action name="actionUndo">
<property name="enabled">
<bool>false</bool>
</property>
<property name="icon">
<iconset>
<normaloff>../resources/arrow-curve-180-left.png</normaloff>../resources/arrow-curve-180-left.png</iconset>
@ -1061,6 +1064,9 @@
</property>
</action>
<action name="actionRedo">
<property name="enabled">
<bool>false</bool>
</property>
<property name="icon">
<iconset>
<normaloff>../resources/arrow-curve.png</normaloff>../resources/arrow-curve.png</iconset>

View file

@ -5,7 +5,7 @@ import calendar
from PyQt6 import QtWidgets
from PyQt6.QtCore import Qt, QPoint
from PyQt6.QtWidgets import QWidget, QFileDialog, QTreeWidgetItem, QMenu
from PyQt6.QtGui import QCloseEvent
from PyQt6.QtGui import QCloseEvent, QIcon
from warchron.constants import ROLE_TYPE, ROLE_ID, ItemType
from warchron.controller.dtos import (
@ -147,8 +147,12 @@ class View(QtWidgets.QMainWindow, Ui_MainWindow):
return
player_id = name_item.data(Qt.ItemDataRole.UserRole)
menu = QMenu(self)
edit_action = menu.addAction("Edit")
delete_action = menu.addAction("Delete")
edit_action = menu.addAction(
QIcon(".\\src\\warchron\\view\\ui\\../resources/pencil.png"), "Edit"
)
delete_action = menu.addAction(
QIcon(".\\src\\warchron\\view\\ui\\../resources/cross.png"), "Delete"
)
viewport = self.playersTable.viewport()
assert viewport is not None
action = menu.exec(viewport.mapToGlobal(pos))
@ -191,8 +195,12 @@ class View(QtWidgets.QMainWindow, Ui_MainWindow):
menu = QMenu(self)
edit_action = None
if item_type != ItemType.ROUND:
edit_action = menu.addAction("Edit")
delete_action = menu.addAction("Delete")
edit_action = menu.addAction(
QIcon(".\\src\\warchron\\view\\ui\\../resources/pencil.png"), "Edit"
)
delete_action = menu.addAction(
QIcon(".\\src\\warchron\\view\\ui\\../resources/cross.png"), "Delete"
)
viewport = self.warsTree.viewport()
assert viewport is not None
action = menu.exec(viewport.mapToGlobal(pos))
@ -275,8 +283,12 @@ class View(QtWidgets.QMainWindow, Ui_MainWindow):
return
objective_id = name_item.data(Qt.ItemDataRole.UserRole)
menu = QMenu(self)
edit_action = menu.addAction("Edit")
delete_action = menu.addAction("Delete")
edit_action = menu.addAction(
QIcon(".\\src\\warchron\\view\\ui\\../resources/pencil.png"), "Edit"
)
delete_action = menu.addAction(
QIcon(".\\src\\warchron\\view\\ui\\../resources/cross.png"), "Delete"
)
viewport = self.objectivesTable.viewport()
assert viewport is not None
action = menu.exec(viewport.mapToGlobal(pos))
@ -295,8 +307,12 @@ class View(QtWidgets.QMainWindow, Ui_MainWindow):
return
participant_id = name_item.data(Qt.ItemDataRole.UserRole)
menu = QMenu(self)
edit_action = menu.addAction("Edit")
delete_action = menu.addAction("Delete")
edit_action = menu.addAction(
QIcon(".\\src\\warchron\\view\\ui\\../resources/pencil.png"), "Edit"
)
delete_action = menu.addAction(
QIcon(".\\src\\warchron\\view\\ui\\../resources/cross.png"), "Delete"
)
viewport = self.warParticipantsTable.viewport()
assert viewport is not None
action = menu.exec(viewport.mapToGlobal(pos))
@ -364,8 +380,12 @@ class View(QtWidgets.QMainWindow, Ui_MainWindow):
return
sector_id = name_item.data(Qt.ItemDataRole.UserRole)
menu = QMenu(self)
edit_action = menu.addAction("Edit")
delete_action = menu.addAction("Delete")
edit_action = menu.addAction(
QIcon(".\\src\\warchron\\view\\ui\\../resources/pencil.png"), "Edit"
)
delete_action = menu.addAction(
QIcon(".\\src\\warchron\\view\\ui\\../resources/cross.png"), "Delete"
)
viewport = self.sectorsTable.viewport()
assert viewport is not None
action = menu.exec(viewport.mapToGlobal(pos))
@ -384,8 +404,12 @@ class View(QtWidgets.QMainWindow, Ui_MainWindow):
return
participant_id = name_item.data(Qt.ItemDataRole.UserRole)
menu = QMenu(self)
edit_action = menu.addAction("Edit")
delete_action = menu.addAction("Delete")
edit_action = menu.addAction(
QIcon(".\\src\\warchron\\view\\ui\\../resources/pencil.png"), "Edit"
)
delete_action = menu.addAction(
QIcon(".\\src\\warchron\\view\\ui\\../resources/cross.png"), "Delete"
)
viewport = self.campaignParticipantsTable.viewport()
assert viewport is not None
action = menu.exec(viewport.mapToGlobal(pos))
@ -448,7 +472,9 @@ class View(QtWidgets.QMainWindow, Ui_MainWindow):
if choice_id is None:
return
menu = QMenu(self)
edit_action = menu.addAction("Edit")
edit_action = menu.addAction(
QIcon(".\\src\\warchron\\view\\ui\\../resources/pencil.png"), "Edit"
)
viewport = self.choicesTable.viewport()
assert viewport is not None
action = menu.exec(viewport.mapToGlobal(pos))
@ -467,7 +493,9 @@ class View(QtWidgets.QMainWindow, Ui_MainWindow):
if battle_id is None:
return
menu = QMenu(self)
edit_action = menu.addAction("Edit")
edit_action = menu.addAction(
QIcon(".\\src\\warchron\\view\\ui\\../resources/pencil.png"), "Edit"
)
viewport = self.battlesTable.viewport()
assert viewport is not None
action = menu.exec(viewport.mapToGlobal(pos))