comparison src/moreinformationdialog.cpp @ 674:4283398d248f

Minor improvement to dialog spacing
author Chris Cannam
date Wed, 05 Dec 2018 13:21:09 +0000
parents ae67ea0af696
children
comparison
equal deleted inserted replaced
673:e4d18e8ef430 674:4283398d248f
33 QWidget *parent) : 33 QWidget *parent) :
34 QDialog(parent) 34 QDialog(parent)
35 { 35 {
36 setWindowTitle(title); 36 setWindowTitle(title);
37 37
38 QGridLayout *layout = new QGridLayout; 38 m_layout = new QGridLayout;
39 layout->setSpacing(10); 39 m_layout->setSpacing(10);
40 setLayout(layout); 40 setLayout(m_layout);
41 41
42 m_iconLabel = new QLabel; 42 m_iconLabel = new QLabel;
43 layout->addWidget(m_iconLabel, 0, 0, 2, 1, Qt::AlignTop); 43 m_layout->addWidget(m_iconLabel, 0, 0, 2, 1, Qt::AlignTop);
44 44
45 QLabel *headLabel = new QLabel(QString("<qt><h3>%1</h3></qt>").arg(head)); 45 QLabel *headLabel = new QLabel(QString("<qt><h3>%1</h3></qt>").arg(head));
46 layout->addWidget(headLabel, 0, 1); 46 m_layout->addWidget(headLabel, 0, 1);
47 47
48 QLabel *textLabel = new QLabel(text); 48 QLabel *textLabel = new QLabel(text);
49 textLabel->setTextFormat(Qt::RichText); 49 textLabel->setTextFormat(Qt::RichText);
50 textLabel->setWordWrap(true); 50 textLabel->setWordWrap(true);
51 layout->addWidget(textLabel, 1, 1, Qt::AlignTop); 51 m_layout->addWidget(textLabel, 1, 1, Qt::AlignTop);
52 52
53 QDialogButtonBox *bb = new QDialogButtonBox(QDialogButtonBox::Ok); 53 QDialogButtonBox *bb = new QDialogButtonBox(QDialogButtonBox::Ok);
54 connect(bb, SIGNAL(accepted()), this, SLOT(accept())); 54 connect(bb, SIGNAL(accepted()), this, SLOT(accept()));
55 layout->addWidget(bb, 2, 0, 1, 2); 55 m_layout->addWidget(bb, 2, 0, 1, 2);
56 56
57 m_moreButton = bb->addButton(tr("More Details..."), 57 m_moreButton = bb->addButton(tr("More Details..."),
58 QDialogButtonBox::ActionRole); 58 QDialogButtonBox::ActionRole);
59 m_moreButton->setAutoDefault(false); 59 m_moreButton->setAutoDefault(false);
60 m_moreButton->setDefault(false); 60 m_moreButton->setDefault(false);
72 72
73 QFont font("Monospace"); 73 QFont font("Monospace");
74 font.setStyleHint(QFont::TypeWriter); 74 font.setStyleHint(QFont::TypeWriter);
75 m_moreText->setFont(font); 75 m_moreText->setFont(font);
76 76
77 layout->addWidget(m_moreText, 3, 0, 1, 2); 77 m_layout->addWidget(m_moreText, 3, 0, 1, 2);
78 78
79 m_moreText->hide(); 79 m_moreText->hide();
80 if (more == "") m_moreButton->hide(); 80 if (more == "") m_moreButton->hide();
81 81
82 layout->setRowStretch(1, 10); 82 m_layout->setRowStretch(1, 10);
83 layout->setColumnStretch(1, 20); 83 m_layout->setColumnStretch(1, 20);
84 setMinimumWidth(400); 84 setMinimumWidth(400);
85 } 85 }
86 86
87 MoreInformationDialog::~MoreInformationDialog() 87 MoreInformationDialog::~MoreInformationDialog()
88 { 88 {
91 void 91 void
92 MoreInformationDialog::moreClicked() 92 MoreInformationDialog::moreClicked()
93 { 93 {
94 if (m_moreText->isVisible()) { 94 if (m_moreText->isVisible()) {
95 m_moreText->hide(); 95 m_moreText->hide();
96 m_layout->setRowStretch(3, 0);
96 m_moreButton->setText(tr("Show Details...")); 97 m_moreButton->setText(tr("Show Details..."));
97 } else { 98 } else {
98 m_moreText->show(); 99 m_moreText->show();
100 m_layout->setRowStretch(3, 30);
99 m_moreButton->setText(tr("Hide Details...")); 101 m_moreButton->setText(tr("Hide Details..."));
100 } 102 }
101 adjustSize(); 103 adjustSize();
102 } 104 }
103 105