From 32aa0070f7ae97454afd3e1ab9d1139c068b4f6c Mon Sep 17 00:00:00 2001 From: firstcryptoman Date: Mon, 29 Apr 2024 02:03:15 +0400 Subject: [PATCH 1/8] Implement qt scaling fixes --- src/qt/overviewpage.cpp | 41 ++++++++++++++++++++- src/qt/overviewpage.h | 6 +++ src/qt/receivecoinsdialog.cpp | 66 +++++++++++++++++++++++++++++++++ src/qt/receivecoinsdialog.h | 5 ++- src/qt/transactionview.cpp | 69 +++++++++++++++++++++++++++++++++++ src/qt/transactionview.h | 3 +- 6 files changed, 187 insertions(+), 3 deletions(-) diff --git a/src/qt/overviewpage.cpp b/src/qt/overviewpage.cpp index ea0d1a7b12..e6a1464e57 100644 --- a/src/qt/overviewpage.cpp +++ b/src/qt/overviewpage.cpp @@ -475,4 +475,43 @@ void MigrateLelantusToSparkDialog::onMigrateClicked() bool MigrateLelantusToSparkDialog::getClickedButton() { return clickedButton; -} \ No newline at end of file +} + +// Handles resize events for the OverviewPage widget by adjusting internal component sizes. +void OverviewPage::resizeEvent(QResizeEvent* event) +{ + QWidget::resizeEvent(event); + + // Retrieve new dimensions from the resize event + int newWidth = event->size().width(); + int newHeight = event->size().height(); + + // 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; + + // Configure the dimensions and constraints of each widget + ui->labelBalance->setFixedWidth(labelWidth); + ui->labelBalance->setMinimumWidth(labelMinWidth); + ui->labelBalance->setMaximumWidth(labelMaxWidth); + ui->labelBalance->setFixedHeight(labelHeight); + + ui->labelUnconfirmed->setFixedWidth(labelWidth); + ui->labelUnconfirmed->setMinimumWidth(labelMinWidth); + 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; + + ui->anonymizeButton->setMinimumWidth(buttonMinWidth); + ui->anonymizeButton->setMaximumWidth(buttonMaxWidth); + ui->anonymizeButton->setMinimumHeight(buttonMinHeight); + ui->anonymizeButton->setMaximumHeight(buttonMaxHeight); +} diff --git a/src/qt/overviewpage.h b/src/qt/overviewpage.h index 3e3e79acd1..822dfe6a79 100644 --- a/src/qt/overviewpage.h +++ b/src/qt/overviewpage.h @@ -16,6 +16,11 @@ #include #include #include +#include +#include +#include +#include + class ClientModel; class TransactionFilterProxy; @@ -44,6 +49,7 @@ class OverviewPage : public QWidget void setWalletModel(WalletModel *walletModel); void showOutOfSyncWarning(bool fShow); void UpdatePropertyBalance(unsigned int propertyId, uint64_t available, uint64_t reserved); + void resizeEvent(QResizeEvent* event) override; public Q_SLOTS: void on_anonymizeButton_clicked(); diff --git a/src/qt/receivecoinsdialog.cpp b/src/qt/receivecoinsdialog.cpp index 963a11f4dd..e70c4eb915 100644 --- a/src/qt/receivecoinsdialog.cpp +++ b/src/qt/receivecoinsdialog.cpp @@ -24,6 +24,7 @@ #include #include #include +#include ReceiveCoinsDialog::ReceiveCoinsDialog(const PlatformStyle *_platformStyle, QWidget *parent) : QDialog(parent), @@ -360,4 +361,69 @@ void RecentRequestsFilterProxy::setTypeFilter(quint32 modes) { this->typeFilter = modes; invalidateFilter(); +} + +// Handles resize events for the ReceiveCoinsDialog widget by adjusting internal component sizes. +void ReceiveCoinsDialog::resizeEvent(QResizeEvent* event) +{ + QDialog::resizeEvent(event); + + // Get new size from the event + int newWidth = event->size().width(); + int newHeight = event->size().height(); + + // Set fixed, minimum, and maximum sizes for ComboBoxes + int comboBoxMinHeight = 20; + int comboBoxMaxHeight = 40; + int comboBoxWidth = newWidth * 0.08; + int comboBoxMinWidth = newWidth * 0.05; + int comboBoxMaxWidth = newWidth * 0.1; + + ui->addressTypeCombobox->setMinimumWidth(comboBoxMinWidth); + ui->addressTypeCombobox->setMaximumWidth(comboBoxMaxWidth); + ui->addressTypeCombobox->setMinimumHeight(comboBoxMinHeight); + ui->addressTypeCombobox->setMaximumHeight(comboBoxMaxHeight); + + ui->addressTypeHistoryCombobox->setMinimumWidth(comboBoxMinWidth); + ui->addressTypeHistoryCombobox->setMaximumWidth(comboBoxMaxWidth); + ui->addressTypeHistoryCombobox->setMinimumHeight(comboBoxMinHeight); + ui->addressTypeHistoryCombobox->setMaximumHeight(comboBoxMaxHeight); + + // Set sizes for buttons dynamically + int buttonMinHeight = 20; + int buttonMaxHeight = 35; + int buttonWidth = newWidth * 0.15; + int buttonMinWidth = newWidth * 0.1; + int buttonMaxWidth = newWidth * 0.4; + + ui->clearButton->setMinimumWidth(buttonMinWidth); + ui->clearButton->setMaximumWidth(buttonMaxWidth); + ui->clearButton->setMinimumHeight(buttonMinHeight); + ui->clearButton->setMaximumHeight(buttonMaxHeight); + + ui->receiveButton->setMinimumWidth(buttonMinWidth); + ui->receiveButton->setMaximumWidth(buttonMaxWidth); + ui->receiveButton->setMinimumHeight(buttonMinHeight); + ui->receiveButton->setMaximumHeight(buttonMaxHeight); + + ui->showRequestButton->setMinimumWidth(buttonMinWidth); + ui->showRequestButton->setMaximumWidth(buttonMaxWidth); + ui->showRequestButton->setMinimumHeight(buttonMinHeight); + ui->showRequestButton->setMaximumHeight(buttonMaxHeight); + + ui->removeRequestButton->setMinimumWidth(buttonMinWidth); + ui->removeRequestButton->setMaximumWidth(buttonMaxWidth); + ui->removeRequestButton->setMinimumHeight(buttonMinHeight); + ui->removeRequestButton->setMaximumHeight(buttonMaxHeight); + + // Adjust column widths proportionally + int dateColumnWidth = newWidth * 0.25; + int labelColumnWidth = newWidth * 0.25; + int addressTypeColumnWidth = newWidth * 0.25; + int amountColumnWidth = newWidth * 0.25; + + ui->recentRequestsView->setColumnWidth(RecentRequestsTableModel::Date, dateColumnWidth); + ui->recentRequestsView->setColumnWidth(RecentRequestsTableModel::Label, labelColumnWidth); + ui->recentRequestsView->setColumnWidth(RecentRequestsTableModel::AddressType, addressTypeColumnWidth); + ui->recentRequestsView->setColumnWidth(RecentRequestsTableModel::Amount, amountColumnWidth); } \ No newline at end of file diff --git a/src/qt/receivecoinsdialog.h b/src/qt/receivecoinsdialog.h index 47dc5e992a..8ac92b0148 100644 --- a/src/qt/receivecoinsdialog.h +++ b/src/qt/receivecoinsdialog.h @@ -15,6 +15,8 @@ #include #include #include +#include +#include class OptionsModel; class PlatformStyle; @@ -57,7 +59,8 @@ class ReceiveCoinsDialog : public QDialog ~ReceiveCoinsDialog(); void setModel(WalletModel *model); - + + void resizeEvent(QResizeEvent* event) override; public Q_SLOTS: void clear(); void reject(); diff --git a/src/qt/transactionview.cpp b/src/qt/transactionview.cpp index bbd3e4b049..8be533cb87 100644 --- a/src/qt/transactionview.cpp +++ b/src/qt/transactionview.cpp @@ -711,3 +711,72 @@ void TransactionView::updateWatchOnlyColumn(bool fHaveWatchOnly) watchOnlyWidget->setVisible(fHaveWatchOnly); transactionView->setColumnHidden(TransactionTableModel::Watchonly, !fHaveWatchOnly); } + +// Handles resize events for the TransactionView widget by adjusting internal component sizes. +void TransactionView::resizeEvent(QResizeEvent* event) +{ + QWidget::resizeEvent(event); + + // Retrieve new dimensions from the resize event + int newWidth = event->size().width(); + int newHeight = event->size().height(); + + int headerHeight = newHeight * 0.1; + headerLayout->setGeometry(QRect(0, 0, newWidth, headerHeight)); + + // Calculate the height of widgets in the header subtracting a small margin + int widgetHeight = headerHeight - 5; + + // Determine widths for specific widgets as percentages of total width + int comboBoxesWidgetWidth = newWidth * 0.10; + int addressWidgetWidth = newWidth * 0.25; + const int minWidgetHeight = 20; + const int maxWidgetHeight = 35; + + // Configure the dimensions and constraints of each widget + watchOnlyWidget->setFixedHeight(widgetHeight); + watchOnlyWidget->setMinimumHeight(minWidgetHeight); + watchOnlyWidget->setMaximumHeight(maxWidgetHeight); + + instantsendWidget->setFixedHeight(widgetHeight); + instantsendWidget->setMinimumHeight(minWidgetHeight); + instantsendWidget->setMaximumHeight(maxWidgetHeight); + + dateWidget->setFixedWidth(comboBoxesWidgetWidth); + dateWidget->setFixedHeight(widgetHeight); + dateWidget->setMinimumHeight(minWidgetHeight); + dateWidget->setMaximumHeight(maxWidgetHeight); + + typeWidget->setFixedWidth(comboBoxesWidgetWidth); + typeWidget->setFixedHeight(widgetHeight); + typeWidget->setMinimumHeight(minWidgetHeight); + typeWidget->setMaximumHeight(maxWidgetHeight); + + addressWidget->setFixedHeight(maxWidgetHeight); + addressWidget->setMinimumHeight(minWidgetHeight); + addressWidget->setMaximumHeight(maxWidgetHeight - 6); + + amountWidget->setFixedWidth(comboBoxesWidgetWidth); + amountWidget->setFixedHeight(widgetHeight); + amountWidget->setMinimumHeight(minWidgetHeight); + amountWidget->setMaximumHeight(maxWidgetHeight); + + // Set the geometry for the main transaction view area below the header + int tableViewHeight = newHeight - headerHeight; + transactionView->setGeometry(QRect(0, headerHeight, newWidth, tableViewHeight)); + + // Calculate and set column widths based on new width, keeping proportions + int statusColumnWidth = newWidth * 0.05; + int watchOnlyColumnWidth = newWidth * 0.05; + int instantSendColumnWidth = newWidth * 0.05; + int dateColumnWidth = newWidth * 0.08; + int typeColumnWidth = newWidth * 0.10; + int addressColumnWidth = newWidth * 0.25; + + transactionView->setColumnWidth(TransactionTableModel::Status, statusColumnWidth); + transactionView->setColumnWidth(TransactionTableModel::Watchonly, watchOnlyColumnWidth); + transactionView->setColumnWidth(TransactionTableModel::InstantSend, instantSendColumnWidth); + transactionView->setColumnWidth(TransactionTableModel::Date, dateColumnWidth); + transactionView->setColumnWidth(TransactionTableModel::Type, typeColumnWidth); + transactionView->setColumnWidth(TransactionTableModel::ToAddress, addressColumnWidth); +} diff --git a/src/qt/transactionview.h b/src/qt/transactionview.h index fcebafc0ea..09c6dd7da5 100644 --- a/src/qt/transactionview.h +++ b/src/qt/transactionview.h @@ -9,6 +9,7 @@ #include #include +#include class PlatformStyle; class TransactionFilterProxy; @@ -37,7 +38,7 @@ class TransactionView : public QWidget explicit TransactionView(const PlatformStyle *platformStyle, QWidget *parent = 0); void setModel(WalletModel *model); - + void resizeEvent(QResizeEvent* event) override; // Date ranges for filter enum DateEnum { From 75bcbe5d8cb3a06dd53ece9bd74d1ab704d98665 Mon Sep 17 00:00:00 2001 From: firstcryptoman Date: Sun, 5 May 2024 00:41:15 +0400 Subject: [PATCH 2/8] Adjust toolbar widget sizes dynamically --- src/qt/bitcoingui.cpp | 27 +++++++++++++++++++++++++-- src/qt/bitcoingui.h | 6 +++++- 2 files changed, 30 insertions(+), 3 deletions(-) diff --git a/src/qt/bitcoingui.cpp b/src/qt/bitcoingui.cpp index bad8afeb82..58a4f0d5b4 100644 --- a/src/qt/bitcoingui.cpp +++ b/src/qt/bitcoingui.cpp @@ -510,7 +510,7 @@ void BitcoinGUI::createToolBars() { if(walletFrame) { - QToolBar *toolbar = addToolBar(tr("Tabs toolbar")); + toolbar = addToolBar(tr("Tabs toolbar")); toolbar->setContextMenuPolicy(Qt::PreventContextMenu); toolbar->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Preferred); toolbar->setToolButtonStyle(Qt::ToolButtonTextOnly); @@ -523,7 +523,7 @@ void BitcoinGUI::createToolBars() toolbar->addAction(lelantusAction); toolbar->addAction(masternodeAction); - QLabel *logoLabel = new QLabel(); + logoLabel = new QLabel(); logoLabel->setObjectName("lblToolbarLogo"); logoLabel->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Preferred); @@ -1474,3 +1474,26 @@ void UnitDisplayStatusBarControl::onMenuSelection(QAction* action) optionsModel->setDisplayUnit(action->data()); } } + +// Handles resize events for the BitcoinGUI widget by adjusting internal component sizes. +void BitcoinGUI::resizeEvent(QResizeEvent* event) { + QMainWindow::resizeEvent(event); + + // Retrieve new dimensions from the resize event + int newWidth = event->size().width(); + int newHeight = event->size().height(); + int actionWidth = newWidth / 6; + + // Set widths for each action dynamically + QWidget* overviewWidget = toolbar->widgetForAction(overviewAction); + QWidget* receiveWidget = toolbar->widgetForAction(receiveCoinsAction); + QWidget* historyWidget = toolbar->widgetForAction(historyAction); + QWidget* sendCoinsWidget = toolbar->widgetForAction(sendCoinsAction); + QWidget* masternodeWidget = toolbar->widgetForAction(masternodeAction); + + overviewWidget->setMinimumWidth(actionWidth); + receiveWidget->setFixedWidth(actionWidth); + historyWidget->setMinimumWidth(actionWidth); + sendCoinsWidget->setMinimumWidth(actionWidth); + masternodeWidget->setMinimumWidth(actionWidth); +} \ No newline at end of file diff --git a/src/qt/bitcoingui.h b/src/qt/bitcoingui.h index a2e6b1c5fd..bb2db20668 100644 --- a/src/qt/bitcoingui.h +++ b/src/qt/bitcoingui.h @@ -17,6 +17,8 @@ #include #include #include +#include +#include class ClientModel; class NetworkStyle; @@ -121,7 +123,8 @@ class BitcoinGUI : public QMainWindow QAction *lelantusAction; QAction *masternodeAction; QAction *logoAction; - + QToolBar *toolbar; + QLabel *logoLabel; QSystemTrayIcon *trayIcon; QMenu *trayIconMenu; Notificator *notificator; @@ -141,6 +144,7 @@ class BitcoinGUI : public QMainWindow void createMenuBar(); /** Create the toolbars */ void createToolBars(); + void resizeEvent(QResizeEvent*); /** Create system tray icon and notification */ void createTrayIcon(const NetworkStyle *networkStyle); /** Create system tray menu (or setup the dock menu) */ From fc5e1c2552b5c0c0f75a579f2f2ad42fc741698a Mon Sep 17 00:00:00 2001 From: firstcryptoman Date: Sun, 5 May 2024 22:01:01 +0400 Subject: [PATCH 3/8] Adjust component sizing dynamically on Masternode and Transaction pages. --- src/qt/masternodelist.cpp | 25 +++++++++++++++++++++++++ src/qt/masternodelist.h | 3 ++- src/qt/transactionview.cpp | 29 +---------------------------- 3 files changed, 28 insertions(+), 29 deletions(-) diff --git a/src/qt/masternodelist.cpp b/src/qt/masternodelist.cpp index a5b5e399e0..66b08ed29a 100644 --- a/src/qt/masternodelist.cpp +++ b/src/qt/masternodelist.cpp @@ -367,3 +367,28 @@ void MasternodeList::copyCollateralOutpoint_clicked() QApplication::clipboard()->setText(QString::fromStdString(dmn->collateralOutpoint.ToStringShort())); } + +void MasternodeList::resizeEvent(QResizeEvent* event) +{ + QWidget::resizeEvent(event); + + int newWidth = event->size().width(); + + // Calculate new column widths based on the new window width + int newWidthOwner = static_cast(newWidth * 0.19); + int newWidthMin = static_cast(newWidth * 0.08); + int newWidthMid = static_cast(newWidth * 0.12); + int newWidthStatus = static_cast(newWidth * 0.11); + + // Apply new column widths + ui->tableWidgetMasternodesDIP3->setColumnWidth(0, newWidthStatus); + ui->tableWidgetMasternodesDIP3->setColumnWidth(1, newWidthMin); + ui->tableWidgetMasternodesDIP3->setColumnWidth(2, newWidthMin); + ui->tableWidgetMasternodesDIP3->setColumnWidth(3, newWidthMid); + ui->tableWidgetMasternodesDIP3->setColumnWidth(4, newWidthMid); + ui->tableWidgetMasternodesDIP3->setColumnWidth(5, newWidthMid); + ui->tableWidgetMasternodesDIP3->setColumnWidth(6, newWidthMid); + ui->tableWidgetMasternodesDIP3->setColumnWidth(7, newWidthMid); + ui->tableWidgetMasternodesDIP3->setColumnWidth(8, newWidthMid); + ui->tableWidgetMasternodesDIP3->setColumnWidth(9, newWidthOwner); +} \ No newline at end of file diff --git a/src/qt/masternodelist.h b/src/qt/masternodelist.h index 58fec5d426..9bccd90f82 100644 --- a/src/qt/masternodelist.h +++ b/src/qt/masternodelist.h @@ -11,6 +11,7 @@ #include #include #include +#include #define MASTERNODELIST_UPDATE_SECONDS 3 #define MASTERNODELIST_FILTER_COOLDOWN_SECONDS 3 @@ -38,7 +39,7 @@ class MasternodeList : public QWidget void setClientModel(ClientModel* clientModel); void setWalletModel(WalletModel* walletModel); - + void resizeEvent(QResizeEvent*) override; private: QMenu* contextMenuDIP3; int64_t nTimeFilterUpdatedDIP3; diff --git a/src/qt/transactionview.cpp b/src/qt/transactionview.cpp index 8be533cb87..cbeb546a69 100644 --- a/src/qt/transactionview.cpp +++ b/src/qt/transactionview.cpp @@ -722,7 +722,6 @@ void TransactionView::resizeEvent(QResizeEvent* event) int newHeight = event->size().height(); int headerHeight = newHeight * 0.1; - headerLayout->setGeometry(QRect(0, 0, newWidth, headerHeight)); // Calculate the height of widgets in the header subtracting a small margin int widgetHeight = headerHeight - 5; @@ -733,38 +732,12 @@ void TransactionView::resizeEvent(QResizeEvent* event) const int minWidgetHeight = 20; const int maxWidgetHeight = 35; - // Configure the dimensions and constraints of each widget - watchOnlyWidget->setFixedHeight(widgetHeight); - watchOnlyWidget->setMinimumHeight(minWidgetHeight); - watchOnlyWidget->setMaximumHeight(maxWidgetHeight); - - instantsendWidget->setFixedHeight(widgetHeight); - instantsendWidget->setMinimumHeight(minWidgetHeight); - instantsendWidget->setMaximumHeight(maxWidgetHeight); - dateWidget->setFixedWidth(comboBoxesWidgetWidth); - dateWidget->setFixedHeight(widgetHeight); - dateWidget->setMinimumHeight(minWidgetHeight); - dateWidget->setMaximumHeight(maxWidgetHeight); - typeWidget->setFixedWidth(comboBoxesWidgetWidth); - typeWidget->setFixedHeight(widgetHeight); - typeWidget->setMinimumHeight(minWidgetHeight); - typeWidget->setMaximumHeight(maxWidgetHeight); - - addressWidget->setFixedHeight(maxWidgetHeight); - addressWidget->setMinimumHeight(minWidgetHeight); - addressWidget->setMaximumHeight(maxWidgetHeight - 6); - amountWidget->setFixedWidth(comboBoxesWidgetWidth); - amountWidget->setFixedHeight(widgetHeight); - amountWidget->setMinimumHeight(minWidgetHeight); - amountWidget->setMaximumHeight(maxWidgetHeight); - // Set the geometry for the main transaction view area below the header int tableViewHeight = newHeight - headerHeight; - transactionView->setGeometry(QRect(0, headerHeight, newWidth, tableViewHeight)); - + // Calculate and set column widths based on new width, keeping proportions int statusColumnWidth = newWidth * 0.05; int watchOnlyColumnWidth = newWidth * 0.05; From 1fc601792a4076f4ceab67dea39192d903084480 Mon Sep 17 00:00:00 2001 From: firstcryptoman Date: Mon, 6 May 2024 20:39:04 +0400 Subject: [PATCH 4/8] Adjust instantsendWidget width to be dynamic in TransactionView --- src/qt/transactionview.cpp | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/qt/transactionview.cpp b/src/qt/transactionview.cpp index cbeb546a69..ed58fb8d8e 100644 --- a/src/qt/transactionview.cpp +++ b/src/qt/transactionview.cpp @@ -67,7 +67,6 @@ TransactionView::TransactionView(const PlatformStyle *platformStyle, QWidget *pa headerLayout->addWidget(watchOnlyWidget); instantsendWidget = new QComboBox(this); - instantsendWidget->setFixedWidth(150); instantsendWidget->addItem(tr("All"), TransactionFilterProxy::InstantSendFilter_All); instantsendWidget->addItem(tr("Locked by InstantSend"), TransactionFilterProxy::InstantSendFilter_Yes); instantsendWidget->addItem(tr("Not locked by InstantSend"), TransactionFilterProxy::InstantSendFilter_No); @@ -729,12 +728,11 @@ void TransactionView::resizeEvent(QResizeEvent* event) // Determine widths for specific widgets as percentages of total width int comboBoxesWidgetWidth = newWidth * 0.10; int addressWidgetWidth = newWidth * 0.25; - const int minWidgetHeight = 20; - const int maxWidgetHeight = 35; dateWidget->setFixedWidth(comboBoxesWidgetWidth); typeWidget->setFixedWidth(comboBoxesWidgetWidth); amountWidget->setFixedWidth(comboBoxesWidgetWidth); + instantsendWidget->setFixedWidth(comboBoxesWidgetWidth); int tableViewHeight = newHeight - headerHeight; From 6aafba44a7536c64dafbdbca6f04df705451d429 Mon Sep 17 00:00:00 2001 From: firstcryptoman Date: Wed, 15 May 2024 22:41:25 +0400 Subject: [PATCH 5/8] 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 e6a1464e57..f7a346631f 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 66b380fea5..2506642369 100644 --- a/src/qt/sendcoinsdialog.cpp +++ b/src/qt/sendcoinsdialog.cpp @@ -1403,4 +1403,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 From 434b088d2bad65297a787b4abb1cf8906ed09f09 Mon Sep 17 00:00:00 2001 From: firstcryptoman Date: Fri, 17 May 2024 22:39:51 +0400 Subject: [PATCH 6/8] Enhance UI scalability by adding dynamic text resizing across various pages --- src/qt/masternodelist.cpp | 20 +++++++++++++++++- src/qt/masternodelist.h | 1 + src/qt/overviewpage.cpp | 6 +++--- src/qt/overviewpage.h | 3 --- src/qt/receivecoinsdialog.cpp | 5 +++-- src/qt/receivecoinsdialog.h | 1 - src/qt/sendcoinsdialog.cpp | 6 +++--- src/qt/sendcoinsdialog.h | 2 +- src/qt/sendcoinsentry.cpp | 38 +++++++++++++++++++++++++++++++++++ src/qt/sendcoinsentry.h | 3 +++ src/qt/transactionview.cpp | 23 +++++++++++++++++++-- src/qt/transactionview.h | 2 ++ 12 files changed, 94 insertions(+), 16 deletions(-) diff --git a/src/qt/masternodelist.cpp b/src/qt/masternodelist.cpp index 66b08ed29a..cf04e90dba 100644 --- a/src/qt/masternodelist.cpp +++ b/src/qt/masternodelist.cpp @@ -372,7 +372,10 @@ void MasternodeList::resizeEvent(QResizeEvent* event) { QWidget::resizeEvent(event); - int newWidth = event->size().width(); + const int newWidth = event->size().width(); + const int newHeight = event->size().height(); + + adjustTextSize(newWidth ,newHeight); // Calculate new column widths based on the new window width int newWidthOwner = static_cast(newWidth * 0.19); @@ -391,4 +394,19 @@ void MasternodeList::resizeEvent(QResizeEvent* event) ui->tableWidgetMasternodesDIP3->setColumnWidth(7, newWidthMid); ui->tableWidgetMasternodesDIP3->setColumnWidth(8, newWidthMid); ui->tableWidgetMasternodesDIP3->setColumnWidth(9, newWidthOwner); +} +void MasternodeList::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->label_filter_2->setFont(font); + ui->label_count_2->setFont(font); + ui->countLabelDIP3->setFont(font); + ui->checkBoxMyMasternodesOnly->setFont(font); + ui->tableWidgetMasternodesDIP3->setFont(font); + ui->tableWidgetMasternodesDIP3->horizontalHeader()->setFont(font); + ui->tableWidgetMasternodesDIP3->verticalHeader()->setFont(font); } \ No newline at end of file diff --git a/src/qt/masternodelist.h b/src/qt/masternodelist.h index 9bccd90f82..6d469ea9be 100644 --- a/src/qt/masternodelist.h +++ b/src/qt/masternodelist.h @@ -40,6 +40,7 @@ class MasternodeList : public QWidget void setClientModel(ClientModel* clientModel); void setWalletModel(WalletModel* walletModel); void resizeEvent(QResizeEvent*) override; + void adjustTextSize(int width,int height); private: QMenu* contextMenuDIP3; int64_t nTimeFilterUpdatedDIP3; diff --git a/src/qt/overviewpage.cpp b/src/qt/overviewpage.cpp index f7a346631f..aa94e03723 100644 --- a/src/qt/overviewpage.cpp +++ b/src/qt/overviewpage.cpp @@ -481,8 +481,8 @@ void OverviewPage::resizeEvent(QResizeEvent* event) QWidget::resizeEvent(event); // Retrieve new dimensions from the resize event - int newWidth = event->size().width(); - int newHeight = event->size().height(); + const int newWidth = event->size().width(); + const int newHeight = event->size().height(); adjustTextSize(newWidth, newHeight); // Determine widths for specific widgets as percentages of total width int labelWidth = static_cast(newWidth * 0.5); @@ -516,7 +516,7 @@ 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();; + QFont textFont = ui->labelBalance->font(); textFont.setPointSize(baseFontSize); // Font for labels, smaller than the text font size diff --git a/src/qt/overviewpage.h b/src/qt/overviewpage.h index 9d98949962..a6e97b27f2 100644 --- a/src/qt/overviewpage.h +++ b/src/qt/overviewpage.h @@ -17,9 +17,6 @@ #include #include #include -#include -#include -#include class ClientModel; diff --git a/src/qt/receivecoinsdialog.cpp b/src/qt/receivecoinsdialog.cpp index 744f53c199..4278e462fc 100644 --- a/src/qt/receivecoinsdialog.cpp +++ b/src/qt/receivecoinsdialog.cpp @@ -369,8 +369,9 @@ void ReceiveCoinsDialog::resizeEvent(QResizeEvent* event) QDialog::resizeEvent(event); // Get new size from the event - int newWidth = event->size().width(); - int newHeight = event->size().height(); + const int newWidth = event->size().width(); + const int newHeight = event->size().height(); + adjustTextSize(newWidth,newHeight); // Set fixed, minimum, and maximum sizes for ComboBoxes int comboBoxMinHeight = 20; diff --git a/src/qt/receivecoinsdialog.h b/src/qt/receivecoinsdialog.h index 0f23f53a4e..c5eac0b986 100644 --- a/src/qt/receivecoinsdialog.h +++ b/src/qt/receivecoinsdialog.h @@ -16,7 +16,6 @@ #include #include #include -#include class OptionsModel; class PlatformStyle; diff --git a/src/qt/sendcoinsdialog.cpp b/src/qt/sendcoinsdialog.cpp index 2506642369..c15405ce9e 100644 --- a/src/qt/sendcoinsdialog.cpp +++ b/src/qt/sendcoinsdialog.cpp @@ -1408,10 +1408,10 @@ 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(); + const int newWidth = event->size().width(); + const int newHeight = event->size().height(); - int labelMinWidth = static_cast(newWidth * 0.15); + const int labelMinWidth = static_cast(newWidth * 0.15); // Resize and adjust components ui->sendButton->setMinimumWidth(labelMinWidth); diff --git a/src/qt/sendcoinsdialog.h b/src/qt/sendcoinsdialog.h index 3215028143..5abf2e3a07 100644 --- a/src/qt/sendcoinsdialog.h +++ b/src/qt/sendcoinsdialog.h @@ -67,7 +67,7 @@ public Q_SLOTS: bool fFeeMinimized; bool fAnonymousMode; const PlatformStyle *platformStyle; - void resizeEvent(QResizeEvent* event); + void resizeEvent(QResizeEvent* event) override; void adjustTextSize(int width, int height); // Process WalletModel::SendCoinsReturn and generate a pair consisting diff --git a/src/qt/sendcoinsentry.cpp b/src/qt/sendcoinsentry.cpp index 49fda59920..1825191da3 100644 --- a/src/qt/sendcoinsentry.cpp +++ b/src/qt/sendcoinsentry.cpp @@ -14,6 +14,7 @@ #include #include +#include SendCoinsEntry::SendCoinsEntry(const PlatformStyle *_platformStyle, QWidget *parent) : QStackedWidget(parent), @@ -265,3 +266,40 @@ bool SendCoinsEntry::updateLabel(const QString &address) ui->addAsLabel->setText(associatedLabel); return true; } +void SendCoinsEntry::resizeEvent(QResizeEvent* event) { + QStackedWidget::resizeEvent(event); + + const int newWidth = event->size().width(); + const int newHeight = event->size().height(); + + adjustTextSize(newWidth, newHeight); +} + + +void SendCoinsEntry::adjustTextSize(int width, int height) { + int baseFontSize = std::max(14, width / 120); + + QFont font = this->font(); + font.setPointSize(baseFontSize); + + ui->payToLabel->setFont(font); + ui->labellLabel->setFont(font); + ui->addAsLabel->setFont(font); + ui->amountLabel->setFont(font); + ui->messageLabel->setFont(font); + ui->messageTextLabel->setFont(font); + ui->payTo->setFont(font); + ui->payTo_is->setFont(font); + ui->memoLabel_is->setFont(font); + ui->memoTextLabel_is->setFont(font); + ui->amountLabel_is->setFont(font); + ui->payToLabel_s->setFont(font); + ui->payTo_s->setFont(font); + ui->memoLabel_s->setFont(font); + ui->memoTextLabel_s->setFont(font); + ui->amountLabel_s->setFont(font); + ui->checkboxSubtractFeeFromAmount->setFont(font); + ui->deleteButton->setFont(font); + ui->pasteButton->setFont(font); + ui->addressBookButton->setFont(font); +} \ No newline at end of file diff --git a/src/qt/sendcoinsentry.h b/src/qt/sendcoinsentry.h index 2c6bf35242..506981d5e3 100644 --- a/src/qt/sendcoinsentry.h +++ b/src/qt/sendcoinsentry.h @@ -73,6 +73,9 @@ private Q_SLOTS: bool isPcodeEntry; bool updateLabel(const QString &address); + void resizeEvent(QResizeEvent* event) override; + void adjustTextSize(int width, int height); + }; #endif // BITCOIN_QT_SENDCOINSENTRY_H diff --git a/src/qt/transactionview.cpp b/src/qt/transactionview.cpp index ed58fb8d8e..c8e0d7502a 100644 --- a/src/qt/transactionview.cpp +++ b/src/qt/transactionview.cpp @@ -717,8 +717,10 @@ void TransactionView::resizeEvent(QResizeEvent* event) QWidget::resizeEvent(event); // Retrieve new dimensions from the resize event - int newWidth = event->size().width(); - int newHeight = event->size().height(); + const int newWidth = event->size().width(); + const int newHeight = event->size().height(); + + adjustTextSize(newWidth, newHeight); int headerHeight = newHeight * 0.1; @@ -751,3 +753,20 @@ void TransactionView::resizeEvent(QResizeEvent* event) transactionView->setColumnWidth(TransactionTableModel::Type, typeColumnWidth); transactionView->setColumnWidth(TransactionTableModel::ToAddress, addressColumnWidth); } +void TransactionView::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 + transactionView->setFont(font); + transactionView->horizontalHeader()->setFont(font); + transactionView->verticalHeader()->setFont(font); + dateWidget->setFont(font); + typeWidget->setFont(font); + amountWidget->setFont(font); + instantsendWidget->setFont(font); + addressWidget->setFont(font); + amountWidget->setFont(font); +} \ No newline at end of file diff --git a/src/qt/transactionview.h b/src/qt/transactionview.h index 09c6dd7da5..5b78cce3f7 100644 --- a/src/qt/transactionview.h +++ b/src/qt/transactionview.h @@ -39,6 +39,8 @@ class TransactionView : public QWidget void setModel(WalletModel *model); void resizeEvent(QResizeEvent* event) override; + void adjustTextSize(int width, int height); + // Date ranges for filter enum DateEnum { From a7fa4c9c0cab746591c6837a34676e2a099289f2 Mon Sep 17 00:00:00 2001 From: firstcryptoman Date: Fri, 31 May 2024 20:47:06 +0400 Subject: [PATCH 7/8] Update font size and set minimum label width for readability. --- src/qt/masternodelist.cpp | 2 +- src/qt/overviewpage.cpp | 19 ++++++++++++++++++- src/qt/receivecoinsdialog.cpp | 2 +- src/qt/sendcoinsdialog.cpp | 2 +- src/qt/transactionview.cpp | 3 +-- 5 files changed, 22 insertions(+), 6 deletions(-) diff --git a/src/qt/masternodelist.cpp b/src/qt/masternodelist.cpp index cf04e90dba..dbd89e3565 100644 --- a/src/qt/masternodelist.cpp +++ b/src/qt/masternodelist.cpp @@ -397,7 +397,7 @@ void MasternodeList::resizeEvent(QResizeEvent* event) } void MasternodeList::adjustTextSize(int width,int height){ - int fontSize = std::max(12, std::min(width, height) / 60); + int fontSize = std::max(12, std::min(width, height) / 70); QFont font = this->font(); font.setPointSize(fontSize); diff --git a/src/qt/overviewpage.cpp b/src/qt/overviewpage.cpp index aa94e03723..8bd40b8969 100644 --- a/src/qt/overviewpage.cpp +++ b/src/qt/overviewpage.cpp @@ -510,10 +510,27 @@ void OverviewPage::resizeEvent(QResizeEvent* event) ui->anonymizeButton->setMaximumWidth(buttonWidth * 2); ui->anonymizeButton->setMinimumHeight(buttonMinHeight); ui->anonymizeButton->setMaximumHeight(buttonMaxHeight); + + // Set the minimum width for all label widgets to ensure they maintain a consistent and readable size regardless of window resizing + ui->labelAnonymizable->setMinimumWidth(labelMinWidth); + ui->labelAlerts->setMinimumWidth(labelMinWidth); + ui->label->setMinimumWidth(labelMinWidth); + ui->labelWatchPending->setMinimumWidth(labelMinWidth); + ui->labelBalance->setMinimumWidth(labelMinWidth); + ui->labelSpendable->setMinimumWidth(labelMinWidth); + ui->labelWatchAvailable->setMinimumWidth(labelMinWidth); + ui->labelUnconfirmedPrivate->setMinimumWidth(labelMinWidth); + ui->labelWatchonly->setMinimumWidth(labelMinWidth); + ui->labelTotal->setMinimumWidth(labelMinWidth); + ui->labelWatchTotal->setMinimumWidth(labelMinWidth); + ui->labelUnconfirmed->setMinimumWidth(labelMinWidth); + ui->labelImmature->setMinimumWidth(labelMinWidth); + ui->labelPrivate->setMinimumWidth(labelMinWidth); + ui->label_4->setMinimumWidth(labelMinWidth); } void OverviewPage::adjustTextSize(int width, int height){ - int baseFontSize = std::max(12, std::min(width, height) / 60); + int baseFontSize = std::max(12, std::min(width, height) / 70); // Font for regular text components QFont textFont = ui->labelBalance->font(); diff --git a/src/qt/receivecoinsdialog.cpp b/src/qt/receivecoinsdialog.cpp index 4278e462fc..f523c19fed 100644 --- a/src/qt/receivecoinsdialog.cpp +++ b/src/qt/receivecoinsdialog.cpp @@ -430,7 +430,7 @@ void ReceiveCoinsDialog::resizeEvent(QResizeEvent* event) } void ReceiveCoinsDialog::adjustTextSize(int width,int height){ - int fontSize = std::max(12, std::min(width, height) / 60); + int fontSize = std::max(12, std::min(width, height) / 70); QFont font = this->font(); font.setPointSize(fontSize); diff --git a/src/qt/sendcoinsdialog.cpp b/src/qt/sendcoinsdialog.cpp index c15405ce9e..844b786070 100644 --- a/src/qt/sendcoinsdialog.cpp +++ b/src/qt/sendcoinsdialog.cpp @@ -1427,7 +1427,7 @@ void SendCoinsDialog::resizeEvent(QResizeEvent* event) { } void SendCoinsDialog::adjustTextSize(int width, int height) { - int baseFontSize = std::max(12, std::min(width, height) / 60); + int baseFontSize = std::max(12, std::min(width, height) / 70); QFont font = this->font(); font.setPointSize(baseFontSize); diff --git a/src/qt/transactionview.cpp b/src/qt/transactionview.cpp index c8e0d7502a..2a268ab47d 100644 --- a/src/qt/transactionview.cpp +++ b/src/qt/transactionview.cpp @@ -755,7 +755,7 @@ void TransactionView::resizeEvent(QResizeEvent* event) } void TransactionView::adjustTextSize(int width,int height){ - int fontSize = std::max(12, std::min(width, height) / 60); + int fontSize = std::max(12, std::min(width, height) / 70); QFont font = this->font(); font.setPointSize(fontSize); @@ -768,5 +768,4 @@ void TransactionView::adjustTextSize(int width,int height){ amountWidget->setFont(font); instantsendWidget->setFont(font); addressWidget->setFont(font); - amountWidget->setFont(font); } \ No newline at end of file From e14108da5faeefc02203d447e37ac47d2768eaca Mon Sep 17 00:00:00 2001 From: firstcryptoman Date: Mon, 17 Jun 2024 01:19:03 +0400 Subject: [PATCH 8/8] Update dynamic scaling --- src/qt/masternodelist.cpp | 4 +- src/qt/overviewpage.cpp | 74 ++++++++++++++++++----------------- src/qt/receivecoinsdialog.cpp | 4 +- src/qt/sendcoinsdialog.cpp | 18 ++++++--- src/qt/sendcoinsentry.cpp | 7 ++-- src/qt/transactionview.cpp | 4 +- 6 files changed, 65 insertions(+), 46 deletions(-) diff --git a/src/qt/masternodelist.cpp b/src/qt/masternodelist.cpp index dbd89e3565..906b924326 100644 --- a/src/qt/masternodelist.cpp +++ b/src/qt/masternodelist.cpp @@ -397,7 +397,9 @@ void MasternodeList::resizeEvent(QResizeEvent* event) } void MasternodeList::adjustTextSize(int width,int height){ - int fontSize = std::max(12, std::min(width, height) / 70); + const double fontSizeScalingFactor = 70.0; + int baseFontSize = std::min(width, height) / fontSizeScalingFactor; + int fontSize = std::min(15, std::max(12, baseFontSize)); QFont font = this->font(); font.setPointSize(fontSize); diff --git a/src/qt/overviewpage.cpp b/src/qt/overviewpage.cpp index 8bd40b8969..d18f106201 100644 --- a/src/qt/overviewpage.cpp +++ b/src/qt/overviewpage.cpp @@ -484,6 +484,7 @@ void OverviewPage::resizeEvent(QResizeEvent* event) const int newWidth = event->size().width(); const int newHeight = event->size().height(); adjustTextSize(newWidth, newHeight); + // Determine widths for specific widgets as percentages of total width int labelWidth = static_cast(newWidth * 0.5); int labelMinWidth = static_cast(newWidth * 0.15); @@ -530,45 +531,48 @@ void OverviewPage::resizeEvent(QResizeEvent* event) } void OverviewPage::adjustTextSize(int width, int height){ - int baseFontSize = std::max(12, std::min(width, height) / 70); - - // Font for regular text components + const double fontSizeScalingFactor = 133.0; + int baseFontSize = width / fontSizeScalingFactor; + int fontSize = std::min(15, std::max(12, baseFontSize)); + + // Font for regular text components(not bold) QFont textFont = ui->labelBalance->font(); - textFont.setPointSize(baseFontSize); + textFont.setPointSize(fontSize); + textFont.setBold(false); - // Font for labels, smaller than the text font size - QFont labelFont = font(); - labelFont.setPointSize(int(baseFontSize * 0.9)); + // Font for text components that should be bold + QFont labelFont = textFont; + labelFont.setBold(true); - ui->textWarning1->setFont(labelFont); - ui->textWarning2->setFont(labelFont); - ui->labelWalletStatus->setFont(labelFont); - ui->anonymizeButton->setFont(labelFont); + ui->textWarning1->setFont(textFont); + ui->textWarning2->setFont(textFont); + ui->labelWalletStatus->setFont(textFont); + ui->anonymizeButton->setFont(textFont); // 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); + ui->labelAlerts->setFont(labelFont); + ui->label_5->setFont(labelFont); + ui->labelAnonymizableText->setFont(textFont); + ui->label->setFont(labelFont); + ui->labelAnonymizable->setFont(labelFont); + ui->labelWatchPending->setFont(labelFont); + ui->labelBalance->setFont(labelFont); + ui->labelSpendable->setFont(labelFont); + ui->labelWatchAvailable->setFont(labelFont); + ui->labelPendingText->setFont(textFont); + ui->labelUnconfirmedPrivate->setFont(labelFont); + ui->labelUnconfirmedPrivateText->setFont(textFont); + ui->labelTotalText->setFont(textFont); + ui->labelWatchonly->setFont(labelFont); + ui->labelBalanceText->setFont(textFont); + ui->labelTotal->setFont(labelFont); + ui->labelWatchTotal->setFont(labelFont); + ui->labelUnconfirmed->setFont(labelFont); + ui->labelImmatureText->setFont(textFont); + ui->labelImmature->setFont(labelFont); + ui->labelWatchImmature->setFont(labelFont); + ui->labelPrivateText->setFont(textFont); + ui->labelPrivate->setFont(labelFont); + ui->label_4->setFont(labelFont); } \ No newline at end of file diff --git a/src/qt/receivecoinsdialog.cpp b/src/qt/receivecoinsdialog.cpp index f523c19fed..21b9352591 100644 --- a/src/qt/receivecoinsdialog.cpp +++ b/src/qt/receivecoinsdialog.cpp @@ -430,7 +430,9 @@ void ReceiveCoinsDialog::resizeEvent(QResizeEvent* event) } void ReceiveCoinsDialog::adjustTextSize(int width,int height){ - int fontSize = std::max(12, std::min(width, height) / 70); + const double fontSizeScalingFactor = 70.0; + int baseFontSize = std::min(width, height) / fontSizeScalingFactor; + int fontSize = std::min(15, std::max(12, baseFontSize)); QFont font = this->font(); font.setPointSize(fontSize); diff --git a/src/qt/sendcoinsdialog.cpp b/src/qt/sendcoinsdialog.cpp index 844b786070..26cbf138e5 100644 --- a/src/qt/sendcoinsdialog.cpp +++ b/src/qt/sendcoinsdialog.cpp @@ -1420,6 +1420,7 @@ void SendCoinsDialog::resizeEvent(QResizeEvent* event) { ui->buttonChooseFee->setMinimumWidth(labelMinWidth); ui->buttonMinimizeFee->setMinimumWidth(labelMinWidth); ui->switchFundButton->setMinimumWidth(labelMinWidth); + ui->pushButtonCoinControl->setMinimumWidth(labelMinWidth); // Dynamically adjust text sizes based on the new dimensions @@ -1427,17 +1428,22 @@ void SendCoinsDialog::resizeEvent(QResizeEvent* event) { } void SendCoinsDialog::adjustTextSize(int width, int height) { - int baseFontSize = std::max(12, std::min(width, height) / 70); + const double fontSizeScalingFactor = 131.3; + int baseFontSize = width / fontSizeScalingFactor; + int fontSize = std::min(15, std::max(12, baseFontSize)); - QFont font = this->font(); - font.setPointSize(baseFontSize); + QFont font = ui->labelBalance->font(); + font.setPointSize(fontSize); + + QFont textFont = font; + textFont.setBold(true); // Set font size for all labels ui->labelBalance->setFont(font); - ui->labelCoinControlAmount->setFont(font); + ui->lineEditCoinControlChange->setFont(font); ui->labelFeeEstimation->setFont(font); ui->labelFeeHeadline->setFont(font); - ui->labelCoinControlFeatures->setFont(font); + ui->labelCoinControlFeatures->setFont(textFont); ui->labelCoinControlAutomaticallySelected->setFont(font); ui->labelCoinControlInsuffFunds->setFont(font); ui->labelCoinControlQuantity->setFont(font); @@ -1472,6 +1478,8 @@ void SendCoinsDialog::adjustTextSize(int width, int height) { ui->fallbackFeeWarningLabel->setFont(font); ui->checkBoxMinimumFee->setFont(font); ui->checkBoxCoinControlChange->setFont(font); + ui->confirmationTargetLabel->setFont(font); + // Adjust font for all buttons ui->sendButton->setFont(font); diff --git a/src/qt/sendcoinsentry.cpp b/src/qt/sendcoinsentry.cpp index 1825191da3..eb2d7e62dc 100644 --- a/src/qt/sendcoinsentry.cpp +++ b/src/qt/sendcoinsentry.cpp @@ -277,10 +277,11 @@ void SendCoinsEntry::resizeEvent(QResizeEvent* event) { void SendCoinsEntry::adjustTextSize(int width, int height) { - int baseFontSize = std::max(14, width / 120); - + const double fontSizeScalingFactor = 130.0; + int baseFontSize = width / fontSizeScalingFactor; + int fontSize = std::max(12,baseFontSize); QFont font = this->font(); - font.setPointSize(baseFontSize); + font.setPointSize(fontSize); ui->payToLabel->setFont(font); ui->labellLabel->setFont(font); diff --git a/src/qt/transactionview.cpp b/src/qt/transactionview.cpp index 2a268ab47d..7ad14a9ac5 100644 --- a/src/qt/transactionview.cpp +++ b/src/qt/transactionview.cpp @@ -755,7 +755,9 @@ void TransactionView::resizeEvent(QResizeEvent* event) } void TransactionView::adjustTextSize(int width,int height){ - int fontSize = std::max(12, std::min(width, height) / 70); + const double fontSizeScalingFactor = 65.0; + int baseFontSize = std::min(width, height) / fontSizeScalingFactor; + int fontSize = std::min(15, std::max(12, baseFontSize)); QFont font = this->font(); font.setPointSize(fontSize);