File indexing completed on 2024-05-19 05:35:25
0001 #ifndef oxygentabwidget_h 0002 #define oxygentabwidget_h 0003 0004 ////////////////////////////////////////////////////////////////////////////// 0005 // oxygentabwidget.h 0006 // ------------------- 0007 // 0008 // SPDX-FileCopyrightText: 2010 Hugo Pereira Da Costa <hugo.pereira@free.fr> 0009 // 0010 // SPDX-License-Identifier: MIT 0011 ////////////////////////////////////////////////////////////////////////////// 0012 0013 #include "../oxygen.h" 0014 0015 #include <QIcon> 0016 #include <QTabBar> 0017 #include <QTabWidget> 0018 0019 namespace Oxygen 0020 { 0021 class TabWidget : public QTabWidget 0022 { 0023 Q_OBJECT 0024 0025 public: 0026 //! constructor 0027 explicit TabWidget(QWidget *parent) 0028 : QTabWidget(parent) 0029 { 0030 tabBar()->setMovable(true); 0031 } 0032 0033 // adjust tabbar size 0034 void adjustTabBarSize(void) 0035 { 0036 if (tabBar()) 0037 tabBar()->adjustSize(); 0038 } 0039 0040 //! show icons 0041 void showIcons(void) 0042 { 0043 // add icons to tabs 0044 tabBar()->setTabIcon(0, QIcon::fromTheme(QStringLiteral("document-open-folder"))); 0045 tabBar()->setTabIcon(1, QIcon::fromTheme(QStringLiteral("document-open-folder"))); 0046 tabBar()->setTabIcon(2, QIcon::fromTheme(QStringLiteral("document-open-folder"))); 0047 tabBar()->setTabIcon(3, QIcon::fromTheme(QStringLiteral("document-open-folder"))); 0048 } 0049 0050 void hideIcons(void) 0051 { 0052 // add icons to tabs 0053 tabBar()->setTabIcon(0, QIcon()); 0054 tabBar()->setTabIcon(1, QIcon()); 0055 tabBar()->setTabIcon(2, QIcon()); 0056 tabBar()->setTabIcon(3, QIcon()); 0057 } 0058 0059 void showText(void) 0060 { 0061 tabBar()->setTabText(0, QStringLiteral("First Tab")); 0062 tabBar()->setTabText(1, QStringLiteral("Second Tab")); 0063 tabBar()->setTabText(2, QStringLiteral("Third Tab")); 0064 tabBar()->setTabText(3, QStringLiteral("Fourth Tab")); 0065 } 0066 0067 void hideText(void) 0068 { 0069 tabBar()->setTabText(0, QString()); 0070 tabBar()->setTabText(1, QString()); 0071 tabBar()->setTabText(2, QString()); 0072 tabBar()->setTabText(3, QString()); 0073 } 0074 0075 public Q_SLOTS: 0076 0077 // toggle tabbar visibility 0078 void toggleTabBarVisibility(bool value) 0079 { 0080 if (tabBar()) 0081 tabBar()->setVisible(!value); 0082 } 0083 }; 0084 } 0085 0086 #endif