1
1
#include " UpdateDialog.hpp"
2
+ #include " obs-utils/obs-config-utils.h"
2
3
3
4
#include < obs.h>
4
5
#include < obs-module.h>
8
9
#include < QString>
9
10
10
11
static QString dialogContent =
12
+ " <h1>Background Removal - Update available! 🚀</h1>"
11
13
" <p>A new version of the Background Removal plugin (<a "
12
14
" href=\" https://github.com/royshil/obs-backgroundremoval/releases\" >v{version}</a>) is "
13
15
" now available for download. We've made some exciting updates and improvements that we think "
@@ -18,53 +20,43 @@ static QString dialogContent =
18
20
" uninstall the previous version.</p>"
19
21
" <p>If you have any questions or need assistance during the update process, feel free to reach out"
20
22
" to our <a href=\" https://github.com/royshil/obs-backgroundremoval/issues\" >support team</a>.</p>"
21
- " <p>Thank you for using our plugin and we hope you enjoy the latest release! 🙏</p>" ;
23
+ " <p>Thank you for using our plugin and we hope you enjoy the latest release! 🙏</p>"
24
+ " <h2>Changelog</h2>" ;
22
25
23
- UpdateDialog::UpdateDialog (const char *latestVersion, QWidget *parent)
26
+ UpdateDialog::UpdateDialog (
27
+ struct github_utils_release_information latestVersion, QWidget *parent)
24
28
: QDialog(parent), layout(new QVBoxLayout)
25
29
{
26
30
setWindowTitle (" Background Removal - Update available! 🚀" );
27
31
setLayout (layout);
28
32
QLabel *label = new QLabel (dialogContent.replace (
29
- QString (" {version}" ), QString (latestVersion)));
33
+ QString (" {version}" ), QString (latestVersion. version )));
30
34
label->setOpenExternalLinks (true );
31
35
label->setTextInteractionFlags (Qt::TextBrowserInteraction);
32
36
label->setTextFormat (Qt::RichText);
33
37
label->setWordWrap (true );
34
38
layout->addWidget (label);
39
+
40
+ QScrollArea *scrollArea = new QScrollArea;
41
+ QLabel *scrollAreaLabel =
42
+ new QLabel (QString (latestVersion.responseBody ));
43
+ scrollAreaLabel->setOpenExternalLinks (true );
44
+ scrollAreaLabel->setTextInteractionFlags (Qt::TextBrowserInteraction);
45
+ scrollAreaLabel->setTextFormat (Qt::MarkdownText);
46
+ scrollAreaLabel->setWordWrap (true );
47
+ scrollArea->setWidget (scrollAreaLabel);
48
+ scrollArea->setWidgetResizable (true );
49
+ layout->addWidget (scrollArea);
50
+
35
51
// Add a checkbox to disable update checks
36
52
QCheckBox *disableCheckbox = new QCheckBox (" Disable update checks" );
37
53
layout->addWidget (disableCheckbox);
38
- connect (disableCheckbox, &QCheckBox::stateChanged, this ,
39
- &UpdateDialog::disableUpdateChecks);
54
+ connect (disableCheckbox, &QCheckBox::stateChanged, this , [](int state) {
55
+ setFlagFromConfig (" check_for_updates" , state == Qt::Unchecked);
56
+ });
57
+
40
58
// Add a button to close the dialog
41
59
QPushButton *closeButton = new QPushButton (" Close" );
42
60
layout->addWidget (closeButton);
43
61
connect (closeButton, &QPushButton::clicked, this , &QDialog::close );
44
62
}
45
-
46
- void UpdateDialog::disableUpdateChecks (int state)
47
- {
48
- UNUSED_PARAMETER (state);
49
-
50
- // Get the config file
51
- char *config_file = obs_module_file (" config.json" );
52
- if (!config_file) {
53
- blog (LOG_INFO, " Unable to find config file" );
54
- return ;
55
- }
56
-
57
- // Parse the config file
58
- obs_data_t *json_data = obs_data_create_from_json_file (config_file);
59
- if (!json_data) {
60
- blog (LOG_INFO, " Failed to parse config file" );
61
- return ;
62
- }
63
-
64
- // Update the config
65
- obs_data_set_bool (json_data, " check_for_updates" ,
66
- state == Qt::Unchecked);
67
- obs_data_save_json (json_data, config_file);
68
-
69
- obs_data_release (json_data);
70
- }
0 commit comments