2021-11-28 20:49:05 +01:00
|
|
|
#ifndef QT_MACHINESTATUS_HPP
|
|
|
|
|
#define QT_MACHINESTATUS_HPP
|
|
|
|
|
|
|
|
|
|
#include <QWidget>
|
2021-12-14 00:31:55 +06:00
|
|
|
#include <QLabel>
|
|
|
|
|
#include <QMouseEvent>
|
2022-05-24 02:14:45 +06:00
|
|
|
#include <QMimeData>
|
2021-11-28 20:49:05 +01:00
|
|
|
|
2021-12-16 22:30:48 +01:00
|
|
|
#include <memory>
|
|
|
|
|
|
2021-11-30 22:06:41 +01:00
|
|
|
class QStatusBar;
|
2021-11-28 20:49:05 +01:00
|
|
|
|
2021-12-14 00:31:55 +06:00
|
|
|
class ClickableLabel : public QLabel {
|
|
|
|
|
Q_OBJECT;
|
|
|
|
|
|
2022-11-19 08:49:04 -05:00
|
|
|
public:
|
|
|
|
|
explicit ClickableLabel(QWidget *parent = nullptr)
|
|
|
|
|
: QLabel(parent)
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
~ClickableLabel() {};
|
|
|
|
|
|
|
|
|
|
signals:
|
|
|
|
|
void clicked(QPoint);
|
|
|
|
|
void doubleClicked(QPoint);
|
|
|
|
|
void dropped(QString);
|
2021-12-14 00:31:55 +06:00
|
|
|
|
2022-11-19 08:49:04 -05:00
|
|
|
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();
|
|
|
|
|
}
|
2021-12-14 00:31:55 +06:00
|
|
|
};
|
|
|
|
|
|
2022-11-19 08:49:04 -05:00
|
|
|
class MachineStatus : public QObject {
|
2021-11-28 20:49:05 +01:00
|
|
|
Q_OBJECT
|
|
|
|
|
|
|
|
|
|
public:
|
2021-11-30 22:06:41 +01:00
|
|
|
explicit MachineStatus(QObject *parent = nullptr);
|
2021-11-28 20:49:05 +01:00
|
|
|
~MachineStatus();
|
|
|
|
|
|
2021-12-03 11:38:00 +01:00
|
|
|
static bool hasCassette();
|
|
|
|
|
static bool hasIDE();
|
|
|
|
|
static bool hasSCSI();
|
2022-11-19 08:49:04 -05:00
|
|
|
static void iterateFDD(const std::function<void(int i)> &cb);
|
|
|
|
|
static void iterateCDROM(const std::function<void(int i)> &cb);
|
|
|
|
|
static void iterateZIP(const std::function<void(int i)> &cb);
|
|
|
|
|
static void iterateMO(const std::function<void(int i)> &cb);
|
|
|
|
|
static void iterateNIC(const std::function<void(int i)> &cb);
|
2021-12-28 16:47:10 +06:00
|
|
|
|
|
|
|
|
QString getMessage();
|
2022-12-09 22:13:15 +02:00
|
|
|
void clearActivity();
|
2021-11-28 20:49:05 +01:00
|
|
|
public slots:
|
2022-11-19 08:49:04 -05:00
|
|
|
void refresh(QStatusBar *sbar);
|
|
|
|
|
void message(const QString &msg);
|
2021-12-14 00:31:55 +06:00
|
|
|
void updateTip(int tag);
|
2024-09-18 09:38:47 +02:00
|
|
|
void refreshEmptyIcons();
|
2022-07-13 01:04:01 +02:00
|
|
|
void refreshIcons();
|
2021-11-28 20:49:05 +01:00
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
struct States;
|
|
|
|
|
std::unique_ptr<States> d;
|
2022-11-19 08:49:04 -05:00
|
|
|
QTimer *refreshTimer;
|
2021-11-28 20:49:05 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
#endif // QT_MACHINESTATUS_HPP
|