@@ -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
242242void 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 ;
0 commit comments