Skip to content

Commit 1ba730d

Browse files
committed
[Cleanup] Continuing with the final cleanup, setProperty methods moved to the new setCssProperty.
1 parent b21956d commit 1ba730d

17 files changed

+183
-293
lines changed

src/qt/openuridialog.cpp

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
1-
// Copyright (c) 2011-2014 The Bitcoin developers
2-
// Copyright (c) 2014-2015 The Dash developers
3-
// Copyright (c) 2015-2018 The PIVX developers
1+
// Copyright (c) 2019 The PIVX developers
42
// Distributed under the MIT/X11 software license, see the accompanying
53
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
64

@@ -21,21 +19,25 @@ OpenURIDialog::OpenURIDialog(QWidget* parent) : QDialog(parent, Qt::WindowSystem
2119
ui->uriEdit->setPlaceholderText("pivx:");
2220

2321
ui->labelSubtitle->setText("URI");
24-
ui->labelSubtitle->setProperty("cssClass", "text-title2-dialog");
25-
26-
ui->frame->setProperty("cssClass", "container-dialog");
27-
ui->labelTitle->setProperty("cssClass", "text-title-dialog");
22+
setCssProperty(ui->labelSubtitle, "text-title2-dialog");
23+
setCssProperty(ui->frame, "container-dialog");
24+
setCssProperty(ui->labelTitle, "text-title-dialog");
2825

2926
setCssBtnPrimary(ui->pushButtonOK);
3027
setCssBtnPrimary(ui->selectFileButton);
31-
ui->pushButtonCancel->setProperty("cssClass", "btn-dialog-cancel");
28+
setCssProperty(ui->pushButtonCancel, "btn-dialog-cancel");
3229

3330
ui->uriEdit->setPlaceholderText("0.000001 zPIV");
3431
initCssEditLine(ui->uriEdit, true);
3532
connect(ui->pushButtonOK, SIGNAL(clicked()), this, SLOT(accept()));
3633
connect(ui->pushButtonCancel, SIGNAL(clicked()), this, SLOT(close()));
3734
}
3835

36+
void OpenURIDialog::showEvent(QShowEvent *event)
37+
{
38+
ui->uriEdit->setFocus();
39+
}
40+
3941
OpenURIDialog::~OpenURIDialog()
4042
{
4143
delete ui;

src/qt/openuridialog.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
// Copyright (c) 2011-2013 The Bitcoin developers
2-
// Copyright (c) 2017-2018 The PIVX developers
1+
// Copyright (c) 2019 The PIVX developers
32
// Distributed under the MIT/X11 software license, see the accompanying
43
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
54

@@ -22,9 +21,10 @@ class OpenURIDialog : public QDialog
2221
~OpenURIDialog();
2322

2423
QString getURI();
24+
void showEvent(QShowEvent *event) override;
2525

2626
protected slots:
27-
void accept();
27+
void accept() override;
2828

2929
private slots:
3030
void on_selectFileButton_clicked();

src/qt/pivx/PIVXGUI.cpp

Lines changed: 48 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -281,67 +281,58 @@ void PIVXGUI::messageInfo(const QString& text){
281281

282282
void PIVXGUI::message(const QString& title, const QString& message, unsigned int style, bool* ret)
283283
{
284-
try {
285-
QString strTitle = tr("PIVX Core"); // default title
286-
// Default to information icon
287-
int nNotifyIcon = Notificator::Information;
288-
289-
QString msgType;
290-
291-
// Prefer supplied title over style based title
292-
if (!title.isEmpty()) {
293-
msgType = title;
294-
} else {
295-
switch (style) {
296-
case CClientUIInterface::MSG_ERROR:
297-
msgType = tr("Error");
298-
break;
299-
case CClientUIInterface::MSG_WARNING:
300-
msgType = tr("Warning");
301-
break;
302-
case CClientUIInterface::MSG_INFORMATION:
303-
msgType = tr("Information");
304-
break;
305-
default:
306-
msgType = tr("System Message");
307-
break;
308-
}
309-
}
284+
QString strTitle = tr("PIVX Core"); // default title
285+
// Default to information icon
286+
int nNotifyIcon = Notificator::Information;
310287

311-
// Check for error/warning icon
312-
if (style & CClientUIInterface::ICON_ERROR) {
313-
nNotifyIcon = Notificator::Critical;
314-
} else if (style & CClientUIInterface::ICON_WARNING) {
315-
nNotifyIcon = Notificator::Warning;
316-
}
288+
QString msgType;
317289

318-
// Display message
319-
if (style & CClientUIInterface::MODAL) {
320-
// Check for buttons, use OK as default, if none was supplied
321-
int r = 0;
322-
showNormalIfMinimized();
323-
if(style & CClientUIInterface::BTN_MASK){
324-
r = openStandardDialog(strTitle, message, "OK", "CANCEL");
325-
}else{
326-
r = openStandardDialog(strTitle, message, "OK");
327-
}
328-
if (ret != NULL)
329-
*ret = r;
330-
} else if(style & CClientUIInterface::MSG_INFORMATION_SNACK){
331-
messageInfo(message);
332-
}else {
333-
// Append title to "PIVX - "
334-
std::cout << "notify" << std::endl;
335-
if (!msgType.isEmpty())
336-
strTitle += " - " + msgType;
337-
notificator->notify((Notificator::Class) nNotifyIcon, strTitle, message);
290+
// Prefer supplied title over style based title
291+
if (!title.isEmpty()) {
292+
msgType = title;
293+
} else {
294+
switch (style) {
295+
case CClientUIInterface::MSG_ERROR:
296+
msgType = tr("Error");
297+
break;
298+
case CClientUIInterface::MSG_WARNING:
299+
msgType = tr("Warning");
300+
break;
301+
case CClientUIInterface::MSG_INFORMATION:
302+
msgType = tr("Information");
303+
break;
304+
default:
305+
msgType = tr("System Message");
306+
break;
338307
}
308+
}
309+
310+
// Check for error/warning icon
311+
if (style & CClientUIInterface::ICON_ERROR) {
312+
nNotifyIcon = Notificator::Critical;
313+
} else if (style & CClientUIInterface::ICON_WARNING) {
314+
nNotifyIcon = Notificator::Warning;
315+
}
339316

340-
// TODO: Furszy remove this please..
341-
} catch (std::exception &e){
342-
LogPrintf("ERROR in message PIVXGUI.. %s\n", e.what());
343-
} catch (...){
344-
LogPrintf("ERROR in message PIVXGUI..\n");
317+
// Display message
318+
if (style & CClientUIInterface::MODAL) {
319+
// Check for buttons, use OK as default, if none was supplied
320+
int r = 0;
321+
showNormalIfMinimized();
322+
if(style & CClientUIInterface::BTN_MASK){
323+
r = openStandardDialog(strTitle, message, "OK", "CANCEL");
324+
}else{
325+
r = openStandardDialog(strTitle, message, "OK");
326+
}
327+
if (ret != NULL)
328+
*ret = r;
329+
} else if(style & CClientUIInterface::MSG_INFORMATION_SNACK){
330+
messageInfo(message);
331+
}else {
332+
// Append title to "PIVX - "
333+
if (!msgType.isEmpty())
334+
strTitle += " - " + msgType;
335+
notificator->notify((Notificator::Class) nNotifyIcon, strTitle, message);
345336
}
346337
}
347338

src/qt/pivx/addresseswidget.cpp

Lines changed: 10 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,8 @@
1010
#include "qt/pivx/qtutils.h"
1111
#include "walletmodel.h"
1212

13-
#include <QAbstractItemDelegate>
14-
#include <QPainter>
15-
#include <QSettings>
1613
#include <QModelIndex>
1714

18-
#include <iostream>
19-
2015
#define DECORATION_SIZE 60
2116
#define NUM_ITEMS 3
2217

@@ -69,21 +64,17 @@ AddressesWidget::AddressesWidget(PIVXGUI* parent) :
6964
);
7065

7166
/* Containers */
72-
ui->left->setProperty("cssClass", "container");
67+
setCssProperty(ui->left, "container");
7368
ui->left->setContentsMargins(0,20,0,20);
74-
ui->right->setProperty("cssClass", "container-right");
69+
setCssProperty(ui->right, "container-right");
7570
ui->right->setContentsMargins(20,10,20,20);
76-
77-
ui->listAddresses->setProperty("cssClass", "container");
71+
setCssProperty(ui->listAddresses, "container");
7872

7973
// Title
8074
ui->labelTitle->setText(tr("Contacts"));
81-
ui->labelTitle->setProperty("cssClass", "text-title-screen");
82-
83-
/* Subtitle */
84-
8575
ui->labelSubtitle1->setText(tr("You can add a new one in the options menu to the side."));
86-
ui->labelSubtitle1->setProperty("cssClass", "text-subtitle");
76+
setCssTitleScreen(ui->labelTitle);
77+
setCssSubtitleScreen(ui->labelSubtitle1);
8778

8879
// Change eddress option
8980
ui->btnAddContact->setTitleClassAndText("btn-title-grey", "Add new contact");
@@ -99,37 +90,28 @@ AddressesWidget::AddressesWidget(PIVXGUI* parent) :
9990

10091
//Empty List
10192
ui->emptyContainer->setVisible(false);
102-
ui->pushImgEmpty->setProperty("cssClass", "img-empty-contacts");
93+
setCssProperty(ui->pushImgEmpty, "img-empty-contacts");
10394

10495
ui->labelEmpty->setText(tr("No contacts yet"));
105-
ui->labelEmpty->setProperty("cssClass", "text-empty");
106-
96+
setCssProperty(ui->labelEmpty, "text-empty");
10797

10898
// Add Contact
109-
ui->layoutNewContact->setProperty("cssClass", "container-options");
110-
99+
setCssProperty(ui->layoutNewContact, "container-options");
111100

112101
// Name
113-
114102
ui->labelName->setText(tr("Contact name"));
115-
ui->labelName->setProperty("cssClass", "text-title");
116-
117-
103+
setCssProperty(ui->labelName, "text-title");
118104
ui->lineEditName->setPlaceholderText(tr("e.g John doe "));
119105
setCssEditLine(ui->lineEditName, true);
120-
ui->lineEditName->setAttribute(Qt::WA_MacShowFocusRect, 0);
121-
setShadow(ui->lineEditName);
122-
123106

124107
// Address
125108
ui->labelAddress->setText(tr("Enter a PIVX address"));
126-
ui->labelAddress->setProperty("cssClass", "text-title");
109+
setCssProperty(ui->labelAddress, "text-title");
127110
ui->lineEditAddress->setPlaceholderText("e.g D7VFR83SQbiezrW72hjc…");
128111
setCssEditLine(ui->lineEditAddress, true);
129112
ui->lineEditAddress->setAttribute(Qt::WA_MacShowFocusRect, 0);
130113
setShadow(ui->lineEditAddress);
131114

132-
133115
// Buttons
134116
ui->btnSave->setText(tr("SAVE"));
135117
setCssBtnPrimary(ui->btnSave);
@@ -184,7 +166,6 @@ void AddressesWidget::onStoreContactClicked(){
184166
QString label = ui->lineEditName->text();
185167
QString address = ui->lineEditAddress->text();
186168

187-
// TODO: Update address status on text change..
188169
if (!walletModel->validateAddress(address)) {
189170
setCssEditLine(ui->lineEditAddress, false, true);
190171
inform(tr("Invalid Contact Address"));
@@ -212,7 +193,6 @@ void AddressesWidget::onStoreContactClicked(){
212193
} else {
213194
inform(tr("Error Storing Contact"));
214195
}
215-
216196
}
217197
}
218198

src/qt/pivx/dashboardwidget.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ DashboardWidget::DashboardWidget(PIVXGUI* parent) :
9595
ui->comboBoxSort->addItem("Amount");
9696
//ui->comboBoxSort->addItem("Sent");
9797
//ui->comboBoxSort->addItem("Received");
98-
connect(ui->comboBoxSort, SIGNAL(currentIndexChanged(const QString&)), this,SLOT(onSortChanged(const QString&)));
98+
connect(ui->comboBoxSort, SIGNAL(currentIndexChanged(const QString&)), this, SLOT(onSortChanged(const QString&)));
9999

100100
// transactions
101101
setCssProperty(ui->listTransactions, "container");
@@ -534,6 +534,7 @@ void DashboardWidget::refreshChart(){
534534
ui->containerBoxMonths->setVisible(true);
535535
break;
536536
}
537+
default: break;
537538
}
538539

539540
// Refresh years filter, first address created is the start

src/qt/pivx/forms/requestdialog.ui

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@
130130
</size>
131131
</property>
132132
<property name="text">
133-
<string>PushButton</string>
133+
<string/>
134134
</property>
135135
</widget>
136136
</item>

0 commit comments

Comments
 (0)