Skip to content

Commit f79a750

Browse files
UdjinM6claude
authored andcommitted
refactor: Move wallet creation dialog styles from C++ to CSS
Move theme-independent styling from inline C++ code to general.css following Dash Core CSS architecture (general.css for layout, dark/light.css for colors). Changes: - Move font sizes, weights, and families to general.css - Move widget size constraints to general.css - Move label margins to general.css - Remove inline HTML style attributes from translated strings - Simplify C++ code to only handle dynamic theme colors via GUIUtil Benefits: - Better separation of concerns (styling vs logic) - Easier theme customization without recompiling - Consistent with Dash Core styling patterns - Cleaner, more maintainable C++ code 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
1 parent fd3c1eb commit f79a750

File tree

2 files changed

+67
-30
lines changed

2 files changed

+67
-30
lines changed

src/qt/mnemonicverificationdialog.cpp

Lines changed: 16 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -115,17 +115,14 @@ void MnemonicVerificationDialog::setupStep1()
115115
// Compact to content
116116
adjustSize();
117117

118-
// Match visual hierarchy and tone of the improved mock
119-
QString warningStyle = QString("font-size:17px; font-weight:700; ") + GUIUtil::getThemedStyleQString(GUIUtil::ThemedStyle::TS_ERROR);
120-
QString instructionStyle = QString("font-size:14px; ") + GUIUtil::getThemedStyleQString(GUIUtil::ThemedStyle::TS_PRIMARY);
118+
// Set warning and instruction text with themed colors
119+
// Font sizes and weights are defined in general.css
121120
ui->warningLabel->setText(
122-
tr("<span style='%1'>WARNING: If you lose your mnemonic seed phrase, you will lose access to your wallet forever. Write it down in a safe place and never share it with anyone.</span>")
123-
.arg(warningStyle)
124-
);
121+
tr("WARNING: If you lose your mnemonic seed phrase, you will lose access to your wallet forever. Write it down in a safe place and never share it with anyone."));
122+
ui->warningLabel->setStyleSheet(GUIUtil::getThemedStyleQString(GUIUtil::ThemedStyle::TS_ERROR));
123+
125124
ui->instructionLabel->setText(
126-
tr("<span style='%1'>Please write down these words in order. You will need them to restore your wallet.</span>")
127-
.arg(instructionStyle)
128-
);
125+
tr("Please write down these words in order. You will need them to restore your wallet."));
129126

130127
// Reduce extra padding to avoid an over-padded look
131128
if (auto outer = findChild<QVBoxLayout*>("verticalLayout_step1")) {
@@ -166,12 +163,7 @@ void MnemonicVerificationDialog::setupStep2()
166163
ui->word1Edit->clear();
167164
ui->word2Edit->clear();
168165
ui->word3Edit->clear();
169-
ui->word1Edit->setMaximumWidth(320);
170-
ui->word2Edit->setMaximumWidth(320);
171-
ui->word3Edit->setMaximumWidth(320);
172-
ui->word1Status->setMinimumWidth(18);
173-
ui->word2Status->setMinimumWidth(18);
174-
ui->word3Status->setMinimumWidth(18);
166+
// Widget sizes are defined in general.css
175167

176168
ui->word1Label->setText(tr("Word #%1:").arg(m_selected_positions[0]));
177169
ui->word2Label->setText(tr("Word #%1:").arg(m_selected_positions[1]));
@@ -191,10 +183,7 @@ void MnemonicVerificationDialog::setupStep2()
191183
if (QAbstractButton* cont = ui->buttonBox->button(QDialogButtonBox::Ok)) cont->setEnabled(false);
192184
if (ui->showMnemonicAgainButton) ui->showMnemonicAgainButton->hide();
193185

194-
// Ensure verification label has minimal top spacing
195-
if (ui->verificationLabel) {
196-
ui->verificationLabel->setStyleSheet("QLabel { margin-top: 0px; margin-bottom: 4px; }");
197-
}
186+
// Verification label styling is defined in general.css
198187

199188
// Hide any existing title label if present
200189
if (auto titleLabel = findChild<QLabel*>("verifyTitleLabel")) {
@@ -303,16 +292,15 @@ void MnemonicVerificationDialog::updateWordValidation()
303292
const bool ok2 = !t2.isEmpty() && validateWord(t2, m_selected_positions[1]);
304293
const bool ok3 = !t3.isEmpty() && validateWord(t3, m_selected_positions[2]);
305294

295+
// Status labels show checkmarks/X marks with themed colors
296+
// Font weight is defined in general.css
306297
auto setStatus = [](QLabel* lbl, bool filled, bool valid) {
307298
if (!lbl) return;
308299
if (!filled) { lbl->clear(); lbl->setStyleSheet(""); return; }
309-
if (valid) {
310-
lbl->setText("");
311-
lbl->setStyleSheet(QString("QLabel { %1 font-weight: 700; }").arg(GUIUtil::getThemedStyleQString(GUIUtil::ThemedStyle::TS_SUCCESS)));
312-
} else {
313-
lbl->setText("");
314-
lbl->setStyleSheet(QString("QLabel { %1 font-weight: 700; }").arg(GUIUtil::getThemedStyleQString(GUIUtil::ThemedStyle::TS_ERROR)));
315-
}
300+
lbl->setText(valid ? "" : "");
301+
lbl->setStyleSheet(valid ?
302+
GUIUtil::getThemedStyleQString(GUIUtil::ThemedStyle::TS_SUCCESS) :
303+
GUIUtil::getThemedStyleQString(GUIUtil::ThemedStyle::TS_ERROR));
316304
};
317305
setStatus(ui->word1Status, !t1.isEmpty(), ok1);
318306
setStatus(ui->word2Status, !t2.isEmpty(), ok2);
@@ -405,7 +393,7 @@ void MnemonicVerificationDialog::buildMnemonicGrid(bool reveal)
405393
const int columns = (n >= 24) ? 4 : 3;
406394
const int rows = (n + columns - 1) / columns;
407395

408-
QFont mono; mono.setStyleHint(QFont::Monospace); mono.setFamily("Monospace"); mono.setPointSize(13);
396+
// Font styling is defined in general.css
409397
m_gridLayout->setContentsMargins(6, 2, 6, 8);
410398
m_gridLayout->setHorizontalSpacing(32);
411399
m_gridLayout->setVerticalSpacing(7);
@@ -415,7 +403,6 @@ void MnemonicVerificationDialog::buildMnemonicGrid(bool reveal)
415403
int idx = r * columns + c; if (idx >= n) break;
416404
const QString text = QString("%1. •••••••").arg(idx + 1, 2);
417405
QLabel* lbl = new QLabel(text);
418-
lbl->setFont(mono);
419406
lbl->setTextInteractionFlags(Qt::TextSelectableByMouse);
420407
m_gridLayout->addWidget(lbl, r, c);
421408
}
@@ -430,7 +417,7 @@ void MnemonicVerificationDialog::buildMnemonicGrid(bool reveal)
430417
const int columns = (n >= 24) ? 4 : 3;
431418
const int rows = (n + columns - 1) / columns;
432419

433-
QFont mono; mono.setStyleHint(QFont::Monospace); mono.setFamily("Monospace"); mono.setPointSize(13);
420+
// Font styling is defined in general.css
434421
m_gridLayout->setContentsMargins(6, 2, 6, 8);
435422
m_gridLayout->setHorizontalSpacing(32);
436423
m_gridLayout->setVerticalSpacing(7);
@@ -440,7 +427,6 @@ void MnemonicVerificationDialog::buildMnemonicGrid(bool reveal)
440427
int idx = r * columns + c; if (idx >= n) break;
441428
const QString text = QString("%1. %2").arg(idx + 1, 2).arg(words[idx]);
442429
QLabel* lbl = new QLabel(text);
443-
lbl->setFont(mono);
444430
lbl->setTextInteractionFlags(Qt::TextSelectableByMouse);
445431
m_gridLayout->addWidget(lbl, r, c);
446432
}

src/qt/res/css/general.css

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1985,3 +1985,54 @@ QDialog#HelpMessageDialog QScrollBar:horizontal {
19851985
}
19861986

19871987
</os>
1988+
1989+
/**
1990+
* CreateWalletDialog (Layout)
1991+
*/
1992+
1993+
QDialog#CreateWalletDialog QGroupBox#groupBox {
1994+
border-radius: 8px;
1995+
padding: 2px 12px 12px 12px;
1996+
margin-top: 0px;
1997+
}
1998+
1999+
QDialog#CreateWalletDialog QGroupBox#groupBox::title {
2000+
padding: 0px;
2001+
}
2002+
2003+
/**
2004+
* MnemonicVerificationDialog (Layout)
2005+
*/
2006+
2007+
QDialog#MnemonicVerificationDialog QLabel#warningLabel {
2008+
font-size: 17px;
2009+
font-weight: 700;
2010+
}
2011+
2012+
QDialog#MnemonicVerificationDialog QLabel#instructionLabel {
2013+
font-size: 14px;
2014+
}
2015+
2016+
QDialog#MnemonicVerificationDialog QLabel#verificationLabel {
2017+
margin-top: 0px;
2018+
margin-bottom: 4px;
2019+
}
2020+
2021+
QDialog#MnemonicVerificationDialog QLabel#word1Status,
2022+
QDialog#MnemonicVerificationDialog QLabel#word2Status,
2023+
QDialog#MnemonicVerificationDialog QLabel#word3Status {
2024+
font-weight: 700;
2025+
min-width: 18px;
2026+
}
2027+
2028+
QDialog#MnemonicVerificationDialog QScrollArea#mnemonicScroll QWidget#mnemonicGridWidget QLabel {
2029+
font-family: monospace;
2030+
font-size: 13pt;
2031+
}
2032+
2033+
QDialog#MnemonicVerificationDialog QLineEdit#word1Edit,
2034+
QDialog#MnemonicVerificationDialog QLineEdit#word2Edit,
2035+
QDialog#MnemonicVerificationDialog QLineEdit#word3Edit {
2036+
max-width: 320px;
2037+
}
2038+

0 commit comments

Comments
 (0)