# HG changeset patch # User Matti Hamalainen # Date 1679051383 -7200 # Node ID df3f902588af2f2f95a75a35416accae1219cd4d # Parent 8c6fb6ee6f9e3b97fdd550ce0fbfa06201d5d3d0 Add parent window argument to slErrorMsg() and use it. Also use main window as parent for other static/modal dialogs. diff -r 8c6fb6ee6f9e -r df3f902588af src/editperson.cpp --- a/src/editperson.cpp Sun Feb 12 15:20:11 2023 +0200 +++ b/src/editperson.cpp Fri Mar 17 13:09:43 2023 +0200 @@ -87,7 +87,7 @@ // if (!validateForm()) { - slErrorMsg( + slErrorMsg(this, tr("Virhe!"), tr("Vaaditut kentät (etunimi, sukunimi) eivät ole täytetty tai lisätietojen pituus on liian suuri.")); @@ -113,7 +113,7 @@ if (person.next()) { // There exists another person with that name - slErrorMsg( + slErrorMsg(this, tr("Virhe!"), tr("Ei pysty! Samalla nimellä '%1 %2' on olemassa jo henkilö!"). arg(selPerson.firstName).arg(selPerson.lastName)); @@ -144,7 +144,7 @@ if (person.next()) { // There exists a record with same name - slErrorMsg( + slErrorMsg(this, tr("Virhe!"), tr("Ei pysty! Samalla nimellä '%1 %2' on olemassa jo henkilö!"). arg(selPerson.firstName).arg(selPerson.lastName)); @@ -156,7 +156,7 @@ qint64 nid = dynamic_cast(parent())->model_People->addPerson(selPerson); if (nid < 0) { - slErrorMsg( + slErrorMsg(this, tr("Virhe!"), tr("Tietokannan käsittelyssä tapahtui virhe (#%1)."). arg(nid)); diff -r 8c6fb6ee6f9e -r df3f902588af src/main.cpp --- a/src/main.cpp Sun Feb 12 15:20:11 2023 +0200 +++ b/src/main.cpp Fri Mar 17 13:09:43 2023 +0200 @@ -161,7 +161,7 @@ RunGuard guard(QStringLiteral(APP_VENDOR) + QStringLiteral(APP_ID)); if (!guard.tryToRun()) { - slErrorMsg( + slErrorMsg(0, QObject::tr("Virhe!"), QObject::tr( "Syntilista-sovellus on jo käynnissä. Sulje tämä ikkuna ja " @@ -215,7 +215,7 @@ if (!db.open()) { - slErrorMsg( + slErrorMsg(0, QObject::tr("Tietokantaa ei voitu avata"), QObject::tr("Yhteyttä SQL-tietokantaan ei saatu.

Virhe: %1

"). arg(db.lastError().text()) @@ -228,7 +228,7 @@ // if (!slConditionallyCreateSQLTables(db, slSQLSchemaData, nslSQLSchemaData)) { - slErrorMsg( + slErrorMsg(0, QObject::tr("Tietokantataulua ei voitu luoda"), QObject::tr("Virhe: %1

"). arg(db.lastError().text()) @@ -346,7 +346,7 @@ QDateTime::fromSecsSinceEpoch(0).msecsTo(settings.dbLastBackup) > 0 && delta > (1000 * 60 * 60 * 24) * threshold) { - slErrorMsg( + slErrorMsg(this, tr("

Huomio!

"), tr( "

Edellisestä onnistuneesta tietokannan varmuuskopioinnista on kulunut %1 päivää.

" @@ -748,8 +748,9 @@ } // Ask for confirmation - QMessageBox dlg; + QMessageBox dlg(this); slSetCommonStyleSheet(&dlg); + dlg.setText(tr("Varmistus")); dlg.setInformativeText(tr( "

Haluatko varmasti poistaa henkilön:

" @@ -774,7 +775,8 @@ setActivePerson(-1); if (rv != 0) { - slErrorMsg(tr("SQL-tietokantavirhe"), + slErrorMsg(this, + tr("SQL-tietokantavirhe"), tr("Henkilön tietoja poistettaessa tapahtui virhe #%1."). arg(rv)); } @@ -1083,7 +1085,7 @@ } else { - slErrorMsg( + slErrorMsg(this, tr("SQL-tietokantavirhe"), tr("Tietokantaan tapahtumaa lisättäessa tapahtui virhe #%1."). arg(ret)); @@ -1118,7 +1120,7 @@ if (currPerson.balance < 0) { // And ask confirmation that user really wants to clear the full debt - QMessageBox dlg; + QMessageBox dlg(this); slSetCommonStyleSheet(&dlg); dlg.setText(tr("Varmistus")); dlg.setInformativeText(tr( diff -r 8c6fb6ee6f9e -r df3f902588af src/printing.cpp --- a/src/printing.cpp Sun Feb 12 15:20:11 2023 +0200 +++ b/src/printing.cpp Fri Mar 17 13:09:43 2023 +0200 @@ -132,7 +132,7 @@ if (!slCheckAndReportSQLError(query, "printDocumentPage()")) { - slErrorMsg( + slErrorMsg(this, tr("SQL-tietokantavirhe"), tr("Tietokantaa selattaessa tapahtui virhe.")); diff -r 8c6fb6ee6f9e -r df3f902588af src/util.cpp --- a/src/util.cpp Sun Feb 12 15:20:11 2023 +0200 +++ b/src/util.cpp Fri Mar 17 13:09:43 2023 +0200 @@ -92,9 +92,9 @@ // // Display an error dialog with given title and message // -int slErrorMsg(const QString &title, const QString &msg) +int slErrorMsg(QWidget *parent, const QString &title, const QString &msg) { - QMessageBox dlg; + QMessageBox dlg(parent); slLog("ERROR", msg); diff -r 8c6fb6ee6f9e -r df3f902588af src/util.h --- a/src/util.h Sun Feb 12 15:20:11 2023 +0200 +++ b/src/util.h Fri Mar 17 13:09:43 2023 +0200 @@ -10,6 +10,9 @@ #define SL_UTIL_H +#include + + #define SQL_MAX_SCHEMA_INSERTS 16 @@ -37,7 +40,7 @@ const QString slDateTimeToStr(const QDateTime &val); void slLog(const QString &mtype, const QString &msg); -int slErrorMsg(const QString &title, const QString &msg); +int slErrorMsg(QWidget *parent, const QString &title, const QString &msg); bool slCheckAndReportSQLError(const QSqlQuery &query, const QString where, bool report = false); bool slConditionallyCreateSQLTables(QSqlDatabase &db, const SLSQLSchemaDef *schema, const int nschema);