Engauge Digitizer 2
Loading...
Searching...
No Matches
ChecklistGuidePage.cpp
Go to the documentation of this file.
1/******************************************************************************************************
2 * (C) 2014 markummitchell@github.com. This file is part of Engauge Digitizer, which is released *
3 * under GNU General Public License version 2 (GPLv2) or (at your option) any later version. See file *
4 * LICENSE or go to gnu.org/licenses for details. Distribution requires prior written permission. *
5 ******************************************************************************************************/
6
8#include "ChecklistLineEdit.h"
9#include "Logger.h"
10#include <QGridLayout>
11#include <QLabel>
12#include <QPalette>
13#include <QRadioButton>
14#include <QVBoxLayout>
15
17 m_row (0),
18 m_checklineLineEditContainer (nullptr),
19 m_checklineLineEditLayout (nullptr)
20{
21 setTitle (title);
22
23 m_layout = new QGridLayout;
24 m_layout->setColumnStretch (0, 0);
25 m_layout->setColumnStretch (1, 1);
26 setLayout (m_layout);
27}
28
29void ChecklistGuidePage::addHtml (const QString &html)
30{
31 LOG4CPP_INFO_S ((*mainCat)) << "ChecklistGuidePage::addHtml";
32
33 QLabel *label = new QLabel (html);
34 label->setWordWrap (true);
35
36 m_layout->addWidget (label, m_row++, 0, 1, 2, Qt::AlignTop);
37}
38
39QRadioButton *ChecklistGuidePage::addLabelAndRadioButton (const QString &label,
40 const QString &whatsThis)
41{
42 LOG4CPP_INFO_S ((*mainCat)) << "ChecklistGuidePage::addLabelAndRadioButton";
43
44 QRadioButton *button = new QRadioButton;
45 button->setWhatsThis (whatsThis);
46 m_layout->addWidget (button, m_row, 0, 1, 1, Qt::AlignTop);
47
48 QLabel *lbl = new QLabel (label);
49 lbl->setWordWrap(true);
50 m_layout->addWidget (lbl, m_row++, 1, 1, 1, Qt::AlignTop);
51
52 return button;
53}
54
56 const QString &whatsThis)
57{
58 LOG4CPP_INFO_S ((*mainCat)) << "ChecklistGuidePage::addLineEdit";
59
60 bool isFirst = false;
61
62 if (m_checklineLineEditContainer == nullptr) {
63
64 isFirst = true;
65
66 // This is the first ChecklistLineEdit, so we create a container for it and any more that get added
67 m_checklineLineEditLayout = new QVBoxLayout;
68 m_checklineLineEditLayout->setSpacing (0); // This is the whole reason we wrap the ChecklineLineEdits in a container
69
70 m_checklineLineEditContainer = new QWidget;
71 m_checklineLineEditContainer->setLayout (m_checklineLineEditLayout);
72 m_layout->addWidget (m_checklineLineEditContainer, m_row++, 0, 1, 2, Qt::AlignTop);
73 }
74
75 edit->setWhatsThis (whatsThis);
76 m_checklineLineEditLayout->addWidget (edit);
77
78 // Windows border is missing on left side so border is made complete here
79 QString style = QString ("QLineEdit { "
80 "border-left : 1px solid gray; "
81 "border-right: 1px solid gray; "
82 "border-top: %1px solid gray; "
83 "border-bottom:1px solid gray; }")
84 .arg (isFirst ? 1 : 0);
85 edit->setStyleSheet (style);
86}
log4cpp::Category * mainCat
Definition Logger.cpp:14
QRadioButton * addLabelAndRadioButton(const QString &label, const QString &whatsThis)
Insert radio button and corresponding label.
void addLineEdit(ChecklistLineEdit *edit, const QString &whatsThis)
Insert line edit.
ChecklistGuidePage(const QString &title)
Single constructor.
void addHtml(const QString &html)
Insert html for display.
Adds key event handling to QLineEdit.
#define LOG4CPP_INFO_S(logger)
Definition convenience.h:18