Skip to content

Commit 6ba4d53

Browse files
authored
Merge pull request #142 from Integer-Ctrl/pr-review
fix: dynamic font size & ui improvements
2 parents a7ca2c7 + f96c88d commit 6ba4d53

20 files changed

+126
-136
lines changed

plugins/SkyCultureMaker/src/SkyCultureMaker.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -79,10 +79,9 @@ SkyCultureMaker::SkyCultureMaker()
7979
: isScmEnabled(false)
8080
, isLineDrawEnabled(false)
8181
{
82-
qDebug() << "SkyCulture Maker constructed";
82+
qDebug() << "SkyCultureMaker constructed";
8383

8484
setObjectName("SkyCultureMaker");
85-
font.setPixelSize(25);
8685

8786
drawObj = new scm::ScmDraw();
8887
scmStartDialog = new ScmStartDialog(this);

plugins/SkyCultureMaker/src/gui/ScmConstellationDialog.cpp

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,13 @@ void ScmConstellationDialog::createDialogContent()
141141
connect(ui->saveBtn, &QPushButton::clicked, this, &ScmConstellationDialog::saveConstellation);
142142
connect(ui->cancelBtn, &QPushButton::clicked, this, &ScmConstellationDialog::cancel);
143143

144+
connect(&StelApp::getInstance(), &StelApp::fontChanged, this, &ScmConstellationDialog::handleFontChanged);
145+
connect(&StelApp::getInstance(), &StelApp::guiFontSizeChanged, this, &ScmConstellationDialog::handleFontChanged);
146+
147+
handleFontChanged();
148+
144149
// LABELS TAB
150+
145151
connect(ui->enNameTE, &QTextEdit::textChanged, this,
146152
[this]()
147153
{
@@ -181,6 +187,18 @@ void ScmConstellationDialog::createDialogContent()
181187
});
182188
}
183189

190+
void ScmConstellationDialog::handleFontChanged()
191+
{
192+
QFont infoLblFont = QApplication::font();
193+
infoLblFont.setBold(true);
194+
ui->infoLbl->setFont(infoLblFont);
195+
196+
QFont labelsTitleFont = QApplication::font();
197+
labelsTitleFont.setPixelSize(labelsTitleFont.pixelSize() + 2);
198+
labelsTitleFont.setBold(true);
199+
ui->labelsTitle->setFont(labelsTitleFont);
200+
}
201+
184202
void ScmConstellationDialog::togglePen(bool checked)
185203
{
186204
if (checked)
@@ -314,6 +332,7 @@ void ScmConstellationDialog::bindSelectedStar()
314332

315333
void ScmConstellationDialog::tabChanged(int index)
316334
{
335+
Q_UNUSED(index);
317336
ui->penBtn->setChecked(false);
318337
ui->eraserBtn->setChecked(false);
319338
maker->setDrawTool(scm::DrawTools::None);

plugins/SkyCultureMaker/src/gui/ScmConstellationDialog.hpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,9 @@ public slots:
5656
*/
5757
void resetDialog();
5858

59+
protected slots:
60+
void handleFontChanged();
61+
5962
private slots:
6063
void togglePen(bool checked);
6164
void toggleEraser(bool checked);

plugins/SkyCultureMaker/src/gui/ScmHideOrAbortMakerDialog.cpp

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,11 @@ void ScmHideOrAbortMakerDialog::createDialogContent()
6060
connect(ui->titleBar, &TitleBar::closeClicked, this, &ScmHideOrAbortMakerDialog::cancelDialog);
6161
connect(ui->titleBar, SIGNAL(movedTo(QPoint)), this, SLOT(handleMovedTo(QPoint)));
6262

63+
connect(&StelApp::getInstance(), &StelApp::fontChanged, this, &ScmHideOrAbortMakerDialog::handleFontChanged);
64+
connect(&StelApp::getInstance(), &StelApp::guiFontSizeChanged, this,
65+
&ScmHideOrAbortMakerDialog::handleFontChanged);
66+
handleFontChanged();
67+
6368
// Buttons
6469
connect(ui->scmMakerAbortButton, &QPushButton::clicked, this,
6570
&ScmHideOrAbortMakerDialog::abortScmCreationProcess); // Abort
@@ -69,6 +74,13 @@ void ScmHideOrAbortMakerDialog::createDialogContent()
6974
&ScmHideOrAbortMakerDialog::cancelDialog); // Cancel
7075
}
7176

77+
void ScmHideOrAbortMakerDialog::handleFontChanged()
78+
{
79+
QFont questionFont = QApplication::font();
80+
questionFont.setPixelSize(questionFont.pixelSize() + 4);
81+
ui->questionLbl->setFont(questionFont);
82+
}
83+
7284
// TODO: save state of the current sky culture
7385
void ScmHideOrAbortMakerDialog::hideScmCreationProcess()
7486
{

plugins/SkyCultureMaker/src/gui/ScmHideOrAbortMakerDialog.hpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,9 @@ class ScmHideOrAbortMakerDialog : public StelDialogSeparate
4242
public slots:
4343
void retranslate() override;
4444

45+
protected slots:
46+
void handleFontChanged();
47+
4548
private slots:
4649
void hideScmCreationProcess();
4750
void abortScmCreationProcess();

plugins/SkyCultureMaker/src/gui/ScmSkyCultureDialog.cpp

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,11 @@ void ScmSkyCultureDialog::createDialogContent()
116116
connect(ui->constellationsList, &QListWidget::itemSelectionChanged, this,
117117
&ScmSkyCultureDialog::updateRemoveConstellationButton);
118118

119-
// License Tab
119+
connect(&StelApp::getInstance(), &StelApp::fontChanged, this, &ScmSkyCultureDialog::handleFontChanged);
120+
connect(&StelApp::getInstance(), &StelApp::guiFontSizeChanged, this, &ScmSkyCultureDialog::handleFontChanged);
121+
handleFontChanged();
122+
123+
// Description Tab
120124

121125
// add all licenses to the combo box
122126
for (const auto &license : scm::LICENSES)
@@ -149,6 +153,20 @@ void ScmSkyCultureDialog::createDialogContent()
149153
}
150154
}
151155

156+
void ScmSkyCultureDialog::handleFontChanged()
157+
{
158+
QFont headlineFont = QApplication::font();
159+
headlineFont.setPixelSize(headlineFont.pixelSize() + 2);
160+
ui->currentSCNameLbl->setFont(headlineFont);
161+
ui->constellationsLbl->setFont(headlineFont);
162+
ui->selectLicenseLbl->setFont(headlineFont);
163+
164+
QFont descriptionTabLblFont = QApplication::font();
165+
descriptionTabLblFont.setPixelSize(descriptionTabLblFont.pixelSize() + 2);
166+
descriptionTabLblFont.setBold(true);
167+
ui->descriptionTabLbl->setFont(descriptionTabLblFont);
168+
}
169+
152170
void ScmSkyCultureDialog::saveSkyCulture()
153171
{
154172
scm::Description desc = getDescriptionFromTextEdit();

plugins/SkyCultureMaker/src/gui/ScmSkyCultureDialog.hpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,9 @@ public slots:
7575
void retranslate() override;
7676
void close() override;
7777

78+
protected slots:
79+
void handleFontChanged();
80+
7881
private slots:
7982
void saveSkyCulture();
8083
void constellationDialog();

plugins/SkyCultureMaker/src/gui/ScmSkyCultureExportDialog.cpp

Lines changed: 28 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,11 @@ void ScmSkyCultureExportDialog::createDialogContent()
6262
{
6363
ui->setupUi(dialog);
6464

65+
connect(&StelApp::getInstance(), &StelApp::fontChanged, this, &ScmSkyCultureExportDialog::handleFontChanged);
66+
connect(&StelApp::getInstance(), &StelApp::guiFontSizeChanged, this,
67+
&ScmSkyCultureExportDialog::handleFontChanged);
68+
handleFontChanged();
69+
6570
connect(&StelApp::getInstance(), SIGNAL(languageChanged()), this, SLOT(retranslate()));
6671
connect(ui->titleBar, SIGNAL(movedTo(QPoint)), this, SLOT(handleMovedTo(QPoint)));
6772
connect(ui->titleBar, &TitleBar::closeClicked, this, &ScmSkyCultureExportDialog::close);
@@ -70,6 +75,14 @@ void ScmSkyCultureExportDialog::createDialogContent()
7075
connect(ui->cancelBtn, &QPushButton::clicked, this, &ScmSkyCultureExportDialog::close);
7176
}
7277

78+
void ScmSkyCultureExportDialog::handleFontChanged()
79+
{
80+
QFont titleLblFont = QApplication::font();
81+
titleLblFont.setPixelSize(titleLblFont.pixelSize() + 2);
82+
titleLblFont.setBold(true);
83+
ui->titleLbl->setFont(titleLblFont);
84+
}
85+
7386
void ScmSkyCultureExportDialog::saveSkyCulture()
7487
{
7588
if (maker == nullptr)
@@ -88,22 +101,23 @@ void ScmSkyCultureExportDialog::saveSkyCulture()
88101
return;
89102
}
90103

91-
QString skyCultureId = currentSkyCulture->getId();
92-
104+
QString skyCultureId = currentSkyCulture->getId();
105+
93106
// Let the user choose the export directory with skyCulturesPath as default
94107
QDir skyCultureDirectory;
95108
bool exportDirectoryChosen = chooseExportDirectory(skyCultureId, skyCultureDirectory);
96109
if (!exportDirectoryChosen)
97110
{
98-
qWarning() << "SkyCultureMaker: Could not export sky culture. User cancelled or failed to choose directory.";
111+
qWarning() << "SkyCultureMaker: Could not export sky culture. User cancelled or failed to choose "
112+
"directory.";
99113
maker->setSkyCultureDialogInfoLabel("ERROR: Failed to choose export directory.");
100114
return; // User cancelled or failed to choose directory
101115
}
102-
116+
103117
if (skyCultureDirectory.exists())
104118
{
105119
qWarning() << "SkyCultureMaker: Sky culture with ID" << skyCultureId
106-
<< "already exists. Cannot export.";
120+
<< "already exists. Cannot export.";
107121
maker->setSkyCultureDialogInfoLabel("ERROR: Sky culture with this ID already exists.");
108122
// dont close the dialog here, so the user can delete the folder first
109123
return;
@@ -114,7 +128,8 @@ void ScmSkyCultureExportDialog::saveSkyCulture()
114128
if (!createdDirectorySuccessfully)
115129
{
116130
maker->setSkyCultureDialogInfoLabel("ERROR: Failed to create sky culture directory.");
117-
qWarning() << "SkyCultureMaker: Failed to create sky culture directory at" << skyCultureDirectory.absolutePath();
131+
qWarning() << "SkyCultureMaker: Failed to create sky culture directory at"
132+
<< skyCultureDirectory.absolutePath();
118133
return;
119134
}
120135

@@ -177,27 +192,29 @@ void ScmSkyCultureExportDialog::saveSkyCulture()
177192
return;
178193
}
179194

180-
maker->setSkyCultureDialogInfoLabel("Sky culture exported successfully to " + skyCultureDirectory.absolutePath());
195+
maker->setSkyCultureDialogInfoLabel("Sky culture exported successfully to " +
196+
skyCultureDirectory.absolutePath());
181197
qInfo() << "SkyCultureMaker: Sky culture exported successfully to" << skyCultureDirectory.absolutePath();
182198
ScmSkyCultureExportDialog::close();
183199
}
184200

185201
bool ScmSkyCultureExportDialog::chooseExportDirectory(const QString& skyCultureId, QDir& skyCultureDirectory)
186202
{
187-
QString selectedDirectory = QFileDialog::getExistingDirectory(nullptr, tr("Choose Export Directory"), skyCulturesPath);
203+
QString selectedDirectory = QFileDialog::getExistingDirectory(nullptr, tr("Choose Export Directory"),
204+
skyCulturesPath);
188205
if (selectedDirectory.isEmpty())
189206
{
190207
// User cancelled the dialog
191208
return false;
192209
}
193-
210+
194211
if (!QDir(selectedDirectory).exists())
195212
{
196213
maker->setSkyCultureDialogInfoLabel("ERROR: The selected directory is not valid");
197214
qDebug() << "SkyCultureMaker: Selected non-existing export directory";
198215
return false;
199216
}
200-
217+
201218
skyCultureDirectory = QDir(selectedDirectory + QDir::separator() + skyCultureId);
202219
return true;
203220
}
@@ -210,7 +227,7 @@ void ScmSkyCultureExportDialog::saveAndExitSkyCulture()
210227
maker->setIsScmEnabled(false);
211228
}
212229

213-
bool ScmSkyCultureExportDialog::saveSkyCultureCMakeListsFile(const QDir &directory)
230+
bool ScmSkyCultureExportDialog::saveSkyCultureCMakeListsFile(const QDir& directory)
214231
{
215232
QFile cmakeListsFile(directory.absoluteFilePath("CMakeLists.txt"));
216233
if (!cmakeListsFile.open(QIODevice::WriteOnly | QIODevice::Text))

plugins/SkyCultureMaker/src/gui/ScmSkyCultureExportDialog.hpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,9 @@ class ScmSkyCultureExportDialog : public StelDialogSeparate
4242
public slots:
4343
void retranslate() override;
4444

45+
protected slots:
46+
void handleFontChanged();
47+
4548
private:
4649
Ui_scmSkyCultureExportDialog *ui = nullptr;
4750
SkyCultureMaker *maker = nullptr;

plugins/SkyCultureMaker/src/gui/ScmStartDialog.cpp

Lines changed: 19 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -69,8 +69,8 @@ void ScmStartDialog::createDialogContent()
6969
ui->setupUi(dialog);
7070

7171
// connect(&StelApp::getInstance(), SIGNAL(languageChanged()), this, SLOT(retranslate()));
72-
connect(ui->titleBar, &TitleBar::closeClicked, this, &ScmStartDialog::closeDialog);
73-
connect(ui->titleBar, SIGNAL(movedTo(QPoint)), this, SLOT(handleMovedTo(QPoint)));
72+
connect(&StelApp::getInstance(), &StelApp::fontChanged, this, &ScmStartDialog::handleFontChanged);
73+
connect(&StelApp::getInstance(), &StelApp::guiFontSizeChanged, this, &ScmStartDialog::handleFontChanged);
7474

7575
// Buttons
7676
connect(ui->scmStartCancelpushButton, &QPushButton::clicked, this, &ScmStartDialog::closeDialog); // Cancel
@@ -79,10 +79,15 @@ void ScmStartDialog::createDialogContent()
7979
connect(ui->scmStartEditpushButton, &QPushButton::clicked, this,
8080
&ScmStartDialog::closeDialog); // Edit - TODO: add logic (currently closing the window)
8181

82+
connect(ui->titleBar, &TitleBar::closeClicked, this, &ScmStartDialog::closeDialog);
83+
connect(ui->titleBar, SIGNAL(movedTo(QPoint)), this, SLOT(handleMovedTo(QPoint)));
84+
// Init the correct font
85+
handleFontChanged();
86+
8287
/* =============================================== SkyCultureConverter ============================================== */
8388
#ifdef SCM_CONVERTER_ENABLED_CPP
8489
ui->scmStartConvertpushButton->setToolTip(
85-
tr("Convert SkyCultures from the legacy (fab) format to the new (json) format"));
90+
tr("Convert sky cultures from the legacy (fab) format to the new (json) format"));
8691
connect(ui->scmStartConvertpushButton, &QPushButton::clicked, this,
8792
[this]()
8893
{
@@ -96,10 +101,18 @@ void ScmStartDialog::createDialogContent()
96101
#else // SCM_CONVERTER_ENABLED_CPP is not defined
97102
// Converter is disabled, so disable the button
98103
ui->scmStartConvertpushButton->setEnabled(false);
99-
ui->scmStartConvertpushButton->setToolTip(
100-
tr("The Sky Culture Converter has been turned off for this build."));
104+
ui->scmStartConvertpushButton->setToolTip(tr("The Sky Culture Converter has been turned off for this build."));
101105
#endif // SCM_CONVERTER_ENABLED_CPP
102-
/* ================================================================================================================== */
106+
/* ================================================================================================================== */
107+
}
108+
109+
void ScmStartDialog::handleFontChanged()
110+
{
111+
// Set welcome label font size
112+
QFont welcomeLabelFont = QApplication::font();
113+
welcomeLabelFont.setPixelSize(welcomeLabelFont.pixelSize() + 4);
114+
welcomeLabelFont.setBold(true);
115+
ui->welcomeLabel->setFont(welcomeLabelFont);
103116
}
104117

105118
void ScmStartDialog::startScmCreationProcess()

0 commit comments

Comments
 (0)