File indexing completed on 2024-04-21 05:01:49

0001 /*
0002     smb4ktooltip  -  Provides tooltips for Smb4K
0003 
0004     SPDX-FileCopyrightText: 2020-2023 Alexander Reinholdt <alexander.reinholdt@kdemail.net>
0005     SPDX-License-Identifier: GPL-2.0-or-later
0006 */
0007 
0008 #ifndef SMB4KTOOLTIP_H
0009 #define SMB4KTOOLTIP_H
0010 
0011 // application specific includes
0012 #include <smb4kglobal.h>
0013 
0014 // Qt includes
0015 #include <QHBoxLayout>
0016 #include <QPoint>
0017 #include <QWindow>
0018 
0019 // KDE includes
0020 #include <KToolTipWidget>
0021 
0022 // Forward declaration
0023 class Smb4KBasicNetworkItem;
0024 
0025 class Smb4KToolTip : public KToolTipWidget
0026 {
0027     Q_OBJECT
0028 
0029 public:
0030     /**
0031      * The constructor
0032      */
0033     Smb4KToolTip(QWidget *parent = nullptr);
0034 
0035     /**
0036      * The destructor
0037      */
0038     ~Smb4KToolTip();
0039 
0040     /**
0041      * This enumeration determines the kind of tooltip
0042      * this is to be shown.
0043      *
0044      * @enum NetworkItem  Tooltip reflecting a remote network item
0045      * @enum MountedShare Tooltip reflecting a mounted share
0046      */
0047     enum Type { NetworkItem, MountedShare, Unknown };
0048 
0049     /**
0050      * Set up the tooltip.
0051      */
0052     void setupToolTip(Type type, NetworkItemPtr item);
0053 
0054     /**
0055      * Show the tooltip
0056      */
0057     void show(const QPoint &pos, QWindow *transientParent);
0058 
0059     /**
0060      * Update the tooltip
0061      */
0062     void update();
0063 
0064 private:
0065     void setupNetworkItemContents();
0066     void setupMountedShareContents();
0067     NetworkItemPtr m_item;
0068     Type m_type;
0069     QWidget *m_contentsWidget;
0070     QHBoxLayout *m_mainLayout;
0071 };
0072 
0073 #endif