LibreVNA/Software/PC_Application/mode.h

74 lines
1.8 KiB
C
Raw Normal View History

#ifndef MODE_H
#define MODE_H
2021-10-21 19:00:34 +08:00
#include "appwindow.h"
#include "savable.h"
2022-04-04 05:34:18 +08:00
#include "scpi.h"
2021-10-21 19:00:34 +08:00
#include <QString>
#include <QWidget>
#include <QButtonGroup>
#include <QToolBar>
2022-04-04 05:34:18 +08:00
#include <QTabBar>
#include <QDockWidget>
#include <set>
2022-04-04 05:34:18 +08:00
class Mode : public QObject, public Savable, public SCPINode
{
Q_OBJECT
public:
2022-04-04 05:34:18 +08:00
enum class Type {
VNA,
SG,
SA,
Last,
};
Mode(AppWindow *window, QString name, QString SCPIname);
~Mode();
2020-11-12 02:13:53 +08:00
virtual void activate(); // derived classes must call Mode::activate before doing anything
virtual void deactivate(); // derived classes must call Mode::deactivate before returning
virtual void shutdown(){}; // called when the application is about to exit
QString getName() const;
2022-04-04 05:34:18 +08:00
void setName(const QString &value);
static Mode *getActiveMode();
2022-04-04 05:34:18 +08:00
static QString TypeToName(Type t);
static Type TypeFromName(QString s);
virtual Type getType() = 0;
virtual void initializeDevice() = 0;
2020-09-14 00:01:32 +08:00
virtual void deviceDisconnected(){};
2021-04-13 02:15:38 +08:00
virtual void saveSreenshot();
2022-04-04 05:34:18 +08:00
static Mode *createNew(AppWindow *window, QString name, Type t);
static bool nameAllowed(QString name);
static std::vector<Mode *> getModes();
static Mode* findFirstOfType(Type t);
signals:
void statusbarMessage(QString msg);
protected:
void setStatusbarMessage(QString msg);
// call once the derived class is fully initialized
void finalize(QWidget *centralWidget);
AppWindow *window;
std::set<QAction*> actions;
std::set<QToolBar*> toolbars;
std::set<QDockWidget*> docks;
private:
2022-04-04 05:34:18 +08:00
int findTabIndex();
static std::vector<Mode*> modes;
static Mode *activeMode;
2022-04-04 05:34:18 +08:00
static QTabBar *tabbar;
static QWidget *cornerWidget;
2022-04-04 05:34:18 +08:00
// static QButtonGroup *modeButtonGroup;
QString name;
QString statusbarMsg;
QWidget *central;
};
#endif // MODE_H