#include <kmimetyperesolver.h>
#include <knewmenu.h>
#include <konqmimedata.h>
-#include <konq_fileitemcapabilities.h>
+#include <kfileitemlistproperties.h>
#include <konq_operations.h>
+#include <kshell.h>
#include <kurl.h>
+#include <kurlcombobox.h>
#include <krun.h>
#include "dolphinmodel.h"
#include "filterbar.h"
#include "kurlnavigator.h"
#include "viewproperties.h"
-#include "dolphinsettings.h"
+#include "settings/dolphinsettings.h"
#include "dolphin_generalsettings.h"
DolphinViewContainer::DolphinViewContainer(DolphinMainWindow* mainWindow,
const KUrl& url) :
QWidget(parent),
m_showProgress(false),
+ m_isFolderWritable(false),
m_mainWindow(mainWindow),
m_topLayout(0),
m_urlNavigator(0),
this, SLOT(dropUrls(const KUrl&, QDropEvent*)));
connect(m_urlNavigator, SIGNAL(activated()),
this, SLOT(activate()));
+ connect(m_urlNavigator->editor(), SIGNAL(completionModeChanged(KGlobalSettings::Completion)),
+ this, SLOT(saveUrlCompletionMode(KGlobalSettings::Completion)));
const GeneralSettings* settings = DolphinSettings::instance().generalSettings();
m_urlNavigator->setUrlEditable(settings->editableUrl());
m_urlNavigator->setShowFullPath(settings->showFullPath());
m_urlNavigator->setHomeUrl(settings->homeUrl());
+ KUrlComboBox* editor = m_urlNavigator->editor();
+ editor->setCompletionMode(KGlobalSettings::Completion(settings->urlCompletionMode()));
m_dirLister = new DolphinDirLister();
m_dirLister->setAutoUpdate(true);
m_proxyModel);
connect(m_view, SIGNAL(urlChanged(const KUrl&)),
m_urlNavigator, SLOT(setUrl(const KUrl&)));
- connect(m_view, SIGNAL(requestContextMenu(KFileItem, const KUrl&)),
- this, SLOT(openContextMenu(KFileItem, const KUrl&)));
+ connect(m_view, SIGNAL(requestContextMenu(KFileItem, const KUrl&, const QList<QAction*>&)),
+ this, SLOT(openContextMenu(KFileItem, const KUrl&, const QList<QAction*>&)));
connect(m_view, SIGNAL(contentsMoved(int, int)),
this, SLOT(saveContentsPos(int, int)));
connect(m_view, SIGNAL(requestItemInfo(KFileItem)),
connect(m_urlNavigator, SIGNAL(urlChanged(const KUrl&)),
this, SLOT(restoreView(const KUrl&)));
+ connect(m_urlNavigator, SIGNAL(historyChanged()),
+ this, SLOT(slotHistoryChanged()));
m_statusBar = new DolphinStatusBar(this, m_view);
this, SLOT(setNameFilter(const QString&)));
connect(m_filterBar, SIGNAL(closeRequest()),
this, SLOT(closeFilterBar()));
+ connect(m_view, SIGNAL(urlChanged(const KUrl&)),
+ m_filterBar, SLOT(clear()));
m_topLayout->addWidget(m_urlNavigator);
m_topLayout->addWidget(m_view);
void DolphinViewContainer::setUrl(const KUrl& newUrl)
{
- m_urlNavigator->setUrl(newUrl);
if (newUrl != m_urlNavigator->url()) {
+ m_urlNavigator->setUrl(newUrl);
// Temporary disable the 'File'->'Create New...' menu until
// the write permissions can be checked in a fast way at
// DolphinViewContainer::slotDirListerCompleted().
- m_mainWindow->newMenu()->menu()->setEnabled(false);
+ m_isFolderWritable = false;
+ if (isActive()) {
+ m_mainWindow->newMenu()->menu()->setEnabled(false);
+ }
}
}
{
m_urlNavigator->setActive(active);
m_view->setActive(active);
+ if (active) {
+ m_mainWindow->newMenu()->menu()->setEnabled(m_isFolderWritable);
+ }
}
bool DolphinViewContainer::isActive() const
return m_filterBar->isVisible();
}
+void DolphinViewContainer::showFilterBar(bool show)
+{
+ Q_ASSERT(m_filterBar != 0);
+ if (show) {
+ m_filterBar->show();
+ } else {
+ closeFilterBar();
+ }
+}
+
bool DolphinViewContainer::isUrlEditable() const
{
return m_urlNavigator->isUrlEditable();
// Enable the 'File'->'Create New...' menu only if the directory
// supports writing.
- KMenu* createNew = m_mainWindow->newMenu()->menu();
KFileItem item = m_dirLister->rootItem();
if (item.isNull()) {
// it is unclear whether writing is supported
- createNew->setEnabled(true);
+ m_isFolderWritable = true;
} else {
- KonqFileItemCapabilities capabilities(KFileItemList() << item);
- createNew->setEnabled(capabilities.supportsWriting());
+ KFileItemListProperties capabilities(KFileItemList() << item);
+ m_isFolderWritable = capabilities.supportsWriting();
}
if (isActive()) {
- m_view->setFocus();
+ m_mainWindow->newMenu()->menu()->setEnabled(m_isFolderWritable);
}
}
emit showFilterBarChanged(false);
}
-void DolphinViewContainer::showFilterBar(bool show)
-{
- Q_ASSERT(m_filterBar != 0);
- m_filterBar->setVisible(show);
-}
-
void DolphinViewContainer::updateStatusBar()
{
// As the item count information is less important
}
void DolphinViewContainer::openContextMenu(const KFileItem& item,
- const KUrl& url)
+ const KUrl& url,
+ const QList<QAction*>& customActions)
{
DolphinContextMenu contextMenu(m_mainWindow, item, url);
+ contextMenu.setCustomActions(customActions);
contextMenu.open();
}
{
if (KProtocolManager::supportsListing(url)) {
m_view->updateView(url, m_urlNavigator->savedRootUrl());
+ if (isActive()) {
+ // When an URL has been entered, the view should get the focus.
+ // The focus must be requested asynchronously, as changing the URL might create
+ // a new view widget. Using QTimer::singleShow() works reliable, however
+ // QMetaObject::invokeMethod() with a queued connection does not work, which might
+ // indicate that we should pass a hint to DolphinView::updateView()
+ // regarding the focus instead. To test: Enter an URL and press CTRL+Enter.
+ // Expected result: The view should get the focus.
+ QTimer::singleShot(0, this, SLOT(requestFocus()));
+ }
} else if (KProtocolManager::isSourceProtocol(url)) {
QString app = "konqueror";
if (url.protocol().startsWith(QLatin1String("http"))) {
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 {
showErrorMessage(i18nc("@info:status",
"Protocol not supported by Dolphin, Konqueror has been launched"));
}
- const QString command = app + ' ' + url.pathOrUrl();
+
+ QString secureUrl = KShell::quoteArg(url.pathOrUrl());
+ const QString command = app + ' ' + secureUrl;
KRun::runCommand(command, app, app, this);
} else {
showErrorMessage(i18nc("@info:status", "Invalid protocol"));
m_urlNavigator->blockSignals(block);
}
+void DolphinViewContainer::requestFocus()
+{
+ m_view->setFocus();
+}
+
+void DolphinViewContainer::saveUrlCompletionMode(KGlobalSettings::Completion completion)
+{
+ DolphinSettings& settings = DolphinSettings::instance();
+ settings.generalSettings()->setUrlCompletionMode(completion);
+ settings.save();
+}
+
+void DolphinViewContainer::slotHistoryChanged()
+{
+ const int index = m_urlNavigator->historyIndex();
+ if (index > 0) {
+ // The "Go Forward" action is enabled. Try to mark
+ // the previous directory as active item:
+ const KUrl url = m_urlNavigator->historyUrl(index - 1);
+ m_view->activateItem(url);
+ }
+}
+
void DolphinViewContainer::slotItemTriggered(const KFileItem& item)
{
KUrl url = item.targetUrl();