Debian Codegraph @

addon/doxywizard/wizard.cpp

raw
1 /******************************************************************************
2 *
3 * Copyright (C) 1997-2025 by Dimitri van Heesch.
4 *
5 * Permission to use, copy, modify, and distribute this software and its
6 * documentation under the terms of the GNU General Public License is hereby
7 * granted. No representations are made about the suitability of this software
8 * for any purpose. It is provided "as is" without express or implied warranty.
9 * See the GNU General Public License for more details.
10 *
11 */
12
13 #include "wizard.h"
14 #include "input.h"
15 #include "doxywizard.h"
16
17 #include <math.h>
18
19 #include <QGridLayout>
20 #include <QImage>
21 #include <QLabel>
22 #include <QHBoxLayout>
23 #include <QPushButton>
24 #include <QPixmap>
25 #include <QPainter>
26 #include <QMouseEvent>
27 #include <QLineEdit>
28 #include <QCheckBox>
29 #include <QFileInfo>
30 #include <QFileDialog>
31 #include <QButtonGroup>
32 #include <QGroupBox>
33 #include <QRadioButton>
34 #include <QTreeWidget>
35 #include <QStackedWidget>
36 #include <qdrawutil.h>
37
38
39 // options configurable via the wizard
40 #define STR_PROJECT_NAME QString::fromLatin1("PROJECT_NAME")
41 #define STR_PROJECT_LOGO QString::fromLatin1("PROJECT_LOGO")
42 #define STR_PROJECT_BRIEF QString::fromLatin1("PROJECT_BRIEF")
43 #define STR_INPUT QString::fromLatin1("INPUT")
44 #define STR_OUTPUT_DIRECTORY QString::fromLatin1("OUTPUT_DIRECTORY")
45 #define STR_PROJECT_NUMBER QString::fromLatin1("PROJECT_NUMBER")
46 #define STR_RECURSIVE QString::fromLatin1("RECURSIVE")
47 #define STR_OPTIMIZE_OUTPUT_FOR_C QString::fromLatin1("OPTIMIZE_OUTPUT_FOR_C")
48 #define STR_OPTIMIZE_OUTPUT_JAVA QString::fromLatin1("OPTIMIZE_OUTPUT_JAVA")
49 #define STR_OPTIMIZE_FOR_FORTRAN QString::fromLatin1("OPTIMIZE_FOR_FORTRAN")
50 #define STR_OPTIMIZE_OUTPUT_VHDL QString::fromLatin1("OPTIMIZE_OUTPUT_VHDL")
51 #define STR_OPTIMIZE_OUTPUT_SLICE QString::fromLatin1("OPTIMIZE_OUTPUT_SLICE")
52 #define STR_CPP_CLI_SUPPORT QString::fromLatin1("CPP_CLI_SUPPORT")
53 #define STR_HIDE_SCOPE_NAMES QString::fromLatin1("HIDE_SCOPE_NAMES")
54 #define STR_EXTRACT_ALL QString::fromLatin1("EXTRACT_ALL")
55 #define STR_SOURCE_BROWSER QString::fromLatin1("SOURCE_BROWSER")
56 #define STR_GENERATE_HTML QString::fromLatin1("GENERATE_HTML")
57 #define STR_GENERATE_LATEX QString::fromLatin1("GENERATE_LATEX")
58 #define STR_GENERATE_MAN QString::fromLatin1("GENERATE_MAN")
59 #define STR_GENERATE_RTF QString::fromLatin1("GENERATE_RTF")
60 #define STR_GENERATE_XML QString::fromLatin1("GENERATE_XML")
61 #define STR_GENERATE_DOCBOOK QString::fromLatin1("GENERATE_DOCBOOK")
62 #define STR_GENERATE_HTMLHELP QString::fromLatin1("GENERATE_HTMLHELP")
63 #define STR_GENERATE_TREEVIEW QString::fromLatin1("GENERATE_TREEVIEW")
64 #define STR_USE_PDFLATEX QString::fromLatin1("USE_PDFLATEX")
65 #define STR_PDF_HYPERLINKS QString::fromLatin1("PDF_HYPERLINKS")
66 #define STR_SEARCHENGINE QString::fromLatin1("SEARCHENGINE")
67 #define STR_HAVE_DOT QString::fromLatin1("HAVE_DOT")
68 #define STR_CLASS_GRAPH QString::fromLatin1("CLASS_GRAPH")
69 #define STR_COLLABORATION_GRAPH QString::fromLatin1("COLLABORATION_GRAPH")
70 #define STR_GRAPHICAL_HIERARCHY QString::fromLatin1("GRAPHICAL_HIERARCHY")
71 #define STR_INCLUDE_GRAPH QString::fromLatin1("INCLUDE_GRAPH")
72 #define STR_INCLUDED_BY_GRAPH QString::fromLatin1("INCLUDED_BY_GRAPH")
73 #define STR_CALL_GRAPH QString::fromLatin1("CALL_GRAPH")
74 #define STR_CALLER_GRAPH QString::fromLatin1("CALLER_GRAPH")
75 #define STR_HTML_COLORSTYLE_HUE QString::fromLatin1("HTML_COLORSTYLE_HUE")
76 #define STR_HTML_COLORSTYLE_SAT QString::fromLatin1("HTML_COLORSTYLE_SAT")
77 #define STR_HTML_COLORSTYLE_GAMMA QString::fromLatin1("HTML_COLORSTYLE_GAMMA")
78
79 static bool g_optimizeMapping[7][7] =
80 {
81 // A: OPTIMIZE_OUTPUT_FOR_C
82 // B: OPTIMIZE_OUTPUT_JAVA
83 // C: OPTIMIZE_FOR_FORTRAN
84 // D: OPTIMIZE_OUTPUT_VHDL
85 // E: CPP_CLI_SUPPORT
86 // F: HIDE_SCOPE_NAMES
87 // G: OPTIMIZE_OUTPUT_SLICE
88 // A B C D E F G
89 { false,false,false,false,false,false,false }, // 0: C++
90 { false,false,false,false,true, false,false }, // 1: C++/CLI
91 { false,true, false,false,false,false,false }, // 2: C#/Java
92 { true, false,false,false,false,true, false }, // 3: C/PHP
93 { false,false,true, false,false,false,false }, // 4: Fortran
94 { false,false,false,true, false,false,false }, // 5: VHDL
95 { false,false,false,false,false,false,true }, // 6: SLICE
96 };
97
98 static QString g_optimizeOptionNames[7] =
99 {
100 STR_OPTIMIZE_OUTPUT_FOR_C,
101 STR_OPTIMIZE_OUTPUT_JAVA,
102 STR_OPTIMIZE_FOR_FORTRAN,
103 STR_OPTIMIZE_OUTPUT_VHDL,
104 STR_CPP_CLI_SUPPORT,
105 STR_HIDE_SCOPE_NAMES,
106 STR_OPTIMIZE_OUTPUT_SLICE
107 };
108
109 //==========================================================================
110
111 static bool stringVariantToBool(const QVariant &v)
112 {
113 QString s = v.toString().toLower();
114 return s==QString::fromLatin1("yes") || s==QString::fromLatin1("true") || s==QString::fromLatin1("1");
115 }
116
117 static bool getBoolOption(
118 const QHash<QString,Input*>&model,const QString &name)
119 {
120 Input *option = model[name];
121 Q_ASSERT(option!=nullptr);
122 return stringVariantToBool(option->value());
123 }
124
125 static int getIntOption(
126 const QHash<QString,Input*>&model,const QString &name)
127 {
128 Input *option = model[name];
129 Q_ASSERT(option!=nullptr);
130 return option->value().toInt();
131 }
132
133 static QString getStringOption(
134 const QHash<QString,Input*>&model,const QString &name)
135 {
136 Input *option = model[name];
137 Q_ASSERT(option!=nullptr);
138 return option->value().toString();
139 }
140
141 static void updateBoolOption(
142 const QHash<QString,Input*>&model,const QString &name,bool bNew)
143 {
144 Input *option = model[name];
145 Q_ASSERT(option!=nullptr);
146 bool bOld = stringVariantToBool(option->value());
147 if (bOld!=bNew)
148 {
149 option->value()=QString::fromLatin1(bNew ? "true" : "false");
150 option->update();
151 }
152 }
153
154 static void updateIntOption(
155 const QHash<QString,Input*>&model,const QString &name,int iNew)
156 {
157 Input *option = model[name];
158 Q_ASSERT(option!=nullptr);
159 int iOld = option->value().toInt();
160 if (iOld!=iNew)
161 {
162 option->value()=QString::fromLatin1("%1").arg(iNew);
163 option->update();
164 }
165 }
166
167
168 static void updateStringOption(
169 const QHash<QString,Input*>&model,const QString &name,const QString &s)
170 {
171 Input *option = model[name];
172 Q_ASSERT(option!=nullptr);
173 if (option->value().toString()!=s)
174 {
175 option->value() = s;
176 option->update();
177 }
178 }
179
180 //==========================================================================
181
182 TuneColorDialog::TuneColorDialog(int hue,int sat,int gamma,QWidget *parent) : QDialog(parent)
183 {
184 setWindowTitle(tr("Tune the color of the HTML output"));
185 QGridLayout *layout = new QGridLayout(this);
186 m_imageLight = QImage(QString::fromLatin1(":/images/tunecolor_light.png"));
187 m_imageDark = QImage(QString::fromLatin1(":/images/tunecolor_dark.png"));
188 m_tab = new QTabWidget;
189 m_imageLabLight = new QLabel;
190 m_imageLabDark = new QLabel;
191 m_tab->addTab(m_imageLabLight,QString::fromLatin1("light"));
192 m_tab->addTab(m_imageLabDark,QString::fromLatin1("dark"));
193 updateImage(hue,sat,gamma);
194 layout->addWidget(new QLabel(tr("Example output: use the sliders on the right to adjust the color")),0,0);
195 layout->addWidget(m_tab,1,0);
196 QHBoxLayout *buttonsLayout = new QHBoxLayout;
197
198 QPushButton *okButton = new QPushButton(tr("Ok"));
199 connect(okButton,SIGNAL(clicked()),SLOT(accept()));
200 okButton->setDefault(true);
201 QPushButton *cancelButton = new QPushButton(tr("Cancel"));
202 connect(cancelButton,SIGNAL(clicked()),SLOT(reject()));
203
204 ColorPicker *huePicker = new ColorPicker(ColorPicker::Hue);
205 huePicker->setCol(hue,sat,gamma);
206 huePicker->setFixedWidth(20);
207 layout->addWidget(huePicker,1,1);
208 ColorPicker *satPicker = new ColorPicker(ColorPicker::Saturation);
209 satPicker->setCol(hue,sat,gamma);
210 satPicker->setFixedWidth(20);
211 layout->addWidget(satPicker,1,2);
212 ColorPicker *gamPicker = new ColorPicker(ColorPicker::Gamma);
213 gamPicker->setCol(hue,sat,gamma);
214 gamPicker->setFixedWidth(20);
215 layout->addWidget(gamPicker,1,3);
216
217 connect(huePicker,SIGNAL(newHsv(int,int,int)),satPicker,SLOT(setCol(int,int,int)));
218 connect(satPicker,SIGNAL(newHsv(int,int,int)),huePicker,SLOT(setCol(int,int,int)));
219 connect(huePicker,SIGNAL(newHsv(int,int,int)),gamPicker,SLOT(setCol(int,int,int)));
220 connect(satPicker,SIGNAL(newHsv(int,int,int)),gamPicker,SLOT(setCol(int,int,int)));
221 connect(gamPicker,SIGNAL(newHsv(int,int,int)),satPicker,SLOT(setCol(int,int,int)));
222 connect(gamPicker,SIGNAL(newHsv(int,int,int)),huePicker,SLOT(setCol(int,int,int)));
223 connect(huePicker,SIGNAL(newHsv(int,int,int)),this,SLOT(updateImage(int,int,int)));
224 connect(satPicker,SIGNAL(newHsv(int,int,int)),this,SLOT(updateImage(int,int,int)));
225 connect(gamPicker,SIGNAL(newHsv(int,int,int)),this,SLOT(updateImage(int,int,int)));
226 connect(m_tab, SIGNAL(currentChanged(int)),this,SLOT(tabChanged(int)));
227
228 buttonsLayout->addStretch();
229 buttonsLayout->addWidget(okButton);
230 buttonsLayout->addWidget(cancelButton);
231 layout->addLayout(buttonsLayout,5,0,1,4);
232 }
233
234 // convert color in HSL color space to RGB
235 static constexpr void hsl2rgb(double h,double s,double l,
236 double *pRed,double *pGreen,double *pBlue)
237 {
238 double r = l; // default to gray
239 double g = l;
240 double b = l;
241 double v = (l <= 0.5) ? (l * (1.0 + s)) : (l + s - l * s);
242 if (v > 0)
243 {
244 double m = l + l - v;
245 double sv = (v - m ) / v;
246 h *= 6.0;
247 int sextant = (int)h;
248 double fract = h - sextant;
249 double vsf = v * sv * fract;
250 double mid1 = m + vsf;
251 double mid2 = v - vsf;
252 switch (sextant)
253 {
254 case 0:
255 r = v;
256 g = mid1;
257 b = m;
258 break;
259 case 1:
260 r = mid2;
261 g = v;
262 b = m;
263 break;
264 case 2:
265 r = m;
266 g = v;
267 b = mid1;
268 break;
269 case 3:
270 r = m;
271 g = mid2;
272 b = v;
273 break;
274 case 4:
275 r = mid1;
276 g = m;
277 b = v;
278 break;
279 case 5:
280 r = v;
281 g = m;
282 b = mid2;
283 break;
284 }
285 }
286 *pRed = r;
287 *pGreen = g;
288 *pBlue = b;
289 }
290
291
292 void TuneColorDialog::tabChanged(int current)
293 {
294 // refresh image with the current settings when switching tabs
295 updateImage(m_hue,m_sat,m_gam);
296 }
297
298 void TuneColorDialog::updateImage(int hue,int sat,int gam)
299 {
300 QImage *image = m_tab->currentIndex()==0 ? &m_imageLight : &m_imageDark;
301 QLabel *label = m_tab->currentIndex()==0 ? m_imageLabLight : m_imageLabDark;
302 QImage coloredImg(image->width(),image->height(),QImage::Format_RGB32);
303 uint *srcPixel = (uint *)image->scanLine(0);
304 uint *dstPixel = (uint *)coloredImg.scanLine(0);
305 uint nrPixels = coloredImg.width()*coloredImg.height();
306 double r,g,b;
307 for (uint i=0;i<nrPixels;i++,srcPixel++,dstPixel++)
308 {
309 QColor c = QColor::fromRgb(*srcPixel);
310 hsl2rgb(hue/359.0, sat/255.0, pow(c.green()/255.0,gam/100.0),&r,&g,&b);
311 *dstPixel = qRgb((int)(r*255.0),(int)(g*255.0),(int)(b*255.0));
312 }
313
314 QPixmap pm = QPixmap::fromImage(coloredImg);
315 pm.setDevicePixelRatio(2.0);
316 label->setPixmap(pm);
317 m_hue = hue;
318 m_sat = sat;
319 m_gam = gam;
320 }
321
322 int TuneColorDialog::getHue() const
323 {
324 return m_hue;
325 }
326
327 int TuneColorDialog::getSaturation() const
328 {
329 return m_sat;
330 }
331
332 int TuneColorDialog::getGamma() const
333 {
334 return m_gam;
335 }
336
337 //==========================================================================
338
339 ColorPicker::ColorPicker(Mode m)
340 {
341 m_hue = 220;
342 m_gam = 100;
343 m_sat = 100;
344 m_mode = m;
345 m_pix = nullptr;
346 }
347
348 ColorPicker::~ColorPicker()
349 {
350 delete m_pix;
351 }
352
353 void ColorPicker::paintEvent(QPaintEvent*)
354 {
355 int w = width() - 5;
356
357 QRect r(0, foff, w, height() - 2*foff);
358 int wi = r.width() - 2;
359 int hi = r.height() - 2;
360 if (!m_pix || m_pix->height() != hi || m_pix->width() != wi)
361 {
362 delete m_pix;
363 QImage img(wi, hi, QImage::Format_RGB32);
364 int y;
365 uint *pixel = (uint *) img.scanLine(0);
366 for (y = 0; y < hi; y++)
367 {
368 const uint *end = pixel + wi;
369 int yh = y2hue(y+coff);
370 int ys = y2sat(y+coff);
371 int yg = y2gam(y+coff);
372 while (pixel < end)
373 {
374 QColor c;
375 c.setHsv(yh, ys, (int)(255*pow(0.7,yg/100.0)));
376 *pixel = c.rgb();
377 ++pixel;
378 }
379 }
380 m_pix = new QPixmap(QPixmap::fromImage(img));
381 }
382 QPainter p(this);
383 p.drawPixmap(1, coff, *m_pix);
384 const QPalette &g = palette();
385 qDrawShadePanel(&p, r, g, true);
386 p.setPen(g.windowText().color());
387 p.setBrush(g.windowText());
388 QPolygon a;
389 int y = m_mode==Hue ? hue2y(m_hue) :
390 m_mode==Saturation ? sat2y(m_sat) :
391 gam2y(m_gam);
392 a.setPoints(3, w, y, w+5, y+5, w+5, y-5);
393 p.eraseRect(w, 0, 5, height());
394 p.drawPolygon(a);
395 }
396
397 void ColorPicker::mouseMoveEvent(QMouseEvent *m)
398 {
399 if (m_mode==Hue) setHue(y2hue(getMouseYPositionFromEvent(m)));
400 else if (m_mode==Saturation) setSat(y2sat(getMouseYPositionFromEvent(m)));
401 else setGam(y2gam(getMouseYPositionFromEvent(m)));
402 }
403
404 void ColorPicker::mousePressEvent(QMouseEvent *m)
405 {
406 if (m_mode==Hue) setHue(y2hue(getMouseYPositionFromEvent(m)));
407 else if (m_mode==Saturation) setSat(y2sat(getMouseYPositionFromEvent(m)));
408 else setGam(y2gam(getMouseYPositionFromEvent(m)));
409 }
410
411 void ColorPicker::setHue(int h)
412 {
413 if (h==m_hue) return;
414 m_hue = qMax(0,qMin(h,359));
415 delete m_pix; m_pix=nullptr;
416 repaint();
417 emit newHsv(m_hue,m_sat,m_gam);
418 }
419
420 void ColorPicker::setSat(int s)
421 {
422 if (s==m_sat) return;
423 m_sat = qMax(0,qMin(s,255));
424 delete m_pix; m_pix=nullptr;
425 repaint();
426 emit newHsv(m_hue,m_sat,m_gam);
427 }
428
429 void ColorPicker::setGam(int g)
430 {
431 if (g==m_gam) return;
432 m_gam = qMax(40,qMin(g,240));
433 delete m_pix; m_pix=nullptr;
434 repaint();
435 emit newHsv(m_hue,m_sat,m_gam);
436 }
437
438 void ColorPicker::setCol(int h, int s, int g)
439 {
440 if (m_hue!=h || m_sat!=s || m_gam!=g)
441 {
442 m_hue = h;
443 m_sat = s;
444 m_gam = g;
445 delete m_pix; m_pix=nullptr;
446 repaint();
447 }
448 }
449
450 int ColorPicker::y2hue(int y)
451 {
452 int d = height() - 2*coff - 1;
453 return m_mode==Hue ? (y - coff)*359/d : m_hue;
454 }
455
456 int ColorPicker::hue2y(int v)
457 {
458 int d = height() - 2*coff - 1;
459 return coff + v*d/359;
460 }
461
462 int ColorPicker::y2sat(int y)
463 {
464 int d = height() - 2*coff - 1;
465 return m_mode==Saturation ? 255 - (y - coff)*255/d : m_sat;
466 }
467
468 int ColorPicker::sat2y(int v)
469 {
470 int d = height() - 2*coff - 1;
471 return coff + (255-v)*d/255;
472 }
473
474 int ColorPicker::y2gam(int y)
475 {
476 int d = height() - 2*coff - 1;
477 return m_mode==Gamma ? 240 - (y - coff)*200/d : m_gam;
478 }
479
480 int ColorPicker::gam2y(int g)
481 {
482 int d = height() - 2*coff - 1;
483 return coff + (240-g)*d/200;
484 }
485
486 //==========================================================================
487
488 Step1::Step1(Wizard *wizard,const QHash<QString,Input*> &modelData) : m_wizard(wizard), m_modelData(modelData)
489 {
490 QVBoxLayout *layout = new QVBoxLayout(this);
491 layout->setContentsMargins(4,4,4,4);
492 layout->setSpacing(8);
493 QLabel *l = new QLabel(this);
494 l->setText(tr("Provide some information "
495 "about the project you are documenting"));
496 layout->addWidget(l);
497 QWidget *w = new QWidget( this );
498 QGridLayout *grid = new QGridLayout(w);
499 grid->setSpacing(10);
500
501 // project name
502 QLabel *projName = new QLabel(this);
503 projName->setText(tr("Project name:"));
504 projName->setAlignment(Qt::AlignRight|Qt::AlignVCenter);
505 // project brief
506 QLabel *projBrief = new QLabel(this);
507 projBrief->setText(tr("Project synopsis:"));
508 projBrief->setAlignment(Qt::AlignRight|Qt::AlignVCenter);
509 // project version
510 QLabel *projVersion = new QLabel(this);
511 projVersion->setText(tr("Project version or id:"));
512 projVersion->setAlignment(Qt::AlignRight|Qt::AlignVCenter);
513 // project icon
514 QLabel *projLogo = new QLabel(this);
515 projLogo->setMinimumSize(1,55);
516 projLogo->setText(tr("Project logo:"));
517 projLogo->setAlignment(Qt::AlignRight|Qt::AlignVCenter);
518
519 grid->addWidget(projName,0,0);
520 grid->addWidget(projBrief,1,0);
521 grid->addWidget(projVersion,2,0);
522 grid->addWidget(projLogo,3,0);
523
524 m_projName = new QLineEdit;
525 m_projBrief = new QLineEdit;
526 m_projNumber = new QLineEdit;
527 QPushButton *projIconSel = new QPushButton(this);
528 projIconSel->setText(tr("Select..."));
529 m_projIconLab = new QLabel;
530
531 grid->addWidget(m_projName,0,1,1,2);
532 grid->addWidget(m_projBrief,1,1,1,2);
533 grid->addWidget(m_projNumber,2,1,1,2);
534 grid->addWidget(projIconSel,3,1);
535 grid->addWidget(m_projIconLab,3,2);
536
537 grid->setColumnStretch(2,1);
538
539 w->setLayout(grid);
540
541 layout->addWidget(w);
542
543 //---------------------------------------------------
544 QFrame *f = new QFrame( this );
545 f->setFrameShape(QFrame::HLine);
546 f->setFrameShadow(QFrame::Sunken);
547 layout->addWidget(f);
548
549 l = new QLabel(this);
550 l->setText(tr("Specify the directory to scan for source code"));
551 layout->addWidget(l);
552 QWidget *row = new QWidget;
553 QHBoxLayout *rowLayout = new QHBoxLayout(row);
554 rowLayout->setSpacing(10);
555 l = new QLabel(this);
556 l->setText(tr("Source code directory:"));
557 rowLayout->addWidget(l);
558 m_sourceDir = new QLineEdit;
559 m_srcSelectDir = new QPushButton(this);
560 m_srcSelectDir->setText(tr("Select..."));
561 rowLayout->addWidget(m_sourceDir);
562 rowLayout->addWidget(m_srcSelectDir);
563 layout->addWidget(row);
564
565 m_recursive = new QCheckBox(this);
566 m_recursive->setText(tr("Scan recursively"));
567 m_recursive->setChecked(true);
568 layout->addWidget(m_recursive);
569
570 //---------------------------------------------------
571 f = new QFrame( this );
572 f->setFrameShape(QFrame::HLine);
573 f->setFrameShadow(QFrame::Sunken);
574 layout->addWidget(f);
575
576 l = new QLabel(this);
577 l->setText(tr("Specify the directory where doxygen should "
578 "put the generated documentation"));
579 layout->addWidget(l);
580 row = new QWidget;
581 rowLayout = new QHBoxLayout(row);
582 rowLayout->setSpacing(10);
583 l = new QLabel(this);
584 l->setText(tr("Destination directory:"));
585 rowLayout->addWidget(l);
586 m_destDir = new QLineEdit;
587 m_dstSelectDir = new QPushButton(this);
588 m_dstSelectDir->setText(tr("Select..."));
589 rowLayout->addWidget(m_destDir);
590 rowLayout->addWidget(m_dstSelectDir);
591 layout->addWidget(row);
592 layout->addStretch(1);
593 setLayout(layout);
594
595 connect(projIconSel,SIGNAL(clicked()),
596 this,SLOT(selectProjectIcon()));
597 connect(m_srcSelectDir,SIGNAL(clicked()),
598 this,SLOT(selectSourceDir()));
599 connect(m_dstSelectDir,SIGNAL(clicked()),
600 this,SLOT(selectDestinationDir()));
601 connect(m_projName,SIGNAL(textChanged(const QString &)),SLOT(setProjectName(const QString &)));
602 connect(m_projBrief,SIGNAL(textChanged(const QString &)),SLOT(setProjectBrief(const QString &)));
603 connect(m_projNumber,SIGNAL(textChanged(const QString &)),SLOT(setProjectNumber(const QString &)));
604 connect(m_sourceDir,SIGNAL(textChanged(const QString &)),SLOT(setSourceDir(const QString &)));
605 connect(m_recursive,SIGNAL(stateChanged(int)),SLOT(setRecursiveScan(int)));
606 connect(m_destDir,SIGNAL(textChanged(const QString &)),SLOT(setDestinationDir(const QString &)));
607 }
608
609 void Step1::selectProjectIcon()
610 {
611 QString path = QFileInfo(MainWindow::instance().configFileName()).path();
612 QString iconName = QFileDialog::getOpenFileName(this,
613 tr("Select project icon/image"),path);
614 if (iconName.isEmpty())
615 {
616 m_projIconLab->setText(tr("No Project logo selected."));
617 }
618 else
619 {
620 QFile Fout(iconName);
621 if(!Fout.exists())
622 {
623 m_projIconLab->setText(tr("Sorry, cannot find file(")+iconName+QString::fromLatin1(");"));
624 }
625 else
626 {
627 QPixmap pm(iconName);
628 if (!pm.isNull())
629 {
630 m_projIconLab->setPixmap(pm.scaledToHeight(55,Qt::SmoothTransformation));
631 }
632 else
633 {
634 m_projIconLab->setText(tr("Sorry, no preview available (")+iconName+QString::fromLatin1(");"));
635 }
636 }
637 }
638 updateStringOption(m_modelData,STR_PROJECT_LOGO,iconName);
639 }
640
641 void Step1::selectSourceDir()
642 {
643 QString path = QFileInfo(MainWindow::instance().configFileName()).path();
644 QString dirName = QFileDialog::getExistingDirectory(this,
645 tr("Select source directory"),path);
646 QDir dir(path);
647 if (!MainWindow::instance().configFileName().isEmpty() && dir.exists())
648 {
649 dirName = dir.relativeFilePath(dirName);
650 }
651 if (dirName.isEmpty())
652 {
653 dirName=QString::fromLatin1(".");
654 }
655 m_sourceDir->setText(dirName);
656 }
657
658 void Step1::selectDestinationDir()
659 {
660 QString path = QFileInfo(MainWindow::instance().configFileName()).path();
661 QString dirName = QFileDialog::getExistingDirectory(this,
662 tr("Select destination directory"),path);
663 QDir dir(path);
664 if (!MainWindow::instance().configFileName().isEmpty() && dir.exists())
665 {
666 dirName = dir.relativeFilePath(dirName);
667 }
668 if (dirName.isEmpty())
669 {
670 dirName=QString::fromLatin1(".");
671 }
672 m_destDir->setText(dirName);
673 }
674
675 void Step1::setProjectName(const QString &name)
676 {
677 updateStringOption(m_modelData,STR_PROJECT_NAME,name);
678 }
679
680 void Step1::setProjectBrief(const QString &desc)
681 {
682 updateStringOption(m_modelData,STR_PROJECT_BRIEF,desc);
683 }
684
685 void Step1::setProjectNumber(const QString &num)
686 {
687 updateStringOption(m_modelData,STR_PROJECT_NUMBER,num);
688 }
689
690 void Step1::setSourceDir(const QString &dir)
691 {
692 Input *option = m_modelData[STR_INPUT];
693 if (option->value().toStringList().count()>0)
694 {
695 QStringList sl = option->value().toStringList();
696 if (sl[0]!=dir)
697 {
698 sl[0] = dir;
699 option->value() = sl;
700 option->update();
701 }
702 }
703 else
704 {
705 option->value() = QStringList() << dir;
706 option->update();
707 }
708 }
709
710 void Step1::setDestinationDir(const QString &dir)
711 {
712 updateStringOption(m_modelData,STR_OUTPUT_DIRECTORY,dir);
713 }
714
715 void Step1::setRecursiveScan(int s)
716 {
717 updateBoolOption(m_modelData,STR_RECURSIVE,s==Qt::Checked);
718 }
719
720 void Step1::init()
721 {
722 Input *option;
723 m_projName->setText(getStringOption(m_modelData,STR_PROJECT_NAME));
724 m_projBrief->setText(getStringOption(m_modelData,STR_PROJECT_BRIEF));
725 m_projNumber->setText(getStringOption(m_modelData,STR_PROJECT_NUMBER));
726 QString iconName = getStringOption(m_modelData,STR_PROJECT_LOGO);
727 if (!iconName.isEmpty())
728 {
729 QFile Fout(iconName);
730 if(!Fout.exists())
731 {
732 m_projIconLab->setText(tr("Sorry, cannot find file(")+iconName+QString::fromLatin1(");"));
733 }
734 else
735 {
736 QPixmap pm(iconName);
737 if (!pm.isNull())
738 {
739 m_projIconLab->setPixmap(pm.scaledToHeight(55,Qt::SmoothTransformation));
740 }
741 else
742 {
743 m_projIconLab->setText(tr("Sorry, no preview available (")+iconName+QString::fromLatin1(");"));
744 }
745 }
746 }
747 else
748 {
749 m_projIconLab->setText(tr("No Project logo selected."));
750 }
751 option = m_modelData[STR_INPUT];
752 if (option->value().toStringList().count()>0)
753 {
754 m_sourceDir->setText(option->value().toStringList().first());
755 }
756 m_recursive->setChecked(
757 getBoolOption(m_modelData,STR_RECURSIVE) ? Qt::Checked : Qt::Unchecked);
758 m_destDir->setText(getStringOption(m_modelData,STR_OUTPUT_DIRECTORY));
759 }
760
761
762 //==========================================================================
763
764 Step2::Step2(Wizard *wizard,const QHash<QString,Input*> &modelData)
765 : m_wizard(wizard), m_modelData(modelData)
766 {
767 QRadioButton *r;
768 QVBoxLayout *layout = new QVBoxLayout(this);
769
770 //---------------------------------------------------
771 m_extractModeGroup = new QButtonGroup(this);
772 m_extractMode = new QGroupBox(this);
773 m_extractMode->setTitle(tr("Select the desired extraction mode:"));
774 QGridLayout *gbox = new QGridLayout( m_extractMode );
775 r = new QRadioButton(tr("Documented entities only"));
776 r->setChecked(true);
777 m_extractModeGroup->addButton(r, 0);
778 gbox->addWidget(r,1,0);
779 // 1 -> EXTRACT_ALL = NO
780 r = new QRadioButton(tr("All Entities"));
781 m_extractModeGroup->addButton(r, 1);
782 gbox->addWidget(r,2,0);
783 // 2 -> EXTRACT_ALL = YES
784 m_crossRef = new QCheckBox(m_extractMode);
785 m_crossRef->setText(tr("Include cross-referenced source code in the output"));
786 // m_crossRef -> SOURCE_BROWSER = YES/NO
787 gbox->addWidget(m_crossRef,3,0);
788 layout->addWidget(m_extractMode);
789
790 //---------------------------------------------------
791 QFrame *f = new QFrame( this );
792 f->setFrameShape(QFrame::HLine);
793 f->setFrameShadow(QFrame::Sunken);
794 layout->addWidget(f);
795
796 m_optimizeLangGroup = new QButtonGroup(this);
797 m_optimizeLang = new QGroupBox(this);
798 m_optimizeLang->setTitle(tr("Select programming language to optimize the results for"));
799 gbox = new QGridLayout( m_optimizeLang );
800
801 r = new QRadioButton(m_optimizeLang);
802 r->setText(tr("Optimize for C++ output"));
803 r->setChecked(true);
804 m_optimizeLangGroup->addButton(r, 0);
805 // 0 -> OPTIMIZE_OUTPUT_FOR_C = NO
806 // OPTIMIZE_OUTPUT_JAVA = NO
807 // OPTIMIZE_FOR_FORTRAN = NO
808 // OPTIMIZE_OUTPUT_VHDL = NO
809 // CPP_CLI_SUPPORT = NO
810 // HIDE_SCOPE_NAMES = NO
811 // OPTIMIZE_OUTPUT_SLICE = NO
812 gbox->addWidget(r,0,0);
813 r = new QRadioButton(tr("Optimize for C++/CLI output"));
814 gbox->addWidget(r,1,0);
815 m_optimizeLangGroup->addButton(r, 1);
816 // 1 -> OPTIMIZE_OUTPUT_FOR_C = NO
817 // OPTIMIZE_OUTPUT_JAVA = NO
818 // OPTIMIZE_FOR_FORTRAN = NO
819 // OPTIMIZE_OUTPUT_VHDL = NO
820 // CPP_CLI_SUPPORT = YES
821 // HIDE_SCOPE_NAMES = NO
822 // OPTIMIZE_OUTPUT_SLICE = NO
823 r = new QRadioButton(tr("Optimize for Java or C# output"));
824 m_optimizeLangGroup->addButton(r, 2);
825 // 2 -> OPTIMIZE_OUTPUT_FOR_C = NO
826 // OPTIMIZE_OUTPUT_JAVA = YES
827 // OPTIMIZE_FOR_FORTRAN = NO
828 // OPTIMIZE_OUTPUT_VHDL = NO
829 // CPP_CLI_SUPPORT = NO
830 // HIDE_SCOPE_NAMES = NO
831 // OPTIMIZE_OUTPUT_SLICE = NO
832 gbox->addWidget(r,2,0);
833 r = new QRadioButton(tr("Optimize for C or PHP output"));
834 m_optimizeLangGroup->addButton(r, 3);
835 // 3 -> OPTIMIZE_OUTPUT_FOR_C = YES
836 // OPTIMIZE_OUTPUT_JAVA = NO
837 // OPTIMIZE_FOR_FORTRAN = NO
838 // OPTIMIZE_OUTPUT_VHDL = NO
839 // CPP_CLI_SUPPORT = NO
840 // HIDE_SCOPE_NAMES = YES
841 // OPTIMIZE_OUTPUT_SLICE = NO
842 gbox->addWidget(r,3,0);
843 r = new QRadioButton(tr("Optimize for Fortran output"));
844 m_optimizeLangGroup->addButton(r, 4);
845 // 4 -> OPTIMIZE_OUTPUT_FOR_C = NO
846 // OPTIMIZE_OUTPUT_JAVA = NO
847 // OPTIMIZE_FOR_FORTRAN = YES
848 // OPTIMIZE_OUTPUT_VHDL = NO
849 // CPP_CLI_SUPPORT = NO
850 // HIDE_SCOPE_NAMES = NO
851 // OPTIMIZE_OUTPUT_SLICE = NO
852 gbox->addWidget(r,4,0);
853 r = new QRadioButton(tr("Optimize for VHDL output"));
854 m_optimizeLangGroup->addButton(r, 5);
855 // 5 -> OPTIMIZE_OUTPUT_FOR_C = NO
856 // OPTIMIZE_OUTPUT_JAVA = NO
857 // OPTIMIZE_FOR_FORTRAN = NO
858 // OPTIMIZE_OUTPUT_VHDL = YES
859 // CPP_CLI_SUPPORT = NO
860 // HIDE_SCOPE_NAMES = NO
861 // OPTIMIZE_OUTPUT_SLICE = NO
862 gbox->addWidget(r,5,0);
863 r = new QRadioButton(tr("Optimize for SLICE output"));
864 m_optimizeLangGroup->addButton(r, 6);
865 // 5 -> OPTIMIZE_OUTPUT_FOR_C = NO
866 // OPTIMIZE_OUTPUT_JAVA = NO
867 // OPTIMIZE_FOR_FORTRAN = NO
868 // OPTIMIZE_OUTPUT_VHDL = NO
869 // CPP_CLI_SUPPORT = NO
870 // HIDE_SCOPE_NAMES = NO
871 // OPTIMIZE_OUTPUT_SLICE = YES
872 gbox->addWidget(r,6,0);
873
874 layout->addWidget(m_optimizeLang);
875 layout->addStretch(1);
876
877 connect(m_crossRef,SIGNAL(stateChanged(int)),
878 SLOT(changeCrossRefState(int)));
879 #if QT_VERSION < QT_VERSION_CHECK(5, 15, 0)
880 connect(m_optimizeLangGroup,SIGNAL(buttonClicked(int)),
881 SLOT(optimizeFor(int)));
882 connect(m_extractModeGroup,SIGNAL(buttonClicked(int)),
883 SLOT(extractMode(int)));
884 #else
885 connect(m_optimizeLangGroup,SIGNAL(idClicked(int)),
886 SLOT(optimizeFor(int)));
887 connect(m_extractModeGroup,SIGNAL(idClicked(int)),
888 SLOT(extractMode(int)));
889 #endif
890 }
891
892
893 void Step2::optimizeFor(int choice)
894 {
895 for (int i=0;i<7;i++)
896 {
897 updateBoolOption(m_modelData,
898 g_optimizeOptionNames[i],
899 g_optimizeMapping[choice][i]);
900 }
901 }
902
903 void Step2::extractMode(int choice)
904 {
905 updateBoolOption(m_modelData,STR_EXTRACT_ALL,choice==1);
906 }
907
908 void Step2::changeCrossRefState(int choice)
909 {
910 updateBoolOption(m_modelData,STR_SOURCE_BROWSER,choice==Qt::Checked);
911 }
912
913 void Step2::init()
914 {
915 m_extractModeGroup->button(
916 getBoolOption(m_modelData,STR_EXTRACT_ALL) ? 1 : 0)->setChecked(true);
917 m_crossRef->setChecked(getBoolOption(m_modelData,STR_SOURCE_BROWSER));
918
919 int x=0;
920 if (getBoolOption(m_modelData,STR_CPP_CLI_SUPPORT)) x=1;
921 else if (getBoolOption(m_modelData,STR_OPTIMIZE_OUTPUT_JAVA)) x=2;
922 else if (getBoolOption(m_modelData,STR_OPTIMIZE_OUTPUT_FOR_C)) x=3;
923 else if (getBoolOption(m_modelData,STR_OPTIMIZE_FOR_FORTRAN)) x=4;
924 else if (getBoolOption(m_modelData,STR_OPTIMIZE_OUTPUT_VHDL)) x=5;
925 else if (getBoolOption(m_modelData,STR_OPTIMIZE_OUTPUT_SLICE)) x=6;
926 m_optimizeLangGroup->button(x)->setChecked(true);
927 }
928
929 //==========================================================================
930
931 Step3::Step3(Wizard *wizard,const QHash<QString,Input*> &modelData)
932 : m_wizard(wizard), m_modelData(modelData)
933 {
934 QVBoxLayout *vbox = nullptr;
935 QRadioButton *r = nullptr;
936
937 QGridLayout *gbox = new QGridLayout( this );
938 gbox->addWidget(new QLabel(tr("Select the output format(s) to generate")),0,0);
939 {
940 m_htmlOptions = new QGroupBox(tr("HTML"));
941 m_htmlOptions->setCheckable(true);
942 // GENERATE_HTML
943 m_htmlOptionsGroup = new QButtonGroup(m_htmlOptions);
944 QRadioButton *r = new QRadioButton(tr("plain HTML"));
945 r->setChecked(true);
946 m_htmlOptionsGroup->addButton(r, 0);
947 vbox = new QVBoxLayout;
948 vbox->addWidget(r);
949 r = new QRadioButton(tr("with navigation panel"));
950 m_htmlOptionsGroup->addButton(r, 1);
951 // GENERATE_TREEVIEW
952 vbox->addWidget(r);
953 r = new QRadioButton(tr("prepare for compressed HTML (.chm)"));
954 m_htmlOptionsGroup->addButton(r, 2);
955 // GENERATE_HTMLHELP
956 vbox->addWidget(r);
957 m_searchEnabled=new QCheckBox(tr("With search function"));
958 vbox->addWidget(m_searchEnabled);
959 // SEARCH_ENGINE
960 QHBoxLayout *hbox = new QHBoxLayout;
961 m_tuneColor=new QPushButton(tr("Change color..."));
962 hbox->addWidget(m_tuneColor);
963 hbox->addStretch(1);
964 vbox->addLayout(hbox);
965 m_htmlOptions->setLayout(vbox);
966 m_htmlOptions->setChecked(true);
967 }
968 gbox->addWidget(m_htmlOptions,1,0);
969
970 {
971 m_texOptions = new QGroupBox(tr("LaTeX"));
972 m_texOptions->setCheckable(true);
973 // GENERATE_LATEX
974 m_texOptionsGroup = new QButtonGroup(m_texOptions);
975 vbox = new QVBoxLayout;
976 r = new QRadioButton(tr("as intermediate format for hyperlinked PDF"));
977 m_texOptionsGroup->addButton(r, 0);
978 // PDF_HYPERLINKS = YES
979 r->setChecked(true);
980 vbox->addWidget(r);
981 r = new QRadioButton(tr("as intermediate format for PDF"));
982 m_texOptionsGroup->addButton(r, 1);
983 // PDF_HYPERLINKS = NO, USE_PDFLATEX = YES
984 vbox->addWidget(r);
985 r = new QRadioButton(tr("as intermediate format for PostScript"));
986 m_texOptionsGroup->addButton(r, 2);
987 // USE_PDFLATEX = NO
988 vbox->addWidget(r);
989 vbox->addStretch(1);
990 m_texOptions->setLayout(vbox);
991 m_texOptions->setChecked(true);
992 }
993 gbox->addWidget(m_texOptions,2,0);
994
995 m_manEnabled=new QCheckBox(tr("Man pages"));
996 // GENERATE_MAN
997 m_rtfEnabled=new QCheckBox(tr("Rich Text Format (RTF)"));
998 // GENERATE_RTF
999 m_xmlEnabled=new QCheckBox(tr("XML"));
1000 // GENERATE_XML
1001 m_docbookEnabled=new QCheckBox(tr("Docbook"));
1002 // GENERATE_DOCBOOK
1003 gbox->addWidget(m_manEnabled,3,0);
1004 gbox->addWidget(m_rtfEnabled,4,0);
1005 gbox->addWidget(m_xmlEnabled,5,0);
1006 gbox->addWidget(m_docbookEnabled,6,0);
1007
1008 gbox->setRowStretch(7,1);
1009 connect(m_htmlOptions,SIGNAL(toggled(bool)),SLOT(setHtmlEnabled(bool)));
1010 connect(m_texOptions,SIGNAL(toggled(bool)),SLOT(setLatexEnabled(bool)));
1011 connect(m_manEnabled,SIGNAL(stateChanged(int)),SLOT(setManEnabled(int)));
1012 connect(m_rtfEnabled,SIGNAL(stateChanged(int)),SLOT(setRtfEnabled(int)));
1013 connect(m_xmlEnabled,SIGNAL(stateChanged(int)),SLOT(setXmlEnabled(int)));
1014 connect(m_docbookEnabled,SIGNAL(stateChanged(int)),SLOT(setDocbookEnabled(int)));
1015 connect(m_searchEnabled,SIGNAL(stateChanged(int)),SLOT(setSearchEnabled(int)));
1016 #if QT_VERSION < QT_VERSION_CHECK(5, 15, 0)
1017 connect(m_htmlOptionsGroup,SIGNAL(buttonClicked(int)),SLOT(setHtmlOptions(int)));
1018 connect(m_texOptionsGroup,SIGNAL(buttonClicked(int)),SLOT(setLatexOptions(int)));
1019 #else
1020 connect(m_htmlOptionsGroup,SIGNAL(idClicked(int)),SLOT(setHtmlOptions(int)));
1021 connect(m_texOptionsGroup,SIGNAL(idClicked(int)),SLOT(setLatexOptions(int)));
1022 #endif
1023 connect(m_tuneColor,SIGNAL(clicked()),SLOT(tuneColorDialog()));
1024 }
1025
1026 void Step3::tuneColorDialog()
1027 {
1028 int hue = getIntOption(m_modelData,STR_HTML_COLORSTYLE_HUE);
1029 int sat = getIntOption(m_modelData,STR_HTML_COLORSTYLE_SAT);
1030 int gam = getIntOption(m_modelData,STR_HTML_COLORSTYLE_GAMMA);
1031 TuneColorDialog tuneColor(hue,sat,gam,this);
1032 if (tuneColor.exec()==QDialog::Accepted)
1033 {
1034 updateIntOption(m_modelData,STR_HTML_COLORSTYLE_HUE,tuneColor.getHue());
1035 updateIntOption(m_modelData,STR_HTML_COLORSTYLE_SAT,tuneColor.getSaturation());
1036 updateIntOption(m_modelData,STR_HTML_COLORSTYLE_GAMMA,tuneColor.getGamma());
1037 }
1038 }
1039
1040 void Step3::setHtmlEnabled(bool b)
1041 {
1042 updateBoolOption(m_modelData,STR_GENERATE_HTML,b);
1043 }
1044
1045 void Step3::setLatexEnabled(bool b)
1046 {
1047 updateBoolOption(m_modelData,STR_GENERATE_LATEX,b);
1048 }
1049
1050 void Step3::setManEnabled(int state)
1051 {
1052 updateBoolOption(m_modelData,STR_GENERATE_MAN,state==Qt::Checked);
1053 }
1054
1055 void Step3::setRtfEnabled(int state)
1056 {
1057 updateBoolOption(m_modelData,STR_GENERATE_RTF,state==Qt::Checked);
1058 }
1059
1060 void Step3::setXmlEnabled(int state)
1061 {
1062 updateBoolOption(m_modelData,STR_GENERATE_XML,state==Qt::Checked);
1063 }
1064
1065 void Step3::setDocbookEnabled(int state)
1066 {
1067 updateBoolOption(m_modelData,STR_GENERATE_DOCBOOK,state==Qt::Checked);
1068 }
1069
1070 void Step3::setSearchEnabled(int state)
1071 {
1072 updateBoolOption(m_modelData,STR_SEARCHENGINE,state==Qt::Checked);
1073 }
1074
1075 void Step3::setHtmlOptions(int id)
1076 {
1077 if (id==0) // plain HTML
1078 {
1079 updateBoolOption(m_modelData,STR_GENERATE_HTMLHELP,false);
1080 updateBoolOption(m_modelData,STR_GENERATE_TREEVIEW,false);
1081 }
1082 else if (id==1) // with navigation tree
1083 {
1084 updateBoolOption(m_modelData,STR_GENERATE_HTMLHELP,false);
1085 updateBoolOption(m_modelData,STR_GENERATE_TREEVIEW,true);
1086 }
1087 else if (id==2) // with compiled help
1088 {
1089 updateBoolOption(m_modelData,STR_GENERATE_HTMLHELP,true);
1090 updateBoolOption(m_modelData,STR_GENERATE_TREEVIEW,false);
1091 }
1092 }
1093
1094 void Step3::setLatexOptions(int id)
1095 {
1096 if (id==0) // hyperlinked PDF
1097 {
1098 updateBoolOption(m_modelData,STR_USE_PDFLATEX,true);
1099 updateBoolOption(m_modelData,STR_PDF_HYPERLINKS,true);
1100 }
1101 else if (id==1) // PDF
1102 {
1103 updateBoolOption(m_modelData,STR_USE_PDFLATEX,true);
1104 updateBoolOption(m_modelData,STR_PDF_HYPERLINKS,false);
1105 }
1106 else if (id==2) // PostScript
1107 {
1108 updateBoolOption(m_modelData,STR_USE_PDFLATEX,false);
1109 updateBoolOption(m_modelData,STR_PDF_HYPERLINKS,false);
1110 }
1111 }
1112
1113 void Step3::init()
1114 {
1115 m_htmlOptions->setChecked(getBoolOption(m_modelData,STR_GENERATE_HTML));
1116 m_texOptions->setChecked(getBoolOption(m_modelData,STR_GENERATE_LATEX));
1117 m_manEnabled->setChecked(getBoolOption(m_modelData,STR_GENERATE_MAN));
1118 m_rtfEnabled->setChecked(getBoolOption(m_modelData,STR_GENERATE_RTF));
1119 m_xmlEnabled->setChecked(getBoolOption(m_modelData,STR_GENERATE_XML));
1120 m_docbookEnabled->setChecked(getBoolOption(m_modelData,STR_GENERATE_DOCBOOK));
1121 m_searchEnabled->setChecked(getBoolOption(m_modelData,STR_SEARCHENGINE));
1122 if (getBoolOption(m_modelData,STR_GENERATE_HTMLHELP))
1123 {
1124 m_htmlOptionsGroup->button(2)->setChecked(true); // compiled help
1125 }
1126 else if (getBoolOption(m_modelData,STR_GENERATE_TREEVIEW))
1127 {
1128 m_htmlOptionsGroup->button(1)->setChecked(true); // navigation tree
1129 }
1130 else
1131 {
1132 m_htmlOptionsGroup->button(0)->setChecked(true); // plain HTML
1133 }
1134 if (!getBoolOption(m_modelData,STR_USE_PDFLATEX))
1135 {
1136 m_texOptionsGroup->button(2)->setChecked(true); // PostScript
1137 }
1138 else if (!getBoolOption(m_modelData,STR_PDF_HYPERLINKS))
1139 {
1140 m_texOptionsGroup->button(1)->setChecked(true); // Plain PDF
1141 }
1142 else
1143 {
1144 m_texOptionsGroup->button(0)->setChecked(true); // PDF with hyperlinks
1145 }
1146 }
1147
1148 //==========================================================================
1149
1150 Step4::Step4(Wizard *wizard,const QHash<QString,Input*> &modelData)
1151 : m_wizard(wizard), m_modelData(modelData)
1152 {
1153 m_diagramModeGroup = new QButtonGroup(this);
1154 QGridLayout *gbox = new QGridLayout( this );
1155 gbox->addWidget(new QLabel(tr("Diagrams to generate")),0,0);
1156
1157 // CLASS_GRAPH = NO, HAVE_DOT = NO
1158 QRadioButton *rb = new QRadioButton(tr("No diagrams"));
1159 m_diagramModeGroup->addButton(rb, 0);
1160 gbox->addWidget(rb,1,0);
1161 rb->setChecked(true);
1162
1163 // CLASS_GRAPH = TEXT, HAVE_DOT = NO
1164 rb = new QRadioButton(tr("Text only"));
1165 m_diagramModeGroup->addButton(rb, 1);
1166 gbox->addWidget(rb,2,0);
1167
1168 // CLASS_GRAPH = YES/GRAPH, HAVE_DOT = NO
1169 rb = new QRadioButton(tr("Use built-in class diagram generator"));
1170 m_diagramModeGroup->addButton(rb, 2);
1171 gbox->addWidget(rb,3,0);
1172
1173 // CLASS_GRAPH = YES/GRAPH, HAVE_DOT = YES
1174 rb = new QRadioButton(tr("Use dot tool from the GraphViz package"));
1175 m_diagramModeGroup->addButton(rb, 3);
1176 gbox->addWidget(rb,4,0);
1177
1178 m_dotGroup = new QGroupBox(tr("Dot graphs to generate"));
1179 QVBoxLayout *vbox = new QVBoxLayout;
1180 m_dotClass=new QCheckBox(tr("Class graphs"));
1181 // CLASS_GRAPH
1182 m_dotCollaboration=new QCheckBox(tr("Collaboration diagrams"));
1183 // COLLABORATION_GRAPH
1184 m_dotInheritance=new QCheckBox(tr("Overall Class hierarchy"));
1185 // GRAPHICAL_HIERARCHY
1186 m_dotInclude=new QCheckBox(tr("Include dependency graphs"));
1187 // INCLUDE_GRAPH
1188 m_dotIncludedBy=new QCheckBox(tr("Included by dependency graphs"));
1189 // INCLUDED_BY_GRAPH
1190 m_dotCall=new QCheckBox(tr("Call graphs"));
1191 // CALL_GRAPH
1192 m_dotCaller=new QCheckBox(tr("Called by graphs"));
1193 // CALLER_GRAPH
1194 vbox->addWidget(m_dotClass);
1195 vbox->addWidget(m_dotCollaboration);
1196 vbox->addWidget(m_dotInheritance);
1197 vbox->addWidget(m_dotInclude);
1198 vbox->addWidget(m_dotIncludedBy);
1199 vbox->addWidget(m_dotCall);
1200 vbox->addWidget(m_dotCaller);
1201 vbox->addStretch(1);
1202 m_dotGroup->setLayout(vbox);
1203 m_dotClass->setChecked(true);
1204 m_dotGroup->setEnabled(false);
1205 gbox->addWidget(m_dotGroup,5,0);
1206
1207 m_dotInclude->setChecked(true);
1208 m_dotCollaboration->setChecked(true);
1209 gbox->setRowStretch(6,1);
1210
1211 #if QT_VERSION < QT_VERSION_CHECK(5, 15, 0)
1212 connect(m_diagramModeGroup,SIGNAL(buttonClicked(int)),
1213 this,SLOT(diagramModeChanged(int)));
1214 #else
1215 connect(m_diagramModeGroup,SIGNAL(idClicked(int)),
1216 this,SLOT(diagramModeChanged(int)));
1217 #endif
1218 connect(m_dotClass,SIGNAL(stateChanged(int)),
1219 this,SLOT(setClassGraphEnabled(int)));
1220 connect(m_dotCollaboration,SIGNAL(stateChanged(int)),
1221 this,SLOT(setCollaborationGraphEnabled(int)));
1222 connect(m_dotInheritance,SIGNAL(stateChanged(int)),
1223 this,SLOT(setGraphicalHierarchyEnabled(int)));
1224 connect(m_dotInclude,SIGNAL(stateChanged(int)),
1225 this,SLOT(setIncludeGraphEnabled(int)));
1226 connect(m_dotIncludedBy,SIGNAL(stateChanged(int)),
1227 this,SLOT(setIncludedByGraphEnabled(int)));
1228 connect(m_dotCall,SIGNAL(stateChanged(int)),
1229 this,SLOT(setCallGraphEnabled(int)));
1230 connect(m_dotCaller,SIGNAL(stateChanged(int)),
1231 this,SLOT(setCallerGraphEnabled(int)));
1232 }
1233
1234 void Step4::diagramModeChanged(int id)
1235 {
1236 if (id==0) // no diagrams
1237 {
1238 updateBoolOption(m_modelData,STR_HAVE_DOT,false);
1239 updateStringOption(m_modelData,STR_CLASS_GRAPH, QString::fromLatin1("NO"));
1240 }
1241 else if (id==1) // text only
1242 {
1243 updateBoolOption(m_modelData,STR_HAVE_DOT,false);
1244 updateStringOption(m_modelData,STR_CLASS_GRAPH, QString::fromLatin1("TEXT"));
1245 }
1246 else if (id==2) // builtin diagrams
1247 {
1248 updateBoolOption(m_modelData,STR_HAVE_DOT,false);
1249 updateStringOption(m_modelData,STR_CLASS_GRAPH, QString::fromLatin1("YES"));
1250 }
1251 else if (id==3) // dot diagrams
1252 {
1253 updateBoolOption(m_modelData,STR_HAVE_DOT,true);
1254 updateStringOption(m_modelData,STR_CLASS_GRAPH, QString::fromLatin1("YES"));
1255 }
1256 m_dotGroup->setEnabled(id==3);
1257 }
1258
1259 void Step4::setClassGraphEnabled(int state)
1260 {
1261 QString classGraph = getStringOption(m_modelData,STR_CLASS_GRAPH);
1262 if (state==Qt::Checked)
1263 {
1264 updateStringOption(m_modelData,STR_CLASS_GRAPH,QString::fromLatin1("YES"));
1265 }
1266 else if (classGraph==QString::fromLatin1("YES") || classGraph==QString::fromLatin1("GRAPH"))
1267 {
1268 updateStringOption(m_modelData,STR_CLASS_GRAPH,QString::fromLatin1("NO"));
1269 }
1270 }
1271
1272 void Step4::setCollaborationGraphEnabled(int state)
1273 {
1274 updateBoolOption(m_modelData,STR_COLLABORATION_GRAPH,state==Qt::Checked);
1275 }
1276
1277 void Step4::setGraphicalHierarchyEnabled(int state)
1278 {
1279 updateBoolOption(m_modelData,STR_GRAPHICAL_HIERARCHY,state==Qt::Checked);
1280 }
1281
1282 void Step4::setIncludeGraphEnabled(int state)
1283 {
1284 updateBoolOption(m_modelData,STR_INCLUDE_GRAPH,state==Qt::Checked);
1285 }
1286
1287 void Step4::setIncludedByGraphEnabled(int state)
1288 {
1289 updateBoolOption(m_modelData,STR_INCLUDED_BY_GRAPH,state==Qt::Checked);
1290 }
1291
1292 void Step4::setCallGraphEnabled(int state)
1293 {
1294 updateBoolOption(m_modelData,STR_CALL_GRAPH,state==Qt::Checked);
1295 }
1296
1297 void Step4::setCallerGraphEnabled(int state)
1298 {
1299 updateBoolOption(m_modelData,STR_CALLER_GRAPH,state==Qt::Checked);
1300 }
1301
1302 void Step4::init()
1303 {
1304 int id = 0;
1305 QString classGraph = getStringOption(m_modelData,STR_CLASS_GRAPH).toLower();
1306 if (classGraph==QString::fromLatin1("yes") || classGraph==QString::fromLatin1("graph"))
1307 {
1308 id = getBoolOption(m_modelData,STR_HAVE_DOT) ? 3 : 2;
1309 }
1310 else if (classGraph==QString::fromLatin1("text"))
1311 {
1312 id = 1;
1313 }
1314 else
1315 {
1316 id = 0;
1317 }
1318 m_diagramModeGroup->button(id)->setChecked(true); // no diagrams
1319 m_dotGroup->setEnabled(id==3);
1320 m_dotClass->setChecked(getBoolOption(m_modelData,STR_CLASS_GRAPH));
1321 m_dotCollaboration->setChecked(getBoolOption(m_modelData,STR_COLLABORATION_GRAPH));
1322 m_dotInheritance->setChecked(getBoolOption(m_modelData,STR_GRAPHICAL_HIERARCHY));
1323 m_dotInclude->setChecked(getBoolOption(m_modelData,STR_INCLUDE_GRAPH));
1324 m_dotIncludedBy->setChecked(getBoolOption(m_modelData,STR_INCLUDED_BY_GRAPH));
1325 m_dotCall->setChecked(getBoolOption(m_modelData,STR_CALL_GRAPH));
1326 m_dotCaller->setChecked(getBoolOption(m_modelData,STR_CALLER_GRAPH));
1327 }
1328
1329 //==========================================================================
1330
1331 Wizard::Wizard(const QHash<QString,Input*> &modelData, QWidget *parent) :
1332 QSplitter(parent), m_modelData(modelData)
1333 {
1334 m_treeWidget = new QTreeWidget;
1335 m_treeWidget->setColumnCount(1);
1336 m_treeWidget->setHeaderLabels(QStringList() << QString::fromLatin1("Topics"));
1337 QList<QTreeWidgetItem*> items;
1338 items.append(new QTreeWidgetItem((QTreeWidget*)nullptr,QStringList(tr("Project"))));
1339 items.append(new QTreeWidgetItem((QTreeWidget*)nullptr,QStringList(tr("Mode"))));
1340 items.append(new QTreeWidgetItem((QTreeWidget*)nullptr,QStringList(tr("Output"))));
1341 items.append(new QTreeWidgetItem((QTreeWidget*)nullptr,QStringList(tr("Diagrams"))));
1342 m_treeWidget->insertTopLevelItems(0,items);
1343
1344 m_topicStack = new QStackedWidget;
1345 m_step1 = new Step1(this,modelData);
1346 m_step2 = new Step2(this,modelData);
1347 m_step3 = new Step3(this,modelData);
1348 m_step4 = new Step4(this,modelData);
1349 m_topicStack->addWidget(m_step1);
1350 m_topicStack->addWidget(m_step2);
1351 m_topicStack->addWidget(m_step3);
1352 m_topicStack->addWidget(m_step4);
1353
1354 QWidget *rightSide = new QWidget;
1355 QGridLayout *grid = new QGridLayout(rightSide);
1356 m_prev = new QPushButton(tr("Previous"));
1357 m_prev->setEnabled(false);
1358 m_next = new QPushButton(tr("Next"));
1359 grid->addWidget(m_topicStack,0,0,1,2);
1360 grid->addWidget(m_prev,1,0,Qt::AlignLeft);
1361 grid->addWidget(m_next,1,1,Qt::AlignRight);
1362 grid->setColumnStretch(0,1);
1363 grid->setRowStretch(0,1);
1364 addWidget(m_treeWidget);
1365 addWidget(rightSide);
1366
1367 connect(m_treeWidget,
1368 SIGNAL(currentItemChanged(QTreeWidgetItem *,QTreeWidgetItem *)),
1369 SLOT(activateTopic(QTreeWidgetItem *,QTreeWidgetItem *)));
1370 connect(m_next,SIGNAL(clicked()),SLOT(nextTopic()));
1371 connect(m_prev,SIGNAL(clicked()),SLOT(prevTopic()));
1372
1373 refresh();
1374 }
1375
1376 Wizard::~Wizard()
1377 {
1378 }
1379
1380 void Wizard::activateTopic(QTreeWidgetItem *item,QTreeWidgetItem *)
1381 {
1382 if (item)
1383 {
1384
1385 QString label = item->text(0);
1386 if (label==tr("Project"))
1387 {
1388 m_topicStack->setCurrentWidget(m_step1);
1389 m_prev->setEnabled(false);
1390 m_next->setEnabled(true);
1391 }
1392 else if (label==tr("Mode"))
1393 {
1394 m_topicStack->setCurrentWidget(m_step2);
1395 m_prev->setEnabled(true);
1396 m_next->setEnabled(true);
1397 }
1398 else if (label==tr("Output"))
1399 {
1400 m_topicStack->setCurrentWidget(m_step3);
1401 m_prev->setEnabled(true);
1402 m_next->setEnabled(true);
1403 }
1404 else if (label==tr("Diagrams"))
1405 {
1406 m_topicStack->setCurrentWidget(m_step4);
1407 m_prev->setEnabled(true);
1408 m_next->setEnabled(true);
1409 }
1410 }
1411 }
1412
1413 void Wizard::nextTopic()
1414 {
1415 if (m_topicStack->currentIndex()+1==m_topicStack->count()) // last topic
1416 {
1417 done();
1418 }
1419 else
1420 {
1421 m_topicStack->setCurrentIndex(m_topicStack->currentIndex()+1);
1422 m_next->setEnabled(m_topicStack->count()!=m_topicStack->currentIndex()+1);
1423 m_prev->setEnabled(m_topicStack->currentIndex()!=0);
1424 m_treeWidget->setCurrentItem(m_treeWidget->invisibleRootItem()->child(m_topicStack->currentIndex()));
1425 }
1426 }
1427
1428 void Wizard::prevTopic()
1429 {
1430 m_topicStack->setCurrentIndex(m_topicStack->currentIndex()-1);
1431 m_next->setEnabled(m_topicStack->count()!=m_topicStack->currentIndex()+1);
1432 m_prev->setEnabled(m_topicStack->currentIndex()!=0);
1433 m_treeWidget->setCurrentItem(m_treeWidget->invisibleRootItem()->child(m_topicStack->currentIndex()));
1434 }
1435
1436 void Wizard::refresh()
1437 {
1438 m_treeWidget->setCurrentItem(m_treeWidget->invisibleRootItem()->child(0));
1439 m_step1->init();
1440 m_step2->init();
1441 m_step3->init();
1442 m_step4->init();
1443 }