Commit 827e6d97 authored by Friedrich W. H. Kossebau's avatar Friedrich W. H. Kossebau
Browse files

Internal previewer: add menu option to show About dialog for kpart

parent 5f54fd84
<!DOCTYPE gui SYSTEM "kpartgui.dtd">
<gui name="ark_viewer" version="1">
<gui name="ark_viewer" version="2">
<MenuBar>
<Menu name="help">
<text>&amp;Help</text>
<Action name="help_about_kpart" append="about_merge"/>
</Menu>
<Merge/>
</MenuBar>
</gui>
......@@ -29,12 +29,16 @@
#include <KMessageBox>
#include <KParts/OpenUrlArguments>
#include <KXMLGUIFactory>
#include <KActionCollection>
#include <KAboutPluginDialog>
#include <KPluginMetaData>
#include <QFile>
#include <QMimeDatabase>
#include <QProgressDialog>
#include <QPushButton>
#include <QStyle>
#include <QAction>
#include <algorithm>
......@@ -199,6 +203,15 @@ bool ArkViewer::viewInInternalViewer(const QString& fileName, const QMimeType &m
// Insert the KPart into its placeholder.
centralWidget()->layout()->replaceWidget(m_partPlaceholder, m_part.data()->widget());
QAction* action = actionCollection()->addAction(QStringLiteral("help_about_kpart"));
const KPluginMetaData partMetaData = m_part->metaData();
const QString iconName = partMetaData.iconName();
if (!iconName.isEmpty()) {
action->setIcon(QIcon::fromTheme(iconName));
}
action->setText(i18nc("@action", "About Viewer Component"));
connect(action, &QAction::triggered, this, &ArkViewer::aboutKPart);
createGUI(m_part.data());
setAutoSaveSettings(QStringLiteral("Viewer"), true);
......@@ -244,3 +257,14 @@ KService::Ptr ArkViewer::getViewer(const QString &mimeType)
return KService::Ptr();
}
}
void ArkViewer::aboutKPart()
{
if (!m_part) {
return;
}
auto *dialog = new KAboutPluginDialog(m_part->metaData(), this);
dialog->setAttribute(Qt::WA_DeleteOnClose);
dialog->show();
}
......@@ -46,6 +46,10 @@ private:
static KService::Ptr getViewer(const QString& mimeType);
bool viewInInternalViewer(const QString& fileName, const QMimeType& mimeType);
private Q_SLOTS:
void aboutKPart();
private:
QPointer<KParts::ReadOnlyPart> m_part;
QString m_fileName;
};
......
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