]> git.lyx.org Git - lyx.git/blob - src/frontends/qt/PanelStack.h
Properly scale some icons for HiDPI (#12695)
[lyx.git] / src / frontends / qt / PanelStack.h
1 // -*- C++ -*-
2 /**
3  * \file PanelStack.h
4  * This file is part of LyX, the document processor.
5  * Licence details can be found in the file COPYING.
6  *
7  * \author John Levon
8  * \author Abdelrazak Younes
9  *
10  * Full author contact details are available in file CREDITS.
11  */
12
13 #ifndef PANELSTACK_H
14 #define PANELSTACK_H
15
16 #include <QHash>
17 #include <QWidget>
18
19 class QHideEvent;
20 class QStackedWidget;
21 class QTimer;
22 class QTreeWidget;
23 class QTreeWidgetItem;
24
25 namespace lyx {
26 namespace frontend {
27
28 class FancyLineEdit;
29
30 class PanelStack : public QWidget
31 {
32         Q_OBJECT
33 public:
34         ///
35         PanelStack(QWidget * parent = 0);
36
37         /// add a category with no associated panel
38         void addCategory(QString const & name, QString const & parent = QString());
39         /// add a widget panel with a given name, under the given parent
40         void addPanel(QWidget * panel, QString const & name,
41                 QString const & parent = QString());
42         /// show or hide panel
43         void showPanel(QString const & name, bool show);
44         /// Mark panel (content) valid
45         void markPanelValid(QString const & name, bool valid);
46         /// set current panel by logical name
47         void setCurrentPanel(QString const &);
48         ///
49         bool isCurrentPanel(QString const & name) const;
50         ///
51         QSize sizeHint() const override;
52
53 public Q_SLOTS:
54         /// the option filter changed
55         void filterChanged(QString const & search);
56         /// perform the search
57         void search();
58         /// reset the search box
59         void resetSearch();
60         /// set current panel from an item
61         void switchPanel(QTreeWidgetItem * it, QTreeWidgetItem * previous = 0);
62         /// click on the tree
63         void itemSelected(QTreeWidgetItem *, int);
64
65 protected:
66         /// widget hidden
67         void hideEvent(QHideEvent * event) override;
68
69 private:
70         ///
71         typedef QHash<QString, QTreeWidgetItem *> PanelMap;
72         ///
73         PanelMap panel_map_;
74
75         typedef QHash<QTreeWidgetItem *, QWidget *> WidgetMap;
76
77         WidgetMap widget_map_;
78
79         /// contains the search box
80         FancyLineEdit * search_;
81
82         /// contains the items
83         QTreeWidget * list_;
84
85         /// contains the panes
86         QStackedWidget * stack_;
87
88         // timer to delay the search between options
89         QTimer * delay_search_;
90
91 };
92
93 } // namespace frontend
94 } // namespace lyx
95
96 #endif // PANELSTACK_H