Skip to content

Commit

Permalink
Enhance UI scalability by adding dynamic text resizing across various…
Browse files Browse the repository at this point in the history
… pages
  • Loading branch information
firstcryptoman committed May 17, 2024
1 parent 017abec commit ea88eac
Show file tree
Hide file tree
Showing 12 changed files with 94 additions and 16 deletions.
20 changes: 19 additions & 1 deletion src/qt/masternodelist.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<int>(newWidth * 0.19);
Expand All @@ -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);
}
1 change: 1 addition & 0 deletions src/qt/masternodelist.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
6 changes: 3 additions & 3 deletions src/qt/overviewpage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<int>(newWidth * 0.5);
Expand Down Expand Up @@ -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
Expand Down
3 changes: 0 additions & 3 deletions src/qt/overviewpage.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,6 @@
#include <QMessageBox>
#include <QTimer>
#include <QResizeEvent>
#include <QPainter>
#include <QStyleOptionViewItem>
#include <QMetaMethod>


class ClientModel;
Expand Down
5 changes: 3 additions & 2 deletions src/qt/receivecoinsdialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
1 change: 0 additions & 1 deletion src/qt/receivecoinsdialog.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
#include <QVariant>
#include <QSortFilterProxyModel>
#include <QResizeEvent>
#include <QScreen>

class OptionsModel;
class PlatformStyle;
Expand Down
6 changes: 3 additions & 3 deletions src/qt/sendcoinsdialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1282,10 +1282,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<int>(newWidth * 0.15);
const int labelMinWidth = static_cast<int>(newWidth * 0.15);

// Resize and adjust components
ui->sendButton->setMinimumWidth(labelMinWidth);
Expand Down
2 changes: 1 addition & 1 deletion src/qt/sendcoinsdialog.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
38 changes: 38 additions & 0 deletions src/qt/sendcoinsentry.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@

#include <QApplication>
#include <QClipboard>
#include<QResizeEvent>

SendCoinsEntry::SendCoinsEntry(const PlatformStyle *_platformStyle, QWidget *parent) :
QStackedWidget(parent),
Expand Down Expand Up @@ -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);
}
3 changes: 3 additions & 0 deletions src/qt/sendcoinsentry.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
23 changes: 21 additions & 2 deletions src/qt/transactionview.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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);
}
2 changes: 2 additions & 0 deletions src/qt/transactionview.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand Down

0 comments on commit ea88eac

Please sign in to comment.