1 /* This file is part of the KDE project 2 Copyright (c) 2007 Marijn Kruisselbrink <mkruisselbrink@kde.org> 3 4 This library is free software; you can redistribute it and/or 5 modify it under the terms of the GNU Library General Public 6 License as published by the Free Software Foundation; either 7 version 2 of the License, or (at your option) any later version. 8 9 This library is distributed in the hope that it will be useful, 10 but WITHOUT ANY WARRANTY; without even the implied warranty of 11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 Library General Public License for more details. 13 14 You should have received a copy of the GNU Library General Public License 15 along with this library; see the file COPYING.LIB. If not, write to 16 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 17 Boston, MA 02110-1301, USA. 18 */ 19 #ifndef KODOCKWIDGETTITLEBAR_H_ 20 #define KODOCKWIDGETTITLEBAR_H_ 21 22 #include "kowidgets_export.h" 23 #include <QDockWidget> 24 25 /** 26 * @short A custom title bar for dock widgets. 27 * 28 * Allow customization such as collapsable, or hidding text. 29 * 30 * @see KoDockWidgetTitleBarButton 31 */ 32 class KOWIDGETS_EXPORT KoDockWidgetTitleBar : public QWidget 33 { 34 Q_OBJECT 35 public: 36 explicit KoDockWidgetTitleBar(QDockWidget *dockWidget); 37 ~KoDockWidgetTitleBar() override; 38 39 QSize minimumSizeHint() const override; ///< reimplemented from QWidget 40 QSize sizeHint() const override; ///< reimplemented from QWidget 41 42 enum TextVisibilityMode {TextCanBeInvisible, FullTextAlwaysVisible}; 43 /// Define whether the minimal width should ensure that the full text is visible. 44 /// textVisibilityMode is FullTextAlwaysVisible by default 45 void setTextVisibilityMode(TextVisibilityMode textVisibilityMode); 46 47 void updateIcons(); 48 49 public Q_SLOTS: 50 void setCollapsed(bool collapsed); 51 void setLocked(bool locked); 52 void setCollapsable(bool collapsable); 53 54 protected: 55 void paintEvent(QPaintEvent* event) override; ///< reimplemented from QWidget 56 void resizeEvent(QResizeEvent* event) override; ///< reimplemented from QWidget 57 private: 58 Q_PRIVATE_SLOT(d, void toggleFloating()) 59 Q_PRIVATE_SLOT(d, void toggleCollapsed()) 60 Q_PRIVATE_SLOT(d, void topLevelChanged(bool topLevel)) 61 Q_PRIVATE_SLOT(d, void featuresChanged(QDockWidget::DockWidgetFeatures)) 62 63 class Private; 64 Private * const d; 65 }; 66 67 #endif // KODOCKWIDGETTITLEBAR_H_ 68