#include "trash/dolphintrash.h"
#include "views/viewmodecontroller.h"
#include "views/viewproperties.h"
+#include "dolphin_detailsmodesettings.h"
+#include "views/dolphinview.h"
#ifdef HAVE_KACTIVITIES
#include <KActivities/ResourceInstance>
#include <QTimer>
#include <QUrl>
#include <QVBoxLayout>
+#include <QDesktopServices>
DolphinViewContainer::DolphinViewContainer(const QUrl& url, QWidget* parent) :
QWidget(parent),
connect(m_searchBox, &DolphinSearchBox::activated, this, &DolphinViewContainer::activate);
connect(m_searchBox, &DolphinSearchBox::closeRequest, this, &DolphinViewContainer::closeSearchBox);
connect(m_searchBox, &DolphinSearchBox::searchRequest, this, &DolphinViewContainer::startSearching);
- connect(m_searchBox, &DolphinSearchBox::returnPressed, this, &DolphinViewContainer::requestFocus);
+ connect(m_searchBox, &DolphinSearchBox::focusViewRequest, this, &DolphinViewContainer::requestFocus);
m_searchBox->setWhatsThis(xi18nc("@info:whatsthis findbar",
"<para>This helps you find files and folders. Enter a <emphasis>"
"search term</emphasis> and specify search settings with the "
setSearchModeEnabled(isSearchUrl(url));
+ connect(DetailsModeSettings::self(), &KCoreConfigSkeleton::configChanged, this, [=]() {
+ if (view()->mode() == DolphinView::Mode::DetailsView) {
+ view()->reload();
+ }
+ });
+
// Initialize kactivities resource instance
#ifdef HAVE_KACTIVITIES
void DolphinViewContainer::setSearchModeEnabled(bool enabled)
{
+ m_searchBox->setVisible(enabled);
+ m_navigatorWidget->setVisible(!enabled);
+
+ if (enabled) {
+ const QUrl& locationUrl = m_urlNavigator->locationUrl();
+ m_searchBox->fromSearchUrl(locationUrl);
+ }
+
if (enabled == isSearchModeEnabled()) {
if (enabled && !m_searchBox->hasFocus()) {
m_searchBox->setFocus();
return;
}
- m_searchBox->setVisible(enabled);
- m_navigatorWidget->setVisible(!enabled);
-
- if (enabled) {
- const QUrl& locationUrl = m_urlNavigator->locationUrl();
- m_searchBox->fromSearchUrl(locationUrl);
- } else {
+ if (!enabled) {
m_view->setViewPropertiesContext(QString());
// Restore the URL for the URL navigator. If Dolphin has been
}
m_searchModeEnabled = enabled;
+
+ emit searchModeEnabledChanged(enabled);
}
bool DolphinViewContainer::isSearchModeEnabled() const
if (isSearchModeEnabled()) {
text = i18n("Search for %1 in %2", m_searchBox->text(), m_searchBox->searchPath().fileName());
} else {
- text = url().fileName();
+ text = url().adjusted(QUrl::StripTrailingSlash).fileName();
if (text.isEmpty()) {
text = url().host();
}
m_messageWidget->hide();
}
-QString DolphinViewContainer::caption() const
+QString DolphinViewContainer::captionWindowTitle() const
{
- if (GeneralSettings::showFullPathInTitlebar()) {
+ if (GeneralSettings::showFullPathInTitlebar() && !isSearchModeEnabled()) {
if (!url().isLocalFile()) {
return url().adjusted(QUrl::StripTrailingSlash).toString();
}
return url().adjusted(QUrl::StripTrailingSlash).path();
+ } else {
+ return DolphinViewContainer::caption();
}
+}
- KFilePlacesModel *placesModel = DolphinPlacesModelSingleton::instance().placesModel();
- const auto& matchedPlaces = placesModel->match(placesModel->index(0,0), KFilePlacesModel::UrlRole, url(), 1, Qt::MatchExactly);
-
- if (!matchedPlaces.isEmpty()) {
- return placesModel->text(matchedPlaces.first());
- }
-
+QString DolphinViewContainer::caption() const
+{
if (isSearchModeEnabled()) {
if (currentSearchText().isEmpty()){
return i18n("Search");
}
}
+ KFilePlacesModel *placesModel = DolphinPlacesModelSingleton::instance().placesModel();
+ const auto& matchedPlaces = placesModel->match(placesModel->index(0,0), KFilePlacesModel::UrlRole, QUrl(url().adjusted(QUrl::StripTrailingSlash).toString(QUrl::FullyEncoded).append("/?")), 1, Qt::MatchRegExp);
+
+ if (!matchedPlaces.isEmpty()) {
+ return placesModel->text(matchedPlaces.first());
+ }
+
+
if (!url().isLocalFile()) {
QUrl adjustedUrl = url().adjusted(QUrl::StripTrailingSlash);
QString caption;
{
Q_ASSERT(m_filterBar);
if (visible) {
+ m_view->hideToolTip(ToolTipManager::HideBehavior::Instantly);
m_filterBar->show();
m_filterBar->setFocus();
m_filterBar->selectAll();
// Trigger an undetermined progress indication. The progress
// information in percent will be triggered by the percent() signal
// of the directory lister later.
+ m_statusBar->setProgressText(QString());
updateDirectoryLoadingProgress(-1);
}
}
void DolphinViewContainer::setNameFilter(const QString& nameFilter)
{
+ m_view->hideToolTip(ToolTipManager::HideBehavior::Instantly);
m_view->setNameFilter(nameFilter);
delayedStatusBarUpdate();
}
QTimer::singleShot(0, this, &DolphinViewContainer::requestFocus);
}
} else if (KProtocolManager::isSourceProtocol(url)) {
- QString app = QStringLiteral("konqueror");
if (url.scheme().startsWith(QLatin1String("http"))) {
showMessage(i18nc("@info:status", // krazy:exclude=qmethods
"Dolphin does not support web pages, the web browser has been launched"),
Information);
-
- const KConfigGroup config(KSharedConfig::openConfig(QStringLiteral("kdeglobals")), "General");
- const QString browser = config.readEntry("BrowserApplication");
- if (!browser.isEmpty()) {
- app = browser;
- if (app.startsWith('!')) {
- // a literal command has been configured, remove the '!' prefix
- app = app.mid(1);
- }
- }
} else {
showMessage(i18nc("@info:status",
- "Protocol not supported by Dolphin, Konqueror has been launched"),
+ "Protocol not supported by Dolphin, default application has been launched"),
Information);
}
- const QString secureUrl = KShell::quoteArg(url.toDisplayString(QUrl::PreferLocalFile));
- const QString command = app + ' ' + secureUrl;
- KRun::runCommand(command, app, app, this);
+ QDesktopServices::openUrl(url);
+ redirect(QUrl(), m_urlNavigator->locationUrl(1));
} else {
showMessage(i18nc("@info:status", "Invalid protocol"), Error);
}
void DolphinViewContainer::redirect(const QUrl& oldUrl, const QUrl& newUrl)
{
- Q_UNUSED(oldUrl);
+ Q_UNUSED(oldUrl)
const bool block = m_urlNavigator->signalsBlocked();
m_urlNavigator->blockSignals(true);
bool DolphinViewContainer::isSearchUrl(const QUrl& url) const
{
- return url.scheme().contains(QStringLiteral("search"));
+ return url.scheme().contains(QLatin1String("search"));
}
void DolphinViewContainer::saveViewState()