mirror of
https://github.com/qTox/qTox.git
synced 2024-03-22 14:00:36 +08:00
Merge branch 'pr1388'
This commit is contained in:
commit
48dd053d07
|
@ -114,8 +114,8 @@ bool PrivacyForm::setChatLogsPassword()
|
|||
}
|
||||
else
|
||||
{
|
||||
if (GUI::askQuestion(tr("Old encrypted chat history", "popup title"), tr("There is currently an unused encrypted chat history, but the password you just entered doesn't match.\n\nIf you don't care about the old history, you may click Ok to delete it and use the password you just entered.\nOtherwise, hit cancel to try again.", "This happens when enabling encryption after previously \"Disabling History\""), false, true, false))
|
||||
if (GUI::askQuestion(tr("Old encrypted chat history", "popup title"), tr("Are you absolutely sure you want to lose the unused encrypted chat history?", "secondary popup")))
|
||||
if (GUI::askQuestion(tr("Old encrypted chat history", "popup title"), tr("There is currently an unused encrypted chat history, but the password you just entered doesn't match.\n\nIf you don't care about the old history, you may delete it and use the password you just entered.\nOtherwise, hit Cancel to try again.", "This happens when enabling encryption after previously \"Disabling History\""), tr("Delete"), tr("Cancel")))
|
||||
if (GUI::askQuestion(tr("Old encrypted chat history", "popup title"), tr("Are you absolutely sure you want to lose the unused encrypted chat history?", "secondary popup"), tr("Delete"), tr("Cancel")))
|
||||
haveEncHist = false; // logically this is really just a `break`, but conceptually this is more accurate
|
||||
}
|
||||
} while (haveEncHist);
|
||||
|
@ -142,31 +142,38 @@ void PrivacyForm::onEncryptLogsUpdated()
|
|||
}
|
||||
else
|
||||
{
|
||||
QMessageBox::StandardButton button = QMessageBox::warning(
|
||||
Widget::getInstance(),
|
||||
QMessageBox box(QMessageBox::Warning,
|
||||
tr("Old encrypted chat history", "title"),
|
||||
tr("Would you like to decrypt your chat history?\nOtherwise it will be deleted."),
|
||||
QMessageBox::Ok | QMessageBox::No | QMessageBox::Cancel,
|
||||
QMessageBox::Cancel
|
||||
);
|
||||
QMessageBox::NoButton, Widget::getInstance());
|
||||
QPushButton* decryptBtn = box.addButton(tr("Decrypt"), QMessageBox::YesRole);
|
||||
QPushButton* deleteBtn = box.addButton(tr("Delete"), QMessageBox::NoRole);
|
||||
QPushButton* cancelBtn = box.addButton(tr("Cancel"), QMessageBox::RejectRole);
|
||||
box.setDefaultButton(cancelBtn);
|
||||
box.setEscapeButton(cancelBtn);
|
||||
|
||||
if (button == QMessageBox::Ok)
|
||||
box.exec();
|
||||
|
||||
if (box.clickedButton() == decryptBtn)
|
||||
{
|
||||
QList<HistoryKeeper::HistMessage> oldMessages = HistoryKeeper::exportMessagesDeleteFile(true);
|
||||
core->clearPassword(Core::ptHistory);
|
||||
Settings::getInstance().setEncryptLogs(false);
|
||||
HistoryKeeper::getInstance()->importMessages(oldMessages);
|
||||
}
|
||||
else if (button == QMessageBox::No)
|
||||
else if (box.clickedButton() == deleteBtn)
|
||||
{
|
||||
if (QMessageBox::critical(
|
||||
Widget::getInstance(),
|
||||
tr("Old encrypted chat history", "title"),
|
||||
tr("Are you sure you want to lose your entire chat history?"),
|
||||
QMessageBox::Yes | QMessageBox::Cancel,
|
||||
QMessageBox::Cancel
|
||||
)
|
||||
== QMessageBox::Yes)
|
||||
QMessageBox box2(QMessageBox::Critical,
|
||||
tr("Old encrypted chat history", "title"),
|
||||
tr("Are you sure you want to lose your entire chat history?"),
|
||||
QMessageBox::NoButton, Widget::getInstance());
|
||||
QPushButton* deleteBtn2 = box2.addButton(tr("Delete"), QMessageBox::AcceptRole);
|
||||
QPushButton* cancelBtn2 = box2.addButton(tr("Cancel"), QMessageBox::RejectRole);
|
||||
box2.setDefaultButton(cancelBtn2);
|
||||
box2.setEscapeButton(cancelBtn2);
|
||||
box2.exec();
|
||||
|
||||
if (box2.clickedButton() == deleteBtn2)
|
||||
{
|
||||
HistoryKeeper::removeHistory(true);
|
||||
}
|
||||
|
@ -239,7 +246,9 @@ void PrivacyForm::onEncryptToxUpdated()
|
|||
}
|
||||
else
|
||||
{
|
||||
if (!GUI::askQuestion(tr("Decrypt your data file", "title"), tr("Would you like to decrypt your data file?")))
|
||||
if (!GUI::askQuestion(tr("Decrypt your data file", "title"),
|
||||
tr("Would you like to decrypt your data file?"),
|
||||
tr("Decrypt"), tr("Cancel")))
|
||||
{
|
||||
bodyUI->cbEncryptTox->setChecked(true);
|
||||
return;
|
||||
|
|
|
@ -113,8 +113,8 @@ void GUI::showError(const QString& title, const QString& msg)
|
|||
}
|
||||
|
||||
bool GUI::askQuestion(const QString& title, const QString& msg,
|
||||
bool defaultAns, bool warning,
|
||||
bool yesno)
|
||||
bool defaultAns, bool warning,
|
||||
bool yesno)
|
||||
{
|
||||
if (QThread::currentThread() == qApp->thread())
|
||||
{
|
||||
|
@ -132,6 +132,25 @@ bool GUI::askQuestion(const QString& title, const QString& msg,
|
|||
}
|
||||
}
|
||||
|
||||
bool GUI::askQuestion(const QString& title, const QString& msg,
|
||||
const QString& button1, const QString& button2,
|
||||
bool defaultAns, bool warning)
|
||||
{
|
||||
if (QThread::currentThread() == qApp->thread())
|
||||
{
|
||||
return getInstance()._askQuestion(title, msg, button1, button2, defaultAns, warning);
|
||||
}
|
||||
else
|
||||
{
|
||||
bool ret;
|
||||
QMetaObject::invokeMethod(&getInstance(), "_askQuestion", Qt::BlockingQueuedConnection,
|
||||
Q_RETURN_ARG(bool, ret),
|
||||
Q_ARG(const QString&, title), Q_ARG(const QString&, msg),
|
||||
Q_ARG(bool, defaultAns), Q_ARG(bool, warning));
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
|
||||
QString GUI::itemInputDialog(QWidget * parent, const QString & title,
|
||||
const QString & label, const QStringList & items,
|
||||
int current, bool editable, bool * ok,
|
||||
|
@ -213,8 +232,8 @@ void GUI::_showError(const QString& title, const QString& msg)
|
|||
}
|
||||
|
||||
bool GUI::_askQuestion(const QString& title, const QString& msg,
|
||||
bool defaultAns, bool warning,
|
||||
bool yesno)
|
||||
bool defaultAns, bool warning,
|
||||
bool yesno)
|
||||
{
|
||||
QMessageBox::StandardButton positiveButton = yesno ? QMessageBox::Yes : QMessageBox::Ok;
|
||||
QMessageBox::StandardButton negativeButton = yesno ? QMessageBox::No : QMessageBox::Cancel;
|
||||
|
@ -227,6 +246,21 @@ bool GUI::_askQuestion(const QString& title, const QString& msg,
|
|||
return QMessageBox::question(getMainWidget(), title, msg, positiveButton | negativeButton, defButton) == positiveButton;
|
||||
}
|
||||
|
||||
bool GUI::_askQuestion(const QString& title, const QString& msg,
|
||||
const QString& button1, const QString& button2,
|
||||
bool defaultAns, bool warning)
|
||||
{
|
||||
QMessageBox box(warning ? QMessageBox::Warning : QMessageBox::Question,
|
||||
title, msg, QMessageBox::NoButton, getMainWidget());
|
||||
QPushButton* pushButton1 = box.addButton(button1, QMessageBox::AcceptRole);
|
||||
QPushButton* pushButton2 = box.addButton(button2, QMessageBox::RejectRole);
|
||||
box.setDefaultButton(defaultAns ? pushButton1 : pushButton2);
|
||||
box.setEscapeButton(pushButton2);
|
||||
|
||||
box.exec();
|
||||
return box.clickedButton() == pushButton1;
|
||||
}
|
||||
|
||||
QString GUI::_itemInputDialog(QWidget * parent, const QString & title,
|
||||
const QString & label, const QStringList & items,
|
||||
int current, bool editable, bool * ok,
|
||||
|
|
|
@ -35,6 +35,13 @@ public:
|
|||
static bool askQuestion(const QString& title, const QString& msg,
|
||||
bool defaultAns = false, bool warning = true,
|
||||
bool yesno = true);
|
||||
/// Asks the user a question, for example in a message box.
|
||||
/// The text for the displayed buttons can be specified.
|
||||
/// If warning is true, we will use a special warning style.
|
||||
/// Returns the answer.
|
||||
static bool askQuestion(const QString& title, const QString& msg,
|
||||
const QString& button1, const QString& button2,
|
||||
bool defaultAns = false, bool warning = true);
|
||||
/// Asks the user to input text and returns the answer.
|
||||
/// The interface is equivalent to QInputDialog::getItem()
|
||||
static QString itemInputDialog(QWidget * parent, const QString & title,
|
||||
|
@ -64,8 +71,11 @@ private slots:
|
|||
void _showWarning(const QString& title, const QString& msg);
|
||||
void _showError(const QString& title, const QString& msg);
|
||||
bool _askQuestion(const QString& title, const QString& msg,
|
||||
bool defaultAns = false, bool warning = true,
|
||||
bool yesno = true);
|
||||
bool defaultAns = false, bool warning = true,
|
||||
bool yesno = true);
|
||||
bool _askQuestion(const QString& title, const QString& msg,
|
||||
const QString& button1, const QString& button2,
|
||||
bool defaultAns = false, bool warning = true);
|
||||
QString _itemInputDialog(QWidget * parent, const QString & title,
|
||||
const QString & label, const QStringList & items,
|
||||
int current = 0, bool editable = true, bool * ok = 0,
|
||||
|
|
Loading…
Reference in New Issue
Block a user