File indexing completed on 2024-04-28 04:37:31
0001 /* 0002 SPDX-FileCopyrightText: 2006-2007 Alexander Dymo <adymo@kdevelop.org> 0003 0004 SPDX-License-Identifier: LGPL-2.0-or-later 0005 */ 0006 0007 #ifndef KDEVPLATFORM_SUBLIMECONTAINER_H 0008 #define KDEVPLATFORM_SUBLIMECONTAINER_H 0009 0010 #include <QWidget> 0011 #include "sublimeexport.h" 0012 0013 class QMenu; 0014 class QPaintEvent; 0015 0016 namespace Sublime { 0017 0018 class View; 0019 class Document; 0020 class ContainerPrivate; 0021 0022 /** 0023 @short Container for the widgets. 0024 0025 This container is placed inside mainwindow splitters to show widgets 0026 for views in the area. 0027 */ 0028 class KDEVPLATFORMSUBLIME_EXPORT Container: public QWidget { 0029 Q_OBJECT 0030 public: 0031 explicit Container(QWidget *parent = nullptr); 0032 ~Container() override; 0033 0034 /**Adds the widget for given @p view to the container.*/ 0035 void addWidget(Sublime::View* view, int position = -1); 0036 /**Removes the widget from the container.*/ 0037 void removeWidget(QWidget *w); 0038 /** @return true if widget is placed inside this container.*/ 0039 bool hasWidget(QWidget* w) const; 0040 0041 QList<View*> views() const; 0042 0043 int count() const; 0044 QWidget *currentWidget() const; 0045 void setCurrentWidget(QWidget *w); 0046 QWidget *widget(int i) const; 0047 int indexOf(QWidget *w) const; 0048 0049 View *viewForWidget(QWidget *w) const; 0050 0051 void setTabBarHidden(bool hide); 0052 void setCloseButtonsOnTabs(bool show); 0053 0054 void setTabColor(const View* view, const QColor& color); 0055 void setTabColors(const QHash<const View*, QColor>& colors); 0056 void resetTabColors(const QColor& color); 0057 0058 /** Adds a corner widget to the left of this containers tab-bar. To remove it again, just delete it. 0059 * The ownership otherwise goes to the container. */ 0060 void setLeftCornerWidget(QWidget* widget); 0061 void showTooltipForTab(int tab); 0062 0063 bool isCurrentTab(int tab) const; 0064 /// @return Rect in global position of the tab identified by index @p tab 0065 QRect tabRect(int tab) const; 0066 0067 static bool configTabBarVisible(); 0068 static bool configCloseButtonsOnTabs(); 0069 0070 Q_SIGNALS: 0071 void activateView(Sublime::View* view); 0072 void requestClose(QWidget *w); 0073 /** 0074 * This signal is emitted whenever the users double clicks on the free 0075 * space next to the tab bar. Typically, a new document should be 0076 * created. 0077 */ 0078 void newTabRequested(); 0079 void tabContextMenuRequested(Sublime::View* view, QMenu* menu); 0080 /** 0081 * @p view The view represented by the tab that was hovered 0082 * @p Container The tab container that triggered the event 0083 * @p idx The index of the tab that was hovered 0084 */ 0085 void tabToolTipRequested(Sublime::View* view, Sublime::Container* container, int idx); 0086 void tabDoubleClicked(Sublime::View* view); 0087 0088 private Q_SLOTS: 0089 void widgetActivated(int idx); 0090 void documentTitleChanged(Sublime::Document* doc); 0091 void statusIconChanged(Sublime::Document*); 0092 void statusChanged(Sublime::View *view); 0093 void requestClose(int idx); 0094 void tabMoved(int from, int to); 0095 void contextMenu(const QPoint&); 0096 void doubleClickTriggered(int tab); 0097 void documentListActionTriggered(QAction*); 0098 0099 private: 0100 Sublime::View* currentView() const; 0101 0102 protected: 0103 void focusInEvent(QFocusEvent*) override; 0104 0105 private: 0106 const QScopedPointer<class ContainerPrivate> d_ptr; 0107 Q_DECLARE_PRIVATE(Container) 0108 }; 0109 0110 } 0111 0112 #endif 0113