m_actionHandler(0),
m_remoteEncoding(0),
m_settingsDialog(0),
- m_captionStatJob(0),
m_lastHandleUrlStatJob(0)
{
+ // Workaround for a X11-issue in combination with KModifierInfo
+ // (see DolphinContextMenu::initializeModifierKeyInfo() for
+ // more information):
+ DolphinContextMenu::initializeModifierKeyInfo();
+
setObjectName("Dolphin#");
m_viewTab.append(ViewTab());
emit selectionChanged(selection);
}
-void DolphinMainWindow::slotWheelMoved(int wheelDelta)
-{
- if (wheelDelta > 0) {
- activatePrevTab();
- } else {
- activateNextTab();
- }
-}
-
void DolphinMainWindow::slotRequestItemInfo(const KFileItem& item)
{
emit requestItemInfo(item);
void DolphinMainWindow::openInNewTab()
{
const KFileItemList list = m_activeViewContainer->view()->selectedItems();
- if ((list.count() == 1) && list[0].isDir()) {
+ if (list.isEmpty()) {
+ openNewTab(m_activeViewContainer->url());
+ } else if ((list.count() == 1) && list[0].isDir()) {
openNewTab(m_activeViewContainer->view()->selectedUrls()[0]);
}
}
void DolphinMainWindow::openInNewWindow()
{
+ KUrl newWindowUrl;
+
const KFileItemList list = m_activeViewContainer->view()->selectedItems();
- if ((list.count() == 1) && list[0].isDir()) {
+ if (list.isEmpty()) {
+ newWindowUrl = m_activeViewContainer->url();
+ } else if ((list.count() == 1) && list[0].isDir()) {
+ newWindowUrl = m_activeViewContainer->view()->selectedUrls()[0];
+ }
+
+ if (!newWindowUrl.isEmpty()) {
DolphinMainWindow* window = DolphinApplication::app()->createMainWindow();
- window->changeUrl(m_activeViewContainer->view()->selectedUrls()[0]);
+ window->changeUrl(newWindowUrl);
window->show();
}
}
void DolphinMainWindow::stopLoading()
{
+ m_activeViewContainer->view()->stopLoading();
+}
+
+void DolphinMainWindow::enableStopAction()
+{
+ actionCollection()->action("stop")->setEnabled(true);
+}
+
+void DolphinMainWindow::disableStopAction()
+{
+ actionCollection()->action("stop")->setEnabled(false);
}
void DolphinMainWindow::toggleFilterBarVisibility(bool show)
void DolphinMainWindow::editSettings()
{
if (m_settingsDialog == 0) {
- const KUrl& url = activeViewContainer()->url();
+ const KUrl url = activeViewContainer()->url();
m_settingsDialog = new DolphinSettingsDialog(url, this);
m_settingsDialog->setAttribute(Qt::WA_DeleteOnClose);
m_settingsDialog->show();
}
}
-void DolphinMainWindow::slotCaptionStatFinished(KJob* job)
-{
- m_captionStatJob = 0;
- const KIO::UDSEntry entry = static_cast<KIO::StatJob*>(job)->statResult();
- const QString name = entry.stringValue(KIO::UDSEntry::UDS_DISPLAY_NAME);
- setCaption(name);
-}
-
void DolphinMainWindow::slotWriteStateChanged(bool isFolderWritable)
{
newFileMenu()->setEnabled(isFolderWritable);
{
DolphinContextMenu contextMenu(this, item, url);
contextMenu.setCustomActions(customActions);
- contextMenu.open();
+ const DolphinContextMenu::Command command = contextMenu.open();
+
+ switch (command) {
+ case DolphinContextMenu::OpenParentFolderInNewWindow: {
+ DolphinMainWindow* window = DolphinApplication::app()->createMainWindow();
+ window->changeUrl(item.url().upUrl());
+ window->show();
+ break;
+ }
+
+ case DolphinContextMenu::OpenParentFolderInNewTab:
+ openNewTab(item.url().upUrl());
+ break;
+
+ case DolphinContextMenu::None:
+ default:
+ break;
+ }
}
void DolphinMainWindow::init()
setupActions();
- const KUrl& homeUrl = generalSettings->homeUrl();
+ const KUrl homeUrl(generalSettings->homeUrl());
setUrlAsCaption(homeUrl);
m_actionHandler = new DolphinViewActionHandler(actionCollection(), this);
connect(m_actionHandler, SIGNAL(actionBeingHandled()), SLOT(clearStatusBar()));
this, SLOT(openNewTab()));
connect(m_tabBar, SIGNAL(testCanDecode(const QDragMoveEvent*, bool&)),
this, SLOT(slotTestCanDecode(const QDragMoveEvent*, bool&)));
- connect(m_tabBar, SIGNAL(wheelDelta(int)),
- this, SLOT(slotWheelMoved(int)));
connect(m_tabBar, SIGNAL(mouseMiddleClick(int)),
this, SLOT(closeTab(int)));
connect(m_tabBar, SIGNAL(tabMoved(int, int)),
updateViewActions();
updateGoActions();
- const KUrl& url = m_activeViewContainer->url();
+ const KUrl url = m_activeViewContainer->url();
setUrlAsCaption(url);
- if (m_viewTab.count() > 1 && m_viewTab[m_tabIndex].secondaryView != 0) {
+ if (m_viewTab.count() > 1) {
m_tabBar->setTabText(m_tabIndex, tabName(url));
m_tabBar->setTabIcon(m_tabIndex, KIcon(KMimeType::iconNameForUrl(url)));
}
void DolphinMainWindow::updateGoActions()
{
QAction* goUpAction = actionCollection()->action(KStandardAction::name(KStandardAction::Up));
- const KUrl& currentUrl = m_activeViewContainer->url();
+ const KUrl currentUrl = m_activeViewContainer->url();
goUpAction->setEnabled(currentUrl.upUrl() != currentUrl);
}
this, SLOT(openNewTab(const KUrl&)));
connect(view, SIGNAL(requestContextMenu(KFileItem, const KUrl&, const QList<QAction*>&)),
this, SLOT(openContextMenu(KFileItem, const KUrl&, const QList<QAction*>&)));
+ connect(view, SIGNAL(startedPathLoading(KUrl)),
+ this, SLOT(enableStopAction()));
+ connect(view, SIGNAL(finishedPathLoading(KUrl)),
+ this, SLOT(disableStopAction()));
const KUrlNavigator* navigator = container->urlNavigator();
connect(navigator, SIGNAL(urlChanged(const KUrl&)),
void DolphinMainWindow::setUrlAsCaption(const KUrl& url)
{
- delete m_captionStatJob;
- m_captionStatJob = 0;
-
- if (url.protocol() == QLatin1String("file")) {
- QString caption;
- if (url.equals(KUrl("file:///"))) {
- caption = '/';
- } else {
- caption = url.fileName();
- if (caption.isEmpty()) {
- caption = url.protocol();
- }
+ QString caption;
+ if (!url.isLocalFile()) {
+ caption.append(url.protocol() + " - ");
+ if (url.hasHost()) {
+ caption.append(url.host() + " - ");
}
-
- setCaption(caption);
- } else {
- m_captionStatJob = KIO::stat(url, KIO::HideProgressInfo);
- connect(m_captionStatJob, SIGNAL(result(KJob*)),
- this, SLOT(slotCaptionStatFinished(KJob*)));
}
+
+ const QString fileName = url.fileName().isEmpty() ? "/" : url.fileName();
+ caption.append(fileName);
+
+ setCaption(caption);
}
QString DolphinMainWindow::squeezedText(const QString& text) const