1 #include "r_version.h"
2 #include "core/Cutter.h"
3 #include "AboutDialog.h"
4
5 #include "ui_AboutDialog.h"
6 #include "R2PluginsDialog.h"
7 #include "common/Configuration.h"
8
9 #include <QUrl>
10 #include <QTimer>
11 #include <QEventLoop>
12 #include <QJsonObject>
13 #include <QProgressBar>
14 #include <QProgressDialog>
15 #include <UpdateWorker.h>
16 #include <QtNetwork/QNetworkRequest>
17 #include <QtNetwork/QNetworkAccessManager>
18
19 #include "CutterConfig.h"
20
AboutDialog(QWidget * parent)21 AboutDialog::AboutDialog(QWidget *parent) :
22 QDialog(parent),
23 ui(new Ui::AboutDialog)
24 {
25 ui->setupUi(this);
26 setWindowFlags(windowFlags() & (~Qt::WindowContextHelpButtonHint));
27 ui->logoSvgWidget->load(Config()->getLogoFile());
28
29 QString aboutString(tr("Version") + " " CUTTER_VERSION_FULL "<br/>"
30 + tr("Using r2-") + R2_GITTAP + "<br/>"
31 + buildQtVersionString()
32 + "<p><b>" + tr("Optional Features:") + "</b><br/>"
33 + QString("Python: %1<br/>").arg(
34 #ifdef CUTTER_ENABLE_PYTHON
35 "ON"
36 #else
37 "OFF"
38 #endif
39 )
40 + QString("Python Bindings: %2</p>").arg(
41 #ifdef CUTTER_ENABLE_PYTHON_BINDINGS
42 "ON"
43 #else
44 "OFF"
45 #endif
46 )
47 + "<h2>" + tr("License") + "</h2>"
48 + tr("This Software is released under the GNU General Public License v3.0")
49 + "<h2>" + tr("Authors") + "</h2>"
50 + tr("Cutter is developed by the community and maintained by its core and development teams.<br/>")
51 + tr("Check our <a href='https://github.com/radareorg/cutter/graphs/contributors'>contributors page</a> for the full list of contributors."));
52 ui->label->setText(aboutString);
53
54 QSignalBlocker s(ui->updatesCheckBox);
55 ui->updatesCheckBox->setChecked(Config()->getAutoUpdateEnabled());
56
57 if (!CUTTER_UPDATE_WORKER_AVAILABLE) {
58 ui->updatesCheckBox->hide();
59 ui->checkForUpdatesButton->hide();
60 }
61 }
62
~AboutDialog()63 AboutDialog::~AboutDialog() {}
64
on_buttonBox_rejected()65 void AboutDialog::on_buttonBox_rejected()
66 {
67 close();
68 }
69
on_showVersionButton_clicked()70 void AboutDialog::on_showVersionButton_clicked()
71 {
72 QMessageBox popup(this);
73 popup.setWindowTitle(tr("radare2 version information"));
74 popup.setTextInteractionFlags(Qt::TextSelectableByMouse);
75 auto versionInformation = Core()->getVersionInformation();
76 popup.setText(versionInformation);
77 popup.exec();
78 }
79
on_showPluginsButton_clicked()80 void AboutDialog::on_showPluginsButton_clicked()
81 {
82 R2PluginsDialog dialog(this);
83 dialog.exec();
84 }
85
on_checkForUpdatesButton_clicked()86 void AboutDialog::on_checkForUpdatesButton_clicked()
87 {
88 #if CUTTER_UPDATE_WORKER_AVAILABLE
89 UpdateWorker updateWorker;
90
91 QProgressDialog waitDialog;
92 QProgressBar *bar = new QProgressBar(&waitDialog);
93 bar->setMaximum(0);
94
95 waitDialog.setBar(bar);
96 waitDialog.setLabel(new QLabel(tr("Checking for updates..."), &waitDialog));
97
98 connect(&updateWorker, &UpdateWorker::checkComplete, &waitDialog, &QProgressDialog::cancel);
99 connect(&updateWorker, &UpdateWorker::checkComplete,
100 [&updateWorker](const QVersionNumber & version, const QString & error) {
101 if (!error.isEmpty()) {
102 QMessageBox::critical(nullptr, tr("Error!"), error);
103 } else {
104 if (version <= UpdateWorker::currentVersionNumber()) {
105 QMessageBox::information(nullptr, tr("Version control"), tr("r2cutter is up to date!"));
106 } else {
107 updateWorker.showUpdateDialog(false);
108 }
109 }
110 });
111
112 updateWorker.checkCurrentVersion(7000);
113 waitDialog.exec();
114 #endif
115 }
116
on_updatesCheckBox_stateChanged(int)117 void AboutDialog::on_updatesCheckBox_stateChanged(int)
118 {
119 Config()->setAutoUpdateEnabled(!Config()->getAutoUpdateEnabled());
120 }
121
compilerString()122 static QString compilerString()
123 {
124 #if defined(Q_CC_CLANG) // must be before GNU, because clang claims to be GNU too
125 QString isAppleString;
126 #if defined(__apple_build_version__) // Apple clang has other version numbers
127 isAppleString = QLatin1String(" (Apple)");
128 #endif
129 return QLatin1String("Clang " ) + QString::number(__clang_major__) + QLatin1Char('.')
130 + QString::number(__clang_minor__) + isAppleString;
131 #elif defined(Q_CC_GNU)
132 return QLatin1String("GCC " ) + QLatin1String(__VERSION__);
133 #elif defined(Q_CC_MSVC)
134 if (_MSC_VER > 1999)
135 return QLatin1String("MSVC <unknown>");
136 if (_MSC_VER >= 1910)
137 return QLatin1String("MSVC 2017");
138 if (_MSC_VER >= 1900)
139 return QLatin1String("MSVC 2015");
140 #endif
141 return QLatin1String("<unknown compiler>");
142 }
143
buildQtVersionString(void)144 QString AboutDialog::buildQtVersionString(void)
145 {
146 return tr("Based on Qt %1 (%2, %3 bit)").arg(QLatin1String(qVersion()),
147 compilerString(),
148 QString::number(QSysInfo::WordSize));
149 }
150