2 * SPDX-FileCopyrightText: 2014 Emmanuel Pescosta <emmanuelpescosta099@gmail.com>
3 * SPDX-FileCopyrightText: 2020 Felix Ernst <fe.a.ernst@gmail.com>
5 * SPDX-License-Identifier: GPL-2.0-or-later
8 #ifndef DOLPHIN_TAB_PAGE_H
9 #define DOLPHIN_TAB_PAGE_H
15 class DolphinNavigatorsWidgetAction
;
16 class DolphinViewContainer
;
18 class QVariantAnimation
;
26 class DolphinTabPage
: public QWidget
31 explicit DolphinTabPage(const QUrl
& primaryUrl
, const QUrl
& secondaryUrl
= QUrl(), QWidget
* parent
= nullptr);
34 * @return True if primary view is the active view in this tab.
36 bool primaryViewActive() const;
39 * @return True if split view is enabled.
41 bool splitViewEnabled() const;
44 * Enables or disables the split view mode.
46 * @param enabled If true, creates a secondary viewContainer in this tab.
47 * Otherwise deletes it.
48 * @param animated Decides wether the effects of this method call should
49 * happen instantly or be transitioned to smoothly.
50 * @param secondaryUrl If \p enabled is true, the new viewContainer will be opened at this
51 * parameter. The default value will set the Url of the new viewContainer
52 * to be the same as the existing one.
54 void setSplitViewEnabled(bool enabled
, Animated animated
, const QUrl
&secondaryUrl
= QUrl());
57 * @return The primary view container.
59 DolphinViewContainer
* primaryViewContainer() const;
62 * @return The secondary view container, can be 0 if split view is disabled.
64 DolphinViewContainer
* secondaryViewContainer() const;
67 * @return DolphinViewContainer of the active view
69 DolphinViewContainer
* activeViewContainer() const;
72 * Returns the selected items. The list is empty if no item has been
75 KFileItemList
selectedItems() const;
78 * Returns the number of selected items (this is faster than
79 * invoking selectedItems().count()).
81 int selectedItemsCount() const;
84 * Connects a navigatorsWidget to this. It will be connected to the DolphinViewContainers
85 * managed by this tab. For alignment purposes this will from now on notify the
86 * navigatorsWidget when this tab or its viewContainers are resized.
88 void connectNavigators(DolphinNavigatorsWidgetAction
*navigatorsWidget
);
91 * Makes it so this tab and its DolphinViewContainers aren't controlled by any
92 * UrlNavigators anymore.
94 void disconnectNavigators();
96 void insertNavigatorsWidget(DolphinNavigatorsWidgetAction
*navigatorsWidget
);
99 * Marks the items indicated by \p urls to get selected after the
100 * directory DolphinView::url() has been loaded. Note that nothing
101 * gets selected if no loading of a directory has been triggered
102 * by DolphinView::setUrl() or DolphinView::reload().
104 void markUrlsAsSelected(const QList
<QUrl
> &urls
);
107 * Marks the item indicated by \p url to be scrolled to and as the
108 * current item after directory DolphinView::url() has been loaded.
110 void markUrlAsCurrent(const QUrl
& url
);
113 * Refreshes the views of the main window by recreating them according to
114 * the given Dolphin settings.
119 * Saves all tab related properties (urls, splitter layout, ...).
121 * @return A byte-array which contains all properties.
123 QByteArray
saveState() const;
126 * Restores all tab related properties (urls, splitter layout, ...) from
127 * the given \a state.
129 void restoreState(const QByteArray
& state
);
132 * Restores all tab related properties (urls, splitter layout, ...) from
133 * the given \a state.
135 * @deprecated The first tab state version has no version number, we keep
136 * this method to restore old states (<= Dolphin 4.14.x).
138 Q_DECL_DEPRECATED
void restoreStateV1(const QByteArray
& state
);
141 * Set whether the tab page is active
144 void setActive(bool active
);
147 void activeViewChanged(DolphinViewContainer
* viewContainer
);
148 void activeViewUrlChanged(const QUrl
& url
);
149 void splitterMoved(int pos
, int index
);
153 * Deletes all zombie viewContainers that were used for the animation
154 * and resets the minimum size of the others to a sane value.
156 void slotAnimationFinished();
159 * This method is called for every frame of the m_expandViewAnimation.
161 void slotAnimationValueChanged(const QVariant
&value
);
164 * Handles the view activated event.
166 * It sets the previous active view to inactive, updates the current
167 * active view type and triggers the activeViewChanged event.
169 void slotViewActivated();
172 * Handles the view url redirection event.
174 * It emits the activeViewUrlChanged signal with the url \a newUrl.
176 void slotViewUrlRedirection(const QUrl
& oldUrl
, const QUrl
& newUrl
);
178 void switchActiveView();
182 * Creates a new view container and does the default initialization.
184 DolphinViewContainer
* createViewContainer(const QUrl
& url
) const;
187 * Starts an animation that transitions between split view mode states.
189 * One of the viewContainers is always being expanded when toggling so
190 * this method can animate both opening and closing of viewContainers.
191 * @param expandingContainer The container that will increase in size
192 * over the course of the animation.
194 void startExpandViewAnimation(DolphinViewContainer
*expandingContainer
);
197 QSplitter
* m_splitter
;
199 QPointer
<DolphinNavigatorsWidgetAction
> m_navigatorsWidget
;
200 QPointer
<DolphinViewContainer
> m_primaryViewContainer
;
201 QPointer
<DolphinViewContainer
> m_secondaryViewContainer
;
203 DolphinViewContainer
*m_expandingContainer
;
204 QPointer
<QVariantAnimation
> m_expandViewAnimation
;
206 bool m_primaryViewActive
;
207 bool m_splitViewEnabled
;
211 #endif // DOLPHIN_TAB_PAGE_H