-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDevWindow.cpp
More file actions
117 lines (94 loc) · 3.71 KB
/
DevWindow.cpp
File metadata and controls
117 lines (94 loc) · 3.71 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
#include <filesystem>
#include <QFileDialog>
#include "DevWindow.hpp"
#include "Dial/Attitude.hpp"
namespace VSCL {
DevWindow::DevWindow()
: QMainWindow()
, Stacker(new QStackedWidget(this))
, MainQuick(new QQuickWidget(this))
{
AttitudeDial* dial = new AttitudeDial(this);
NumericDisplaysTest = new NumericTestWidget(this, dial, [dial](int newValue) { dial->SetDialAngle(newValue); });
setCentralWidget(Stacker);
Stacker->addWidget(MainQuick);
Stacker->addWidget(NumericDisplaysTest);
QLayout* layout = Stacker->layout();
layout->setContentsMargins(5, 5, 5, 5);
CreateActions();
CreateMenus();
QString message = tr("Howdy");
statusBar()->showMessage(message);
setWindowTitle(tr("VSCL Gyroscopic Test Rig"));
setMinimumSize(160, 160);
resize(720, 480);
} // void DevWindow::DevWindow()
void DevWindow::SetQMLFromPath(const QUrl& path) {
MainQuick->setSource(path);
CurrentQML = path;
}
void DevWindow::SwapSetting() {
switch (CurrentSetting) {
case DevWindow::NumericTesting:
Stacker->setCurrentIndex(1);
CurrentSetting = DevWindow::QMLView;
break;
case DevWindow::QMLView:
Stacker->setCurrentIndex(0);
CurrentSetting = DevWindow::NumericTesting;
break;
}
}
void DevWindow::OpenQML() {
std::string currentWd = std::filesystem::current_path().string();
const char* cwd = currentWd.c_str();
QUrl qmlPath = QFileDialog::getOpenFileUrl(this,
tr("Open QML Source"), QUrl::fromLocalFile(cwd),
tr("QML Sources (*.qml)"));
SetQMLFromPath(qmlPath);
} // void DevWindow::OpenQML()
void DevWindow::ReloadQML() {
SetQMLFromPath(CurrentQML);
} // void DevWindow::ReloadQML()
void DevWindow::About() {
QMessageBox::about(this, tr("About"),
tr("Currently in development mode."));
} // void DevWindow::About()
void DevWindow::CreateMenus() {
FileMenu = menuBar()->addMenu(tr("&File"));
FileMenu->addAction(QMLLoadAct);
FileMenu->addAction(SwapSettingAct);
FileMenu->addSeparator();
FileMenu->addAction(ExitAct);
EditMenu = menuBar()->addMenu(tr("&Edit"));
EditMenu->addAction(ReloadAct);
HelpMenu = menuBar()->addMenu(tr("&Help"));
HelpMenu->addAction(AboutAct);
} // void DevWindow::CreateMenus()
void DevWindow::CreateActions() {
QMLLoadAct = new QAction(QIcon::fromTheme(QIcon::ThemeIcon::DocumentOpen),
tr("Load QML"), this);
QMLLoadAct->setShortcuts(QKeySequence::Open);
QMLLoadAct->setStatusTip(tr("Load QML into the viewport."));
connect(QMLLoadAct, &QAction::triggered, this, &DevWindow::OpenQML);
SwapSettingAct = new QAction(QIcon::fromTheme(QIcon::ThemeIcon::DocumentOpen),
tr("Change Setting"), this);
SwapSettingAct->setShortcuts(QKeySequence::NextChild);
SwapSettingAct->setStatusTip(tr("Change between QML viewport and numeric testing modes"));
connect(SwapSettingAct, &QAction::triggered, this, &DevWindow::SwapSetting);
ExitAct = new QAction(QIcon::fromTheme(QIcon::ThemeIcon::ApplicationExit),
tr("Exit"), this);
ExitAct->setShortcuts(QKeySequence::Quit);
ExitAct->setStatusTip(tr("Exit the application"));
connect(ExitAct, &QAction::triggered, this, &QWidget::close);
ReloadAct = new QAction(QIcon::fromTheme(QIcon::ThemeIcon::EditRedo),
tr("Reload"), this);
ReloadAct->setShortcuts(QKeySequence::Redo);
ReloadAct->setStatusTip(tr("Reload QML sources"));
connect(ReloadAct, &QAction::triggered, this, &DevWindow::ReloadQML);
AboutAct = new QAction(QIcon::fromTheme(QIcon::ThemeIcon::HelpAbout),
tr("&About"), this);
AboutAct->setStatusTip(tr("Show the application's About box"));
connect(AboutAct, &QAction::triggered, this, &DevWindow::About);
} // void DevWindow::CreateActions()
} // namespace VSCL