-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathHelpMenu.cpp
187 lines (156 loc) · 6.28 KB
/
HelpMenu.cpp
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
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
#include "HelpMenu.h"
#include "QWindow"
#include "QLabel"
#include "QHBoxLayout"
#include "QTabWidget"
#include "QCoreApplication"
#include "QTextEdit"
#include "QGridLayout"
#include "QScrollArea"
#define TABUTILITY(SOURCE,GENERATOR,NAME,TARGET)\
SOURCE = GENERATOR;\
TARGET->addTab(SOURCE,NAME);
HelpMenu::HelpMenu(QWidget *parent) : QDialog(parent)
{
generateTabs();
QHBoxLayout* QHB = new QHBoxLayout();
QHB->addWidget(Tabs);
this->setLayout(QHB);
setWindowTitle("Info");
setBaseSize(400,400);
resize(700,600);
}
void HelpMenu::generateTabs()
{
Tabs = new QTabWidget(this);
// TABUTILITY(QuickStartTab,generateQuickStartTab(),"Quick Start",Tabs);
TABUTILITY(GeneralTab ,generateGeneralTab(),"General", Tabs);
// TABUTILITY(MemViewTab ,generateMemViewTab(),"Memory and Stack", Tabs);
// TABUTILITY(StackViewTab ,generateStackViewTab(),"Stack", Tabs);
// TABUTILITY(RegViewTab ,generateRegViewTab(),"Registers", Tabs);
// TABUTILITY(SettingTab ,generateSettingTab(),"Settings", Tabs);
// TABUTILITY(ContactTab ,generateContactTab(),"Contact", Tabs);
// SettingTab->deleteLater();
}
QWidget* HelpMenu::generateGeneralTab()
{
QWidget* genTab = new QWidget();
QTextEdit* generalInfo = new QTextEdit("A");
generalInfo->setParent(genTab);
QGridLayout* QVB = new QGridLayout(genTab);
genTab->setLayout(QVB);
QString* info = new QString("Hello!\n"
"\n"
"Welcome to LC3-Sim v"+QCoreApplication::applicationVersion()+
"\n"
"\n"
"Please read the README.txt and Appendix for more information.");
generalInfo->setText(*info);
generalInfo->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
generalInfo->setVerticalScrollBarPolicy(Qt::ScrollBarAsNeeded);
#define QUICKER QSizePolicy::MinimumExpanding
generalInfo->setSizePolicy(QUICKER,QUICKER);
// QScrollArea* QSA = new QScrollArea(genTab);
// QSA->setWidget(generalInfo);
// QSA->setSizePolicy(QUICKER,QUICKER);
QVB->addWidget(generalInfo,1,0);
generalInfo->adjustSize();
genTab->setSizePolicy(QUICKER,QUICKER);
return genTab;
}
QWidget* HelpMenu::generateMemViewTab()
{
QWidget* stackTab = new QWidget();
// QTabWidget* stackInfo = new QTabWidget();
// QHBoxLayout* QHB = new QHBoxLayout();
// stackTab->setLayout(QHB);
// stackTab->layout()->addWidget(stackInfo);
// QWidget* TipsNTricks = new QWidget();
// TipsNTricks->setLayout(new QHBoxLayout());
// QLabel * tips = new QLabel(
// "Here is where the memory of the machine is displayed. For more info about the system memory, please address the included Appendix."
// "\n"
// "\n"
// "What to know:"
// " BR stands for breakpoint, and can be set to halt execution. If a register points to that line, this box will be filled with that register's color.\n"
// " Addr is the hex address of the line in memory.\n"
// " Name is the label of that line.\n"
// " Value is the value of a given line, and will dictate what Mnem displays.\n"
// " Mnem is the mnemonic (if it exists) for that line's value.\n"
// " Comments are any comments that exist for that line.\n"
// "\n"
// " "
// );
// TipsNTricks->layout()->addWidget(tips);
// stackInfo->addTab(TipsNTricks,"Tips && Tricks");
return stackTab;
// return memTab;
}
QWidget* HelpMenu::generateStackViewTab()
{
QWidget* stackTab = new QWidget();
QTabWidget* stackInfo = new QTabWidget();
QHBoxLayout* QHB = new QHBoxLayout();
stackTab->setLayout(QHB);
stackTab->layout()->addWidget(stackInfo);
QWidget* TipsNTricks = new QWidget();
TipsNTricks->setLayout(new QHBoxLayout());
QLabel * tips = new QLabel("You might have noticed that the Stack View has some weird discoloration.\n This is because, whenever a value is changed in that range,"
"a color is generated based on the value of ");
TipsNTricks->layout()->addWidget(tips);
stackInfo->addTab(TipsNTricks,"Tips && Tricks");
return stackTab;
}
QWidget* HelpMenu::generateRegViewTab()
{
QWidget* RegViewTab = new QWidget();
return RegViewTab;
}
QWidget *HelpMenu::generateQuickStartTab()
{
QWidget* quickStartTab = new QWidget();
QTextEdit* quickstartTE = new QTextEdit("A");
quickstartTE->setParent(quickStartTab);
QGridLayout* QVB = new QGridLayout(quickStartTab);
quickStartTab->setLayout(QVB);
QString* info =
new QString(
"To Load, go to the menu bar, press assemble and load.\n\n"
"To Save, go to the Console Tab, type ``save x{begining line number} x{end line number}``"
", replacing the values between the curly brackets with the hexadecimal line numbers that inclusively contain the program."
);
quickstartTE->setText(*info);
quickstartTE->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
quickstartTE->setVerticalScrollBarPolicy(Qt::ScrollBarAsNeeded);
quickstartTE->setSizePolicy(QUICKER,QUICKER);
QScrollArea* QSA = new QScrollArea(quickStartTab);
QSA->setWidget(quickStartTab);
QSA->setSizePolicy(QUICKER,QUICKER);
QVB->addWidget(quickstartTE,1,0);
quickstartTE->adjustSize();
quickStartTab->setSizePolicy(QUICKER,QUICKER);
return quickStartTab;
}
QWidget *HelpMenu::generateContactTab()
{
QWidget* stackTab = new QWidget();
QTabWidget* stackInfo = new QTabWidget();
QHBoxLayout* QHB = new QHBoxLayout();
stackTab->setLayout(QHB);
stackTab->layout()->addWidget(stackInfo);
QWidget* TipsNTricks = new QWidget();
TipsNTricks->setLayout(new QHBoxLayout());
QLabel * tips = new QLabel("You might have noticed that the Stack View has some weird discoloration.\n This is because, whenever a value is changed in that range,"
"a color is generated based on the value of ");
TipsNTricks->layout()->addWidget(tips);
stackInfo->addTab(TipsNTricks,"Tips && Tricks");
return stackTab;
}
QWidget *HelpMenu::generateSettingTab()
{
QWidget* setTab = new QWidget();
QTabWidget* holder = new QTabWidget(setTab);
QWidget* shortcuts;
// TABUTILITY(shortcuts,new QWidget(holder),"Shortcuts",holder);
return setTab;
}