Skip to content

Extract hardware controller lifecycle from MainWindow into HardwareManager service #83

@ny4i

Description

@ny4i

Problem

MainWindow directly creates and wires all hardware controllers (RadioController, AmplifierController, RotatorController, KeyerController, IambicKeyer). Each adds ~10-20 lines of construction, signal wiring, and auto-connect logic. This contributes to MainWindow bloat (currently 5,050+ lines, well over the 3,000 STOP limit).

Current State

All four hardware controllers follow the same pattern in MainWindow:

  1. Create controller instance
  2. Wire signals (connection status, state updates)
  3. Check AppSettings for auto-connect
  4. Initiate async connection if enabled

Files affected:

  • src/ui/MainWindow.cpp lines ~1160-1240 (amplifier, rotator, keyer creation)
  • src/ui/MainWindow.h (member variables: m_amplifierController, m_rotatorController, m_keyerController, m_iambicKeyer)

Proposed Solution

Create HardwareManager service class that:

  • Owns all hardware controllers (RadioController, AmplifierController, RotatorController, KeyerController, IambicKeyer)
  • Handles construction, signal wiring, auto-connect logic
  • Exposes controllers via getters for other services/dialogs that need them
  • Follows existing service patterns (e.g., AmplifierService, RotatorService)
class HardwareManager : public QObject {
    Q_OBJECT
public:
    explicit HardwareManager(QObject* parent = nullptr);
    
    RadioController* radioController() const;
    AmplifierController* amplifierController() const;
    RotatorController* rotatorController() const;
    KeyerController* keyerController() const;
    IambicKeyer* iambicKeyer() const;
    
    void initializeFromSettings();  // Read AppSettings, create controllers, auto-connect
    
signals:
    void radioConnectionChanged(bool connected);
    void amplifierConnectionChanged(bool connected);
    // etc.
};

MainWindow would then hold a single HardwareManager* instead of 5+ individual controller pointers.

Acceptance Criteria

  • All hardware controller creation moved out of MainWindow
  • All auto-connect logic moved out of MainWindow
  • MainWindow only holds HardwareManager*, accesses controllers via getters
  • No behavioral changes (all signals still reach the same destinations)
  • Existing tests still pass

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions