Qt: replace deprecated methods of QMessageBox

This commit is contained in:
wmayer
2022-11-03 09:54:00 +01:00
parent f1d07db7b8
commit 6118dfd7bd
8 changed files with 30 additions and 27 deletions

View File

@@ -154,11 +154,15 @@ void StdCmdOpen::activated(int iMsg)
App::Document *doc = App::GetApplication().getActiveDocument();
if(doc && doc->testStatus(App::Document::PartialRestore))
QMessageBox::critical(getMainWindow(), QObject::tr("Error"), QObject::tr("There were errors while loading the file. Some data might have been modified or not recovered at all. Look in the report view for more specific information about the objects involved."));
if(doc && doc->testStatus(App::Document::PartialRestore)) {
QMessageBox::critical(getMainWindow(), QObject::tr("Error"),
QObject::tr("There were errors while loading the file. Some data might have been modified or not recovered at all. Look in the report view for more specific information about the objects involved."));
}
if(doc && doc->testStatus(App::Document::RestoreError))
QMessageBox::critical(getMainWindow(), QObject::tr("Error"), QObject::tr("There were serious errors while loading the file. Some data might have been modified or not recovered at all. Saving the project will most likely result in loss of data."));
if(doc && doc->testStatus(App::Document::RestoreError)) {
QMessageBox::critical(getMainWindow(), QObject::tr("Error"),
QObject::tr("There were serious errors while loading the file. Some data might have been modified or not recovered at all. Saving the project will most likely result in loss of data."));
}
}
}
}
@@ -1193,7 +1197,7 @@ void StdCmdDuplicateSelection::activated(int iMsg)
if (doc) {
bool proceed = true;
if(hasXLink && !doc->isSaved()) {
int ret = QMessageBox::question(getMainWindow(),
auto ret = QMessageBox::question(getMainWindow(),
qApp->translate("Std_DuplicateSelection","Object dependencies"),
qApp->translate("Std_DuplicateSelection",
"To link to external objects, the document must be saved at least once.\n"
@@ -1342,7 +1346,7 @@ void StdCmdDelete::activated(int iMsg)
if(more)
bodyMessageStream << "\n...";
int ret = QMessageBox::warning(Gui::getMainWindow(),
auto ret = QMessageBox::warning(Gui::getMainWindow(),
qApp->translate("Std_Delete", "Object dependencies"), bodyMessage,
QMessageBox::Yes, QMessageBox::No);
if (ret == QMessageBox::Yes)
@@ -1432,7 +1436,7 @@ void StdCmdRefresh::activated(int iMsg)
doCommand(Doc,"App.activeDocument().recompute(None,True,True)");
}
catch (Base::Exception& /*e*/) {
int ret = QMessageBox::warning(getMainWindow(), QObject::tr("Dependency error"),
auto ret = QMessageBox::warning(getMainWindow(), QObject::tr("Dependency error"),
qApp->translate("Std_Refresh", "The document contains dependency cycles.\n"
"Please check the Report View for more details.\n\n"
"Do you still want to proceed?"),

View File

@@ -446,11 +446,11 @@ void StdCmdFreezeViews::onRestoreViews()
{
// Should we clear the already saved views
if (savedViews > 0) {
int ret = QMessageBox::question(getMainWindow(), QObject::tr("Restore views"),
auto ret = QMessageBox::question(getMainWindow(), QObject::tr("Restore views"),
QObject::tr("Importing the restored views would clear the already stored views.\n"
"Do you want to continue?"), QMessageBox::Yes|QMessageBox::Default,
QMessageBox::No|QMessageBox::Escape);
if (ret!=QMessageBox::Yes)
"Do you want to continue?"), QMessageBox::Yes | QMessageBox::No,
QMessageBox::Yes);
if (ret != QMessageBox::Yes)
return;
}

View File

@@ -415,11 +415,10 @@ void DlgMacroExecuteImp::on_deleteButton_clicked()
}
QString fn = item->text(0);
int ret = QMessageBox::question(this, tr("Delete macro"),
auto ret = QMessageBox::question(this, tr("Delete macro"),
tr("Do you really want to delete the macro '%1'?").arg( fn ),
QMessageBox::Yes, QMessageBox::No|QMessageBox::Default|QMessageBox::Escape);
if (ret == QMessageBox::Yes)
{
QMessageBox::Yes | QMessageBox::No, QMessageBox::No);
if (ret == QMessageBox::Yes) {
QDir dir(this->macroPath);
dir.remove(fn);
int index = ui->userMacroListBox->indexOfTopLevelItem(item);

View File

@@ -103,10 +103,8 @@ void DlgMacroRecordImp::on_buttonStart_clicked()
if (fi.isFile() && fi.exists()) {
if (QMessageBox::question(this, tr("Existing macro"),
tr("The macro '%1' already exists. Do you want to overwrite?").arg(fn),
QMessageBox::Yes,
QMessageBox::No|
QMessageBox::Default|
QMessageBox::Escape) == QMessageBox::No)
QMessageBox::Yes | QMessageBox::No,
QMessageBox::No) == QMessageBox::No)
return;
}

View File

@@ -504,7 +504,7 @@ void ParameterGroup::onDeleteSelectedItem()
if (sel && sel->isSelected() && sel->parent())
{
if ( QMessageBox::question(this, tr("Remove group"), tr("Do you really want to remove this parameter group?"),
QMessageBox::Yes, QMessageBox::No|QMessageBox::Default|QMessageBox::Escape) ==
QMessageBox::Yes | QMessageBox::No, QMessageBox::No) ==
QMessageBox::Yes )
{
QTreeWidgetItem* parent = sel->parent();

View File

@@ -195,7 +195,7 @@ void EditorView::checkTimestamp()
if (timeStamp != d->timeStamp) {
switch( QMessageBox::question( this, tr("Modified file"),
tr("%1.\n\nThis has been modified outside of the source editor. Do you want to reload it?").arg(d->fileName),
QMessageBox::Yes|QMessageBox::Default, QMessageBox::No|QMessageBox::Escape) )
QMessageBox::Yes | QMessageBox::No, QMessageBox::Yes) )
{
case QMessageBox::Yes:
// updates time stamp and timer
@@ -204,6 +204,8 @@ void EditorView::checkTimestamp()
case QMessageBox::No:
d->timeStamp = timeStamp;
break;
default:
break;
}
}
@@ -318,8 +320,7 @@ bool EditorView::canClose()
switch( QMessageBox::question(this, tr("Unsaved document"),
tr("The document has been modified.\n"
"Do you want to save your changes?"),
QMessageBox::Yes|QMessageBox::Default, QMessageBox::No,
QMessageBox::Cancel|QMessageBox::Escape))
QMessageBox::Yes | QMessageBox::No | QMessageBox::Cancel, QMessageBox::Cancel))
{
case QMessageBox::Yes:
return saveFile();

View File

@@ -999,13 +999,13 @@ void ManualAlignment::align()
}
else {
// Inform user that alignment failed
int ret = QMessageBox::critical(myViewer, tr("Manual alignment"),
auto ret = QMessageBox::critical(myViewer, tr("Manual alignment"),
tr("The alignment failed.\nHow do you want to proceed?"),
tr("Retry"), tr("Ignore"), tr("Abort"));
if ( ret == 1 ) {
QMessageBox::Retry | QMessageBox::Ignore | QMessageBox::Abort);
if ( ret == QMessageBox::Ignore ) {
myAlignModel.continueAlignment();
}
else if ( ret == 2 ) {
else if ( ret == QMessageBox::Abort ) {
finish();
return;
}

View File

@@ -25,6 +25,7 @@
# include <cstdlib>
# include <QApplication>
# include <QClipboard>
# include <QFile>
# include <QLocale>
# include <QMutex>
# include <QProcessEnvironment>