File indexing completed on 2024-05-19 05:55:47
0001 /* 0002 SPDX-FileCopyrightText: 2003-2005 George Staikos <staikos@kde.org> 0003 SPDX-FileCopyrightText: 2005 Isaac Clerencia <isaac@warp.es> 0004 0005 SPDX-License-Identifier: GPL-2.0-or-later 0006 */ 0007 0008 #ifndef KWALLETEDITOR_H 0009 #define KWALLETEDITOR_H 0010 0011 #include "ui_walletwidget.h" 0012 #include "registercreateactionmethod.h" 0013 0014 #include <KWallet> 0015 0016 #include <QLabel> 0017 0018 class KActionCollection; 0019 class QMenu; 0020 class QTreeWidgetItem; 0021 class QCheckBox; 0022 class KWalletEntryList; 0023 class KWMapEditor; 0024 class KTreeWidgetSearchLine; 0025 0026 class KWalletEditor : public QWidget, public Ui::WalletWidget 0027 { 0028 Q_OBJECT 0029 0030 public: 0031 explicit KWalletEditor(QWidget *parent, const QString &name = QString()); 0032 ~KWalletEditor() override; 0033 0034 void setWallet(KWallet::Wallet *wallet, bool isPath = false); 0035 bool isOpen() const; 0036 0037 bool hasUnsavedChanges() const; 0038 void setNewWallet(bool newWallet); 0039 0040 protected: 0041 void hideEvent(QHideEvent *) override; 0042 void showEvent(QShowEvent *) override; 0043 0044 public Q_SLOTS: 0045 void walletClosed(); 0046 void createFolder(); 0047 void deleteFolder(); 0048 0049 private Q_SLOTS: 0050 void updateFolderList(bool checkEntries = false); 0051 void entrySelectionChanged(QTreeWidgetItem *item); 0052 void listItemChanged(QTreeWidgetItem *, int column); 0053 void listContextMenuRequested(const QPoint &pos); 0054 void updateEntries(const QString &folder); 0055 0056 void newEntry(); 0057 void renameEntry(); 0058 void deleteEntry(); 0059 void entryEditted(); 0060 void restoreEntry(); 0061 void saveEntry(); 0062 0063 void changePassword(); 0064 0065 void walletOpened(bool success); 0066 void hidePasswordContents(); 0067 void showPasswordContents(); 0068 void showHideMapEditorValue(bool show); 0069 0070 void exportXML(); 0071 void importXML(); 0072 void importWallet(); 0073 0074 void copyPassword(); 0075 0076 void onSearchTextChanged(const QString &); 0077 void onAlwaysShowContents(bool); 0078 void onAlwaysHideContents(bool); 0079 0080 Q_SIGNALS: 0081 void enableWalletActions(bool enable); 0082 void enableFolderActions(bool enable); 0083 void enableContextFolderActions(bool enable); 0084 0085 public: 0086 QString _walletName; 0087 0088 private: 0089 static void createActions(KActionCollection *); 0090 void connectActions(); 0091 void disconnectActions(); 0092 KActionCollection *actionCollection(); 0093 0094 bool _nonLocal; 0095 KWallet::Wallet *_w = nullptr; 0096 KWalletEntryList *_entryList = nullptr; 0097 static RegisterCreateActionsMethod _registerCreateActionMethod; 0098 static QAction *_newFolderAction, *_deleteFolderAction; 0099 static QAction *_exportAction, *_saveAsAction, *_mergeAction, *_importAction; 0100 static QAction *_newEntryAction, *_renameEntryAction, *_deleteEntryAction; 0101 static QAction *_copyPassAction; 0102 QString _currentFolder; 0103 QMap<QString, QString> _currentMap; // save memory by storing 0104 // only the most recent map. 0105 KWMapEditor *_mapEditor = nullptr; 0106 QCheckBox *_mapEditorShowHide = nullptr; 0107 bool _newWallet; 0108 QMenu *_contextMenu = nullptr; 0109 QTreeWidgetItem *_displayedItem = nullptr; // used to find old item when selection just changed 0110 KActionCollection *_actionCollection = nullptr; 0111 QMenu *_controlMenu = nullptr; 0112 QMenu *_walletSubmenu = nullptr; 0113 KTreeWidgetSearchLine *_searchLine = nullptr; 0114 static QAction *_alwaysShowContentsAction, *_alwaysHideContentsAction; 0115 bool _alwaysShowContents; 0116 bool _hasUnsavedChanges; 0117 }; 0118 0119 #endif