File indexing completed on 2024-05-19 05:21:23

0001 /*
0002   This file is part of the KDE Kontact.
0003 
0004   SPDX-FileCopyrightText: 2003 Cornelius Schumacher <schumacher@kde.org>
0005   SPDX-FileCopyrightText: 2008 Rafael Fernández López <ereslibre@kde.org>
0006 
0007   SPDX-License-Identifier: GPL-2.0-or-later
0008 */
0009 
0010 #pragma once
0011 
0012 #include "sidepanebase.h"
0013 
0014 #include <QListView>
0015 
0016 namespace KontactInterface
0017 {
0018 class Core;
0019 class Plugin;
0020 }
0021 
0022 class QAction;
0023 
0024 namespace Kontact
0025 {
0026 class Model;
0027 class MainWindow;
0028 class Navigator;
0029 
0030 class Navigator : public QListView
0031 {
0032     Q_OBJECT
0033 
0034 public:
0035     explicit Navigator(SidePaneBase *parent = nullptr);
0036 
0037     void updatePlugins(const QList<KontactInterface::Plugin *> &plugins);
0038     void setCurrentPlugin(const QString &plugin);
0039 
0040     [[nodiscard]] int iconSize() const
0041     {
0042         return mIconSize;
0043     }
0044 
0045     [[nodiscard]] bool showIcons() const
0046     {
0047         return mShowIcons;
0048     }
0049 
0050     [[nodiscard]] bool showText() const
0051     {
0052         return mShowText;
0053     }
0054 
0055     void setMainWindow(MainWindow *mainWindow)
0056     {
0057         mMainWindow = mainWindow;
0058     }
0059 
0060     [[nodiscard]] MainWindow *mainWindow()
0061     {
0062         return mMainWindow;
0063     }
0064 
0065     QSize sizeHint() const override;
0066 
0067 Q_SIGNALS:
0068     void pluginActivated(KontactInterface::Plugin *plugin);
0069 
0070 protected:
0071     void dragEnterEvent(QDragEnterEvent *event) override;
0072     void dragMoveEvent(QDragMoveEvent *event) override;
0073     void dropEvent(QDropEvent *event) override;
0074     void showEvent(QShowEvent *event) override;
0075 
0076 private:
0077     void slotCurrentChanged(const QModelIndex &current);
0078     void slotActionTriggered(QAction *checked);
0079     void slotHideSideBarTriggered();
0080     void updateNavigatorSize();
0081 
0082     void setHelpText(QAction *act, const QString &text);
0083     SidePaneBase *const mSidePane;
0084     MainWindow *mMainWindow = nullptr;
0085     Model *mModel = nullptr;
0086 
0087     int mIconSize = 0;
0088     bool mShowIcons = false;
0089     bool mShowText = false;
0090 
0091     QAction *mShowIconsAction = nullptr;
0092     QAction *mShowTextAction = nullptr;
0093     QAction *mShowBothAction = nullptr;
0094     QAction *mBigIconsAction = nullptr;
0095     QAction *mNormalIconsAction = nullptr;
0096     QAction *mSmallIconsAction = nullptr;
0097     QAction *mHideSideBarAction = nullptr;
0098 };
0099 
0100 class IconSidePane : public SidePaneBase
0101 {
0102     Q_OBJECT
0103 
0104 public:
0105     IconSidePane(KontactInterface::Core *core, QWidget *parent);
0106     ~IconSidePane() override;
0107 
0108     void setCurrentPlugin(const QString &plugin) override;
0109 
0110 public Q_SLOTS:
0111     void updatePlugins() override;
0112 
0113 protected:
0114     void resizeEvent(QResizeEvent *event) override;
0115 
0116 private:
0117     Navigator *mNavigator = nullptr;
0118 };
0119 }