Skip to content

Commit 9174d24

Browse files
committed
remove info labels
1 parent 77cb318 commit 9174d24

8 files changed

Lines changed: 125 additions & 164 deletions

plugins/SkyCultureMaker/src/SkyCultureMaker.cpp

Lines changed: 21 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -428,14 +428,6 @@ void SkyCultureMaker::updateSkyCultureDialog()
428428
scmSkyCultureDialog->setConstellations(currentSkyCulture->getConstellations());
429429
}
430430

431-
void SkyCultureMaker::setSkyCultureDialogInfoLabel(const QString &text)
432-
{
433-
if (scmSkyCultureDialog != nullptr)
434-
{
435-
scmSkyCultureDialog->setInfoLabel(text);
436-
}
437-
}
438-
439431
void SkyCultureMaker::setSkyCultureDescription(const scm::Description &description)
440432
{
441433
if (currentSkyCulture != nullptr)
@@ -585,3 +577,24 @@ void SkyCultureMaker::initSetting(QSettings *conf, const QString key, const QVar
585577
conf->setValue(key, defaultValue);
586578
}
587579
}
580+
581+
void SkyCultureMaker::showUserInfoMessage(QWidget *parent, const QString &dialogName, const QString &message)
582+
{
583+
const QString level = q_("INFO");
584+
const QString title = dialogName.isEmpty() ? level : dialogName + ": " + level;
585+
QMessageBox::information(parent, title, message);
586+
}
587+
588+
void SkyCultureMaker::showUserWarningMessage(QWidget *parent, const QString &dialogName, const QString &message)
589+
{
590+
const QString level = q_("WARNING");
591+
const QString title = dialogName.isEmpty() ? level : dialogName + ": " + level;
592+
QMessageBox::warning(parent, title, message);
593+
}
594+
595+
void SkyCultureMaker::showUserErrorMessage(QWidget *parent, const QString &dialogName, const QString &message)
596+
{
597+
const QString level = q_("ERROR");
598+
const QString title = dialogName.isEmpty() ? level : dialogName + ": " + level;
599+
QMessageBox::critical(parent, title, message);
600+
}

plugins/SkyCultureMaker/src/SkyCultureMaker.hpp

Lines changed: 30 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@
3737
#include <QDir>
3838
#include <QFile>
3939
#include <QFont>
40+
#include <QMessageBox>
4041

4142
class QPixmap;
4243
class StelButton;
@@ -177,12 +178,6 @@ class SkyCultureMaker : public StelModule
177178
*/
178179
void updateSkyCultureDialog();
179180

180-
/**
181-
* @brief Sets the info label text in the sky culture dialog.
182-
* @param text The text to set in the info label.
183-
*/
184-
void setSkyCultureDialogInfoLabel(const QString &text);
185-
186181
/**
187182
* @brief Sets the current sky culture description.
188183
* @param description The description to set.
@@ -238,6 +233,35 @@ class SkyCultureMaker : public StelModule
238233
*/
239234
void openConstellationDialog(const QString &constellationId);
240235

236+
/**
237+
* @brief Displays an information message to the user.
238+
*
239+
* @param parent The parent widget of the message box.
240+
* @param dialogName The name of the dialog to be shown in the title bar.
241+
* @param message The message to be displayed.
242+
*/
243+
void showUserInfoMessage(QWidget *parent, const QString &dialogName, const QString &message);
244+
245+
/**
246+
* @brief Displays a warning message to the user.
247+
*
248+
* @param parent The parent widget of the message box.
249+
* @param dialogName The name of the dialog to be shown in the title bar.
250+
* @param message The message to be displayed.
251+
*/
252+
void showUserWarningMessage(QWidget *parent, const QString &dialogName, const QString &message);
253+
254+
/**
255+
* @brief Displays an error message to the user.
256+
*
257+
* @param parent The parent widget of the message box.
258+
* @param dialogName The name of the dialog to be shown in the title bar.
259+
* @param message The message to be displayed.
260+
*/
261+
void showUserErrorMessage(QWidget *parent, const QString &dialogName, const QString &message);
262+
263+
264+
241265
signals:
242266
void eventIsScmEnabled(bool b);
243267

plugins/SkyCultureMaker/src/gui/ScmConstellationDialog.cpp

Lines changed: 34 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ void ScmConstellationDialog::setIsDarkConstellation(bool isDark)
115115
}
116116

117117
// the value changed, so we should reset some data from the previous mode
118-
if(isDarkConstellation != isDark)
118+
if (isDarkConstellation != isDark)
119119
{
120120
// reset drawn lines as they are not compatible between modes
121121
draw->resetDrawing();
@@ -241,10 +241,6 @@ void ScmConstellationDialog::createDialogContent()
241241

242242
void ScmConstellationDialog::handleFontChanged()
243243
{
244-
QFont infoLblFont = QApplication::font();
245-
infoLblFont.setBold(true);
246-
ui->infoLbl->setFont(infoLblFont);
247-
248244
QFont labelsTitleFont = QApplication::font();
249245
labelsTitleFont.setPixelSize(labelsTitleFont.pixelSize() + 2);
250246
labelsTitleFont.setBold(true);
@@ -300,21 +296,20 @@ void ScmConstellationDialog::triggerUploadImage()
300296

301297
if (!fileInfo.isFile())
302298
{
303-
ui->infoLbl->setText(q_("Choosen path is not a valid file:\n") + filePath);
299+
maker->showUserErrorMessage(this->dialog, ui->titleBar->title(),
300+
q_("Chosen path is not a valid file:\n") + filePath);
304301
return;
305302
}
306303

307304
if (!(fileInfo.suffix().compare("PNG", Qt::CaseInsensitive) == 0 ||
308305
fileInfo.suffix().compare("JPG", Qt::CaseInsensitive) == 0 ||
309306
fileInfo.suffix().compare("JPEG", Qt::CaseInsensitive) == 0))
310307
{
311-
ui->infoLbl->setText(q_("Chosen file is not a PNG, JPG or JPEG image:\n") + filePath);
308+
maker->showUserErrorMessage(this->dialog, ui->titleBar->title(),
309+
q_("Chosen file is not a PNG, JPG or JPEG image:\n") + filePath);
312310
return;
313311
}
314312

315-
// Reset text
316-
ui->infoLbl->setText("");
317-
318313
QPixmap image = QPixmap(fileInfo.absoluteFilePath());
319314
imageItem->setImage(image);
320315
imageItem->show();
@@ -337,7 +332,8 @@ void ScmConstellationDialog::bindSelectedStar()
337332
{
338333
if (!imageItem->hasAnchorSelection())
339334
{
340-
ui->infoLbl->setText(q_("WARNING: Select an anchor to bind to."));
335+
maker->showUserErrorMessage(this->dialog, ui->titleBar->title(),
336+
q_("No anchor was selected. Please select an anchor to bind to."));
341337
qDebug() << "SkyCultureMaker: No anchor was selected.";
342338
return;
343339
}
@@ -347,38 +343,41 @@ void ScmConstellationDialog::bindSelectedStar()
347343

348344
if (!objectMgr.getWasSelected())
349345
{
350-
ui->infoLbl->setText(q_("WARNING: Select a star to bind to the current selected anchor."));
346+
maker->showUserErrorMessage(this->dialog, ui->titleBar->title(),
347+
q_("No star was selected to bind to the current selected anchor."));
351348
qDebug() << "SkyCultureMaker: No star was selected to bind to.";
352349
return;
353350
}
354351

355352
StelObjectP stelObj = objectMgr.getLastSelectedObject();
356353
assert(stelObj != nullptr); // Checked through getWasSelected
357-
if (stelObj->getType().compare("star", Qt::CaseInsensitive) != 0)
354+
if (stelObj->getType().compare("star", Qt::CaseInsensitive) != 0 &&
355+
stelObj->getType().compare("nebula", Qt::CaseInsensitive) != 0)
358356
{
359-
ui->infoLbl->setText(q_("WARNING: The selected object must be of type star."));
360-
qDebug() << "SkyCultureMaker: The selected object is not of type start, got " << stelObj->getType();
357+
maker->showUserErrorMessage(this->dialog, ui->titleBar->title(),
358+
q_("The selected object must be of type Star or Nebula."));
359+
qDebug() << "SkyCultureMaker: The selected object is not of type Star, got " << stelObj->getType();
361360
return;
362361
}
363362

364363
ScmConstellationImageAnchor *anchor = imageItem->getSelectedAnchor();
365364
if (anchor == nullptr)
366365
{
367-
ui->infoLbl->setText(q_("WARNING: No anchor is selected."));
368-
qDebug() << "SkyCultureMaker: No anchor is selected";
366+
maker->showUserErrorMessage(this->dialog, ui->titleBar->title(),
367+
q_("No anchor was selected. Please select an anchor to bind to."));
368+
qDebug() << "SkyCultureMaker: No anchor was selected";
369369
return;
370370
}
371371

372372
bool success = anchor->trySetStarHip(stelObj->getID());
373373
if (success == false)
374374
{
375-
ui->infoLbl->setText(q_("WARNING: The selected object must contain a HIP number."));
375+
maker->showUserErrorMessage(this->dialog, ui->titleBar->title(),
376+
q_("The selected object must contain a HIP number."));
376377
qDebug() << "SkyCultureMaker: The object does not contain a HIP, id = " << stelObj->getID();
377378
return;
378379
}
379380

380-
ui->infoLbl->setText(""); // Reset
381-
382381
updateArtwork();
383382
}
384383

@@ -396,14 +395,16 @@ bool ScmConstellationDialog::canConstellationBeSaved() const
396395
scm::ScmSkyCulture *currentSkyCulture = maker->getCurrentSkyCulture();
397396
if (currentSkyCulture == nullptr)
398397
{
399-
ui->infoLbl->setText(q_("WARNING: Could not save: Sky Culture is not set"));
398+
maker->showUserErrorMessage(this->dialog, ui->titleBar->title(),
399+
q_("Could not save: Sky Culture is not set"));
400400
qDebug() << "SkyCultureMaker: Could not save: Sky Culture is not set";
401401
return false;
402402
}
403403

404404
if (constellationEnglishName.isEmpty())
405405
{
406-
ui->infoLbl->setText(q_("WARNING: Could not save: English name is empty"));
406+
maker->showUserErrorMessage(this->dialog, ui->titleBar->title(),
407+
q_("Could not save: English name is empty"));
407408
qDebug() << "SkyCultureMaker: Could not save: English name is empty";
408409
return false;
409410
}
@@ -412,15 +413,17 @@ bool ScmConstellationDialog::canConstellationBeSaved() const
412413
QString finalId = constellationId.isEmpty() ? constellationPlaceholderId : constellationId;
413414
if (finalId.isEmpty())
414415
{
415-
ui->infoLbl->setText(q_("WARNING: Could not save: Constellation ID is empty"));
416+
maker->showUserErrorMessage(this->dialog, ui->titleBar->title(),
417+
q_("Could not save: Constellation ID is empty"));
416418
qDebug() << "SkyCultureMaker: Could not save: Constellation ID is empty";
417419
return false;
418420
}
419421

420422
// Not editing a constellation, but the ID already exists
421423
if (constellationBeingEdited == nullptr && currentSkyCulture->getConstellation(finalId) != nullptr)
422424
{
423-
ui->infoLbl->setText(q_("WARNING: Could not save: Constellation with this ID already exists"));
425+
maker->showUserErrorMessage(this->dialog, ui->titleBar->title(),
426+
q_("Could not save: Constellation with this ID already exists"));
424427
qDebug() << "SkyCultureMaker: Could not save: Constellation with this ID already exists, id = "
425428
<< finalId;
426429
return false;
@@ -429,7 +432,8 @@ bool ScmConstellationDialog::canConstellationBeSaved() const
429432
else if (constellationBeingEdited != nullptr && constellationBeingEdited->getId() != finalId &&
430433
currentSkyCulture->getConstellation(finalId) != nullptr)
431434
{
432-
ui->infoLbl->setText(q_("WARNING: Could not save: Constellation with this ID already exists"));
435+
maker->showUserErrorMessage(this->dialog, ui->titleBar->title(),
436+
q_("Could not save: Constellation with this ID already exists"));
433437
qDebug() << "SkyCultureMaker: Could not save: Constellation with this ID already exists, id = "
434438
<< finalId;
435439
return false;
@@ -439,7 +443,8 @@ bool ScmConstellationDialog::canConstellationBeSaved() const
439443
auto drawnConstellation = maker->getScmDraw()->getCoordinates();
440444
if (drawnConstellation.empty())
441445
{
442-
ui->infoLbl->setText(q_("WARNING: Could not save: The constellation does not contain any drawings"));
446+
maker->showUserErrorMessage(this->dialog, ui->titleBar->title(),
447+
q_("Could not save: The constellation does not contain any drawings"));
443448
qDebug() << "SkyCultureMaker: Could not save: The constellation does not contain any drawings";
444449
return false;
445450
}
@@ -449,8 +454,9 @@ bool ScmConstellationDialog::canConstellationBeSaved() const
449454
{
450455
if (!imageItem->isImageAnchored())
451456
{
452-
ui->infoLbl->setText(q_("WARNING: Could not save: An artwork is attached, but not all "
453-
"anchors have a star bound."));
457+
maker->showUserErrorMessage(this->dialog, ui->titleBar->title(),
458+
q_("Could not save: An artwork is attached, but not all "
459+
"anchors have a star bound."));
454460
qDebug() << "SkyCultureMaker: Could not save: An artwork is attached, but not all "
455461
"anchors have a star bound.";
456462
return false;

plugins/SkyCultureMaker/src/gui/ScmSkyCultureDialog.cpp

Lines changed: 2 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -176,13 +176,13 @@ void ScmSkyCultureDialog::saveSkyCulture()
176176
// check if license is set
177177
if (desc.license == scm::LicenseType::NONE)
178178
{
179-
ui->infoLbl->setText(q_("WARNING: Please select a license for the sky culture."));
179+
maker->showUserWarningMessage(dialog, ui->titleBar->title(), q_("Please select a license for the sky culture."));
180180
return;
181181
}
182182
// check if description is complete
183183
if (!desc.isComplete())
184184
{
185-
ui->infoLbl->setText(q_("WARNING: The sky culture description is not complete."));
185+
maker->showUserWarningMessage(dialog, ui->titleBar->title(), q_("The sky culture description is not complete. Please fill in all required fields."));
186186
return;
187187
}
188188

@@ -321,18 +321,6 @@ scm::Description ScmSkyCultureDialog::getDescriptionFromTextEdit() const
321321
return desc;
322322
}
323323

324-
void ScmSkyCultureDialog::setInfoLabel(const QString &text)
325-
{
326-
if (ui && dialog)
327-
{
328-
ui->infoLbl->setText(text);
329-
}
330-
else
331-
{
332-
qDebug() << "ScmSkyCultureDialog: UI or dialog is not initialized.";
333-
}
334-
}
335-
336324
void ScmSkyCultureDialog::resetDialog()
337325
{
338326
if (ui && dialog)
@@ -357,7 +345,6 @@ void ScmSkyCultureDialog::resetDialog()
357345
name.clear();
358346
setIdFromName(name);
359347
resetConstellations();
360-
maker->setSkyCultureDialogInfoLabel("");
361348
maker->setSkyCultureDescription(getDescriptionFromTextEdit());
362349
updateRemoveConstellationButton();
363350
}

plugins/SkyCultureMaker/src/gui/ScmSkyCultureDialog.hpp

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -59,13 +59,6 @@ class ScmSkyCultureDialog : public StelDialogSeparate
5959
*/
6060
void resetConstellations();
6161

62-
/**
63-
* @brief Sets the info label text.
64-
*
65-
* @param text The text to set in the info label.
66-
*/
67-
void setInfoLabel(const QString &text);
68-
6962
/**
7063
* @brief Resets all fields in the dialog to their default values.
7164
*/

0 commit comments

Comments
 (0)