GUI: fix setting "open temp copy do not show next time" from the dialog, did not work with newer qt versions

This commit is contained in:
Jean-Francois Dockes 2022-01-21 19:38:45 +01:00
parent 44c0ec93e4
commit 32195d0899
3 changed files with 12 additions and 11 deletions

View File

@ -21,6 +21,7 @@
#include <list> #include <list>
#include <QMessageBox> #include <QMessageBox>
#include <QSettings>
#include "qxtconfirmationmessage.h" #include "qxtconfirmationmessage.h"
@ -382,11 +383,11 @@ void RclMain::startNativeViewer(Rcl::Doc doc, int pagenum, QString qterm)
"<br/>them to a permanent location."), "<br/>them to a permanent location."),
tr("Do not show this warning next time (use GUI preferences " tr("Do not show this warning next time (use GUI preferences "
"to restore).")); "to restore)."));
confirm.setOverrideSettingsKey("Recoll/prefs/showTempFileWarning"); confirm.setOverrideSettingsKey("/Recoll/prefs/showTempFileWarning");
confirm.exec(); confirm.exec();
QSettings settings; QSettings settings;
prefs.showTempFileWarning = prefs.showTempFileWarning =
settings.value("Recoll/prefs/showTempFileWarning").toInt(); settings.value("/Recoll/prefs/showTempFileWarning").toInt();
} }
// If we are not called with a page number (which would happen for a call // If we are not called with a page number (which would happen for a call

View File

@ -35,6 +35,7 @@
#include <QPushButton> #include <QPushButton>
#include <QGridLayout> #include <QGridLayout>
#include <QCheckBox> #include <QCheckBox>
#include <QSettings>
class QxtConfirmationMessagePrivate : public QxtPrivate<QxtConfirmationMessage> class QxtConfirmationMessagePrivate : public QxtPrivate<QxtConfirmationMessage>
{ {
@ -140,6 +141,8 @@ QxtConfirmationMessage::QxtConfirmationMessage(QWidget* parent)
{ {
QXT_INIT_PRIVATE(QxtConfirmationMessage); QXT_INIT_PRIVATE(QxtConfirmationMessage);
qxt_d().init(); qxt_d().init();
connect(this, SIGNAL(buttonClicked(QAbstractButton*)),
this, SLOT(onButtonClicked(QAbstractButton*)));
} }
/*! /*!
@ -154,6 +157,8 @@ QxtConfirmationMessage::QxtConfirmationMessage(
{ {
QXT_INIT_PRIVATE(QxtConfirmationMessage); QXT_INIT_PRIVATE(QxtConfirmationMessage);
qxt_d().init(confirmation); qxt_d().init(confirmation);
connect(this, SIGNAL(buttonClicked(QAbstractButton*)),
this, SLOT(onButtonClicked(QAbstractButton*)));
} }
/*! /*!
@ -284,21 +289,17 @@ int QxtConfirmationMessage::exec()
return res; return res;
} }
/*! void QxtConfirmationMessage::onButtonClicked(QAbstractButton *button)
\reimp
*/
void QxtConfirmationMessage::done(int result)
{ {
QDialogButtonBox* buttons = this->findChild<QDialogButtonBox*>(); QDialogButtonBox* buttons = this->findChild<QDialogButtonBox*>();
Q_ASSERT(buttons != 0); Q_ASSERT(buttons != 0);
int role = buttons->buttonRole(clickedButton()); int role = buttons->buttonRole(button);
if (qxt_d().confirm->isChecked() && if (qxt_d().confirm->isChecked() &&
(qxt_d().remember || role != QDialogButtonBox::RejectRole)) (qxt_d().remember || role != QDialogButtonBox::RejectRole))
{ {
qxt_d().doNotShowAgain(result); qxt_d().doNotShowAgain(0);
} }
QMessageBox::done(result);
} }
/*! /*!

View File

@ -32,7 +32,6 @@
#define QXTCONFIRMATIONMESSAGE_H #define QXTCONFIRMATIONMESSAGE_H
#include <QSettings>
#include <QMessageBox> #include <QMessageBox>
#include "qxtglobal.h" #include "qxtglobal.h"
@ -75,7 +74,7 @@ public:
public Q_SLOTS: public Q_SLOTS:
int exec(); int exec();
void reset(); void reset();
virtual void done(int result); void onButtonClicked(QAbstractButton *button);
}; };
#endif // QXTCONFIRMATIONMESSAGE_H #endif // QXTCONFIRMATIONMESSAGE_H