X-Git-Url: https://cloud.milkyroute.net/gitweb/dolphin.git/blobdiff_plain/b2e08712f2cf61a713ee6d85fe21aec034241114..60d6a3bdbcd44360e1c6ae1c82239ecf6d60ded7:/src/views/dolphinview.cpp diff --git a/src/views/dolphinview.cpp b/src/views/dolphinview.cpp index 40346c169..5b00fa36d 100644 --- a/src/views/dolphinview.cpp +++ b/src/views/dolphinview.cpp @@ -97,7 +97,7 @@ DolphinView::DolphinView(const QUrl& url, QWidget* parent) : { m_topLayout = new QVBoxLayout(this); m_topLayout->setSpacing(0); - m_topLayout->setMargin(0); + m_topLayout->setContentsMargins(0, 0, 0, 0); // When a new item has been created by the "Create New..." menu, the item should // get selected and it must be assured that the item will get visible. As the @@ -182,6 +182,7 @@ DolphinView::DolphinView(const QUrl& url, QWidget* parent) : #endif m_versionControlObserver = new VersionControlObserver(this); + m_versionControlObserver->setView(this); m_versionControlObserver->setModel(m_model); connect(m_versionControlObserver, &VersionControlObserver::infoMessage, this, &DolphinView::infoMessage); connect(m_versionControlObserver, &VersionControlObserver::errorMessage, this, &DolphinView::errorMessage); @@ -638,9 +639,7 @@ void DolphinView::renameSelectedItems() RenameDialog* dialog = new RenameDialog(this, items); connect(dialog, &RenameDialog::renamingFinished, this, &DolphinView::slotRenameDialogRenamingFinished); - dialog->show(); - dialog->raise(); - dialog->activateWindow(); + dialog->open(); } // Assure that the current index remains visible when KFileItemModel @@ -710,7 +709,7 @@ void DolphinView::stopLoading() void DolphinView::updatePalette() { - QColor color = KColorScheme(QPalette::Active, KColorScheme::View).background().color(); + QColor color = KColorScheme(isActiveWindow() ? QPalette::Active : QPalette::Inactive, KColorScheme::View).background().color(); if (!m_active) { color.setAlpha(150); } @@ -739,6 +738,11 @@ bool DolphinView::eventFilter(QObject* watched, QEvent* event) QPixmapCache::clear(); break; + case QEvent::WindowActivate: + case QEvent::WindowDeactivate: + updatePalette(); + break; + case QEvent::KeyPress: if (GeneralSettings::useTabForSwitchingSplitView()) { QKeyEvent* keyEvent = static_cast(event); @@ -849,7 +853,7 @@ void DolphinView::slotItemsActivated(const KItemSet& indexes) const QUrl& url = openItemAsFolderUrl(item); if (!url.isEmpty()) { // Open folders in new tabs - emit tabRequested(url); + emit tabRequested(url, DolphinTabWidget::AfterLastTab); } else { items.append(item); } @@ -867,9 +871,9 @@ void DolphinView::slotItemMiddleClicked(int index) const KFileItem& item = m_model->fileItem(index); const QUrl& url = openItemAsFolderUrl(item); if (!url.isEmpty()) { - emit tabRequested(url); + emit tabRequested(url, DolphinTabWidget::AfterCurrentTab); } else if (isTabsForFilesEnabled()) { - emit tabRequested(item.url()); + emit tabRequested(item.url(), DolphinTabWidget::AfterCurrentTab); } } @@ -1120,7 +1124,7 @@ void DolphinView::slotMouseButtonPressed(int itemIndex, Qt::MouseButtons buttons void DolphinView::slotSelectedItemTextPressed(int index) { - if (GeneralSettings::renameInline()) { + if (GeneralSettings::renameInline() && !m_view->style()->styleHint(QStyle::SH_ItemView_ActivateItemOnSingleClick)) { const KFileItem item = m_model->fileItem(index); const KFileItemListProperties capabilities(KFileItemList() << item); if (capabilities.supportsMoving()) { @@ -1575,6 +1579,29 @@ void DolphinView::slotRoleEditingFinished(int index, const QByteArray& role, con QUrl newUrl = oldUrl.adjusted(QUrl::RemoveFilename); newUrl.setPath(newUrl.path() + KIO::encodeFileName(newName)); +#ifndef Q_OS_WIN + //Confirm hiding file/directory by renaming inline + if (!hiddenFilesShown() && newName.startsWith(QLatin1Char('.')) && !oldItem.name().startsWith(QLatin1Char('.'))) { + KGuiItem yesGuiItem(KStandardGuiItem::yes()); + yesGuiItem.setText(i18nc("@action:button", "Rename and Hide")); + + const auto code = KMessageBox::questionYesNo(this, + oldItem.isFile() ? i18n("Adding a dot to the beginning of this file's name will hide it from view.\n" + "Do you still want to rename it?") + : i18n("Adding a dot to the beginning of this folder's name will hide it from view.\n" + "Do you still want to rename it?"), + oldItem.isFile() ? i18n("Hide this File?") : i18n("Hide this Folder?"), + yesGuiItem, + KStandardGuiItem::cancel(), + QStringLiteral("ConfirmHide") + ); + + if (code == KMessageBox::No) { + return; + } + } +#endif + const bool newNameExistsAlready = (m_model->index(newUrl) >= 0); if (!newNameExistsAlready) { // Only change the data in the model if no item with the new name