Vuo 2.4.4
Loading...
Searching...
No Matches
VuoInfoDialog.cc
Go to the documentation of this file.
1
10#include "VuoInfoDialog.hh"
11
12#include "VuoRendererFonts.hh"
13
23VuoInfoDialog::VuoInfoDialog(QWidget *parent, QString summary, QString details, QString checkboxLabel, QString settingsKey)
24 : QMessageBox(parent)
25{
26 this->summary = summary;
27 this->details = details;
28 this->checkboxLabel = checkboxLabel;
29 this->settingsKey = settingsKey;
30}
31
39VuoInfoDialog::VuoInfoDialog(QWidget *parent, QString summary, QString details)
40 : QMessageBox(parent)
41{
42 this->summary = summary;
43 this->details = details;
44}
45
50{
51 bool hasCheckbox = ! settingsKey.isEmpty() && ! checkboxLabel.isEmpty();
52
53 QSettings *settings = nullptr;
54 if (hasCheckbox)
55 {
56 settings = new QSettings;
57 if (!settings->value(settingsKey, true).toBool())
58 {
59 emit notShown();
60 return;
61 }
62 }
63
65
66 setWindowFlags(Qt::Sheet);
67 setWindowModality(Qt::WindowModal);
68 setFont(fonts->dialogHeadingFont());
69 setTextFormat(Qt::RichText);
70 setText(summary);
71 setInformativeText("<style>p{" + fonts->getCSS(fonts->dialogBodyFont()) + "}</style>" + details);
72 setIcon(QMessageBox::Information);
73
74 // Make the dialog wide enough to show "⚠️ The app requires macOS on an Apple Silicon (ARM64/M1/M2/M3) CPU." without wrapping.
75 setStyleSheet("QLabel{min-width: 410px;}");
76
77 QCheckBox *cb = nullptr;
78 if (hasCheckbox)
79 {
80 cb = new QCheckBox(this);
81 cb->setFont(fonts->dialogBodyFont());
82 cb->setText(checkboxLabel);
83 cb->setChecked(true);
84 setCheckBox(cb);
85 }
86
87 if (hasCheckbox)
88 {
89 connect(this, &QMessageBox::finished, [=](){
90 if (!cb->isChecked())
91 settings->setValue(settingsKey, false);
92 delete settings;
93 });
94 }
95
96 open();
97}