File indexing completed on 2024-05-19 05:55:47
0001 /* 0002 This file is part of the KDE libraries 0003 SPDX-FileCopyrightText: 2013 Valentin Rusu <kde@rusu.info> 0004 0005 SPDX-License-Identifier: LGPL-2.0-or-later 0006 */ 0007 #ifndef KWALLETMANAGERWIDGET_H 0008 #define KWALLETMANAGERWIDGET_H 0009 0010 #include <KPageWidget> 0011 #include <QLabel> 0012 0013 class QUrl; 0014 class QDropEvent; 0015 class KWalletManagerWidgetItem; 0016 class QDragEnterEvent; 0017 class QDragMoveEvent; 0018 0019 class KWalletManagerWidget : public KPageWidget 0020 { 0021 Q_OBJECT 0022 public: 0023 explicit KWalletManagerWidget(QWidget *parent = nullptr, Qt::WindowFlags flags = {}); 0024 ~KWalletManagerWidget() override; 0025 0026 void updateWalletDisplay(const QString &selectWallet = QString()); 0027 bool hasWallet(const QString &) const; 0028 bool openWalletFile(const QString &path); 0029 bool openWallet(const QString &name); 0030 0031 QString activeWalletName() const; 0032 bool hasUnsavedChanges(const QString& name) const; 0033 0034 void setErrorMessage(const QString &message); 0035 0036 protected: 0037 void dragEnterEvent(QDragEnterEvent *e) override; 0038 void dragMoveEvent(QDragMoveEvent *e) override; 0039 void dropEvent(QDropEvent *e) override; 0040 0041 private Q_SLOTS: 0042 void onCurrentPageChanged(KPageWidgetItem *, KPageWidgetItem *); 0043 0044 private: 0045 bool shouldIgnoreDropEvent(const QDropEvent *e, QUrl *u) const; 0046 0047 using WalletPagesHash = QHash<QString, KWalletManagerWidgetItem *>; 0048 WalletPagesHash _walletPages; 0049 KPageWidgetItem *_errorItem = nullptr; 0050 QLabel *_errorLabel = nullptr; 0051 }; 0052 0053 #endif // KWALLETMANAGERWIDGET_H 0054