Skip to content

Commit

Permalink
Update dynamic scaling
Browse files Browse the repository at this point in the history
  • Loading branch information
firstcryptoman committed Jun 16, 2024
1 parent a7fa4c9 commit e14108d
Show file tree
Hide file tree
Showing 6 changed files with 65 additions and 46 deletions.
4 changes: 3 additions & 1 deletion src/qt/masternodelist.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down
74 changes: 39 additions & 35 deletions src/qt/overviewpage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<int>(newWidth * 0.5);
int labelMinWidth = static_cast<int>(newWidth * 0.15);
Expand Down Expand Up @@ -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);

}
4 changes: 3 additions & 1 deletion src/qt/receivecoinsdialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down
18 changes: 13 additions & 5 deletions src/qt/sendcoinsdialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1420,24 +1420,30 @@ 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
adjustTextSize(newWidth, newHeight);
}

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);
Expand Down Expand Up @@ -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);
Expand Down
7 changes: 4 additions & 3 deletions src/qt/sendcoinsentry.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
4 changes: 3 additions & 1 deletion src/qt/transactionview.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down

0 comments on commit e14108d

Please sign in to comment.