m_assureVisibleCurrentIndex(false),
m_isFolderWritable(true),
m_dragging(false),
+ m_loading(false),
m_url(url),
m_viewPropertiesContext(),
m_mode(DolphinView::IconsView),
m_placeholderLabel->setGraphicsEffect(effect);
// Set initial text and visibility
updatePlaceholderLabel();
- // Add a new layout to hold it and put it in the layout
- auto *centeringLayout = new QVBoxLayout(this);
- m_container->setLayout(centeringLayout);
+
+ auto *centeringLayout = new QVBoxLayout(m_container);
centeringLayout->addWidget(m_placeholderLabel);
centeringLayout->setAlignment(m_placeholderLabel, Qt::AlignCenter);
connect(m_model, &KFileItemModel::directoryLoadingStarted, this, &DolphinView::slotDirectoryLoadingStarted);
connect(m_model, &KFileItemModel::directoryLoadingCompleted, this, &DolphinView::slotDirectoryLoadingCompleted);
- connect(m_model, &KFileItemModel::directoryLoadingCanceled, this, &DolphinView::directoryLoadingCanceled);
+ connect(m_model, &KFileItemModel::directoryLoadingCanceled, this, &DolphinView::slotDirectoryLoadingCanceled);
connect(m_model, &KFileItemModel::directoryLoadingProgress, this, &DolphinView::directoryLoadingProgress);
connect(m_model, &KFileItemModel::directorySortingProgress, this, &DolphinView::directorySortingProgress);
connect(m_model, &KFileItemModel::itemsChanged,
connect(this, &DolphinView::itemCountChanged,
this, &DolphinView::updatePlaceholderLabel);
- connect(this, &DolphinView::urlChanged,
- this, &DolphinView::updatePlaceholderLabel);
m_view->installEventFilter(this);
connect(m_view, &DolphinItemListView::sortOrderChanged,
const QUrl& url = openItemAsFolderUrl(item);
if (!url.isEmpty()) { // Open folders in new tabs
- Q_EMIT tabRequested(url, DolphinTabWidget::AfterLastTab);
+ Q_EMIT tabRequested(url);
} else {
items.append(item);
}
const KFileItem& item = m_model->fileItem(index);
const QUrl& url = openItemAsFolderUrl(item);
if (!url.isEmpty()) {
- Q_EMIT tabRequested(url, DolphinTabWidget::AfterCurrentTab);
+ Q_EMIT tabRequested(url);
} else if (isTabsForFilesEnabled()) {
- Q_EMIT tabRequested(item.url(), DolphinTabWidget::AfterCurrentTab);
+ Q_EMIT tabRequested(item.url());
}
}
void DolphinView::slotDirectoryLoadingStarted()
{
- // We don't want the placeholder label to flicker while the folder is loading
- m_placeholderLabel->setVisible(false);
+ m_loading = true;
+ updatePlaceholderLabel();
// Disable the writestate temporary until it can be determined in a fast way
// in DolphinView::slotDirectoryLoadingCompleted()
void DolphinView::slotDirectoryLoadingCompleted()
{
+ m_loading = false;
+
// Update the view-state. This has to be done asynchronously
// because the view might not be in its final state yet.
QTimer::singleShot(0, this, &DolphinView::updateViewState);
updateWritableState();
}
+void DolphinView::slotDirectoryLoadingCanceled()
+{
+ m_loading = false;
+
+ updatePlaceholderLabel();
+
+ Q_EMIT directoryLoadingCanceled();
+}
+
void DolphinView::slotItemsChanged()
{
m_assureVisibleCurrentIndex = false;
void DolphinView::updatePlaceholderLabel()
{
- if (itemsCount() > 0) {
+ if (m_loading || itemsCount() > 0) {
m_placeholderLabel->setVisible(false);
return;
}