diff --git a/kded/ui/mountdialog.cpp b/kded/ui/mountdialog.cpp index e5582ce..4a4a946 100644 --- a/kded/ui/mountdialog.cpp +++ b/kded/ui/mountdialog.cpp @@ -1,107 +1,108 @@ /* * Copyright 2017 by Kees vd Broek * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License as * published by the Free Software Foundation; either version 2 of * the License or (at your option) version 3 or any later version * accepted by the membership of KDE e.V. (or its successor approved * by the membership of KDE e.V.), which shall act as a proxy * defined in Section 14 of version 3 of the license. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ #include "mountdialog.h" #include #include #include #include #include #include MountDialog::MountDialog(PlasmaVault::Vault *vault) : m_vault(vault) { m_ui.setupUi(this); + setWindowTitle(i18nc("%1 is the name of the Plasma Vault to open", "Open '%1' Plasma Vault", vault->name())); m_errorLabel = new KMessageWidget(this); m_errorLabel->setMessageType(KMessageWidget::Error); m_errorLabel->setCloseButtonVisible(false); m_errorLabel->setIcon(QIcon::fromTheme("dialog-error")); m_errorLabel->setVisible(false); m_detailsAction = new QAction(this); m_detailsAction->setToolTip(i18n("Details...")); m_detailsAction->setIcon(QIcon::fromTheme("view-list-details")); connect(m_detailsAction, &QAction::triggered, this, [this] { QString message; const auto out = m_lastError.out().trimmed(); const auto err = m_lastError.err().trimmed(); if (!out.isEmpty() && !err.isEmpty()) { message = i18n("Command output:\n%1\n\nError output: %2", m_lastError.out(), m_lastError.err()); } else { message = out + err; } auto messageBox = new QMessageBox(QMessageBox::Critical, i18n("Error details"), message, QMessageBox::Ok, this); messageBox->setAttribute(Qt::WA_DeleteOnClose); messageBox->show(); }); auto errorLabelSizePolicy = m_errorLabel->sizePolicy(); errorLabelSizePolicy.setHorizontalPolicy(QSizePolicy::Expanding); m_errorLabel->setSizePolicy(errorLabelSizePolicy); m_errorLabel->setVisible(false); m_ui.formLayout->addRow(QString(), m_errorLabel); m_ui.vaultName->setText(vault->name()); QStyleOption option; option.initFrom(this); const int iconSize = style()->pixelMetric(QStyle::PM_MessageBoxIconSize, &option, this); m_ui.icon->setPixmap(QIcon::fromTheme(QStringLiteral("dialog-password")).pixmap(iconSize)); } void MountDialog::accept() { setCursor(Qt::WaitCursor); m_errorLabel->setVisible(false); setEnabled(false); m_ui.password->lineEdit()->setCursor(Qt::WaitCursor); QString pwd = m_ui.password->password(); auto future = m_vault->open({ { KEY_PASSWORD, pwd } }); const auto result = AsynQt::await(future); unsetCursor(); setEnabled(true); m_ui.password->lineEdit()->unsetCursor(); if (result) { QDialog::accept(); } else { m_lastError = result.error(); m_errorLabel->setText(i18n("Failed to open: %1", m_lastError.message())); m_errorLabel->setVisible(true); if (!m_lastError.out().isEmpty() || !m_lastError.err().isEmpty()) { m_errorLabel->addAction(m_detailsAction); } else { m_errorLabel->removeAction(m_detailsAction); } } } diff --git a/kded/ui/mountdialog.ui b/kded/ui/mountdialog.ui index 5f0dcbc..749f04e 100644 --- a/kded/ui/mountdialog.ui +++ b/kded/ui/mountdialog.ui @@ -1,178 +1,175 @@ MountDialog 0 0 488 198 - - Plasma Vault - .. 16 64 64 0 Qt::Vertical 0 0 Please enter the password to open this vault: 0 0 Qt::Vertical 0 0 Password: password QLineEdit::Password Qt::Vertical 0 0 Qt::Horizontal QDialogButtonBox::Cancel|QDialogButtonBox::Ok false KPasswordLineEdit QWidget
kpasswordlineedit.h
buttonBox accepted() MountDialog accept() 248 254 157 274 buttonBox rejected() MountDialog reject() 316 260 286 274