Skip to content

Commit

Permalink
Adjust component sizing dynamically on Masternode and Transaction pages.
Browse files Browse the repository at this point in the history
  • Loading branch information
firstcryptoman committed May 5, 2024
1 parent 20c4ee7 commit 7d71311
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 29 deletions.
25 changes: 25 additions & 0 deletions src/qt/masternodelist.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<int>(newWidth * 0.19);
int newWidthMin = static_cast<int>(newWidth * 0.08);
int newWidthMid = static_cast<int>(newWidth * 0.12);
int newWidthStatus = static_cast<int>(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);
}
3 changes: 2 additions & 1 deletion src/qt/masternodelist.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
#include <QMenu>
#include <QTimer>
#include <QWidget>
#include <QResizeEvent>

#define MASTERNODELIST_UPDATE_SECONDS 3
#define MASTERNODELIST_FILTER_COOLDOWN_SECONDS 3
Expand Down Expand Up @@ -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;
Expand Down
29 changes: 1 addition & 28 deletions src/qt/transactionview.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand Down

0 comments on commit 7d71311

Please sign in to comment.