m_actionHandler(0),
m_remoteEncoding(0),
m_settingsDialog(0),
- m_captionStatJob(0)
+ m_captionStatJob(0),
+ m_lastHandleUrlStatJob(0)
{
setObjectName("Dolphin#");
void DolphinMainWindow::openNewTab()
{
+ const bool isUrlEditable = m_activeViewContainer->urlNavigator()->isUrlEditable();
+
openNewTab(m_activeViewContainer->url());
m_tabBar->setCurrentIndex(m_viewTab.count() - 1);
+ // The URL navigator of the new tab should have the same editable state
+ // as the current tab
KUrlNavigator* navigator = m_activeViewContainer->urlNavigator();
- if (navigator->isUrlEditable()) {
- // if a new tab is opened and the URL is editable, assure that
+ navigator->setUrlEditable(isUrlEditable);
+
+ if (isUrlEditable) {
+ // If a new tab is opened and the URL is editable, assure that
// the user can edit the URL without manually setting the focus
navigator->setFocus();
}
void DolphinMainWindow::updateNewMenu()
{
m_newMenu->setViewShowsHiddenFiles(activeViewContainer()->view()->showHiddenFiles());
- m_newMenu->slotCheckUpToDate();
+ m_newMenu->checkUpToDate();
m_newMenu->setPopupFiles(activeViewContainer()->url());
}
void DolphinMainWindow::handleUrl(const KUrl& url)
{
- if (KProtocolManager::supportsListing(url)) {
+ delete m_lastHandleUrlStatJob;
+ m_lastHandleUrlStatJob = 0;
+
+ if (url.isLocalFile() && QFileInfo(url.toLocalFile()).isDir()) {
+ activeViewContainer()->setUrl(url);
+ } else if (KProtocolManager::supportsListing(url)) {
+ // stat the URL to see if it is a dir or not
+ m_lastHandleUrlStatJob = KIO::stat(url, KIO::HideProgressInfo);
+ connect(m_lastHandleUrlStatJob, SIGNAL(result(KJob*)),
+ this, SLOT(slotHandleUrlStatFinished(KJob*)));
+
+ } else {
+ new KRun(url, this);
+ }
+}
+
+void DolphinMainWindow::slotHandleUrlStatFinished(KJob* job)
+{
+ m_lastHandleUrlStatJob = 0;
+ const KIO::UDSEntry entry = static_cast<KIO::StatJob*>(job)->statResult();
+ const KUrl url = static_cast<KIO::StatJob*>(job)->url();
+ if ( entry.isDir() ) {
activeViewContainer()->setUrl(url);
} else {
new KRun(url, this);
}
}
+void DolphinMainWindow::tabDropEvent(int tab, QDropEvent* event)
+{
+ const KUrl::List urls = KUrl::List::fromMimeData(event->mimeData());
+ if (!urls.isEmpty() && tab != -1) {
+ const ViewTab& viewTab = m_viewTab[tab];
+ const KUrl destPath = viewTab.isPrimaryViewActive ? viewTab.primaryView->url() : viewTab.secondaryView->url();
+ DragAndDropHelper::instance().dropUrls(KFileItem(), destPath, event, m_tabBar);
+ }
+}
+
void DolphinMainWindow::slotCaptionStatFinished(KJob* job)
{
m_captionStatJob = 0;
this, SLOT(closeTab(int)));
connect(m_tabBar, SIGNAL(tabMoved(int, int)),
this, SLOT(slotTabMoved(int, int)));
+ connect(m_tabBar, SIGNAL(receivedDropEvent(int, QDropEvent*)),
+ this, SLOT(tabDropEvent(int, QDropEvent*)));
m_tabBar->blockSignals(true); // signals get unblocked after at least 2 tabs are open
KStandardAction::preferences(this, SLOT(editSettings()), actionCollection());
// not in menu actions
+ QList<QKeySequence> nextTabKeys;
+ nextTabKeys.append(KStandardShortcut::tabNext().primary());
+ nextTabKeys.append(QKeySequence(Qt::CTRL + Qt::Key_Tab));
+
+ QList<QKeySequence> prevTabKeys;
+ prevTabKeys.append(KStandardShortcut::tabPrev().primary());
+ prevTabKeys.append(QKeySequence(Qt::CTRL + Qt::SHIFT + Qt::Key_Tab));
+
KAction* activateNextTab = actionCollection()->addAction("activate_next_tab");
activateNextTab->setText(i18nc("@action:inmenu", "Activate Next Tab"));
connect(activateNextTab, SIGNAL(triggered()), SLOT(activateNextTab()));
- activateNextTab->setShortcuts(QApplication::isRightToLeft() ? KStandardShortcut::tabPrev() :
- KStandardShortcut::tabNext());
+ activateNextTab->setShortcuts(QApplication::isRightToLeft() ? prevTabKeys : nextTabKeys);
KAction* activatePrevTab = actionCollection()->addAction("activate_prev_tab");
activatePrevTab->setText(i18nc("@action:inmenu", "Activate Previous Tab"));
connect(activatePrevTab, SIGNAL(triggered()), SLOT(activatePrevTab()));
- activatePrevTab->setShortcuts(QApplication::isRightToLeft() ? KStandardShortcut::tabNext() :
- KStandardShortcut::tabPrev());
+ activatePrevTab->setShortcuts(QApplication::isRightToLeft() ? nextTabKeys : prevTabKeys);
// for context menu
KAction* openInNewTab = actionCollection()->addAction("open_in_new_tab");
this, SLOT(updateHistory()));
connect(navigator, SIGNAL(editableStateChanged(bool)),
this, SLOT(slotEditableStateChanged(bool)));
+ connect(navigator, SIGNAL(tabRequested(const KUrl&)),
+ this, SLOT(openNewTab(KUrl)));
}
void DolphinMainWindow::updateSplitAction()