Initial qml root window

This commit is contained in:
Nicolas Werner 2022-01-12 19:09:46 +01:00
parent 9a2e07cbce
commit b106eafb0e
No known key found for this signature in database
GPG key ID: C8D75E610773F2D9
21 changed files with 426 additions and 397 deletions

View file

@ -1518,7 +1518,7 @@ UserSettingsModel::setData(const QModelIndex &index, const QVariant &value, int
QString homeFolder =
QStandardPaths::writableLocation(QStandardPaths::HomeLocation);
auto filepath = QFileDialog::getOpenFileName(
MainWindow::instance(), tr("Select a file"), homeFolder, tr("All Files (*)"));
nullptr, tr("Select a file"), homeFolder, tr("All Files (*)"));
if (!filepath.isEmpty()) {
i->setRingtone(filepath);
i->setRingtone(filepath);
@ -1600,11 +1600,11 @@ UserSettingsModel::importSessionKeys()
{
const QString homeFolder = QStandardPaths::writableLocation(QStandardPaths::HomeLocation);
const QString fileName = QFileDialog::getOpenFileName(
MainWindow::instance(), tr("Open Sessions File"), homeFolder, QLatin1String(""));
nullptr, tr("Open Sessions File"), homeFolder, QLatin1String(""));
QFile file(fileName);
if (!file.open(QIODevice::ReadOnly)) {
QMessageBox::warning(MainWindow::instance(), tr("Error"), file.errorString());
QMessageBox::warning(nullptr, tr("Error"), file.errorString());
return;
}
@ -1612,7 +1612,7 @@ UserSettingsModel::importSessionKeys()
auto payload = std::string(bin.data(), bin.size());
bool ok;
auto password = QInputDialog::getText(MainWindow::instance(),
auto password = QInputDialog::getText(nullptr,
tr("File Password"),
tr("Enter the passphrase to decrypt the file:"),
QLineEdit::Password,
@ -1622,8 +1622,7 @@ UserSettingsModel::importSessionKeys()
return;
if (password.isEmpty()) {
QMessageBox::warning(
MainWindow::instance(), tr("Error"), tr("The password cannot be empty"));
QMessageBox::warning(nullptr, tr("Error"), tr("The password cannot be empty"));
return;
}
@ -1631,7 +1630,7 @@ UserSettingsModel::importSessionKeys()
auto sessions = mtx::crypto::decrypt_exported_sessions(payload, password.toStdString());
cache::importSessionKeys(std::move(sessions));
} catch (const std::exception &e) {
QMessageBox::warning(MainWindow::instance(), tr("Error"), e.what());
QMessageBox::warning(nullptr, tr("Error"), e.what());
}
}
void
@ -1639,7 +1638,7 @@ UserSettingsModel::exportSessionKeys()
{
// Open password dialog.
bool ok;
auto password = QInputDialog::getText(MainWindow::instance(),
auto password = QInputDialog::getText(nullptr,
tr("File Password"),
tr("Enter passphrase to encrypt your session keys:"),
QLineEdit::Password,
@ -1649,19 +1648,18 @@ UserSettingsModel::exportSessionKeys()
return;
if (password.isEmpty()) {
QMessageBox::warning(
MainWindow::instance(), tr("Error"), tr("The password cannot be empty"));
QMessageBox::warning(nullptr, tr("Error"), tr("The password cannot be empty"));
return;
}
// Open file dialog to save the file.
const QString homeFolder = QStandardPaths::writableLocation(QStandardPaths::HomeLocation);
const QString fileName = QFileDialog::getSaveFileName(
MainWindow::instance(), tr("File to save the exported session keys"), homeFolder);
nullptr, tr("File to save the exported session keys"), homeFolder);
QFile file(fileName);
if (!file.open(QIODevice::WriteOnly | QIODevice::Text)) {
QMessageBox::warning(MainWindow::instance(), tr("Error"), file.errorString());
QMessageBox::warning(nullptr, tr("Error"), file.errorString());
return;
}
@ -1679,7 +1677,7 @@ UserSettingsModel::exportSessionKeys()
out << prefix << newline << b64 << newline << suffix << newline;
file.close();
} catch (const std::exception &e) {
QMessageBox::warning(MainWindow::instance(), tr("Error"), e.what());
QMessageBox::warning(nullptr, tr("Error"), e.what());
}
}
void