Skip to content

Port to Qt6: eliminate dependency on Gtkmm. #1

@dooglio

Description

@dooglio

I propose the following plan to convert this project into Qt6 completely and remove the dependency on Gtkmm. This opens up the Mac OS/X platform as presently this app only runs under Linux and Windows. This summary was written by anthropic.claude-sonnet-4-6:1m.

I will employ AI to do the conversion and help with the debugging.

TurnWatcher → Qt6 Conversion Plan

Project Overview

This is a D&D initiative tracker ("Turn Watcher") written in C++ originally built against GTK+/GTKMM. There is already a partial Qt5 port in progress — the src/gui/ui/ directory, the src/gui/base/ layer, and the src/gui/transactions/ layer already use Qt/sigc++ but many UI windows still live in src/gui/ui-gtk/ and use pure GTK classes. The motk library (a thin GTK helper wrapper) is also GTK-heavy.

The entry point TurnWatcher.cpp still calls Gtk::Main, and many windows still inherit from Gtk::Dialog, Gtk::Window, Gtk::TreeView, etc.


Key Layers to Convert

Layer Location Status Work Needed
Entry point TurnWatcher.cpp GTK Gtk::Main Replace with QApplication
motk library src/motk/ GTK (Gtk::ActionGroup, Gtk::UIManager, Gtk::AccelGroup) Replace with Qt6 equivalents or eliminate
Base/model layer src/gui/base/ Already Qt5-ish (QString, Qt signal patterns) but uses sigc::signal Replace sigc::signal with Qt signals/slots
CharacterModel src/gui/base/CharacterModel.h Uses Gtk::TreeStore, Gdk::Pixbuf Replace with QAbstractItemModel / QStandardItemModel
CharacterColumns src/gui/base/CharacterColumns.h GTK TreeView columns Replace with Qt model column definitions
GTK UI windows src/gui/ui-gtk/ All GTK Full Qt6 rewrite
Qt stub UI src/gui/ui/ Already Qt5 .ui + stub .cpp/.h Upgrade to Qt6, wire up logic
CMakeLists All CMakeLists.txt Qt5 find_package Upgrade to Qt6

Detailed Plan

Phase 1 — CMake Build System (Qt5 → Qt6)

  • Update src/gui/CMakeLists.txt and src/motk/CMakeLists.txt
  • Change find_package(Qt5...)find_package(Qt6...)
  • Set CMAKE_PREFIX_PATH to /Users/doug-personal/Qt
  • Change Qt5::Core, Qt5::Widgets, etc. → Qt6::Core, Qt6::Widgets, etc.
  • Use qt_wrap_ui() / qt_add_resources() (Qt6 macros)
  • Remove the motk GTK dependency (include(gtkmm)) entirely

Phase 2 — Drop motk GTK library

The motk library provides:

  • ActionManager — wraps Gtk::ActionGroup / Gtk::UIManager / icon factories
  • UiBase — wraps Gtk::UIManager for XML-based menus
  • LabelTable / LabelTableScroller — GTK form layout helpers
  • MenuManager, HtmlWidget, Chooser

Strategy: Replace motk entirely — Qt6 provides direct equivalents:

  • QAction, QMenu, QMenuBar, QToolBar → replace ActionManager / UIBase
  • QFormLayout → replace LabelTable
  • QTextBrowser → replace HtmlWidget

The new motk CMakeLists will become a minimal shim or be eliminated — all its functionality gets absorbed directly into the Qt UI layer.

Phase 3 — Base Layer: Replace sigc::signal with Qt Signals

Several classes in src/gui/base/ use sigc::signal:

  • AppSettings, CharacterManager, InitiativeManager, TransactionManager, StatManager

Strategy: Convert each singleton manager class to a QObject subclass with proper signals: blocks. Replace all sigc::signal<void> with void signal_xxx(), and all .connect(sigc::mem_fun(...)) call sites with QObject::connect(...).

Phase 4 — CharacterModel: GTK TreeStore → Qt Item Model

CharacterModel currently inherits from nothing but manages a Glib::RefPtr<Gtk::TreeStore>.

Strategy: Rewrite as QStandardItemModel (or QAbstractItemModel subclass). Character rows become QStandardItem rows with custom data roles. The sort model will be QSortFilterProxyModel.

Phase 5 — Rewrite All GTK UI Windows as Qt6 Dialogs/Widgets

Each GTK window in src/gui/ui-gtk/ gets a Qt6 replacement in src/gui/ui/:

GTK Class Qt6 Replacement
MainWindow (Gtk::Window) QMainWindow (already stubbed — flesh out)
AboutWindow (Gtk::AboutDialog) QDialog (already stubbed as AboutDialog)
EditWindow (Gtk::Dialog) New EditDialog (QDialog with QFormLayout)
DamageWindow (Gtk::Dialog) New DamageDialog (QDialog with QSpinBox)
InitWindow (Gtk::Dialog) New InitDialog (QDialog with QTableWidget)
SettingsWindow (Gtk::Dialog) New SettingsDialog (QDialog with QFormLayout)
StatWindow (Gtk::Dialog) New StatDialog (QDialog)
CharacterView (Gtk::TreeView) QTreeView + new Qt item model
HUDWindow (Gtk::Window) QWidget floating window with QTreeView
RoundsHelper Keep the logic, replace Gtk:: references with Qt
StatusBox QStatusBar
Splash QSplashScreen
EffectsBook, EffectsEditor, EffectsList, EffectEditor New Qt tabs/dialogs
DuplicateWindow New QDialog with QSpinBox
JumpInWindow, InputWindow New simple QDialog variants
ExpiredEffectsWindow New QDialog

Phase 6 — Wire Up MainWindow

The existing src/gui/ui/MainWindow.cpp is just a stub with setupUi(this). The real logic is in the GTK version. Strategy:

  • Uncomment and implement all the action slots
  • Connect QAction signals to slots for all menu/toolbar actions
  • Integrate CharacterView (Qt TreeView) as central widget
  • Implement Load(), Save(), UpdateUI(), UpdateMenus() using the base managers
  • Add QTimer for periodic save
  • Restore window geometry from AppSettings

Phase 7 — Update TurnWatcher.cpp Entry Point

  • Remove #include <gtkmm.h>, Gtk::Main, g_log_set_default_handler
  • Add QApplication, QCoreApplication::setApplicationName/Version
  • Replace moApplication integration where it applies to path management
  • Keep molib usage for file I/O (it's pure C++ and doesn't need GTK)

Phase 8 — Remove GTK cmake modules

  • Remove src/motk/CMakeLists.txt inclusion of include(gtkmm)
  • Remove cmake/gtkmm.cmake dependency from build
  • Clean up unused sigc references in CMakeLists (sigc++ is no longer needed once signals are converted to Qt)

Directory Strategy

  • Keep src/gui/ui-gtk/ as-is for reference (do not delete, just stop compiling them)
  • All new Qt6 UI code goes into src/gui/ui/ (already exists)
  • New .ui files created with Qt Designer for any dialog that benefits from it
  • The existing src/gui/ui/MainWindow.ui and AboutDialog.ui are already Qt5 compatible and need only minor Qt6 updates

What stays the same (no GTK dependency)

  • src/molib/ — pure C++ library for prop bags, XML I/O, name management
  • src/gui/base/character.cpp/.h, effect.cpp/.h, stat.cpp/.h — pure data models
  • src/gui/transactions/ — transaction pattern, pure C++
  • All .ui Qt Designer files and src/gui/ui/res/ resources

Estimated Scope

This is a large but structured conversion. The logical business layer (transactions, characters, effects, stats, initiative management) is already mostly decoupled from GTK. The GTK dependency is concentrated in:

  1. The motk library (~8 files)
  2. The ui-gtk/ windows (~18 files)
  3. CharacterModel.h and ActionsManager.h (GTK includes)
  4. TurnWatcher.cpp entry point

Metadata

Metadata

Assignees

No fields configured for Feature.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions