1 /*
2     ark: A program for modifying archives via a GUI.
3 
4     SPDX-FileCopyrightText: 2004-2008 Henrique Pinto <henrique.pinto@kdemail.net>
5 
6     SPDX-License-Identifier: GPL-2.0-or-later
7 */
8 
9 #ifndef ARKVIEWER_H
10 #define ARKVIEWER_H
11 
12 #include "ui_arkviewer.h"
13 
14 #include <KParts/MainWindow>
15 #include <KParts/ReadOnlyPart>
16 #include <KService>
17 
18 #include <QMimeType>
19 #include <QPointer>
20 
21 class ArkViewer : public KParts::MainWindow, public Ui::ArkViewer
22 {
23     Q_OBJECT
24 
25 public:
26     ~ArkViewer() override;
27 
28     static void view(const QString& fileName);
29 
30 private:
31     explicit ArkViewer();
32 
33     static KService::Ptr getExternalViewer(const QString& mimeType);
34     static KService::Ptr getInternalViewer(const QString& mimeType);
35 
36     static void openExternalViewer(const KService::Ptr viewer, const QString& fileName);
37     static void openInternalViewer(const KService::Ptr viewer, const QString& fileName, const QMimeType& mimeType);
38 
39     static bool askViewAsPlainText(const QMimeType& mimeType);
40 
41     bool viewInInternalViewer(const KService::Ptr viewer, const QString& fileName, const QMimeType& mimeType);
42 
43 private Q_SLOTS:
44     void aboutKPart();
45 
46 private:
47     QPointer<KParts::ReadOnlyPart> m_part;
48     QString m_fileName;
49 };
50 
51 #endif // ARKVIEWER_H
52 
53