X-Git-Url: https://cloud.milkyroute.net/gitweb/dolphin.git/blobdiff_plain/75bf8edaeb4a6a7b3bf03a3171661b577af79135..11289b4fc3efbc074b668d4516cd896f8ade9761:/src/dolphinmainwindow.cpp diff --git a/src/dolphinmainwindow.cpp b/src/dolphinmainwindow.cpp index 04ce2b741..cf2064482 100644 --- a/src/dolphinmainwindow.cpp +++ b/src/dolphinmainwindow.cpp @@ -43,6 +43,7 @@ #include "dolphin_generalsettings.h" #include "dolphin_iconsmodesettings.h" +#include "draganddrophelper.h" #include #include @@ -82,8 +83,6 @@ #include #include -#include - DolphinMainWindow::DolphinMainWindow(int id) : KXmlGuiWindow(0), m_newMenu(0), @@ -115,7 +114,9 @@ DolphinMainWindow::DolphinMainWindow(int id) : connect(undoManager, SIGNAL(jobRecordingFinished(CommandType)), this, SLOT(showCommand(CommandType))); connect(DolphinSettings::instance().placesModel(), SIGNAL(errorMessage(const QString&)), - this, SLOT(slotHandlePlacesError(const QString&))); + this, SLOT(showErrorMessage(const QString&))); + connect(&DragAndDropHelper::instance(), SIGNAL(errorMessage(const QString&)), + this, SLOT(showErrorMessage(const QString&))); } DolphinMainWindow::~DolphinMainWindow() @@ -324,7 +325,7 @@ void DolphinMainWindow::activateNextTab() return; } - int tabIndex = (m_tabBar->currentIndex() + 1) % m_tabBar->count(); + const int tabIndex = (m_tabBar->currentIndex() + 1) % m_tabBar->count(); m_tabBar->setCurrentIndex(tabIndex); } @@ -334,13 +335,32 @@ void DolphinMainWindow::activatePrevTab() return; } - int tabIndex = (m_tabBar->currentIndex() - 1); + int tabIndex = m_tabBar->currentIndex() - 1; if (tabIndex == -1) { tabIndex = m_tabBar->count() - 1; } m_tabBar->setCurrentIndex(tabIndex); } +void DolphinMainWindow::openInNewTab() +{ + const KFileItemList list = m_activeViewContainer->view()->selectedItems(); + if ((list.count() == 1) && list[0].isDir()) { + openNewTab(m_activeViewContainer->view()->selectedUrls()[0]); + m_tabBar->setCurrentIndex(m_viewTab.count() - 1); + } +} + +void DolphinMainWindow::openInNewWindow() +{ + const KFileItemList list = m_activeViewContainer->view()->selectedItems(); + if ((list.count() == 1) && list[0].isDir()) { + DolphinMainWindow* window = DolphinApplication::app()->createMainWindow(); + window->changeUrl(m_activeViewContainer->view()->selectedUrls()[0]); + window->show(); + } +} + void DolphinMainWindow::toggleActiveView() { if (m_viewTab[m_tabIndex].secondaryView == 0) { @@ -422,7 +442,7 @@ void DolphinMainWindow::quit() close(); } -void DolphinMainWindow::slotHandlePlacesError(const QString &message) +void DolphinMainWindow::showErrorMessage(const QString& message) { if (!message.isEmpty()) { DolphinStatusBar* statusBar = m_activeViewContainer->statusBar(); @@ -565,7 +585,7 @@ void DolphinMainWindow::toggleEditLocation() urlNavigator->setUrlEditable(action->isChecked()); } -void DolphinMainWindow::editLocation() +void DolphinMainWindow::replaceLocation() { KUrlNavigator* navigator = m_activeViewContainer->urlNavigator(); navigator->setUrlEditable(true); @@ -925,7 +945,7 @@ void DolphinMainWindow::setActiveViewContainer(DolphinViewContainer* viewContain void DolphinMainWindow::setupActions() { // setup 'File' menu - m_newMenu = new DolphinNewMenu(this); + m_newMenu = new DolphinNewMenu(this, this); KMenu* menu = m_newMenu->menu(); menu->setTitle(i18nc("@title:menu Create new folder, file, link, etc.", "Create New")); menu->setIcon(KIcon("document-new")); @@ -995,16 +1015,15 @@ void DolphinMainWindow::setupActions() stop->setIcon(KIcon("process-stop")); connect(stop, SIGNAL(triggered()), this, SLOT(stopLoading())); - // TODO: the naming "Show full Location" is currently confusing... KToggleAction* showFullLocation = actionCollection()->add("editable_location"); - showFullLocation->setText(i18nc("@action:inmenu Navigation Bar", "Show Full Location")); + showFullLocation->setText(i18nc("@action:inmenu Navigation Bar", "Editable Location")); showFullLocation->setShortcut(Qt::CTRL | Qt::Key_L); connect(showFullLocation, SIGNAL(triggered()), this, SLOT(toggleEditLocation())); - KAction* editLocation = actionCollection()->addAction("edit_location"); - editLocation->setText(i18nc("@action:inmenu Navigation Bar", "Edit Location")); - editLocation->setShortcut(Qt::Key_F6); - connect(editLocation, SIGNAL(triggered()), this, SLOT(editLocation())); + KAction* replaceLocation = actionCollection()->addAction("replace_location"); + replaceLocation->setText(i18nc("@action:inmenu Navigation Bar", "Replace Location")); + replaceLocation->setShortcut(Qt::Key_F6); + connect(replaceLocation, SIGNAL(triggered()), this, SLOT(replaceLocation())); // setup 'Go' menu KAction* backAction = KStandardAction::back(this, SLOT(goBack()), actionCollection()); @@ -1041,14 +1060,27 @@ void DolphinMainWindow::setupActions() // not in menu actions KAction* activateNextTab = actionCollection()->addAction("activatenexttab"); - activateNextTab->setText( i18n( "Activate Next Tab" ) ); - connect(activateNextTab, SIGNAL(triggered()), SLOT( activateNextTab() )); - activateNextTab->setShortcuts(QApplication::isRightToLeft() ? KStandardShortcut::tabPrev() : KStandardShortcut::tabNext()); + activateNextTab->setText(i18nc("@action:inmenu", "Activate Next Tab")); + connect(activateNextTab, SIGNAL(triggered()), SLOT(activateNextTab())); + activateNextTab->setShortcuts(QApplication::isRightToLeft() ? KStandardShortcut::tabPrev() : + KStandardShortcut::tabNext()); KAction* activatePrevTab = actionCollection()->addAction("activateprevtab"); - activatePrevTab->setText( i18n( "Activate Previous Tab" ) ); - connect(activatePrevTab, SIGNAL(triggered()), SLOT( activatePrevTab() )); - activatePrevTab->setShortcuts(QApplication::isRightToLeft() ? KStandardShortcut::tabNext() : KStandardShortcut::tabPrev()); + activatePrevTab->setText(i18nc("@action:inmenu", "Activate Previous Tab")); + connect(activatePrevTab, SIGNAL(triggered()), SLOT(activatePrevTab())); + activatePrevTab->setShortcuts(QApplication::isRightToLeft() ? KStandardShortcut::tabNext() : + KStandardShortcut::tabPrev()); + + // for context menu + KAction* openInNewTab = actionCollection()->addAction("open_in_new_tab"); + openInNewTab->setText(i18nc("@action:inmenu", "Open in New Tab")); + openInNewTab->setIcon(KIcon("tab-new")); + connect(openInNewTab, SIGNAL(triggered()), this, SLOT(openInNewTab())); + + KAction* openInNewWindow = actionCollection()->addAction("open_in_new_window"); + openInNewWindow->setText(i18nc("@action:inmenu", "Open in New Window")); + openInNewWindow->setIcon(KIcon("window-new")); + connect(openInNewWindow, SIGNAL(triggered()), this, SLOT(openInNewWindow())); } void DolphinMainWindow::setupDockWidgets()