File indexing completed on 2024-12-22 05:00:57

0001 /*
0002   This file is part of KTnef.
0003 
0004   SPDX-FileCopyrightText: 2002 Michael Goffioul <kdeprint@swing.be>
0005   SPDX-FileCopyrightText: 2012 Allen Winter <winter@kde.org>
0006 
0007   SPDX-License-Identifier: GPL-2.0-or-later
0008 
0009   You should have received a copy of the GNU General Public License
0010   along with this program; if not, write to the Free Software Foundation,
0011   Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
0012 */
0013 
0014 #pragma once
0015 
0016 #include <KService>
0017 #include <KTNEF/KTNEFAttach>
0018 #include <KXmlGuiWindow>
0019 
0020 class QActionGroup;
0021 class QAction;
0022 class QContextMenuEvent;
0023 class QTreeWidgetItem;
0024 class KRecentFilesMenu;
0025 class QUrl;
0026 
0027 namespace KTnef
0028 {
0029 class KTNEFParser;
0030 }
0031 using namespace KTnef;
0032 
0033 class KTNEFView;
0034 
0035 class KTNEFMain : public KXmlGuiWindow
0036 {
0037     Q_OBJECT
0038 
0039 public:
0040     explicit KTNEFMain(QWidget *parent = nullptr);
0041     ~KTNEFMain() override;
0042 
0043     void loadFile(const QString &filename);
0044 
0045 protected:
0046     void contextMenuEvent(QContextMenuEvent *event) override;
0047 
0048 protected Q_SLOTS:
0049     void openFile();
0050     void viewFile();
0051     void viewFileAs();
0052     void extractFile();
0053     void extractFileTo();
0054     void propertiesFile();
0055     void optionDefaultDir();
0056     void extractAllFiles();
0057     void slotEditToolbars();
0058     void slotNewToolbarConfig();
0059     void slotShowMessageProperties();
0060     void slotShowMessageText();
0061     void slotSaveMessageText();
0062 
0063     void viewSelectionChanged();
0064     void viewDoubleClicked(QTreeWidgetItem *);
0065     void viewDragRequested(const QList<KTnef::KTNEFAttach *> &list);
0066     void slotConfigureKeys();
0067     void openRecentFile(const QUrl &);
0068 
0069 private:
0070     void slotOpenWithAction(QAction *act);
0071     void addRecentFile(const QUrl &url);
0072     void setupStatusbar();
0073     void setupActions();
0074     void setupTNEF();
0075     void enableExtractAll(bool on = true);
0076     void enableSingleAction(bool on = true);
0077     void cleanup();
0078 
0079     void extractTo(const QString &dirname);
0080     QString extractTemp(KTNEFAttach *att);
0081 
0082     void openWith(const KService::Ptr &offer);
0083     void createOpenWithMenu(QMenu *topMenu);
0084     QAction *createAppAction(const KService::Ptr &service, bool singleOffer, QActionGroup *actionGroup, QObject *parent);
0085 
0086 private:
0087     QString mFilename;
0088     QString mDefaultDir;
0089     QString mLastDir;
0090     KTNEFView *mView = nullptr;
0091     KTNEFParser *mParser = nullptr;
0092     KRecentFilesMenu *mOpenRecentFileMenu = nullptr;
0093 };
0094 Q_DECLARE_METATYPE(KService::Ptr)