2 * SPDX-FileCopyrightText: 2014 Emmanuel Pescosta <emmanuelpescosta099@gmail.com>
4 * SPDX-License-Identifier: GPL-2.0-or-later
7 #ifndef DOLPHIN_TAB_WIDGET_H
8 #define DOLPHIN_TAB_WIDGET_H
10 #include "dolphinnavigatorswidgetaction.h"
11 #include "dolphintabpage.h"
16 class DolphinViewContainer
;
19 class DolphinTabWidget
: public QTabWidget
26 * @param navigatorsWidget The navigatorsWidget which is always going to be connected
27 * to the active tabPage.
29 explicit DolphinTabWidget(DolphinNavigatorsWidgetAction
*navigatorsWidget
, QWidget
*parent
);
32 * @return Tab page at the current index (can be 0 if tabs count is smaller than 1)
34 DolphinTabPage
* currentTabPage() const;
37 * @return the next tab page. If the current active tab is the last tab,
38 * it returns the first tab. If there is only one tab, returns nullptr
40 DolphinTabPage
* nextTabPage() const;
43 * @return the previous tab page. If the current active tab is the first tab,
44 * it returns the last tab. If there is only one tab, returns nullptr
46 DolphinTabPage
* prevTabPage() const;
49 * @return Tab page at the given \a index (can be 0 if the index is out-of-range)
51 DolphinTabPage
* tabPageAt(const int index
) const;
53 void saveProperties(KConfigGroup
& group
) const;
54 void readProperties(const KConfigGroup
& group
);
57 * Refreshes the views of the main window by recreating them according to
58 * the given Dolphin settings.
63 * @return Whether any of the tab pages contains @p url in their primary
66 bool isUrlOpen(const QUrl
& url
) const;
70 * Is emitted when the active view has been changed, by changing the current
71 * tab or by activating another view when split view is enabled in the current
74 void activeViewChanged(DolphinViewContainer
* viewContainer
);
77 * Is emitted when the number of open tabs has changed (e.g. by opening or
80 void tabCountChanged(int count
);
83 * Is emitted when a tab has been closed.
85 void rememberClosedTab(const QUrl
& url
, const QByteArray
& state
);
88 * Is emitted when the url of the current tab has been changed. This signal
89 * is also emitted when the active view has been changed.
91 void currentUrlChanged(const QUrl
& url
);
95 * Opens a new view with the current URL that is part of a tab and activates
98 void openNewActivatedTab();
101 * Opens a new tab showing the URL \a primaryUrl and the optional URL
102 * \a secondaryUrl and activates the tab.
104 void openNewActivatedTab(const QUrl
& primaryUrl
, const QUrl
& secondaryUrl
= QUrl());
107 * Opens a new tab in the background showing the URL \a primaryUrl and the
108 * optional URL \a secondaryUrl.
110 void openNewTab(const QUrl
&primaryUrl
, const QUrl
&secondaryUrl
= QUrl());
113 * Opens each directory in \p dirs in a separate tab. If \a splitView is set,
114 * 2 directories are collected within one tab.
115 * \pre \a dirs must contain at least one url.
117 void openDirectories(const QList
<QUrl
>& dirs
, bool splitView
);
120 * Opens the directories which contain the files \p files and selects all files.
121 * If \a splitView is set, 2 directories are collected within one tab.
122 * \pre \a files must contain at least one url.
124 void openFiles(const QList
<QUrl
> &files
, bool splitView
);
127 * Closes the currently active tab.
132 * Closes the tab with the index \a index and activates the tab with index - 1.
134 void closeTab(const int index
);
137 * Activates the tab with the index \a index.
139 void activateTab(const int index
);
142 * Activates the last tab in the tab bar.
144 void activateLastTab();
147 * Activates the next tab in the tab bar.
148 * If the current active tab is the last tab, it activates the first tab.
150 void activateNextTab();
153 * Activates the previous tab in the tab bar.
154 * If the current active tab is the first tab, it activates the last tab.
156 void activatePrevTab();
159 * Is called when the user wants to reopen a previously closed tab from
160 * the recent tabs menu.
162 void restoreClosedTab(const QByteArray
& state
);
164 /** Copies all selected items to the inactive view. */
165 void copyToInactiveSplitView();
167 /** Moves all selected items to the inactive view. */
168 void moveToInactiveSplitView();
172 * Opens the tab with the index \a index in a new Dolphin instance and closes
175 void detachTab(int index
);
178 * Opens a new tab showing the url from tab at the given \a index and
181 void openNewActivatedTab(int index
);
184 * Is connected to the KTabBar signal receivedDropEvent.
185 * Allows dragging and dropping files onto tabs.
187 void tabDropEvent(int tab
, QDropEvent
* event
);
190 * The active view url of a tab has been changed so update the text and the
191 * icon of the corresponding tab.
193 void tabUrlChanged(const QUrl
& url
);
195 void currentTabChanged(int index
);
198 void tabInserted(int index
) override
;
199 void tabRemoved(int index
) override
;
203 * @param tabPage The tab page to get the name of
204 * @return The name of the tab page
206 QString
tabName(DolphinTabPage
* tabPage
) const;
209 * @param url The URL that we would like
210 * @return a QPair with first containing the index of the tab with the
211 * desired URL or -1 if not found. Second says true if URL is in primary
212 * view container, false otherwise. False means the URL is in the secondary
213 * view container, unless first == -1. In that case the value of second
216 QPair
<int, bool> indexByUrl(const QUrl
& url
) const;
219 QPointer
<DolphinTabPage
> m_lastViewedTab
;
220 QPointer
<DolphinNavigatorsWidgetAction
> m_navigatorsWidget
;