From 017abec2771b053d088ece9b85aff7d4cc267adb Mon Sep 17 00:00:00 2001 From: firstcryptoman Date: Wed, 15 May 2024 22:41:25 +0400 Subject: [PATCH] Bug fixes and dynamic text scaling --- src/qt/bitcoingui.cpp | 2 +- src/qt/overviewpage.cpp | 70 ++++++++++++++++++++++++------- src/qt/overviewpage.h | 2 +- src/qt/receivecoinsdialog.cpp | 28 ++++++++++++- src/qt/receivecoinsdialog.h | 2 +- src/qt/sendcoinsdialog.cpp | 78 ++++++++++++++++++++++++++++++++++- src/qt/sendcoinsdialog.h | 3 ++ 7 files changed, 165 insertions(+), 20 deletions(-) diff --git a/src/qt/bitcoingui.cpp b/src/qt/bitcoingui.cpp index 58a4f0d5b4..b07dbbfe66 100644 --- a/src/qt/bitcoingui.cpp +++ b/src/qt/bitcoingui.cpp @@ -1492,7 +1492,7 @@ void BitcoinGUI::resizeEvent(QResizeEvent* event) { QWidget* masternodeWidget = toolbar->widgetForAction(masternodeAction); overviewWidget->setMinimumWidth(actionWidth); - receiveWidget->setFixedWidth(actionWidth); + receiveWidget->setMinimumWidth(actionWidth); historyWidget->setMinimumWidth(actionWidth); sendCoinsWidget->setMinimumWidth(actionWidth); masternodeWidget->setMinimumWidth(actionWidth); diff --git a/src/qt/overviewpage.cpp b/src/qt/overviewpage.cpp index 7d0c703676..225aa2341b 100644 --- a/src/qt/overviewpage.cpp +++ b/src/qt/overviewpage.cpp @@ -476,8 +476,6 @@ bool MigrateLelantusToSparkDialog::getClickedButton() { return clickedButton; } - -// Handles resize events for the OverviewPage widget by adjusting internal component sizes. void OverviewPage::resizeEvent(QResizeEvent* event) { QWidget::resizeEvent(event); @@ -485,12 +483,12 @@ void OverviewPage::resizeEvent(QResizeEvent* event) // Retrieve new dimensions from the resize event int newWidth = event->size().width(); int newHeight = event->size().height(); - + adjustTextSize(newWidth, newHeight); // Determine widths for specific widgets as percentages of total width - int labelWidth = newWidth * 0.5; - int labelMinWidth = newWidth * 0.15; - int labelMaxWidth = newWidth * 0.35; - const int labelHeight = 20; + int labelWidth = static_cast(newWidth * 0.5); + int labelMinWidth = static_cast(newWidth * 0.15); + int labelMaxWidth = static_cast(newWidth * 0.35); + const int labelHeight = 20; // Configure the dimensions and constraints of each widget ui->labelBalance->setFixedWidth(labelWidth); @@ -503,15 +501,57 @@ void OverviewPage::resizeEvent(QResizeEvent* event) ui->labelUnconfirmed->setMaximumWidth(labelMaxWidth); ui->labelUnconfirmed->setFixedHeight(labelHeight); - int buttonWidth = newWidth * 0.15; - int buttonMinWidth = newWidth * 0.15; - int buttonMaxWidth = newWidth * 0.4; - int buttonHeight = newHeight * 0.05; - int buttonMinHeight = 20; - int buttonMaxHeight = 45; + int buttonWidth = static_cast(newWidth * 0.15); + int buttonHeight = static_cast(newHeight * 0.05); + int buttonMinHeight = static_cast(20); + int buttonMaxHeight = static_cast(45); - ui->anonymizeButton->setMinimumWidth(buttonMinWidth); - ui->anonymizeButton->setMaximumWidth(buttonMaxWidth); + ui->anonymizeButton->setMinimumWidth(buttonWidth); + ui->anonymizeButton->setMaximumWidth(buttonWidth * 2); ui->anonymizeButton->setMinimumHeight(buttonMinHeight); ui->anonymizeButton->setMaximumHeight(buttonMaxHeight); } +void OverviewPage::adjustTextSize(int width, int height){ + + int baseFontSize = std::max(12, std::min(width, height) / 60); + + // Font for regular text components + QFont textFont = ui->labelBalance->font();; + textFont.setPointSize(baseFontSize); + + // Font for labels, smaller than the text font size + QFont labelFont = font(); + labelFont.setPointSize(int(baseFontSize * 0.9)); + + ui->textWarning1->setFont(labelFont); + ui->textWarning2->setFont(labelFont); + ui->labelWalletStatus->setFont(labelFont); + ui->anonymizeButton->setFont(labelFont); + + // Apply label font to all label components + ui->labelAlerts->setFont(textFont); + ui->label_5->setFont(textFont); + ui->labelAnonymizableText->setFont(labelFont); + ui->label->setFont(textFont); + ui->labelAnonymizable->setFont(textFont); + ui->labelWatchPending->setFont(textFont); + ui->labelBalance->setFont(textFont); + ui->labelSpendable->setFont(textFont); + ui->labelWatchAvailable->setFont(textFont); + ui->labelPendingText->setFont(labelFont); + ui->labelUnconfirmedPrivate->setFont(textFont); + ui->labelUnconfirmedPrivateText->setFont(labelFont); + ui->labelTotalText->setFont(labelFont); + ui->labelWatchonly->setFont(textFont); + ui->labelBalanceText->setFont(labelFont); + ui->labelTotal->setFont(textFont); + ui->labelWatchTotal->setFont(textFont); + ui->labelUnconfirmed->setFont(textFont); + ui->labelImmatureText->setFont(labelFont); + ui->labelImmature->setFont(textFont); + ui->labelWatchImmature->setFont(textFont); + ui->labelPrivateText->setFont(labelFont); + ui->labelPrivate->setFont(textFont); + ui->label_4->setFont(textFont); + +} \ No newline at end of file diff --git a/src/qt/overviewpage.h b/src/qt/overviewpage.h index 822dfe6a79..9d98949962 100644 --- a/src/qt/overviewpage.h +++ b/src/qt/overviewpage.h @@ -95,7 +95,7 @@ public Q_SLOTS: QString lelantusGracefulPeriod; QString currentBlock; QString migrateAmount; - + void adjustTextSize(int width,int height); private Q_SLOTS: void updateDisplayUnit(); void handleTransactionClicked(const QModelIndex &index); diff --git a/src/qt/receivecoinsdialog.cpp b/src/qt/receivecoinsdialog.cpp index e70c4eb915..744f53c199 100644 --- a/src/qt/receivecoinsdialog.cpp +++ b/src/qt/receivecoinsdialog.cpp @@ -371,7 +371,7 @@ void ReceiveCoinsDialog::resizeEvent(QResizeEvent* event) // Get new size from the event int newWidth = event->size().width(); int newHeight = event->size().height(); - + adjustTextSize(newWidth,newHeight); // Set fixed, minimum, and maximum sizes for ComboBoxes int comboBoxMinHeight = 20; int comboBoxMaxHeight = 40; @@ -426,4 +426,30 @@ void ReceiveCoinsDialog::resizeEvent(QResizeEvent* event) ui->recentRequestsView->setColumnWidth(RecentRequestsTableModel::Label, labelColumnWidth); ui->recentRequestsView->setColumnWidth(RecentRequestsTableModel::AddressType, addressTypeColumnWidth); ui->recentRequestsView->setColumnWidth(RecentRequestsTableModel::Amount, amountColumnWidth); +} +void ReceiveCoinsDialog::adjustTextSize(int width,int height){ + + int fontSize = std::max(12, std::min(width, height) / 60); + QFont font = this->font(); + font.setPointSize(fontSize); + + // Set font size for all labels + ui->reuseAddress->setFont(font); + ui->label_4->setFont(font); + ui->label_3->setFont(font); + ui->addressTypeLabel->setFont(font); + ui->label_5->setFont(font); + ui->label_2->setFont(font); + ui->label->setFont(font); + ui->label_7->setFont(font); + ui->label_6->setFont(font); + ui->receiveButton->setFont(font); + ui->clearButton->setFont(font); + ui->showRequestButton->setFont(font); + ui->removeRequestButton->setFont(font); + ui->addressTypeCombobox->setFont(font); + ui->addressTypeHistoryCombobox->setFont(font); + ui->recentRequestsView->setFont(font); + ui->recentRequestsView->horizontalHeader()->setFont(font); + ui->recentRequestsView->verticalHeader()->setFont(font); } \ No newline at end of file diff --git a/src/qt/receivecoinsdialog.h b/src/qt/receivecoinsdialog.h index 8ac92b0148..0f23f53a4e 100644 --- a/src/qt/receivecoinsdialog.h +++ b/src/qt/receivecoinsdialog.h @@ -80,7 +80,7 @@ public Q_SLOTS: QModelIndex selectedRow(); void copyColumnToClipboard(int column); RecentRequestsFilterProxy *recentRequestsProxyModel; - + void adjustTextSize(int width,int height); private Q_SLOTS: void on_receiveButton_clicked(); void on_showRequestButton_clicked(); diff --git a/src/qt/sendcoinsdialog.cpp b/src/qt/sendcoinsdialog.cpp index 8880bf0af7..723d502cf1 100644 --- a/src/qt/sendcoinsdialog.cpp +++ b/src/qt/sendcoinsdialog.cpp @@ -1277,4 +1277,80 @@ void SendGoPrivateDialog::onGoPrivateClicked() bool SendGoPrivateDialog::getClickedButton() { return clickedButton; -} \ No newline at end of file +} +void SendCoinsDialog::resizeEvent(QResizeEvent* event) { + QWidget::resizeEvent(event); + + // Retrieve new dimensions from the resize event + int newWidth = event->size().width(); + int newHeight = event->size().height(); + + int labelMinWidth = static_cast(newWidth * 0.15); + + // Resize and adjust components + ui->sendButton->setMinimumWidth(labelMinWidth); + ui->clearButton->setMinimumWidth(labelMinWidth); + ui->addButton->setMinimumWidth(labelMinWidth); + ui->buttonChooseFee->setMinimumWidth(labelMinWidth); + ui->buttonMinimizeFee->setMinimumWidth(labelMinWidth); + ui->switchFundButton->setMinimumWidth(labelMinWidth); + + + // Dynamically adjust text sizes based on the new dimensions + adjustTextSize(newWidth, newHeight); +} + +void SendCoinsDialog::adjustTextSize(int width, int height) { + int baseFontSize = std::max(12, std::min(width, height) / 60); + + QFont font = this->font(); + font.setPointSize(baseFontSize); + + // Set font size for all labels + ui->labelBalance->setFont(font); + ui->labelCoinControlAmount->setFont(font); + ui->labelFeeEstimation->setFont(font); + ui->labelFeeHeadline->setFont(font); + ui->labelCoinControlFeatures->setFont(font); + ui->labelCoinControlAutomaticallySelected->setFont(font); + ui->labelCoinControlInsuffFunds->setFont(font); + ui->labelCoinControlQuantity->setFont(font); + ui->labelCoinControlBytes->setFont(font); + ui->labelCoinControlAmount->setFont(font); + ui->labelCoinControlLowOutput->setFont(font); + ui->labelCoinControlFee->setFont(font); + ui->labelCoinControlAfterFee->setFont(font); + ui->labelCoinControlChange->setFont(font); + ui->labelFeeMinimized->setFont(font); + ui->labelBalance->setFont(font); + ui->radioSmartFee->setFont(font); + ui->radioCustomPerKilobyte->setFont(font); + ui->radioCustomFee->setFont(font); + ui->radioCustomAtLeast->setFont(font); + ui->labelBalanceText->setFont(font); + ui->labelFeeEstimation->setFont(font); + ui->labelSmartFee->setFont(font); + ui->labelSmartFee2->setFont(font); + ui->labelSmartFee3->setFont(font); + ui->labelSmartFeeNormal->setFont(font); + ui->labelSmartFeeFast->setFont(font); + ui->labelCoinControlQuantityText->setFont(font); + ui->labelCoinControlBytesText->setFont(font); + ui->labelCoinControlAmountText->setFont(font); + ui->labelCoinControlLowOutputText->setFont(font); + ui->labelCoinControlFeeText->setFont(font); + ui->labelCoinControlAfterFeeText->setFont(font); + ui->labelCoinControlChangeText->setFont(font); + ui->labelCoinControlChangeLabel->setFont(font); + ui->labelMinFeeWarning->setFont(font); + ui->fallbackFeeWarningLabel->setFont(font); + ui->checkBoxMinimumFee->setFont(font); + ui->checkBoxCoinControlChange->setFont(font); + + // Adjust font for all buttons + ui->sendButton->setFont(font); + ui->clearButton->setFont(font); + ui->addButton->setFont(font); + ui->pushButtonCoinControl->setFont(font); + ui->customFee->setFont(font); +} diff --git a/src/qt/sendcoinsdialog.h b/src/qt/sendcoinsdialog.h index 7656627a55..3215028143 100644 --- a/src/qt/sendcoinsdialog.h +++ b/src/qt/sendcoinsdialog.h @@ -67,6 +67,8 @@ public Q_SLOTS: bool fFeeMinimized; bool fAnonymousMode; const PlatformStyle *platformStyle; + void resizeEvent(QResizeEvent* event); + void adjustTextSize(int width, int height); // Process WalletModel::SendCoinsReturn and generate a pair consisting // of a message and message flags for use in Q_EMIT message(). @@ -125,6 +127,7 @@ private Q_SLOTS: QAbstractButton *yesButton; QTimer countDownTimer; int secDelay; + }; class SendGoPrivateDialog : public QMessageBox