TabBar.h 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. /*
  2. * TabBar.h - class tabBar
  3. *
  4. * Copyright (c) 2004-2008 Tobias Doerffel <tobydox/at/users.sourceforge.net>
  5. *
  6. * This file is part of LMMS - https://lmms.io
  7. *
  8. * This program is free software; you can redistribute it and/or
  9. * modify it under the terms of the GNU General Public
  10. * License as published by the Free Software Foundation; either
  11. * version 2 of the License, or (at your option) any later version.
  12. *
  13. * This program is distributed in the hope that it will be useful,
  14. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  16. * General Public License for more details.
  17. *
  18. * You should have received a copy of the GNU General Public
  19. * License along with this program (see COPYING); if not, write to the
  20. * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
  21. * Boston, MA 02110-1301 USA.
  22. *
  23. */
  24. #ifndef TAB_BAR_H
  25. #define TAB_BAR_H
  26. #include <QtCore/QMap>
  27. #include <QLayout>
  28. #include <QWidget>
  29. #include "lmms_export.h"
  30. class TabButton;
  31. class LMMS_EXPORT TabBar : public QWidget
  32. {
  33. Q_OBJECT
  34. public:
  35. TabBar( QWidget * _parent,
  36. QBoxLayout::Direction _dir = QBoxLayout::LeftToRight );
  37. virtual ~TabBar() = default;
  38. TabButton * addTab( QWidget * _w, const QString & _text,
  39. int _id, bool _add_stretch = false,
  40. bool _text_is_tooltip = false );
  41. void removeTab( int _id );
  42. inline void setExclusive( bool _on )
  43. {
  44. m_exclusive = _on;
  45. }
  46. int activeTab();
  47. public slots:
  48. void setActiveTab( int _id );
  49. protected:
  50. bool tabState( int _id );
  51. void setTabState( int _id, bool _checked );
  52. bool allHidden();
  53. protected slots:
  54. void hideAll( int _exception = -1 );
  55. void tabClicked( int _id );
  56. private:
  57. QMap<int, QPair<TabButton *, QWidget *> > m_tabs;
  58. QBoxLayout * m_layout;
  59. bool m_exclusive;
  60. signals:
  61. void allWidgetsHidden();
  62. void widgetShown();
  63. } ;
  64. #endif