Always show Details in resultitemwidget

Manual Decrypt / Verify is already an interactive task. The
user can just look at the color / summary line anyway and ignore
the details. Change based on user feedback.
parent 4fc2cce8
......@@ -97,7 +97,7 @@ class ResultItemWidget::Private
{
ResultItemWidget *const q;
public:
explicit Private(const std::shared_ptr<const Task::Result> &result, ResultItemWidget *qq) : q(qq), m_result(result), m_detailsLabel(nullptr), m_showDetailsLabel(nullptr), m_closeButton(nullptr)
explicit Private(const std::shared_ptr<const Task::Result> &result, ResultItemWidget *qq) : q(qq), m_result(result), m_detailsLabel(nullptr), m_actionsLabel(nullptr), m_closeButton(nullptr)
{
assert(m_result);
}
......@@ -107,7 +107,7 @@ public:
const std::shared_ptr<const Task::Result> m_result;
QLabel *m_detailsLabel;
QLabel *m_showDetailsLabel;
QLabel *m_actionsLabel;
QPushButton *m_closeButton;
};
......@@ -119,14 +119,12 @@ static QUrl auditlog_url_template()
void ResultItemWidget::Private::updateShowDetailsLabel()
{
if (!m_showDetailsLabel || !m_detailsLabel) {
if (!m_actionsLabel || !m_detailsLabel) {
return;
}
const bool detailsVisible = m_detailsLabel->isVisible();
const QString auditLogLink = m_result->auditLog().formatLink(auditlog_url_template());
m_showDetailsLabel->setText(QStringLiteral("<a href=\"kleoresultitem://toggledetails/\">%1</a><br/>%2").arg(detailsVisible ? i18n("Hide Details") : i18n("Show Details"), auditLogLink));
m_showDetailsLabel->setAccessibleDescription(detailsVisible ? i18n("Hide Details") : i18n("Show Details"));
m_actionsLabel->setText(auditLogLink);
}
ResultItemWidget::ResultItemWidget(const std::shared_ptr<const Task::Result> &result, QWidget *parent, Qt::WindowFlags flags) : QWidget(parent, flags), d(new Private(result, this))
......@@ -163,13 +161,12 @@ ResultItemWidget::ResultItemWidget(const std::shared_ptr<const Task::Result> &re
const QString details = d->m_result->details();
d->m_showDetailsLabel = new QLabel;
connect(d->m_showDetailsLabel, SIGNAL(linkActivated(QString)), this, SLOT(slotLinkActivated(QString)));
hlay->addWidget(d->m_showDetailsLabel);
d->m_showDetailsLabel->setVisible(!details.isEmpty());
d->m_showDetailsLabel->setFocusPolicy(Qt::StrongFocus);
d->m_showDetailsLabel->setTextInteractionFlags(Qt::TextBrowserInteraction);
d->m_showDetailsLabel->setStyleSheet(styleSheet);
d->m_actionsLabel = new QLabel;
connect(d->m_actionsLabel, SIGNAL(linkActivated(QString)), this, SLOT(slotLinkActivated(QString)));
hlay->addWidget(d->m_actionsLabel);
d->m_actionsLabel->setFocusPolicy(Qt::StrongFocus);
d->m_actionsLabel->setTextInteractionFlags(Qt::TextBrowserInteraction);
d->m_actionsLabel->setStyleSheet(styleSheet);
d->m_detailsLabel = new QLabel;
d->m_detailsLabel->setWordWrap(true);
......@@ -181,8 +178,6 @@ ResultItemWidget::ResultItemWidget(const std::shared_ptr<const Task::Result> &re
connect(d->m_detailsLabel, SIGNAL(linkActivated(QString)), this, SLOT(slotLinkActivated(QString)));
layout->addWidget(d->m_detailsLabel);
d->m_detailsLabel->setVisible(false);
d->m_closeButton = new QPushButton;
KGuiItem::assign(d->m_closeButton, KStandardGuiItem::close());
d->m_closeButton->setFixedSize(d->m_closeButton->sizeHint());
......@@ -202,11 +197,6 @@ void ResultItemWidget::showCloseButton(bool show)
d->m_closeButton->setVisible(show);
}
bool ResultItemWidget::detailsVisible() const
{
return d->m_detailsLabel && d->m_detailsLabel->isVisible();
}
bool ResultItemWidget::hasErrorResult() const
{
return d->m_result->hasError();
......@@ -233,10 +223,6 @@ void ResultItemWidget::Private::slotLinkActivated(const QString &link)
}
const QUrl url(link);
if (url.host() == QLatin1String("toggledetails")) {
q->showDetails(!q->detailsVisible());
return;
}
if (url.host() == QLatin1String("showauditlog")) {
q->showAuditLog();
......@@ -250,14 +236,4 @@ void ResultItemWidget::showAuditLog()
MessageBox::auditLog(parentWidget(), d->m_result->auditLog().text());
}
void ResultItemWidget::showDetails(bool show)
{
if (show == d->m_detailsLabel->isVisible()) {
return;
}
d->m_detailsLabel->setVisible(show);
d->updateShowDetailsLabel();
Q_EMIT detailsToggled(show);
}
#include "moc_resultitemwidget.cpp"
......@@ -60,19 +60,16 @@ public:
explicit ResultItemWidget(const std::shared_ptr<const Task::Result> &result, QWidget *parent = nullptr, Qt::WindowFlags flags = 0);
~ResultItemWidget();
bool detailsVisible() const;
bool hasErrorResult() const;
void showCloseButton(bool show);
public Q_SLOTS:
void showDetails(bool show = true);
void showAuditLog();
Q_SIGNALS:
void linkActivated(const QString &link);
void closeButtonClicked();
void detailsToggled(bool);
private:
class Private;
......
......@@ -65,7 +65,6 @@ public:
void result(const std::shared_ptr<const Task::Result> &result);
void started(const std::shared_ptr<Task> &task);
void detailsToggled(bool);
void allTasksDone();
void addResultWidget(ResultItemWidget *widget);
......@@ -180,7 +179,6 @@ void ResultListWidget::Private::result(const std::shared_ptr<const Task::Result>
assert(std::any_of(m_collections.cbegin(), m_collections.cend(),
[](const std::shared_ptr<TaskCollection> &t) { return !t->isEmpty(); }));
ResultItemWidget *wid = new ResultItemWidget(result);
q->connect(wid, SIGNAL(detailsToggled(bool)), q, SLOT(detailsToggled(bool)));
q->connect(wid, &ResultItemWidget::linkActivated, q, &ResultListWidget::linkActivated);
q->connect(wid, &ResultItemWidget::closeButtonClicked, q, &ResultListWidget::close);
addResultWidget(wid);
......@@ -224,11 +222,6 @@ void ResultListWidget::addTaskCollection(const std::shared_ptr<TaskCollection> &
setStandaloneMode(d->m_standaloneMode);
}
void ResultListWidget::Private::detailsToggled(bool)
{
resizeIfStandalone();
}
void ResultListWidget::Private::started(const std::shared_ptr<Task> &task)
{
assert(task);
......
......@@ -79,7 +79,6 @@ private:
kdtools::pimpl_ptr<Private> d;
Q_PRIVATE_SLOT(d, void result(std::shared_ptr<const Kleo::Crypto::Task::Result>))
Q_PRIVATE_SLOT(d, void started(std::shared_ptr<Kleo::Crypto::Task>))
Q_PRIVATE_SLOT(d, void detailsToggled(bool))
Q_PRIVATE_SLOT(d, void allTasksDone())
};
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment