qt: General qt/c++ related fixes and updates (#3562)

* qt: Draw a border around net traffic graph

* qt: ReceiveRequestDialog - Improve QR code image

- Fix issue with bluriness
- Refine sizing/layout of QR code and address
- Adjust coloring to match the themes

* qt: Give the TransactionView's instantsendWidget a name

Required to access it in css

* qt: Rename conflicting label in SendCoinsDialog

- Was named the same as the the label in EditAddressDialog so it couldn't be accessed properly in css

* qt: Give the TransactionView's search field the first focus on startup

* qt: Some updates to the PrivateSend widget on the OverviewPage

- Hide denom labels if inactive
- Enable wordwrap for denom label
- Add some spacer
- Make sure it gets its basic initialization on startup

* qt: Fix some layout issues in SendCoinsDialog's UI file.

- Added some margins for fee selection radio buttons to align them centered to their options
- Removed a weird placed spacer

* qt: Fix vertical alignment of the two balance labels in SendCoinsDialog

* qt: Add newline in textedit of receiverequest

* qt: OptionsDialog - Hide override hint if there is nothing overridden

* qt: Allow stylesheet modifications for auto completition popup

- Inheritance doesn't work here obviously because of QCompleter is parent of the popup
- QStyledItemDelegate delegate is required. Without its not possible to access `::item` selectors from css.

* qt: Make the progress label in the status bar accessible in css

* qt: Update weekend colors of QCalendarWidget on style changes

Its obviously not possible to do this in stylesheets thats why i added
this as workaround.

* qt: Load stylesheets for Intro

This is the datadir selection dialog.

* Drop labelPrivateSendLastMessage

* Add a space

Co-authored-by: PastaPastaPasta <6443210+PastaPastaPasta@users.noreply.github.com>

Co-authored-by: UdjinM6 <UdjinM6@users.noreply.github.com>
Co-authored-by: PastaPastaPasta <6443210+PastaPastaPasta@users.noreply.github.com>
This commit is contained in:
dustinface 2020-07-20 17:01:11 +02:00 committed by GitHub
parent 415e504780
commit 354ff23c68
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
15 changed files with 165 additions and 77 deletions

View File

@ -216,6 +216,7 @@ BitcoinGUI::BitcoinGUI(const PlatformStyle *_platformStyle, const NetworkStyle *
// Progress bar and label for blocks download // Progress bar and label for blocks download
progressBarLabel = new QLabel(); progressBarLabel = new QLabel();
progressBarLabel->setVisible(true); progressBarLabel->setVisible(true);
progressBarLabel->setObjectName("lblStatusBarProgress");
progressBar = new GUIUtil::ProgressBar(); progressBar = new GUIUtil::ProgressBar();
progressBar->setAlignment(Qt::AlignCenter); progressBar->setAlignment(Qt::AlignCenter);
progressBar->setVisible(true); progressBar->setVisible(true);

View File

@ -475,6 +475,9 @@
<property name="text"> <property name="text">
<string>n/a</string> <string>n/a</string>
</property> </property>
<property name="wordWrap">
<bool>true</bool>
</property>
</widget> </widget>
</item> </item>
</layout> </layout>
@ -482,30 +485,63 @@
<item> <item>
<layout class="QVBoxLayout" name="VerticalLayout_PS"> <layout class="QVBoxLayout" name="VerticalLayout_PS">
<item> <item>
<widget class="QLabel" name="labelPrivateSendLastMessage"> <layout class="QHBoxLayout" name="horizontalLayout_3">
<property name="text"> <property name="topMargin">
<string>(Last Message)</string> <number>0</number>
</property> </property>
<property name="alignment"> <item>
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop</set> <spacer name="horizontalSpacer_5">
</property> <property name="orientation">
<property name="wordWrap"> <enum>Qt::Horizontal</enum>
<bool>true</bool> </property>
</property> <property name="sizeHint" stdset="0">
</widget> <size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QPushButton" name="togglePrivateSend">
<property name="sizePolicy">
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Start/Stop Mixing</string>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer_6">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout>
</item> </item>
<item> <item>
<widget class="QPushButton" name="togglePrivateSend"> <spacer name="verticalSpacer_3">
<property name="sizePolicy"> <property name="orientation">
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Fixed"> <enum>Qt::Vertical</enum>
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property> </property>
<property name="text"> <property name="sizeHint" stdset="0">
<string>Start/Stop Mixing</string> <size>
<width>20</width>
<height>40</height>
</size>
</property> </property>
</widget> </spacer>
</item> </item>
</layout> </layout>
</item> </item>

View File

@ -778,8 +778,11 @@
<property name="spacing"> <property name="spacing">
<number>6</number> <number>6</number>
</property> </property>
<property name="topMargin">
<number>3</number>
</property>
<item> <item>
<layout class="QHBoxLayout" name="horizontalLayoutFee13"> <layout class="QHBoxLayout" name="horizontalLayoutFee13" stretch="0,0,1">
<item> <item>
<widget class="QLabel" name="labelCustomPerKilobyte"> <widget class="QLabel" name="labelCustomPerKilobyte">
<property name="toolTip"> <property name="toolTip">
@ -855,6 +858,12 @@
</item> </item>
<item row="0" column="0"> <item row="0" column="0">
<layout class="QVBoxLayout" name="verticalLayoutFee4" stretch="0,1"> <layout class="QVBoxLayout" name="verticalLayoutFee4" stretch="0,1">
<property name="topMargin">
<number>20</number>
</property>
<property name="bottomMargin">
<number>3</number>
</property>
<item> <item>
<widget class="QRadioButton" name="radioSmartFee"> <widget class="QRadioButton" name="radioSmartFee">
<property name="text"> <property name="text">
@ -885,6 +894,9 @@
</item> </item>
<item row="1" column="0"> <item row="1" column="0">
<layout class="QVBoxLayout" name="verticalLayoutFee9" stretch="0,1"> <layout class="QVBoxLayout" name="verticalLayoutFee9" stretch="0,1">
<property name="topMargin">
<number>30</number>
</property>
<item> <item>
<widget class="QRadioButton" name="radioCustomFee"> <widget class="QRadioButton" name="radioCustomFee">
<property name="text"> <property name="text">
@ -916,7 +928,10 @@
<number>6</number> <number>6</number>
</property> </property>
<property name="topMargin"> <property name="topMargin">
<number>2</number> <number>0</number>
</property>
<property name="bottomMargin">
<number>3</number>
</property> </property>
<item> <item>
<layout class="QHBoxLayout" name="horizontalLayoutFee12"> <layout class="QHBoxLayout" name="horizontalLayoutFee12">
@ -976,19 +991,6 @@
</property> </property>
</widget> </widget>
</item> </item>
<item>
<spacer name="verticalSpacer_3">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>1</width>
<height>1</height>
</size>
</property>
</spacer>
</item>
</layout> </layout>
</item> </item>
<item> <item>
@ -1136,7 +1138,7 @@
<number>3</number> <number>3</number>
</property> </property>
<item> <item>
<widget class="QLabel" name="label"> <widget class="QLabel" name="labelBalanceText">
<property name="text"> <property name="text">
<string>Balance:</string> <string>Balance:</string>
</property> </property>
@ -1145,7 +1147,7 @@
<item> <item>
<widget class="QLabel" name="labelBalance"> <widget class="QLabel" name="labelBalance">
<property name="sizePolicy"> <property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Fixed"> <sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<horstretch>0</horstretch> <horstretch>0</horstretch>
<verstretch>0</verstretch> <verstretch>0</verstretch>
</sizepolicy> </sizepolicy>

View File

@ -206,6 +206,7 @@ bool Intro::pickDataDirectory()
/* Let the user choose one */ /* Let the user choose one */
Intro intro; Intro intro;
GUIUtil::disableMacFocusRect(&intro); GUIUtil::disableMacFocusRect(&intro);
GUIUtil::loadStyleSheet(&intro);
intro.setDataDirectory(dataDirDefaultCurrent); intro.setDataDirectory(dataDirDefaultCurrent);
intro.setWindowIcon(QIcon(":icons/bitcoin")); intro.setWindowIcon(QIcon(":icons/bitcoin"));

View File

@ -167,9 +167,11 @@ void OptionsDialog::setModel(OptionsModel *_model)
showRestartWarning(true); showRestartWarning(true);
QString strLabel = _model->getOverriddenByCommandLine(); QString strLabel = _model->getOverriddenByCommandLine();
if (strLabel.isEmpty()) if (strLabel.isEmpty()) {
strLabel = tr("none"); ui->frame->setHidden(true);
ui->overriddenByCommandLineLabel->setText(strLabel); } else {
ui->overriddenByCommandLineLabel->setText(strLabel);
}
mapper->setModel(_model); mapper->setModel(_model);
setMapper(); setMapper();

View File

@ -305,6 +305,9 @@ void OverviewPage::setWalletModel(WalletModel *model)
// explicitly update PS frame and transaction list to reflect actual settings // explicitly update PS frame and transaction list to reflect actual settings
updateAdvancedPSUI(model->getOptionsModel()->getShowAdvancedPSUI()); updateAdvancedPSUI(model->getOptionsModel()->getShowAdvancedPSUI());
// Initialize PS UI
privateSendStatus(true);
if(!privateSendClient.fEnablePrivateSend) return; if(!privateSendClient.fEnablePrivateSend) return;
connect(model->getOptionsModel(), SIGNAL(privateSendRoundsChanged()), this, SLOT(updatePrivateSendProgress())); connect(model->getOptionsModel(), SIGNAL(privateSendRoundsChanged()), this, SLOT(updatePrivateSendProgress()));
@ -467,15 +470,23 @@ void OverviewPage::updateAdvancedPSUI(bool fShowAdvancedPSUI) {
ui->privateSendProgress->setVisible(fShowAdvancedPSUI); ui->privateSendProgress->setVisible(fShowAdvancedPSUI);
ui->labelSubmittedDenomText->setVisible(fShowAdvancedPSUI); ui->labelSubmittedDenomText->setVisible(fShowAdvancedPSUI);
ui->labelSubmittedDenom->setVisible(fShowAdvancedPSUI); ui->labelSubmittedDenom->setVisible(fShowAdvancedPSUI);
ui->labelPrivateSendLastMessage->setVisible(fShowAdvancedPSUI);
} }
void OverviewPage::privateSendStatus() void OverviewPage::privateSendStatus(bool fForce)
{ {
if(!masternodeSync.IsBlockchainSynced() || ShutdownRequested()) return; if (!fForce && (!masternodeSync.IsBlockchainSynced() || ShutdownRequested())) return;
if(!walletModel) return; if(!walletModel) return;
auto tempWidgets = {ui->labelSubmittedDenomText,
ui->labelSubmittedDenom};
auto setWidgetsVisible = [&](bool fVisible) {
for (const auto& it : tempWidgets) {
it->setVisible(fVisible);
}
};
static int64_t nLastDSProgressBlockTime = 0; static int64_t nLastDSProgressBlockTime = 0;
int nBestHeight = clientModel->getNumBlocks(); int nBestHeight = clientModel->getNumBlocks();
@ -495,7 +506,7 @@ void OverviewPage::privateSendStatus()
updatePrivateSendProgress(); updatePrivateSendProgress();
} }
ui->labelPrivateSendLastMessage->setText(""); setWidgetsVisible(false);
ui->togglePrivateSend->setText(tr("Start Mixing")); ui->togglePrivateSend->setText(tr("Start Mixing"));
QString strEnabled = tr("Disabled"); QString strEnabled = tr("Disabled");
@ -574,14 +585,7 @@ void OverviewPage::privateSendStatus()
updatePrivateSendProgress(); updatePrivateSendProgress();
} }
QString strStatus = QString(privateSendClient.GetStatuses().c_str()); setWidgetsVisible(true);
QString s = tr("Last PrivateSend message:\n") + strStatus;
if(s != ui->labelPrivateSendLastMessage->text())
LogPrint(BCLog::PRIVATESEND, "OverviewPage::privateSendStatus -- Last PrivateSend message: %s\n", strStatus.toStdString());
ui->labelPrivateSendLastMessage->setText(s);
ui->labelSubmittedDenom->setText(QString(privateSendClient.GetSessionDenoms().c_str())); ui->labelSubmittedDenom->setText(QString(privateSendClient.GetSessionDenoms().c_str()));
} }

View File

@ -38,7 +38,7 @@ public:
void showOutOfSyncWarning(bool fShow); void showOutOfSyncWarning(bool fShow);
public Q_SLOTS: public Q_SLOTS:
void privateSendStatus(); void privateSendStatus(bool fForce = false);
void setBalance(const CAmount& balance, const CAmount& unconfirmedBalance, const CAmount& immatureBalance, const CAmount& anonymizedBalance, void setBalance(const CAmount& balance, const CAmount& unconfirmedBalance, const CAmount& immatureBalance, const CAmount& anonymizedBalance,
const CAmount& watchOnlyBalance, const CAmount& watchUnconfBalance, const CAmount& watchImmatureBalance); const CAmount& watchOnlyBalance, const CAmount& watchUnconfBalance, const CAmount& watchImmatureBalance);

View File

@ -137,7 +137,7 @@ void ReceiveRequestDialog::update()
ui->btnSaveAs->setEnabled(false); ui->btnSaveAs->setEnabled(false);
QString html; QString html;
html += "<html>"; html += "<html>";
html += "<b>"+tr("Payment information")+"</b><br>"; html += "<b>" + tr("Payment information") + "</b><br><br>";
html += "<b>"+tr("URI")+"</b>: "; html += "<b>"+tr("URI")+"</b>: ";
html += QString("<a style=\"%1\"href=\"").arg(GUIUtil::getThemedStyleQString(GUIUtil::ThemedStyle::TS_COMMAND)) + html += QString("<a style=\"%1\"href=\"").arg(GUIUtil::getThemedStyleQString(GUIUtil::ThemedStyle::TS_COMMAND)) +
uri + "\">" + GUIUtil::HtmlEscape(uri) + "</a><br>"; uri + "\">" + GUIUtil::HtmlEscape(uri) + "</a><br>";
@ -165,34 +165,39 @@ void ReceiveRequestDialog::update()
ui->lblQRCode->setText(tr("Error encoding URI into QR Code.")); ui->lblQRCode->setText(tr("Error encoding URI into QR Code."));
return; return;
} }
QImage qrImage = QImage(code->width + 8, code->width + 8, QImage::Format_RGB32); QImage qrImage = QImage(code->width + 6, code->width + 6, QImage::Format_RGB32);
qrImage.fill(GUIUtil::getThemedQColor(GUIUtil::ThemedColor::BACKGROUND_WIDGET)); qrImage.fill(GUIUtil::getThemedQColor(GUIUtil::ThemedColor::BACKGROUND_WIDGET));
unsigned char *p = code->data; unsigned char *p = code->data;
for (int y = 0; y < code->width; y++) for (int y = 0; y < code->width; y++)
{ {
for (int x = 0; x < code->width; x++) for (int x = 0; x < code->width; x++)
{ {
qrImage.setPixel(x + 4, y + 4, ((*p & 1) ? GUIUtil::getThemedQColor(GUIUtil::ThemedColor::QR_PIXEL).rgb() : GUIUtil::getThemedQColor(GUIUtil::ThemedColor::BACKGROUND_WIDGET).rgb())); qrImage.setPixel(x + 3, y + 3, ((*p & 1) ? GUIUtil::getThemedQColor(GUIUtil::ThemedColor::QR_PIXEL).rgb() : GUIUtil::getThemedQColor(GUIUtil::ThemedColor::BACKGROUND_WIDGET).rgb()));
p++; p++;
} }
} }
QRcode_free(code); QRcode_free(code);
// Create the image with respect to the device pixel ratio
QImage qrAddrImage = QImage(QR_IMAGE_SIZE, QR_IMAGE_SIZE+20, QImage::Format_RGB32); int qrAddrImageWidth = QR_IMAGE_SIZE;
qrAddrImage.fill(GUIUtil::getThemedQColor(GUIUtil::ThemedColor::BORDER_WIDGET)); int qrAddrImageHeight = QR_IMAGE_SIZE + 20;
qreal scale = qApp->devicePixelRatio();
QImage qrAddrImage = QImage(qrAddrImageWidth * scale, qrAddrImageHeight * scale, QImage::Format_RGB32);
qrAddrImage.setDevicePixelRatio(scale);
QPainter painter(&qrAddrImage); QPainter painter(&qrAddrImage);
QRect paddedRect = qrAddrImage.rect().adjusted(1, 1, -1, -1); // Fill the whole image with border color
qrAddrImage.fill(GUIUtil::getThemedQColor(GUIUtil::ThemedColor::BORDER_WIDGET));
// Create a 2px/2px smaller rect and fill it with background color to keep the 1px border with the border color
QRect paddedRect = QRect(1, 1, qrAddrImageWidth - 2, qrAddrImageHeight - 2);
painter.fillRect(paddedRect, GUIUtil::getThemedQColor(GUIUtil::ThemedColor::BACKGROUND_WIDGET)); painter.fillRect(paddedRect, GUIUtil::getThemedQColor(GUIUtil::ThemedColor::BACKGROUND_WIDGET));
painter.drawImage(1, 1, qrImage.scaled(QR_IMAGE_SIZE - 2, QR_IMAGE_SIZE - 2)); painter.drawImage(2, 2, qrImage.scaled(QR_IMAGE_SIZE - 4, QR_IMAGE_SIZE - 4));
QFont font = GUIUtil::fixedPitchFont();
// calculate ideal font size // calculate ideal font size
qreal font_size = GUIUtil::calculateIdealFontSize(paddedRect.width() - 20, info.address, font); QFont font = GUIUtil::fixedPitchFont();
qreal font_size = GUIUtil::calculateIdealFontSize((paddedRect.width() - 20), info.address, font);
font.setPointSizeF(font_size); font.setPointSizeF(font_size);
// paint the address
painter.setFont(font); painter.setFont(font);
paddedRect.setHeight(QR_IMAGE_SIZE);
painter.setPen(GUIUtil::getThemedQColor(GUIUtil::ThemedColor::QR_PIXEL)); painter.setPen(GUIUtil::getThemedQColor(GUIUtil::ThemedColor::QR_PIXEL));
paddedRect.setHeight(QR_IMAGE_SIZE + 3);
painter.drawText(paddedRect, Qt::AlignBottom|Qt::AlignCenter, info.address); painter.drawText(paddedRect, Qt::AlignBottom|Qt::AlignCenter, info.address);
painter.end(); painter.end();

View File

@ -1482,12 +1482,6 @@ QWidget .QFrame#framePrivateSend .QWidget#layoutWidgetLastMessageAndButtons {
max-width: 451px; max-width: 451px;
} }
QWidget .QFrame#framePrivateSend .QLabel#labelPrivateSendLastMessage { /* PrivateSend Status Notifications */
qproperty-alignment: 'AlignVCenter | AlignLeft';
min-width: 288px;
min-height: 50px;
}
QWidget .QFrame#framePrivateSend .QPushButton#togglePrivateSend { /* Start PrivateSend Mixing */ QWidget .QFrame#framePrivateSend .QPushButton#togglePrivateSend { /* Start PrivateSend Mixing */
margin-top: 5px; margin-top: 5px;
} }

View File

@ -39,6 +39,7 @@
#include <QTime> #include <QTime>
#include <QTimer> #include <QTimer>
#include <QStringList> #include <QStringList>
#include <QStyledItemDelegate>
// TODO: add a scrollback limit, as there is currently none // TODO: add a scrollback limit, as there is currently none
// TODO: make it possible to filter out categories (esp debug messages when implemented) // TODO: make it possible to filter out categories (esp debug messages when implemented)
@ -717,6 +718,9 @@ void RPCConsole::setClientModel(ClientModel *model)
wordList << "help-console"; wordList << "help-console";
wordList.sort(); wordList.sort();
autoCompleter = new QCompleter(wordList, this); autoCompleter = new QCompleter(wordList, this);
autoCompleter->popup()->setItemDelegate(new QStyledItemDelegate(this));
autoCompleter->popup()->setObjectName("rpcAutoCompleter");
GUIUtil::loadStyleSheet(autoCompleter->popup());
autoCompleter->setModelSorting(QCompleter::CaseSensitivelySortedModel); autoCompleter->setModelSorting(QCompleter::CaseSensitivelySortedModel);
ui->lineEdit->setCompleter(autoCompleter); ui->lineEdit->setCompleter(autoCompleter);
autoCompleter->popup()->installEventFilter(this); autoCompleter->popup()->installEventFilter(this);

View File

@ -78,7 +78,7 @@ SendCoinsDialog::SendCoinsDialog(const PlatformStyle *_platformStyle, QWidget *p
}, GUIUtil::FontWeight::Bold); }, GUIUtil::FontWeight::Bold);
GUIUtil::setFont({ui->labelBalance, GUIUtil::setFont({ui->labelBalance,
ui->label ui->labelBalanceText
}, GUIUtil::FontWeight::Bold, 14); }, GUIUtil::FontWeight::Bold, 14);
GUIUtil::setFont({ui->labelCoinControlFeatures GUIUtil::setFont({ui->labelCoinControlFeatures

View File

@ -185,11 +185,11 @@ void TestGUI()
QString paymentText = rlist->toPlainText(); QString paymentText = rlist->toPlainText();
QStringList paymentTextList = paymentText.split('\n'); QStringList paymentTextList = paymentText.split('\n');
QCOMPARE(paymentTextList.at(0), QString("Payment information")); QCOMPARE(paymentTextList.at(0), QString("Payment information"));
QVERIFY(paymentTextList.at(1).indexOf(QString("URI: dash:")) != -1); QVERIFY(paymentTextList.at(2).indexOf(QString("URI: dash:")) != -1);
QVERIFY(paymentTextList.at(2).indexOf(QString("Address:")) != -1); QVERIFY(paymentTextList.at(3).indexOf(QString("Address:")) != -1);
QCOMPARE(paymentTextList.at(3), QString("Amount: 0.00000001 ") + BitcoinUnits::name(unit)); QCOMPARE(paymentTextList.at(4), QString("Amount: 0.00000001 ") + BitcoinUnits::name(unit));
QCOMPARE(paymentTextList.at(4), QString("Label: TEST_LABEL_1")); QCOMPARE(paymentTextList.at(5), QString("Label: TEST_LABEL_1"));
QCOMPARE(paymentTextList.at(5), QString("Message: TEST_MESSAGE_1")); QCOMPARE(paymentTextList.at(6), QString("Message: TEST_MESSAGE_1"));
} }
} }

View File

@ -79,6 +79,9 @@ void TrafficGraphWidget::paintEvent(QPaintEvent *)
{ {
QPainter painter(this); QPainter painter(this);
QRect drawRect = rect(); QRect drawRect = rect();
// First draw the border
painter.fillRect(drawRect, GUIUtil::getThemedQColor(GUIUtil::ThemedColor::BORDER_WIDGET));
drawRect.adjust(1, 1, -1, -1);
painter.fillRect(drawRect, GUIUtil::getThemedQColor(GUIUtil::ThemedColor::BACKGROUND_WIDGET)); painter.fillRect(drawRect, GUIUtil::getThemedQColor(GUIUtil::ThemedColor::BACKGROUND_WIDGET));
if(fMax <= 0.0f) return; if(fMax <= 0.0f) return;

View File

@ -19,6 +19,7 @@
#include <ui_interface.h> #include <ui_interface.h>
#include <QCalendarWidget>
#include <QComboBox> #include <QComboBox>
#include <QDateTimeEdit> #include <QDateTimeEdit>
#include <QDesktopServices> #include <QDesktopServices>
@ -33,6 +34,7 @@
#include <QSettings> #include <QSettings>
#include <QSignalMapper> #include <QSignalMapper>
#include <QTableView> #include <QTableView>
#include <QTextCharFormat>
#include <QTimer> #include <QTimer>
#include <QUrl> #include <QUrl>
#include <QVBoxLayout> #include <QVBoxLayout>
@ -69,6 +71,7 @@ TransactionView::TransactionView(const PlatformStyle *platformStyle, QWidget *pa
instantsendWidget->addItem(tr("All"), TransactionFilterProxy::InstantSendFilter_All); instantsendWidget->addItem(tr("All"), TransactionFilterProxy::InstantSendFilter_All);
instantsendWidget->addItem(tr("Locked by InstantSend"), TransactionFilterProxy::InstantSendFilter_Yes); instantsendWidget->addItem(tr("Locked by InstantSend"), TransactionFilterProxy::InstantSendFilter_Yes);
instantsendWidget->addItem(tr("Not locked by InstantSend"), TransactionFilterProxy::InstantSendFilter_No); instantsendWidget->addItem(tr("Not locked by InstantSend"), TransactionFilterProxy::InstantSendFilter_No);
instantsendWidget->setObjectName("instantsendWidget");
hlayout->addWidget(instantsendWidget); hlayout->addWidget(instantsendWidget);
dateWidget = new QComboBox(this); dateWidget = new QComboBox(this);
@ -645,9 +648,25 @@ QWidget *TransactionView::createDateRangeWidget()
connect(dateFrom, SIGNAL(dateChanged(QDate)), this, SLOT(dateRangeChanged())); connect(dateFrom, SIGNAL(dateChanged(QDate)), this, SLOT(dateRangeChanged()));
connect(dateTo, SIGNAL(dateChanged(QDate)), this, SLOT(dateRangeChanged())); connect(dateTo, SIGNAL(dateChanged(QDate)), this, SLOT(dateRangeChanged()));
updateCalendarWidgets();
return dateRangeWidget; return dateRangeWidget;
} }
void TransactionView::updateCalendarWidgets()
{
auto adjustWeekEndColors = [](QCalendarWidget* w) {
QTextCharFormat format = w->weekdayTextFormat(Qt::Saturday);
format.setForeground(QBrush(GUIUtil::getThemedQColor(GUIUtil::ThemedColor::DEFAULT), Qt::SolidPattern));
w->setWeekdayTextFormat(Qt::Saturday, format);
w->setWeekdayTextFormat(Qt::Sunday, format);
};
adjustWeekEndColors(dateFrom->calendarWidget());
adjustWeekEndColors(dateTo->calendarWidget());
}
void TransactionView::dateRangeChanged() void TransactionView::dateRangeChanged()
{ {
if(!transactionProxyModel) if(!transactionProxyModel)
@ -709,6 +728,13 @@ void TransactionView::resizeEvent(QResizeEvent* event)
columnResizingFixer->stretchColumnWidth(TransactionTableModel::ToAddress); columnResizingFixer->stretchColumnWidth(TransactionTableModel::ToAddress);
} }
void TransactionView::changeEvent(QEvent* e)
{
if (e->type() == QEvent::StyleChange) {
updateCalendarWidgets();
}
}
// Need to override default Ctrl+C action for amount as default behaviour is just to copy DisplayRole text // Need to override default Ctrl+C action for amount as default behaviour is just to copy DisplayRole text
bool TransactionView::eventFilter(QObject *obj, QEvent *event) bool TransactionView::eventFilter(QObject *obj, QEvent *event)
{ {
@ -721,6 +747,14 @@ bool TransactionView::eventFilter(QObject *obj, QEvent *event)
return true; return true;
} }
} }
if (event->type() == QEvent::Show) {
// Give the search field the first focus on startup
static bool fGotFirstFocus = false;
if (!fGotFirstFocus) {
search_widget->setFocus();
fGotFirstFocus = true;
}
}
return QWidget::eventFilter(obj, event); return QWidget::eventFilter(obj, event);
} }

View File

@ -82,10 +82,12 @@ private:
QAction *abandonAction; QAction *abandonAction;
QWidget *createDateRangeWidget(); QWidget *createDateRangeWidget();
void updateCalendarWidgets();
GUIUtil::TableViewLastColumnResizingFixer *columnResizingFixer; GUIUtil::TableViewLastColumnResizingFixer *columnResizingFixer;
virtual void resizeEvent(QResizeEvent* event) override; virtual void resizeEvent(QResizeEvent* event) override;
void changeEvent(QEvent* e) override;
bool eventFilter(QObject *obj, QEvent *event) override; bool eventFilter(QObject *obj, QEvent *event) override;