Changeset View
Changeset View
Standalone View
Standalone View
kded/ui/mountdialog.cpp
Show All 12 Lines | |||||
13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
15 | * GNU General Public License for more details. | 15 | * GNU General Public License for more details. | ||
16 | * | 16 | * | ||
17 | * You should have received a copy of the GNU General Public License | 17 | * You should have received a copy of the GNU General Public License | ||
18 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | 18 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
19 | */ | 19 | */ | ||
20 | #include "mountdialog.h" | 20 | #include "mountdialog.h" | ||
21 | #include "engine/vault.h" | | |||
22 | 21 | | |||
23 | #include <QCloseEvent> | 22 | #include <QCloseEvent> | ||
24 | #include <QStyle> | 23 | #include <QStyle> | ||
25 | #include <QStyleOption> | 24 | #include <QStyleOption> | ||
25 | #include <QAction> | ||||
26 | #include <QMessageBox> | ||||
26 | 27 | | |||
27 | #include <KMessageWidget> | 28 | #include <KMessageWidget> | ||
28 | 29 | | |||
29 | MountDialog::MountDialog(PlasmaVault::Vault *vault) | 30 | MountDialog::MountDialog(PlasmaVault::Vault *vault) | ||
30 | : m_vault(vault) | 31 | : m_vault(vault) | ||
31 | { | 32 | { | ||
32 | m_ui.setupUi(this); | 33 | m_ui.setupUi(this); | ||
33 | 34 | | |||
34 | m_errorLabel = new KMessageWidget(this); | 35 | m_errorLabel = new KMessageWidget(this); | ||
35 | m_errorLabel->setMessageType(KMessageWidget::Error); | 36 | m_errorLabel->setMessageType(KMessageWidget::Error); | ||
36 | m_errorLabel->setCloseButtonVisible(false); | 37 | m_errorLabel->setCloseButtonVisible(false); | ||
37 | m_errorLabel->setIcon(QIcon::fromTheme("dialog-error")); | 38 | m_errorLabel->setIcon(QIcon::fromTheme("dialog-error")); | ||
38 | m_errorLabel->setVisible(false); | 39 | m_errorLabel->setVisible(false); | ||
39 | 40 | | |||
41 | m_detailsAction = new QAction(this); | ||||
42 | m_detailsAction->setToolTip(i18n("Details...")); | ||||
43 | m_detailsAction->setIcon(QIcon::fromTheme("view-list-details")); | ||||
44 | | ||||
45 | connect(m_detailsAction, &QAction::triggered, | ||||
46 | this, [this] { | ||||
47 | QString message; | ||||
48 | const auto out = m_lastError.out().trimmed(); | ||||
49 | const auto err = m_lastError.err().trimmed(); | ||||
50 | | ||||
51 | if (!out.isEmpty() && !err.isEmpty()) { | ||||
52 | message = i18n("Command output:\n%1\n\nError output: %2", m_lastError.out(), m_lastError.err()); | ||||
53 | } else { | ||||
54 | message = out + err; | ||||
55 | } | ||||
56 | | ||||
57 | auto messageBox = new QMessageBox(QMessageBox::Critical, i18n("Error details"), message, QMessageBox::Ok, this); | ||||
davidedmundson: Kded is one of the processes that shouldn't freeze, lets avoid nested event loops
Some sort of… | |||||
58 | messageBox->setAttribute(Qt::WA_DeleteOnClose); | ||||
59 | messageBox->show(); | ||||
60 | | ||||
61 | }); | ||||
62 | | ||||
40 | auto errorLabelSizePolicy = m_errorLabel->sizePolicy(); | 63 | auto errorLabelSizePolicy = m_errorLabel->sizePolicy(); | ||
41 | errorLabelSizePolicy.setHorizontalPolicy(QSizePolicy::Expanding); | 64 | errorLabelSizePolicy.setHorizontalPolicy(QSizePolicy::Expanding); | ||
42 | m_errorLabel->setSizePolicy(errorLabelSizePolicy); | 65 | m_errorLabel->setSizePolicy(errorLabelSizePolicy); | ||
43 | m_errorLabel->setVisible(false); | 66 | m_errorLabel->setVisible(false); | ||
44 | m_ui.formLayout->addRow(QString(), m_errorLabel); | 67 | m_ui.formLayout->addRow(QString(), m_errorLabel); | ||
45 | m_ui.vaultName->setText(vault->name()); | 68 | m_ui.vaultName->setText(vault->name()); | ||
46 | 69 | | |||
47 | QStyleOption option; | 70 | QStyleOption option; | ||
Show All 15 Lines | 77 | { | |||
63 | 86 | | |||
64 | unsetCursor(); | 87 | unsetCursor(); | ||
65 | setEnabled(true); | 88 | setEnabled(true); | ||
66 | m_ui.password->lineEdit()->unsetCursor(); | 89 | m_ui.password->lineEdit()->unsetCursor(); | ||
67 | 90 | | |||
68 | if (result) { | 91 | if (result) { | ||
69 | QDialog::accept(); | 92 | QDialog::accept(); | ||
70 | } else { | 93 | } else { | ||
71 | qDebug() << "We've got an error" << result.error().message(); | 94 | m_lastError = result.error(); | ||
72 | // m_ui.errorLabel->setText(i18n("Failed to open: %1").arg(result.error().message())); | 95 | | ||
73 | m_errorLabel->setText(i18n("Failed to open: %1", result.error().message())); | 96 | m_errorLabel->setText(i18n("Failed to open: %1", m_lastError.message())); | ||
74 | m_errorLabel->setVisible(true); | 97 | m_errorLabel->setVisible(true); | ||
98 | | ||||
99 | if (!m_lastError.out().isEmpty() || !m_lastError.err().isEmpty()) { | ||||
100 | m_errorLabel->addAction(m_detailsAction); | ||||
101 | | ||||
102 | } else { | ||||
103 | m_errorLabel->removeAction(m_detailsAction); | ||||
104 | | ||||
105 | } | ||||
75 | } | 106 | } | ||
76 | } | 107 | } |
Kded is one of the processes that shouldn't freeze, lets avoid nested event loops
Some sort of
box = new QMessageBox()
box->setWidgetAttribute(delete on close)
box->show();
would be preferred