#ifndef QT_MACHINESTATUS_HPP #define QT_MACHINESTATUS_HPP #include #include #include #include #include #include #include class QStatusBar; class ClickableLabel : public QLabel { Q_OBJECT; public: explicit ClickableLabel(QWidget *parent = nullptr) : QLabel(parent) { } ~ClickableLabel() {}; signals: void clicked(QPoint); void doubleClicked(QPoint); void dropped(QString); protected: void mousePressEvent(QMouseEvent *event) override { emit clicked(event->globalPos()); } void mouseDoubleClickEvent(QMouseEvent *event) override { emit doubleClicked(event->globalPos()); } void dragEnterEvent(QDragEnterEvent *event) override { if (event->mimeData()->hasUrls() && event->mimeData()->urls().size() == 1) { event->setDropAction(Qt::CopyAction); event->acceptProposedAction(); } else event->ignore(); } void dragMoveEvent(QDragMoveEvent *event) override { if (event->mimeData()->hasUrls() && event->mimeData()->urls().size() == 1) { event->setDropAction(Qt::CopyAction); event->acceptProposedAction(); } else event->ignore(); } void dropEvent(QDropEvent *event) override { if (event->dropAction() == Qt::CopyAction) { emit dropped(event->mimeData()->urls()[0].toLocalFile()); } else event->ignore(); } }; class MachineStatus : public QObject { Q_OBJECT public: explicit MachineStatus(QObject *parent = nullptr); ~MachineStatus(); static bool hasCassette(); static bool hasIDE(); static bool hasSCSI(); static void iterateFDD(const std::function &cb); static void iterateCDROM(const std::function &cb); static void iterateZIP(const std::function &cb); static void iterateMO(const std::function &cb); static void iterateNIC(const std::function &cb); QString getMessage(); void clearActivity(); void setSoundGainAction(QAction* action); public slots: void refresh(QStatusBar *sbar); void message(const QString &msg); void updateTip(int tag); void refreshEmptyIcons(); void refreshIcons(); private: struct States; std::unique_ptr d; QTimer *refreshTimer; QAction *soundGainAction; QAction *muteUnmuteAction; QMenu *soundMenu; }; #endif // QT_MACHINESTATUS_HPP