-
Notifications
You must be signed in to change notification settings - Fork 0
/
mainwindow.cpp
155 lines (147 loc) · 6.14 KB
/
mainwindow.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
#include "mainwindow.h"
#include "ui_mainwindow.h"
#include <QDebug>
MainWindow::MainWindow(QWidget *parent) :
QMainWindow(parent),
ui(new Ui::MainWindow)
{
ui->setupUi(this);
//create widgets
ConditionDialog *adialog = new ConditionDialog();
ExpressionsDialog *bdialog = new ExpressionsDialog();
SolvedSystemDialog *cdialog = new SolvedSystemDialog();
TwoDimensionalProblem *ddialog = new TwoDimensionalProblem();
GraphDialog1 *edialog = new GraphDialog1();
GraphDialog2 *fdialog = new GraphDialog2();
MinMaxIntercectCheckDialog *gdialog = new MinMaxIntercectCheckDialog();
FinishDialog *zdialog = new FinishDialog();
//
AboutDialog *aboutDialog = new AboutDialog();
PasswordDialog *passDialog = new PasswordDialog();
m_textEdit = new QTextEdit();
m_textEdit->hide();
m_textEdit->setMinimumWidth(250);
m_textEdit->setMaximumWidth(250);
//menu
ui->menu->addAction(QString::fromLocal8Bit("Правильный ответ"), passDialog, SLOT(show()));
ui->menu->addSeparator();
ui->menu->addAction(QString::fromLocal8Bit("О программе"), aboutDialog, SLOT(show()));
ui->menu->addAction(QString::fromLocal8Bit("О Qt"), qApp, SLOT(aboutQt()));
ui->menu->addSeparator();
ui->menu->addAction(QString::fromLocal8Bit("Выход"), qApp, SLOT(quit()));
//add widgets
ui->stackedWidget->addWidget(adialog);
ui->stackedWidget->addWidget(bdialog);
ui->stackedWidget->addWidget(cdialog);
ui->stackedWidget->addWidget(ddialog);
ui->stackedWidget->addWidget(edialog);
ui->stackedWidget->addWidget(fdialog);
ui->stackedWidget->addWidget(gdialog);
ui->stackedWidget->addWidget(zdialog);
//connect
//ConditionDialog
connect(adialog, SIGNAL(next()), this, SLOT(nextWidget()));
connect(adialog, SIGNAL(result(int,int)), bdialog, SLOT(setCondition(int,int)));
//ExpressionsDialog
connect(bdialog, SIGNAL(back()), this, SLOT(previousWidget()));
connect(bdialog, SIGNAL(result(double*,double**,double*,quint8,quint8)), cdialog, SLOT(setCondition(double*,double**,double*,quint8,quint8)));
connect(bdialog, SIGNAL(next()), this, SLOT(nextWidget()));
connect(bdialog, SIGNAL(userError()), zdialog, SLOT(addUserError()));
//SolvedSystemDialog
connect(cdialog, SIGNAL(back()), this, SLOT(previousWidget()));
connect(cdialog, SIGNAL(next()), this, SLOT(nextWidget()));
connect(cdialog, SIGNAL(userError()), zdialog, SLOT(addUserError()));
connect(cdialog, SIGNAL(result(double**,quint8)), ddialog, SLOT(setCondition(double**,quint8)));
//TwoDimensionalProblem
connect(ddialog, SIGNAL(back()), this, SLOT(previousWidget()));
connect(ddialog, SIGNAL(next()), this, SLOT(nextWidget()));
connect(ddialog, SIGNAL(result(double**,quint8)), edialog, SLOT(setCondition(double**,quint8)));
//GraphDialog1
connect(edialog, SIGNAL(next()), this, SLOT(nextWidget()));
connect(edialog, SIGNAL(back()), this, SLOT(previousWidget()));
connect(edialog, SIGNAL(result(double**,quint8)), fdialog, SLOT(setCondition(double**,quint8)));
connect(edialog, SIGNAL(userError()), zdialog, SLOT(addUserError()));
//GraphDialog2
connect(fdialog, SIGNAL(next()), this, SLOT(nextWidget()));
connect(fdialog, SIGNAL(back()), this, SLOT(previousWidget()));
connect(fdialog, SIGNAL(result(QPointF,QPointF,qreal,qreal)), gdialog, SLOT(getResult(QPointF,QPointF,qreal,qreal)));
connect(fdialog, SIGNAL(userError()), zdialog, SLOT(addUserError()));
//MinMaxIntercectCheckDialog
connect(gdialog, SIGNAL(next()), this, SLOT(nextWidget()));
connect(gdialog, SIGNAL(back()), this, SLOT(previousWidget()));
connect(gdialog, SIGNAL(result(qreal,qreal,qreal,qreal,qreal,qreal)), zdialog, SLOT(setAnswer(qreal,qreal,qreal,qreal,qreal,qreal)));
connect(gdialog, SIGNAL(userError()), zdialog, SLOT(addUserError()));
connect(ui->resetButton, SIGNAL(clicked()), zdialog, SLOT(reset()));
connect(ui->quitButton, SIGNAL(clicked()), qApp, SLOT(quit()));
connect(passDialog, SIGNAL(accept()), this, SLOT(showHint()));
}
MainWindow::~MainWindow()
{
delete ui;
}
void MainWindow::nextWidget()
{
ui->stackedWidget->setCurrentIndex(ui->stackedWidget->currentIndex() + 1);
}
void MainWindow::previousWidget()
{
ui->stackedWidget->setCurrentIndex(ui->stackedWidget->currentIndex() - 1);
}
void MainWindow::on_resetButton_clicked()
{
ui->stackedWidget->setCurrentIndex(0);
}
void MainWindow::on_toolButton_clicked()
{
if(ui->toolButton->arrowType() == Qt::RightArrow)
{
ui->toolButton->setArrowType(Qt::LeftArrow);
this->resize(this->width() + m_textEdit->width(), this->height());
ui->additionalLayout->addWidget(m_textEdit);
m_textEdit->show();
}
else
{
this->setMinimumWidth(0);
ui->toolButton->setArrowType(Qt::RightArrow);
this->resize(this->width() - m_textEdit->width(), this->height());
ui->additionalLayout->removeWidget(m_textEdit);
m_textEdit->hide();
}
}
void MainWindow::showHint()
{
switch(ui->stackedWidget->currentIndex())
{
case 2:
{
SolvedSystemDialog *dialog = dynamic_cast<SolvedSystemDialog*>(ui->stackedWidget->currentWidget());
dialog->showHint();
break;
}
// case 4:
// {
// GraphDialog1 *dialog = dynamic_cast<GraphDialog1*>(ui->stackedWidget->currentWidget());
// dialog->showHint();
// break;
// }
case 5:
{
GraphDialog2 *dialog = dynamic_cast<GraphDialog2*>(ui->stackedWidget->currentWidget());
dialog->showHint();
break;
}
case 6:
{
MinMaxIntercectCheckDialog *dialog = dynamic_cast<MinMaxIntercectCheckDialog*>(ui->stackedWidget->currentWidget());
dialog->showHint();
break;
}
default:
{
QMessageBox::information(this, QString::fromLocal8Bit("Уведомление"),
QString::fromLocal8Bit("На этом этапе нет правильных ответов!"), QMessageBox::Ok);
break;
}
}
}