mirror of
https://github.com/qTox/qTox.git
synced 2024-03-22 14:00:36 +08:00
Implement hack to make closing the history dialog not disable history
Also word wrap the extra long text
This commit is contained in:
parent
864d1297e7
commit
aa122bf246
|
@ -225,7 +225,7 @@ void Core::checkEncryptedHistory()
|
|||
|
||||
QString a(tr("Please enter the password for the chat history for the %1 profile.", "used in load() when no hist pw set").arg(Settings::getInstance().getCurrentProfile()));
|
||||
QString b(tr("The previous password is incorrect; please try again:", "used on retries in load()"));
|
||||
QString c(tr("Disabling chat history now will leave the encrypted history intact (but not usable); if you later remember the password, you may re-enable encryption from the Privacy tab with the correct password to use the history.", "part of history password dialog"));
|
||||
QString c(tr("\nDisabling chat history now will leave the encrypted history intact (but not usable); if you later remember the password, you may re-enable encryption from the Privacy tab with the correct password to use the history.", "part of history password dialog"));
|
||||
QString dialogtxt;
|
||||
|
||||
if (pwsaltedkeys[ptHistory])
|
||||
|
|
|
@ -47,6 +47,7 @@
|
|||
#include <QThread>
|
||||
#include <QFileDialog>
|
||||
#include <QInputDialog>
|
||||
#include <QDialogButtonBox>
|
||||
#include <QTimer>
|
||||
#include <QStyleFactory>
|
||||
#include <QTranslator>
|
||||
|
@ -1294,18 +1295,48 @@ QString Widget::passwordDialog(const QString& cancel, const QString& body)
|
|||
}
|
||||
else
|
||||
{
|
||||
// we use a hack. It is considered that closing the dialog without explicitly clicking
|
||||
// disable history is confusing. But we can't distinguish between clicking the cancel
|
||||
// button and closing the dialog. So instead, we reverse the Ok and Cancel roles,
|
||||
// so that nothing but explicitly clicking disable history closes the dialog
|
||||
QString ret;
|
||||
QInputDialog dialog;
|
||||
dialog.setWindowTitle(tr("Enter your password"));
|
||||
dialog.setOkButtonText(tr("Decrypt"));
|
||||
dialog.setCancelButtonText(cancel);
|
||||
dialog.setOkButtonText(cancel);
|
||||
dialog.setCancelButtonText(tr("Decrypt"));
|
||||
dialog.setInputMode(QInputDialog::TextInput);
|
||||
dialog.setTextEchoMode(QLineEdit::Password);
|
||||
dialog.setLabelText(body);
|
||||
|
||||
// problem with previous hack: the default button is disable history, not decrypt.
|
||||
// use another hack to reverse the default buttons.
|
||||
// http://www.qtcentre.org/threads/49924-Change-property-of-QInputDialog-button
|
||||
QList<QDialogButtonBox*> l = dialog.findChildren<QDialogButtonBox*>();
|
||||
if (!l.isEmpty())
|
||||
{
|
||||
QPushButton* ok = l.first()->button(QDialogButtonBox::Ok);
|
||||
QPushButton* cancel = l.first()->button(QDialogButtonBox::Cancel);
|
||||
if (ok && cancel)
|
||||
{
|
||||
ok->setAutoDefault(false);
|
||||
ok->setDefault(false);
|
||||
cancel->setAutoDefault(true);
|
||||
cancel->setDefault(true);
|
||||
}
|
||||
else
|
||||
qWarning() << "PasswordDialog: Missing button!";
|
||||
}
|
||||
else
|
||||
qWarning() << "PasswordDialog: No QDialogButtonBox!";
|
||||
|
||||
// using similar code, set QLabels to wrap
|
||||
for (auto* label : dialog.findChildren<QLabel*>())
|
||||
label->setWordWrap(true);
|
||||
|
||||
while (true)
|
||||
{
|
||||
int val = dialog.exec();
|
||||
if (val != QDialog::Accepted)
|
||||
if (val == QDialog::Accepted)
|
||||
return QString();
|
||||
else
|
||||
{
|
||||
|
@ -1314,7 +1345,7 @@ QString Widget::passwordDialog(const QString& cancel, const QString& body)
|
|||
return ret;
|
||||
}
|
||||
dialog.setTextValue("");
|
||||
dialog.setLabelText(body + "\n" + tr("You must enter a non-empty password."));
|
||||
dialog.setLabelText(body + "\n\n" + tr("You must enter a non-empty password:"));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user