1
0
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:
Dubslow 2014-12-05 19:26:34 -06:00
parent 2e6b0f7b2b
commit 67027814e5
No known key found for this signature in database
GPG Key ID: 3DB8E05315C220AA
5 changed files with 18 additions and 8 deletions

View File

@ -428,7 +428,7 @@ void AutoUpdater::checkUpdatesAsyncInteractiveWorker()
return;
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();
}

View File

@ -30,7 +30,6 @@
#include <QDebug>
#include <QSaveFile>
#include <QFile>
#include <QInputDialog>
void Core::setPassword(QString& password, PasswordType passtype, uint8_t* salt)
{

View File

@ -121,7 +121,7 @@ void PrivacyForm::onEncryptLogsUpdated()
}
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);
core->clearPassword(Core::ptHistory);

View File

@ -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
if (QThread::currentThread() != qApp->thread())
@ -1223,15 +1223,26 @@ bool Widget::askQuestion(const QString& title, const QString& msg, bool warning)
bool ret;
QMetaObject::invokeMethod(this, "askMsgboxQuestion", Qt::BlockingQueuedConnection,
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;
}
else
{
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
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;
}
}
}

View File

@ -66,7 +66,7 @@ public:
void updateTrayIcon();
Q_INVOKABLE void showWarningMsgBox(const QString& title, const QString& msg);
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);
// hooray for threading hacks
~Widget();