-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfensecondaire.cpp
More file actions
66 lines (55 loc) · 1.99 KB
/
fensecondaire.cpp
File metadata and controls
66 lines (55 loc) · 1.99 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
#include "fensecondaire.h"
fenSecondaire::fenSecondaire(const QString& codeH, const QString& codeCpp, QString* const nomPageH, QString* const nomPageCpp,QWidget *parent) : QDialog(parent)
{
pageH = new QTextEdit;
pageH->setPlainText(codeH);
pageH->setReadOnly(true);
pageH->setFont(QFont("Courier"));
pageH->setLineWrapMode(QTextEdit::NoWrap);
pageCpp = new QTextEdit;
pageCpp->setPlainText(codeCpp);
pageCpp->setReadOnly(true);
pageCpp->setFont(QFont("Courier"));
pageCpp->setLineWrapMode(QTextEdit::NoWrap);
enregistrer = new QPushButton("enregistrer");
fermer = new QPushButton("fermer");
setWindowTitle("ClassGenerator");
QTabWidget* onglets = new QTabWidget;
onglets->addTab(pageH, *nomPageH);
onglets->addTab(pageCpp, *nomPageCpp);
QHBoxLayout* buttonsLayout = new QHBoxLayout;
buttonsLayout->addWidget(enregistrer);
buttonsLayout->addWidget(fermer);
QGridLayout* grid = new QGridLayout(this);
grid->addWidget(onglets, 0, 0);
grid->addLayout(buttonsLayout, 1, 0);
setLayout(grid);
connect(fermer, SIGNAL(clicked()), this, SLOT(accept()));
connect(enregistrer, SIGNAL(clicked()), this, SLOT(slot_enregistrer()));
resize(400,450);
nomFichierH = new QString;
*nomFichierH = *nomPageH;
nomFichierCpp = new QString;
*nomFichierCpp = *nomPageCpp;
textH = new QString;
*textH = codeH;
textCpp = new QString;
*textCpp = codeCpp;
}
void fenSecondaire::slot_enregistrer()
{
QString fileH = QFileDialog::getSaveFileName(this, *nomFichierH, *nomFichierH, "header (*.h)");
QFile fileh (fileH);
if ( fileh.open(QIODevice::WriteOnly) )
{
QTextStream stream( &fileh );
stream << *textH << endl;
}
QString fileCPP = QFileDialog::getSaveFileName(this, *nomFichierCpp, *nomFichierCpp, "cpp (*.cpp)");
QFile fileCpp (fileCPP);
if ( fileCpp.open(QIODevice::WriteOnly) )
{
QTextStream stream( &fileCpp );
stream << *textCpp << endl;
}
}