File indexing completed on 2024-04-28 16:26:34
0001 /************************************************************************************** 0002 Copyright (C) 2004 by Jeroen Wijnhout (Jeroen.Wijnhout@kdemail.net) 0003 (C) 2006 by Thomas Braun (thomas.braun@virtuell-zuhause.de) 0004 (C) 2006-2018 by Michel Ludwig (michel.ludwig@kdemail.net) 0005 **************************************************************************************/ 0006 0007 /*************************************************************************** 0008 * * 0009 * This program is free software; you can redistribute it and/or modify * 0010 * it under the terms of the GNU General Public License as published by * 0011 * the Free Software Foundation; either version 2 of the License, or * 0012 * (at your option) any later version. * 0013 * * 0014 ***************************************************************************/ 0015 0016 #ifndef SIDEBAR_H 0017 #define SIDEBAR_H 0018 0019 #include <QIcon> 0020 #include <QStackedWidget> 0021 #include <QWidget> 0022 0023 #include <KMultiTabBar> 0024 0025 namespace KileWidget { 0026 0027 class SideBar : public QWidget 0028 { 0029 Q_OBJECT 0030 0031 public: 0032 explicit SideBar(QWidget *parent = Q_NULLPTR, Qt::Orientation orientation = Qt::Vertical); 0033 virtual ~SideBar(); 0034 0035 int addPage(QWidget *tab, const QIcon &pic, const QString &text = QString()); 0036 void removePage(QWidget *w); 0037 0038 QWidget* currentPage(); 0039 0040 /** 0041 * Returns the index of the widget which is currently shown, or -1 if the side bar is minimized. 0042 **/ 0043 int currentTab(); 0044 0045 bool isMinimized(); 0046 0047 int count(); 0048 0049 /** 0050 * Shows or hides the tab connected to the widget "w". If the tab to be hidden is 0051 * currently selected, the next tab will be shown (cyclically). 0052 * 0053 * @param b set to "true" to show the tab connected to the widget "w", "false" to 0054 * hide it 0055 **/ 0056 void setPageVisible(QWidget *w, bool b); 0057 0058 /** 0059 * Returns the side bar's height if its orientation is vertical, its width otherwise. 0060 **/ 0061 int directionalSize(); 0062 0063 /** 0064 * Sets the side bar's height if its orientation is vertical, its width otherwise. 0065 **/ 0066 void setDirectionalSize(int i); 0067 0068 /** 0069 * Add a widget to the (right or bottom) of the tab bar, which is not connected to any tabs. 0070 **/ 0071 void addExtraWidget(QWidget *w); 0072 0073 Q_SIGNALS: 0074 void visibilityChanged(bool b); 0075 0076 public Q_SLOTS: 0077 void showPage(QWidget *w); 0078 0079 /** 0080 * Shows the widget with index 'id'. If 'id' is not a valid index, the side bar will be 0081 * minimized. 0082 **/ 0083 void switchToTab(int id); 0084 0085 void shrink(); 0086 0087 private: 0088 int findNextShownTab(int i); 0089 0090 protected Q_SLOTS: 0091 void expand(); 0092 void tabClicked(int i); 0093 0094 protected: 0095 Qt::Orientation m_orientation; 0096 bool m_minimized; /* using m_tabStack->isVisible is not enough */ 0097 int m_directionalSize; /* directional size in the unminized state */ 0098 int m_currentTab; 0099 QStackedWidget *m_tabStack; 0100 KMultiTabBar *m_tabBar; 0101 QWidget *m_extraWidget; 0102 }; 0103 0104 class BottomBar : public SideBar 0105 { 0106 Q_OBJECT 0107 0108 public: 0109 explicit BottomBar(QWidget *parent = Q_NULLPTR); 0110 0111 }; 0112 0113 } 0114 0115 #endif