Skip to content

Commit b417880

Browse files
committed
acceptlicensedialog
1 parent 7fcf17c commit b417880

7 files changed

+150
-2
lines changed

coinvault.pro

+3
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ RCC_DIR = $$DESTDIR/rcc
3232
UI_DIR = $$DESTDIR/ui
3333

3434
FORMS = \
35+
src/acceptlicensedialog.ui \
3536
src/requestpaymentdialog.ui
3637

3738
HEADERS = \
@@ -41,6 +42,7 @@ HEADERS = \
4142
src/coinparams.h \
4243
src/severitylogger.h \
4344
src/splashscreen.h \
45+
src/acceptlicensedialog.h \
4446
src/mainwindow.h \
4547
src/commandserver.h \
4648
src/paymentrequest.h \
@@ -69,6 +71,7 @@ SOURCES = \
6971
src/coinparams.cpp \
7072
src/main.cpp \
7173
src/splashscreen.cpp \
74+
src/acceptlicensedialog.cpp \
7275
src/mainwindow.cpp \
7376
src/commandserver.cpp \
7477
src/paymentrequest.cpp \

src/acceptlicensedialog.cpp

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
#include "acceptlicensedialog.h"
2+
#include "ui_acceptlicensedialog.h"
3+
4+
AcceptLicenseDialog::AcceptLicenseDialog(QWidget *parent) :
5+
QDialog(parent),
6+
ui(new Ui::AcceptLicenseDialog)
7+
{
8+
ui->setupUi(this);
9+
}
10+
11+
AcceptLicenseDialog::~AcceptLicenseDialog()
12+
{
13+
delete ui;
14+
}

src/acceptlicensedialog.h

+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
#ifndef ACCEPTLICENSEDIALOG_H
2+
#define ACCEPTLICENSEDIALOG_H
3+
4+
#include <QDialog>
5+
6+
namespace Ui {
7+
class AcceptLicenseDialog;
8+
}
9+
10+
class AcceptLicenseDialog : public QDialog
11+
{
12+
Q_OBJECT
13+
14+
public:
15+
explicit AcceptLicenseDialog(QWidget *parent = 0);
16+
~AcceptLicenseDialog();
17+
18+
private:
19+
Ui::AcceptLicenseDialog *ui;
20+
};
21+
22+
#endif // ACCEPTLICENSEDIALOG_H

src/acceptlicensedialog.ui

+91
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,91 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<ui version="4.0">
3+
<class>AcceptLicenseDialog</class>
4+
<widget class="QDialog" name="AcceptLicenseDialog">
5+
<property name="geometry">
6+
<rect>
7+
<x>0</x>
8+
<y>0</y>
9+
<width>738</width>
10+
<height>488</height>
11+
</rect>
12+
</property>
13+
<property name="windowTitle">
14+
<string>License Agreement</string>
15+
</property>
16+
<widget class="QDialogButtonBox" name="buttonBox">
17+
<property name="geometry">
18+
<rect>
19+
<x>360</x>
20+
<y>440</y>
21+
<width>341</width>
22+
<height>32</height>
23+
</rect>
24+
</property>
25+
<property name="orientation">
26+
<enum>Qt::Horizontal</enum>
27+
</property>
28+
<property name="standardButtons">
29+
<set>QDialogButtonBox::Close|QDialogButtonBox::Yes</set>
30+
</property>
31+
</widget>
32+
<widget class="QTextBrowser" name="licenseTextBrowser">
33+
<property name="geometry">
34+
<rect>
35+
<x>10</x>
36+
<y>10</y>
37+
<width>721</width>
38+
<height>411</height>
39+
</rect>
40+
</property>
41+
</widget>
42+
<widget class="QLabel" name="promptLabel">
43+
<property name="geometry">
44+
<rect>
45+
<x>30</x>
46+
<y>450</y>
47+
<width>281</width>
48+
<height>16</height>
49+
</rect>
50+
</property>
51+
<property name="text">
52+
<string>Do you accept these terms and conditions?</string>
53+
</property>
54+
</widget>
55+
</widget>
56+
<resources/>
57+
<connections>
58+
<connection>
59+
<sender>buttonBox</sender>
60+
<signal>accepted()</signal>
61+
<receiver>AcceptLicenseDialog</receiver>
62+
<slot>accept()</slot>
63+
<hints>
64+
<hint type="sourcelabel">
65+
<x>248</x>
66+
<y>254</y>
67+
</hint>
68+
<hint type="destinationlabel">
69+
<x>157</x>
70+
<y>274</y>
71+
</hint>
72+
</hints>
73+
</connection>
74+
<connection>
75+
<sender>buttonBox</sender>
76+
<signal>rejected()</signal>
77+
<receiver>AcceptLicenseDialog</receiver>
78+
<slot>reject()</slot>
79+
<hints>
80+
<hint type="sourcelabel">
81+
<x>316</x>
82+
<y>260</y>
83+
</hint>
84+
<hint type="destinationlabel">
85+
<x>286</x>
86+
<y>274</y>
87+
</hint>
88+
</hints>
89+
</connection>
90+
</connections>
91+
</ui>

src/main.cpp

+10-1
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
#include <QMessageBox>
1717

1818
#include "splashscreen.h"
19+
#include "acceptlicensedialog.h"
1920
#include "mainwindow.h"
2021
#include "commandserver.h"
2122

@@ -88,9 +89,17 @@ int main(int argc, char* argv[])
8889
timer_io.stop();
8990

9091
mainWin.tryConnect();
91-
9292
mainWin.show();
9393
splash.finish(&mainWin);
94+
95+
if (!mainWin.isLicenseAccepted()) {
96+
//Display license agreement
97+
AcceptLicenseDialog acceptLicenseDialog;
98+
if (!acceptLicenseDialog.exec()) return -1;
99+
mainWin.setLicenseAccepted(true);
100+
mainWin.saveSettings();
101+
}
102+
94103
commandServer.uiReady();
95104

96105
int rval = app.exec();

src/mainwindow.cpp

+4-1
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ using namespace CoinQ::Script;
6262
using namespace std;
6363

6464
MainWindow::MainWindow()
65-
: networkSync(getCoinParams()), syncHeight(0), bestHeight(0), connected(false), doneHeaderSync(false), networkState(NETWORK_STATE_NOT_CONNECTED)
65+
: licenseAccepted(false), networkSync(getCoinParams()), syncHeight(0), bestHeight(0), connected(false), doneHeaderSync(false), networkState(NETWORK_STATE_NOT_CONNECTED)
6666
{
6767
loadSettings();
6868

@@ -1575,6 +1575,8 @@ void MainWindow::loadSettings()
15751575
resize(size);
15761576
move(pos);
15771577

1578+
licenseAccepted = settings.value("licenseaccepted", false).toBool();
1579+
15781580
blockTreeFile = settings.value("blocktreefile", "blocktree.dat").toString();
15791581
host = settings.value("host", "localhost").toString();
15801582
port = settings.value("port", getCoinParams().default_port()).toInt();
@@ -1587,6 +1589,7 @@ void MainWindow::saveSettings()
15871589
QSettings settings("Ciphrex", APPNAME);
15881590
settings.setValue("pos", pos());
15891591
settings.setValue("size", size());
1592+
settings.setValue("licenseaccepted", licenseAccepted);
15901593
settings.setValue("blocktreefile", blockTreeFile);
15911594
settings.setValue("host", host);
15921595
settings.setValue("port", port);

src/mainwindow.h

+6
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,9 @@ class MainWindow : public QMainWindow
4545
public:
4646
MainWindow();
4747

48+
bool isLicenseAccepted() const { return licenseAccepted; }
49+
void setLicenseAccepted(bool licenseAccepted = true) { this->licenseAccepted = licenseAccepted; }
50+
4851
void loadSettings();
4952
void saveSettings();
5053

@@ -177,6 +180,9 @@ private slots:
177180
void processFile(const QString& fileName);
178181

179182
private:
183+
// License accepted?
184+
bool licenseAccepted;
185+
180186
void createActions();
181187
void createMenus();
182188
void createToolBars();

0 commit comments

Comments
 (0)