**Open Path**
When user clicks on "Open Path" after searching for an item,
user expects the view to show the item immediately.
We wait for the KItemListSmoothScroller to be done with its animation before the
scrollbar sizes are being changed.
**Open Path in New Tab**
When user selects "Open Path in New Tab", we open a new tab to the folder where the file is, then select and set the file current. We need to get the correct tab when opening one, so it has been added as a return value.
BUG:495613
});
addAction(QIcon::fromTheme(QStringLiteral("tab-new")), i18nc("@action:inmenu", "Open Path in New Tab"), [this]() {
});
addAction(QIcon::fromTheme(QStringLiteral("tab-new")), i18nc("@action:inmenu", "Open Path in New Tab"), [this]() {
- m_mainWindow->openNewTab(KIO::upUrl(m_fileInfo.targetUrl()));
+ const QUrl url = m_fileInfo.targetUrl();
+ const QUrl parentUrl = KIO::upUrl(url);
+ DolphinTabPage *tabPage = m_mainWindow->openNewTab(parentUrl);
+ tabPage->activeViewContainer()->view()->markUrlsAsSelected({url});
+ tabPage->activeViewContainer()->view()->markUrlAsCurrent(url);
});
addAction(QIcon::fromTheme(QStringLiteral("window-new")), i18nc("@action:inmenu", "Open Path in New Window"), [this]() {
});
addAction(QIcon::fromTheme(QStringLiteral("window-new")), i18nc("@action:inmenu", "Open Path in New Window"), [this]() {
-void DolphinMainWindow::openNewTab(const QUrl &url)
+DolphinTabPage *DolphinMainWindow::openNewTab(const QUrl &url)
- m_tabWidget->openNewTab(url, QUrl());
+ return m_tabWidget->openNewTab(url, QUrl());
}
void DolphinMainWindow::openNewTabAndActivate(const QUrl &url)
}
void DolphinMainWindow::openNewTabAndActivate(const QUrl &url)
/**
* Opens a new tab in the background showing the URL \a url.
/**
* Opens a new tab in the background showing the URL \a url.
+ * @return A pointer to the opened DolphinTabPage.
- void openNewTab(const QUrl &url);
+ DolphinTabPage *openNewTab(const QUrl &url);
/**
* Opens a new tab showing the URL \a url and activate it.
/**
* Opens a new tab showing the URL \a url and activate it.
-void DolphinTabWidget::openNewTab(const QUrl &primaryUrl, const QUrl &secondaryUrl, DolphinTabWidget::NewTabPosition position)
+DolphinTabPage *DolphinTabWidget::openNewTab(const QUrl &primaryUrl, const QUrl &secondaryUrl, DolphinTabWidget::NewTabPosition position)
{
QWidget *focusWidget = QApplication::focusWidget();
{
QWidget *focusWidget = QApplication::focusWidget();
// in background, assure that the previous focused widget gets the focus back.
focusWidget->setFocus();
}
// in background, assure that the previous focused widget gets the focus back.
focusWidget->setFocus();
}
}
void DolphinTabWidget::openDirectories(const QList<QUrl> &dirs, bool splitView)
}
void DolphinTabWidget::openDirectories(const QList<QUrl> &dirs, bool splitView)
/**
* Opens a new tab in the background showing the URL \a primaryUrl and the
* optional URL \a secondaryUrl.
/**
* Opens a new tab in the background showing the URL \a primaryUrl and the
* optional URL \a secondaryUrl.
+ * @return A pointer to the opened DolphinTabPage.
- void openNewTab(const QUrl &primaryUrl,
- const QUrl &secondaryUrl = QUrl(),
- DolphinTabWidget::NewTabPosition position = DolphinTabWidget::NewTabPosition::FollowSetting);
+ DolphinTabPage *openNewTab(const QUrl &primaryUrl,
+ const QUrl &secondaryUrl = QUrl(),
+ DolphinTabWidget::NewTabPosition position = DolphinTabWidget::NewTabPosition::FollowSetting);
/**
* Opens each directory in \p dirs in a separate tab unless it is already open.
/**
* Opens each directory in \p dirs in a separate tab unless it is already open.
int maximum = 0;
if (view->scrollOrientation() == Qt::Vertical) {
smoothScroller = m_verticalSmoothScroller;
int maximum = 0;
if (view->scrollOrientation() == Qt::Vertical) {
smoothScroller = m_verticalSmoothScroller;
+ if (smoothScroller->isAnimating()) {
+ return;
+ }
scrollOffsetScrollBar = verticalScrollBar();
// Don't scroll super fast when using a wheel mouse:
scrollOffsetScrollBar = verticalScrollBar();
// Don't scroll super fast when using a wheel mouse:
maximum = qMax(0, int(view->maximumScrollOffset() - view->size().height()));
} else {
smoothScroller = m_horizontalSmoothScroller;
maximum = qMax(0, int(view->maximumScrollOffset() - view->size().height()));
} else {
smoothScroller = m_horizontalSmoothScroller;
+ if (smoothScroller->isAnimating()) {
+ return;
+ }
scrollOffsetScrollBar = horizontalScrollBar();
singleStep = view->itemSize().width();
pageStep = view->size().width();
scrollOffsetScrollBar = horizontalScrollBar();
singleStep = view->itemSize().width();
pageStep = view->size().width();
int pageStep = 0;
if (view->scrollOrientation() == Qt::Vertical) {
smoothScroller = m_horizontalSmoothScroller;
int pageStep = 0;
if (view->scrollOrientation() == Qt::Vertical) {
smoothScroller = m_horizontalSmoothScroller;
+ if (smoothScroller->isAnimating()) {
+ return;
+ }
itemOffsetScrollBar = horizontalScrollBar();
singleStep = view->size().width() / 10;
pageStep = view->size().width();
} else {
smoothScroller = m_verticalSmoothScroller;
itemOffsetScrollBar = horizontalScrollBar();
singleStep = view->size().width() / 10;
pageStep = view->size().width();
} else {
smoothScroller = m_verticalSmoothScroller;
+ if (smoothScroller->isAnimating()) {
+ return;
+ }
itemOffsetScrollBar = verticalScrollBar();
singleStep = view->size().height() / 10;
pageStep = view->size().height();
itemOffsetScrollBar = verticalScrollBar();
singleStep = view->size().height() / 10;
pageStep = view->size().height();
m_smoothScrolling = previous;
}
m_smoothScrolling = previous;
}
+bool KItemListSmoothScroller::isAnimating()
+{
+ if (m_animation) {
+ return (m_animation->state() == QAbstractAnimation::Running);
+ }
+ return false;
+}
+
#include "moc_kitemlistsmoothscroller.cpp"
#include "moc_kitemlistsmoothscroller.cpp"
*/
void handleWheelEvent(QWheelEvent *event);
*/
void handleWheelEvent(QWheelEvent *event);
Q_SIGNALS:
/**
* Emitted when the scrolling animation has finished
Q_SIGNALS:
/**
* Emitted when the scrolling animation has finished