mirror of
https://github.com/TomHarte/CLK.git
synced 2024-11-29 12:50:28 +00:00
Exposes activity lights in Qt.
As a status bar, which is a bit of a quick fix, but it's better than not displaying this information.
This commit is contained in:
parent
f0c0caf800
commit
86737454a0
@ -74,6 +74,9 @@ void MainWindow::deleteMachine() {
|
|||||||
if(controlsMenu) menuBar()->removeAction(controlsMenu->menuAction());
|
if(controlsMenu) menuBar()->removeAction(controlsMenu->menuAction());
|
||||||
if(inputMenu) menuBar()->removeAction(inputMenu->menuAction());
|
if(inputMenu) menuBar()->removeAction(inputMenu->menuAction());
|
||||||
displayMenu = enhancementsMenu = controlsMenu = inputMenu = nullptr;
|
displayMenu = enhancementsMenu = controlsMenu = inputMenu = nullptr;
|
||||||
|
|
||||||
|
// Remove the status bar, if any.
|
||||||
|
setStatusBar(nullptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
MainWindow::~MainWindow() {
|
MainWindow::~MainWindow() {
|
||||||
@ -453,6 +456,9 @@ void MainWindow::launchMachine() {
|
|||||||
|
|
||||||
// Push the help menu after any that were just added.
|
// Push the help menu after any that were just added.
|
||||||
addHelpMenu();
|
addHelpMenu();
|
||||||
|
|
||||||
|
// Add activity LED UI.
|
||||||
|
addActivityObserver();
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::addDisplayMenu(const std::string &machinePrefix, const std::string &compositeColour, const std::string &compositeMono, const std::string &svideo, const std::string &rgb) {
|
void MainWindow::addDisplayMenu(const std::string &machinePrefix, const std::string &compositeColour, const std::string &compositeMono, const std::string &svideo, const std::string &rgb) {
|
||||||
@ -1320,3 +1326,36 @@ void MainWindow::restoreSelections() {
|
|||||||
#undef CheckBox
|
#undef CheckBox
|
||||||
#undef ComboBox
|
#undef ComboBox
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// MARK: - Activity observation
|
||||||
|
|
||||||
|
void MainWindow::addActivityObserver() {
|
||||||
|
auto activitySource = machine->activity_source();
|
||||||
|
if(!activitySource) return;
|
||||||
|
|
||||||
|
setStatusBar(new QStatusBar());
|
||||||
|
activitySource->set_activity_observer(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
void MainWindow::register_led(const std::string &name) {
|
||||||
|
ledStatuses[name] = false;
|
||||||
|
updateStatusBarText();
|
||||||
|
}
|
||||||
|
|
||||||
|
void MainWindow::set_led_status(const std::string &name, bool isLit) {
|
||||||
|
ledStatuses[name] = isLit;
|
||||||
|
updateStatusBarText(); // Assumption here: Qt's attempt at automatic thread confinement will work here.
|
||||||
|
}
|
||||||
|
|
||||||
|
void MainWindow::updateStatusBarText() {
|
||||||
|
QString fullText;
|
||||||
|
bool isFirst = true;
|
||||||
|
for(const auto &pair: ledStatuses) {
|
||||||
|
if(!isFirst) fullText += " | ";
|
||||||
|
fullText += QString::fromStdString(pair.first);
|
||||||
|
fullText += " ";
|
||||||
|
fullText += pair.second ? "■" : "□";
|
||||||
|
isFirst = false;
|
||||||
|
}
|
||||||
|
statusBar()->showMessage(fullText);
|
||||||
|
}
|
||||||
|
@ -15,6 +15,8 @@
|
|||||||
#include "../../Analyser/Static/StaticAnalyser.hpp"
|
#include "../../Analyser/Static/StaticAnalyser.hpp"
|
||||||
#include "../../Machines/Utility/MachineForTarget.hpp"
|
#include "../../Machines/Utility/MachineForTarget.hpp"
|
||||||
|
|
||||||
|
#include "../../Activity/Observer.hpp"
|
||||||
|
|
||||||
// There are machine-specific controls for the following:
|
// There are machine-specific controls for the following:
|
||||||
#include "../../Machines/ZX8081/ZX8081.hpp"
|
#include "../../Machines/ZX8081/ZX8081.hpp"
|
||||||
#include "../../Machines/Atari/2600/Atari2600.hpp"
|
#include "../../Machines/Atari/2600/Atari2600.hpp"
|
||||||
@ -23,7 +25,7 @@ QT_BEGIN_NAMESPACE
|
|||||||
namespace Ui { class MainWindow; }
|
namespace Ui { class MainWindow; }
|
||||||
QT_END_NAMESPACE
|
QT_END_NAMESPACE
|
||||||
|
|
||||||
class MainWindow : public QMainWindow, public Outputs::Speaker::Speaker::Delegate, public ScanTargetWidget::MouseDelegate {
|
class MainWindow : public QMainWindow, public Outputs::Speaker::Speaker::Delegate, public ScanTargetWidget::MouseDelegate, public Activity::Observer {
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
void createActions();
|
void createActions();
|
||||||
@ -139,6 +141,12 @@ class MainWindow : public QMainWindow, public Outputs::Speaker::Speaker::Delegat
|
|||||||
QMenu *inputMenu = nullptr;
|
QMenu *inputMenu = nullptr;
|
||||||
|
|
||||||
std::optional<Inputs::Keyboard::Key> keyForEvent(QKeyEvent *);
|
std::optional<Inputs::Keyboard::Key> keyForEvent(QKeyEvent *);
|
||||||
|
|
||||||
|
void register_led(const std::string &) override;
|
||||||
|
void set_led_status(const std::string &, bool) override;
|
||||||
|
std::map<std::string, bool> ledStatuses;
|
||||||
|
void addActivityObserver();
|
||||||
|
void updateStatusBarText();
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // MAINWINDOW_H
|
#endif // MAINWINDOW_H
|
||||||
|
Loading…
Reference in New Issue
Block a user