mirror of
https://github.com/qTox/qTox.git
synced 2024-03-22 14:00:36 +08:00
tweak to popup questions
This commit is contained in:
parent
2e6b0f7b2b
commit
67027814e5
|
@ -428,7 +428,7 @@ void AutoUpdater::checkUpdatesAsyncInteractiveWorker()
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (Widget::getInstance()->askQuestion(QObject::tr("Update", "The title of a message box"),
|
if (Widget::getInstance()->askQuestion(QObject::tr("Update", "The title of a message box"),
|
||||||
QObject::tr("An update is available, do you want to download it now?\nIt will be installed when qTox restarts."), false))
|
QObject::tr("An update is available, do you want to download it now?\nIt will be installed when qTox restarts."), true, false))
|
||||||
{
|
{
|
||||||
downloadUpdate();
|
downloadUpdate();
|
||||||
}
|
}
|
||||||
|
|
|
@ -30,7 +30,6 @@
|
||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
#include <QSaveFile>
|
#include <QSaveFile>
|
||||||
#include <QFile>
|
#include <QFile>
|
||||||
#include <QInputDialog>
|
|
||||||
|
|
||||||
void Core::setPassword(QString& password, PasswordType passtype, uint8_t* salt)
|
void Core::setPassword(QString& password, PasswordType passtype, uint8_t* salt)
|
||||||
{
|
{
|
||||||
|
|
|
@ -121,7 +121,7 @@ void PrivacyForm::onEncryptLogsUpdated()
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (Widget::getInstance()->askQuestion(tr("Old encrypted chat logs", "title"), tr("Would you like to un-encrypt your chat logs?\nOtherwise they will be deleted."), false))
|
if (Widget::getInstance()->askQuestion(tr("Old encrypted chat logs", "title"), tr("Would you like to un-encrypt your chat logs?\nOtherwise they will be deleted."), true, false))
|
||||||
{
|
{
|
||||||
QList<HistoryKeeper::HistMessage> oldMessages = HistoryKeeper::exportMessagesDeleteFile(true);
|
QList<HistoryKeeper::HistMessage> oldMessages = HistoryKeeper::exportMessagesDeleteFile(true);
|
||||||
core->clearPassword(Core::ptHistory);
|
core->clearPassword(Core::ptHistory);
|
||||||
|
|
|
@ -1215,7 +1215,7 @@ void Widget::setEnabledThreadsafe(bool enabled)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Widget::askQuestion(const QString& title, const QString& msg, bool warning)
|
bool Widget::askQuestion(const QString& title, const QString& msg, bool defaultAns, bool warning)
|
||||||
{
|
{
|
||||||
// We can only display widgets from the GUI thread
|
// We can only display widgets from the GUI thread
|
||||||
if (QThread::currentThread() != qApp->thread())
|
if (QThread::currentThread() != qApp->thread())
|
||||||
|
@ -1223,15 +1223,26 @@ bool Widget::askQuestion(const QString& title, const QString& msg, bool warning)
|
||||||
bool ret;
|
bool ret;
|
||||||
QMetaObject::invokeMethod(this, "askMsgboxQuestion", Qt::BlockingQueuedConnection,
|
QMetaObject::invokeMethod(this, "askMsgboxQuestion", Qt::BlockingQueuedConnection,
|
||||||
Q_RETURN_ARG(bool, ret),
|
Q_RETURN_ARG(bool, ret),
|
||||||
Q_ARG(const QString&, title), Q_ARG(const QString&, msg), Q_ARG(bool, warning));
|
Q_ARG(const QString&, title), Q_ARG(const QString&, msg),
|
||||||
|
Q_ARG(bool, defaultAns), Q_ARG(bool, warning));
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (warning)
|
if (warning)
|
||||||
return QMessageBox::warning(this, title, msg, QMessageBox::Ok | QMessageBox::Cancel) == QMessageBox::StandardButton::Ok;
|
{
|
||||||
|
QMessageBox::StandardButton def = QMessageBox::Cancel;
|
||||||
|
if (defaultAns)
|
||||||
|
def = QMessageBox::Ok;
|
||||||
|
return QMessageBox::warning(this, title, msg, QMessageBox::Ok | QMessageBox::Cancel, def) == QMessageBox::Ok;
|
||||||
|
}
|
||||||
else
|
else
|
||||||
return QMessageBox::question(this, title, msg) == QMessageBox::StandardButton::Yes;
|
{
|
||||||
|
QMessageBox::StandardButton def = QMessageBox::No;
|
||||||
|
if (defaultAns)
|
||||||
|
def = QMessageBox::Yes;
|
||||||
|
return QMessageBox::question(this, title, msg, QMessageBox::Yes | QMessageBox::No, def) == QMessageBox::Yes;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -66,7 +66,7 @@ public:
|
||||||
void updateTrayIcon();
|
void updateTrayIcon();
|
||||||
Q_INVOKABLE void showWarningMsgBox(const QString& title, const QString& msg);
|
Q_INVOKABLE void showWarningMsgBox(const QString& title, const QString& msg);
|
||||||
Q_INVOKABLE void setEnabledThreadsafe(bool enabled);
|
Q_INVOKABLE void setEnabledThreadsafe(bool enabled);
|
||||||
Q_INVOKABLE bool askQuestion(const QString& title, const QString& msg, bool warning = true);
|
Q_INVOKABLE bool askQuestion(const QString& title, const QString& msg, bool defaultAns = false, bool warning = true);
|
||||||
Q_INVOKABLE QString passwordDialog(const QString& cancel, const QString& body);
|
Q_INVOKABLE QString passwordDialog(const QString& cancel, const QString& body);
|
||||||
// hooray for threading hacks
|
// hooray for threading hacks
|
||||||
~Widget();
|
~Widget();
|
||||||
|
|
Loading…
Reference in New Issue
Block a user