| 126 | } |
| 127 | |
| 128 | class PluginUpdate : public QDialog { |
| 129 | Q_OBJECT |
| 130 | private: |
| 131 | std::unique_ptr<Ui::PluginUpdate> ui; |
| 132 | |
| 133 | public: |
| 134 | explicit PluginUpdate(const PluginUpdateInfo &pluginUpdateInfo, QWidget *parent = nullptr) |
| 135 | : QDialog(parent), |
| 136 | ui(new Ui::PluginUpdate) |
| 137 | { |
| 138 | ui->setupUi(this); |
| 139 | |
| 140 | auto pluginDisplayName = QString(PLUGIN_DISPLAY_NAME); |
| 141 | |
| 142 | auto config = Config::Current(); |
| 143 | |
| 144 | auto textTemp = QTStr("NDIPlugin.Update.Title").arg(pluginDisplayName); |
| 145 | setWindowTitle(textTemp); |
| 146 | |
| 147 | textTemp = QString("<h2>%1</h2>") |
| 148 | .arg(QTStr("NDIPlugin.Update.NewVersionAvailable") |
| 149 | .arg(pluginDisplayName) |
| 150 | .arg(pluginUpdateInfo.versionLatest.toString())); |
| 151 | ui->labelVersionNew->setText(textTemp); |
| 152 | |
| 153 | QVersionNumber yourVersion = QVersionNumber::fromString(PLUGIN_VERSION); |
| 154 | textTemp = QString("<font size='+1'>%1</font>") |
| 155 | .arg(QTStr("NDIPlugin.Update.YourVersion").arg(yourVersion.toString())); |
| 156 | ui->labelVersionYours->setText(textTemp); |
| 157 | |
| 158 | textTemp = QString("<h3>%1</h3>").arg(Str("NDIPlugin.Update.ReleaseNotes")); |
| 159 | ui->labelReleaseNotes->setText(textTemp); |
| 160 | |
| 161 | auto utcDateTime = QDateTime::fromString(pluginUpdateInfo.releaseDate, Qt::ISODate); |
| 162 | utcDateTime.setTimeZone(QTimeZone::utc()); |
| 163 | auto formattedUtcDateTime = utcDateTime.toString("yyyy-MM-dd hh:mm:ss 'UTC'"); |
| 164 | textTemp = QString("<h3>%1</h3>").arg(Str("NDIPlugin.Update.ReleaseDate")); |
| 165 | ui->labelReleaseDate->setText(textTemp); |
| 166 | ui->textReleaseDate->setText(formattedUtcDateTime); |
| 167 | |
| 168 | ui->textReleaseNotes->document()->setMarkdown( |
| 169 | pluginUpdateInfo.releaseNotes, |
| 170 | QTextDocument::MarkdownFeatures(QTextDocument::MarkdownDialectGitHub | |
| 171 | QTextDocument::MarkdownNoHTML)); |
| 172 | |
| 173 | ui->checkBoxAutoCheckForUpdates->setChecked(config->AutoCheckForUpdates()); |
| 174 | #if QT_VERSION < QT_VERSION_CHECK(6, 7, 0) |
| 175 | connect(ui->checkBoxAutoCheckForUpdates, &QCheckBox::stateChanged, this, |
| 176 | [](int state) { Config::Current(false)->AutoCheckForUpdates(state == Qt::Checked); }); |
| 177 | #else |
| 178 | connect(ui->checkBoxAutoCheckForUpdates, &QCheckBox::checkStateChanged, this, |
| 179 | [](int state) { Config::Current(false)->AutoCheckForUpdates(state == Qt::Checked); }); |
| 180 | #endif |
| 181 | |
| 182 | connect(ui->buttonSkipThisVersion, &QPushButton::clicked, this, [this, pluginUpdateInfo]() { |
| 183 | Config::Current(false)->SkipUpdateVersion(pluginUpdateInfo.versionLatest); |
| 184 | reject(); |
| 185 | }); |
nothing calls this directly
no outgoing calls
no test coverage detected