-macro_optional_find_package(Baloo)
-set_package_properties(Baloo PROPERTIES DESCRIPTION "Baloo Core libraries"
- URL "http://www.kde.org"
- TYPE OPTIONAL
- PURPOSE "For adding desktop-wide search and tagging support to dolphin"
- )
-
-macro_optional_find_package(BalooWidgets)
-set_package_properties(BalooWidgets PROPERTIES DESCRIPTION "Baloos Widgets"
- URL "http://www.kde.org"
- TYPE OPTIONAL
- )
-
-macro_optional_find_package(KFileMetaData)
-set_package_properties(KFileMetaData PROPERTIES
- URL "https://projects.kde.org/kfilemetadata"
- TYPE OPTIONAL
- PURPOSE "For accessing file metadata labels"
- )
-
-if (Baloo_FOUND AND BalooWidgets_FOUND AND KFileMetaData_FOUND)
- set(HAVE_BALOO TRUE)
-endif()
-configure_file(config-baloo.h.cmake ${CMAKE_CURRENT_BINARY_DIR}/config-baloo.h )
+configure_file(config-baloo.h.cmake ${CMAKE_CURRENT_BINARY_DIR}/config-baloo.h)
-macro_bool_to_01(X11_Xrender_FOUND HAVE_XRENDER)
-configure_file(config-X11.h.cmake ${CMAKE_CURRENT_BINARY_DIR}/config-X11.h )
+configure_file(config-dolphin.h.cmake ${CMAKE_CURRENT_BINARY_DIR}/config-dolphin.h)
-include_directories( ${KACTIVITIES_INCLUDE_DIRS} ${CMAKE_CURRENT_BINARY_DIR} )
+add_definitions(-DTRANSLATION_DOMAIN=\"dolphin\")
+add_definitions(-Wno-deprecated-declarations)
+remove_definitions(-DQT_NO_CAST_FROM_BYTEARRAY -DQT_NO_URL_CAST_FROM_STRING)
-if(HAVE_BALOO)
- include_directories(${BALOO_INCLUDE_DIR} ${BALOO_WIDGETS_INCLUDE_DIR} ${KFILEMETADATA_INCLUDE_DIR})
+if(X11_Xrender_FOUND)
+ set(HAVE_XRENDER TRUE)
endif()
-add_subdirectory(tests)
+configure_file(config-X11.h.cmake ${CMAKE_CURRENT_BINARY_DIR}/config-X11.h)
########### next target ###############
)
endif()
-kde4_add_kcfg_files(dolphinprivate_LIB_SRCS
+kconfig_add_kcfg_files(dolphinprivate_LIB_SRCS
settings/dolphin_compactmodesettings.kcfgc
settings/dolphin_directoryviewpropertysettings.kcfgc
settings/dolphin_detailsmodesettings.kcfgc
settings/dolphin_versioncontrolsettings.kcfgc
)
-kde4_add_library(dolphinprivate SHARED ${dolphinprivate_LIB_SRCS})
+add_library(dolphinprivate ${dolphinprivate_LIB_SRCS})
target_link_libraries(
- dolphinprivate
- ${KDE4_KFILE_LIBS}
- konq
- ${KDE4_KNEWSTUFF3_LIBS}
+ dolphinprivate PUBLIC
+ KF5::KDELibs4Support
+ KF5::Konq
+ KF5::NewStuff
)
if(HAVE_BALOO)
target_link_libraries(
- dolphinprivate
- ${BALOO_LIBRARIES}
- ${BALOO_WIDGETS_LIBRARY}
- ${KFILEMETADATA_LIBRARY}
+ dolphinprivate PUBLIC
+ KF5::FileMetaData
+ KF5::BalooCore
+ KF5::BalooFiles
+ KF5::BalooWidgets
)
endif()
target_link_libraries(dolphinprivate ${X11_Xrender_LIB})
endif(X11_Xrender_FOUND)
-target_link_libraries(dolphinprivate ${KDE4_PLASMA_LIBS})
+set_target_properties(dolphinprivate PROPERTIES
+ VERSION ${DOLPHINPRIVATE_VERSION_STRING}
+ SOVERSION ${DOLPHINPRIVATE_SOVERSION}
+)
-set_target_properties(dolphinprivate PROPERTIES VERSION ${GENERIC_LIB_VERSION} SOVERSION ${GENERIC_LIB_SOVERSION} )
-install(TARGETS dolphinprivate ${INSTALL_TARGETS_DEFAULT_ARGS})
+install(TARGETS dolphinprivate ${KF5_INSTALL_TARGETS_DEFAULT_ARGS})
##########################################
set(dolphinpart_SRCS
dolphinpart.cpp
+ dolphinpart_ext.cpp
)
-# Add dolphinpart_ext.cpp conditionally, only with KDE > 4.9.1.
-if (${KDE_VERSION} VERSION_GREATER "4.9.1")
-set(dolphinpart_SRCS
- ${dolphinpart_SRCS}
- dolphinpart_ext.cpp)
-endif (${KDE_VERSION} VERSION_GREATER "4.9.1")
-
-kde4_add_plugin(dolphinpart ${dolphinpart_SRCS})
+add_library(dolphinpart MODULE ${dolphinpart_SRCS})
-target_link_libraries(dolphinpart dolphinprivate konq ${KDE4_KPARTS_LIBS} ${KDE4_KFILE_LIBS})
+target_link_libraries(dolphinpart
+ dolphinprivate
+ KF5::Konq
+ KF5::KDELibs4Support
+)
install(TARGETS dolphinpart DESTINATION ${PLUGIN_INSTALL_DIR})
install(FILES dolphinpart.rc DESTINATION ${DATA_INSTALL_DIR}/dolphinpart)
-install(FILES dolphinpart.desktop DESTINATION ${SERVICES_INSTALL_DIR} )
+install(FILES dolphinpart.desktop DESTINATION ${SERVICES_INSTALL_DIR})
install(FILES views/versioncontrol/fileviewversioncontrolplugin.desktop DESTINATION ${SERVICETYPES_INSTALL_DIR})
##########################################
dolphintabbar.cpp
dolphinrecenttabsmenu.cpp
dolphintabpage.cpp
+ dolphintabwidget.cpp
filterbar/filterbar.cpp
main.cpp
panels/information/filemetadataconfigurationdialog.cpp
views/zoomlevelinfo.cpp
)
-kde4_add_kcfg_files(dolphin_SRCS
+kconfig_add_kcfg_files(dolphin_SRCS
panels/folders/dolphin_folderspanelsettings.kcfgc
panels/information/dolphin_informationpanelsettings.kcfgc
panels/places/dolphin_placespanelsettings.kcfgc
if(NOT WIN32)
set(dolphin_SRCS ${dolphin_SRCS} panels/terminal/terminalpanel.cpp)
-endif(NOT WIN32)
+endif()
-kde4_add_app_icon(dolphin_SRCS "${KDE4_ICON_INSTALL_DIR}/oxygen/*/apps/system-file-manager.png")
+# TODO Does anything replace kde4_add_app_icon ?
+#kde4_add_app_icon(dolphin_SRCS "${KDE4_ICON_INSTALL_DIR}/oxygen/*/apps/system-file-manager.png")
-kde4_add_kdeinit_executable(dolphin ${dolphin_SRCS})
+kf5_add_kdeinit_executable(dolphin ${dolphin_SRCS})
+
+target_include_directories(kdeinit_dolphin PRIVATE ${PHONON_INCLUDES})
target_link_libraries(kdeinit_dolphin
- ${KDE4_KDEPRINT_LIBS}
- ${KDE4_KFILE_LIBS}
- ${KDE4_KPARTS_LIBS}
- ${KDE4_KCMUTILS_LIBRARY}
- konq
+ KF5::Konq
dolphinprivate
- knewstuff3
- ${KDE4_SOLID_LIBS}
- ${KDE4_PHONON_LIBS}
+ KF5::NewStuff
+ KF5::Parts
+ KF5::KCMUtils
+ KF5::Solid
+ Phonon::phonon4qt5
+ KF5::KDELibs4Support
)
-if(HAVE_BALOO)
- target_link_libraries(kdeinit_dolphin
- ${BALOO_LIBRARIES}
- ${BALOO_WIDGETS_LIBRARY}
- )
-endif()
-
-if (KActivities_FOUND)
+if (KF5Activities_FOUND)
target_link_libraries(
kdeinit_dolphin
- ${KACTIVITIES_LIBRARY}
+ KF5::Activities
)
-endif (KActivities_FOUND)
+endif()
-install(TARGETS kdeinit_dolphin ${INSTALL_TARGETS_DEFAULT_ARGS})
-install(TARGETS dolphin ${INSTALL_TARGETS_DEFAULT_ARGS})
+install(TARGETS kdeinit_dolphin ${KF5_INSTALL_TARGETS_DEFAULT_ARGS})
+install(TARGETS dolphin ${KF5_INSTALL_TARGETS_DEFAULT_ARGS})
##########################################
settings/serviceitemdelegate.cpp
settings/servicemodel.cpp)
-kde4_add_kcfg_files(kcm_dolphinviewmodes_PART_SRCS
+kconfig_add_kcfg_files(kcm_dolphinviewmodes_PART_SRCS
settings/dolphin_compactmodesettings.kcfgc
settings/dolphin_directoryviewpropertysettings.kcfgc
settings/dolphin_detailsmodesettings.kcfgc
settings/dolphin_versioncontrolsettings.kcfgc
)
-kde4_add_kcfg_files(kcm_dolphinnavigation_PART_SRCS
+kconfig_add_kcfg_files(kcm_dolphinnavigation_PART_SRCS
settings/dolphin_generalsettings.kcfgc)
-kde4_add_kcfg_files(kcm_dolphinservices_PART_SRCS
+kconfig_add_kcfg_files(kcm_dolphinservices_PART_SRCS
settings/dolphin_generalsettings.kcfgc
settings/dolphin_versioncontrolsettings.kcfgc)
-kde4_add_kcfg_files(kcm_dolphingeneral_PART_SRCS
+kconfig_add_kcfg_files(kcm_dolphingeneral_PART_SRCS
settings/dolphin_generalsettings.kcfgc)
-kde4_add_plugin(kcm_dolphinviewmodes ${kcm_dolphinviewmodes_PART_SRCS})
-kde4_add_plugin(kcm_dolphinnavigation ${kcm_dolphinnavigation_PART_SRCS})
-kde4_add_plugin(kcm_dolphinservices ${kcm_dolphinservices_PART_SRCS})
-kde4_add_plugin(kcm_dolphingeneral ${kcm_dolphingeneral_PART_SRCS})
+add_library(kcm_dolphinviewmodes MODULE ${kcm_dolphinviewmodes_PART_SRCS})
+add_library(kcm_dolphinnavigation MODULE ${kcm_dolphinnavigation_PART_SRCS})
+add_library(kcm_dolphinservices MODULE ${kcm_dolphinservices_PART_SRCS})
+add_library(kcm_dolphingeneral MODULE ${kcm_dolphingeneral_PART_SRCS})
-target_link_libraries(kcm_dolphinviewmodes ${KDE4_KDEUI_LIBS} ${KDE4_KFILE_LIBS} dolphinprivate)
-target_link_libraries(kcm_dolphinnavigation ${KDE4_KDEUI_LIBS} ${KDE4_KFILE_LIBS} dolphinprivate)
-target_link_libraries(kcm_dolphinservices ${KDE4_KDEUI_LIBS} ${KDE4_KFILE_LIBS} ${KDE4_KIO_LIBS} ${KDE4_KNEWSTUFF3_LIBRARY} dolphinprivate)
-target_link_libraries(kcm_dolphingeneral ${KDE4_KDEUI_LIBS} ${KDE4_KFILE_LIBS} ${KDE4_KIO_LIBS} dolphinprivate)
+target_link_libraries(kcm_dolphinviewmodes KF5::KDELibs4Support dolphinprivate)
+target_link_libraries(kcm_dolphinnavigation KF5::KDELibs4Support dolphinprivate)
+target_link_libraries(kcm_dolphinservices KF5::KDELibs4Support dolphinprivate)
+target_link_libraries(kcm_dolphingeneral KF5::KDELibs4Support dolphinprivate)
install(TARGETS kcm_dolphinviewmodes DESTINATION ${PLUGIN_INSTALL_DIR} )
install(TARGETS kcm_dolphinnavigation DESTINATION ${PLUGIN_INSTALL_DIR} )
set(kio_search_PART_SRCS
search/filenamesearchprotocol.cpp)
-kde4_add_plugin(kio_filenamesearch ${kio_search_PART_SRCS})
-target_link_libraries(kio_filenamesearch ${KDE4_KIO_LIBS})
+
+add_library(kio_filenamesearch MODULE ${kio_search_PART_SRCS})
+
+target_link_libraries(kio_filenamesearch KF5::KDELibs4Support)
+
install(TARGETS kio_filenamesearch DESTINATION ${PLUGIN_INSTALL_DIR})
########### install files ###############
settings/dolphin_detailsmodesettings.kcfg
settings/dolphin_versioncontrolsettings.kcfg
DESTINATION ${KCFG_INSTALL_DIR} )
-install( FILES dolphinui.rc DESTINATION ${DATA_INSTALL_DIR}/dolphin )
+install( FILES dolphinui.rc DESTINATION ${KXMLGUI_INSTALL_DIR}/dolphin )
install( FILES dolphin.appdata.xml DESTINATION ${SHARE_INSTALL_PREFIX}/appdata )
install( FILES search/filenamesearch.protocol DESTINATION ${SERVICES_INSTALL_DIR} )
install( FILES settings/kcm/kcmdolphinviewmodes.desktop DESTINATION
install( PROGRAMS settings/services/servicemenuinstallation DESTINATION ${BIN_INSTALL_DIR} )
install( PROGRAMS settings/services/servicemenudeinstallation DESTINATION ${BIN_INSTALL_DIR} )
+add_subdirectory(tests)
#include "dolphincontextmenu.h"
#include "dolphinnewfilemenu.h"
#include "dolphinrecenttabsmenu.h"
- #include "dolphintabbar.h"
+ #include "dolphintabwidget.h"
#include "dolphinviewcontainer.h"
#include "dolphintabpage.h"
#include "panels/folders/folderspanel.h"
#include "dolphin_generalsettings.h"
#include <KAcceleratorManager>
-#include <KAction>
#include <KActionCollection>
#include <KActionMenu>
#include <KConfig>
#include <kdualaction.h>
#include <KFileDialog>
#include <KGlobal>
+#include <KDialog>
+#include <KJobWidgets>
#include <KLineEdit>
#include <KToolBar>
-#include <KIcon>
#include <KIconLoader>
#include <KIO/NetAccess>
#include <KIO/JobUiDelegate>
#include <KMenuBar>
#include <KMessageBox>
#include <KFileItemListProperties>
-#include <konqmimedata.h>
#include <KProtocolInfo>
#include <KRun>
#include <KShell>
#include <KStandardAction>
#include <KToggleAction>
#include <KUrlNavigator>
-#include <KUrl>
#include <KUrlComboBox>
#include <KToolInvocation>
#include <QKeyEvent>
#include <QClipboard>
#include <QToolButton>
+#include <QSplitter>
+#include <QTimer>
+#include <QPushButton>
namespace {
// Used for GeneralSettings::version() to determine whether
DolphinMainWindow::DolphinMainWindow() :
KXmlGuiWindow(0),
m_newFileMenu(0),
- m_tabBar(0),
+ m_tabWidget(0),
m_activeViewContainer(0),
- m_centralWidgetLayout(0),
- m_tabIndex(-1),
- m_viewTab(),
m_actionHandler(0),
m_remoteEncoding(0),
m_settingsDialog(),
{
setObjectName("Dolphin#");
- connect(&DolphinNewFileMenuObserver::instance(), SIGNAL(errorMessage(QString)),
- this, SLOT(showErrorMessage(QString)));
+ connect(&DolphinNewFileMenuObserver::instance(), &DolphinNewFileMenuObserver::errorMessage,
+ this, &DolphinMainWindow::showErrorMessage);
KIO::FileUndoManager* undoManager = KIO::FileUndoManager::self();
undoManager->setUiInterface(new UndoUiInterface());
- connect(undoManager, SIGNAL(undoAvailable(bool)),
- this, SLOT(slotUndoAvailable(bool)));
- connect(undoManager, SIGNAL(undoTextChanged(QString)),
- this, SLOT(slotUndoTextChanged(QString)));
- connect(undoManager, SIGNAL(jobRecordingStarted(CommandType)),
- this, SLOT(clearStatusBar()));
- connect(undoManager, SIGNAL(jobRecordingFinished(CommandType)),
- this, SLOT(showCommand(CommandType)));
+ connect(undoManager, static_cast<void(KIO::FileUndoManager::*)(bool)>(&KIO::FileUndoManager::undoAvailable),
+ this, &DolphinMainWindow::slotUndoAvailable);
+ connect(undoManager, &KIO::FileUndoManager::undoTextChanged,
+ this, &DolphinMainWindow::slotUndoTextChanged);
+ connect(undoManager, &KIO::FileUndoManager::jobRecordingStarted,
+ this, &DolphinMainWindow::clearStatusBar);
+ connect(undoManager, &KIO::FileUndoManager::jobRecordingFinished,
+ this, &DolphinMainWindow::showCommand);
GeneralSettings* generalSettings = GeneralSettings::self();
const bool firstRun = (generalSettings->version() < 200);
setAcceptDrops(true);
+ m_tabWidget = new DolphinTabWidget(this);
+ connect(m_tabWidget, SIGNAL(activeViewChanged(DolphinViewContainer*)),
+ this, SLOT(activeViewChanged(DolphinViewContainer*)));
+ connect(m_tabWidget, SIGNAL(tabCountChanged(int)),
+ this, SLOT(tabCountChanged(int)));
+ connect(m_tabWidget, SIGNAL(currentUrlChanged(KUrl)),
+ this, SLOT(setUrlAsCaption(KUrl)));
+ setCentralWidget(m_tabWidget);
+
setupActions();
m_actionHandler = new DolphinViewActionHandler(actionCollection(), this);
- connect(m_actionHandler, SIGNAL(actionBeingHandled()), SLOT(clearStatusBar()));
- connect(m_actionHandler, SIGNAL(createDirectory()), SLOT(createDirectory()));
+ connect(m_actionHandler, &DolphinViewActionHandler::actionBeingHandled, this, &DolphinMainWindow::clearStatusBar);
+ connect(m_actionHandler, &DolphinViewActionHandler::createDirectory, this, &DolphinMainWindow::createDirectory);
m_remoteEncoding = new DolphinRemoteEncoding(this, m_actionHandler);
- connect(this, SIGNAL(urlChanged(KUrl)),
- m_remoteEncoding, SLOT(slotAboutToOpenUrl()));
+ connect(this, &DolphinMainWindow::urlChanged,
+ m_remoteEncoding, &DolphinRemoteEncoding::slotAboutToOpenUrl);
- m_tabBar = new DolphinTabBar(this);
- connect(m_tabBar, SIGNAL(currentChanged(int)),
- this, SLOT(setActiveTab(int)));
- connect(m_tabBar, SIGNAL(tabCloseRequested(int)),
- this, SLOT(closeTab(int)));
- connect(m_tabBar, SIGNAL(openNewActivatedTab(int)),
- this, SLOT(openNewActivatedTab(int)));
- connect(m_tabBar, SIGNAL(tabMoved(int,int)),
- this, SLOT(slotTabMoved(int,int)));
- connect(m_tabBar, SIGNAL(tabDropEvent(int,QDropEvent*)),
- this, SLOT(tabDropEvent(int,QDropEvent*)));
- connect(m_tabBar, SIGNAL(tabDetachRequested(int)),
- this, SLOT(detachTab(int)));
-
- m_tabBar->blockSignals(true); // signals get unblocked after at least 2 tabs are open
- m_tabBar->hide();
-
- QWidget* centralWidget = new QWidget(this);
- m_centralWidgetLayout = new QVBoxLayout(centralWidget);
- m_centralWidgetLayout->setSpacing(0);
- m_centralWidgetLayout->setMargin(0);
- m_centralWidgetLayout->addWidget(m_tabBar);
-
- setCentralWidget(centralWidget);
setupDockWidgets();
setupGUI(Keys | Save | Create | ToolBar);
stateChanged("new_file");
QClipboard* clipboard = QApplication::clipboard();
- connect(clipboard, SIGNAL(dataChanged()),
- this, SLOT(updatePasteAction()));
+ connect(clipboard, &QClipboard::dataChanged,
+ this, &DolphinMainWindow::updatePasteAction);
QAction* showFilterBarAction = actionCollection()->action("show_filter_bar");
showFilterBarAction->setChecked(generalSettings->filterBar());
void DolphinMainWindow::openDirectories(const QList<KUrl>& dirs)
{
- const bool hasSplitView = GeneralSettings::splitView();
-
- // Open each directory inside a new tab. If the "split view" option has been enabled,
- // always show two directories within one tab.
- QList<KUrl>::const_iterator it = dirs.constBegin();
- while (it != dirs.constEnd()) {
- const KUrl& primaryUrl = *(it++);
- if (hasSplitView && (it != dirs.constEnd())) {
- const KUrl& secondaryUrl = *(it++);
- openNewTab(primaryUrl, secondaryUrl);
- } else {
- openNewTab(primaryUrl);
- }
- }
+ m_tabWidget->openDirectories(dirs);
}
void DolphinMainWindow::openFiles(const QList<KUrl>& files)
{
- if (files.isEmpty()) {
- return;
- }
-
- // Get all distinct directories from 'files' and open a tab
- // for each directory. If the "split view" option is enabled, two
- // directories are shown inside one tab (see openDirectories()).
- QList<KUrl> dirs;
- foreach (const KUrl& url, files) {
- const KUrl dir(url.directory());
- if (!dirs.contains(dir)) {
- dirs.append(dir);
- }
- }
-
- openDirectories(dirs);
-
- // Select the files. Although the files can be split between several
- // tabs, there is no need to split 'files' accordingly, as
- // the DolphinView will just ignore invalid selections.
- foreach (DolphinTabPage* tabPage, m_viewTab) {
- tabPage->markUrlsAsSelected(files);
- tabPage->markUrlAsCurrent(files.first());
- }
+ m_tabWidget->openFiles(files);
}
void DolphinMainWindow::showCommand(CommandType command)
return;
}
- DolphinViewContainer* view = activeViewContainer();
- if (view) {
- view->setUrl(url);
- updateEditActions();
- updatePasteAction();
- updateViewActions();
- updateGoActions();
- setUrlAsCaption(url);
-
- const QString iconName = KIO::iconNameForUrl(url);
- m_tabBar->setTabIcon(m_tabIndex, QIcon::fromTheme(iconName));
- m_tabBar->setTabText(m_tabIndex, squeezedText(tabName(view->url())));
-
- emit urlChanged(url);
- }
+ m_activeViewContainer->setUrl(url);
+ updateEditActions();
+ updatePasteAction();
+ updateViewActions();
+ updateGoActions();
+
+ emit urlChanged(url);
}
void DolphinMainWindow::slotTerminalDirectoryChanged(const KUrl& url)
{
updateEditActions();
- const int selectedUrlsCount = m_viewTab.at(m_tabIndex)->selectedItemsCount();
+ const int selectedUrlsCount = m_tabWidget->currentTabPage()->selectedItemsCount();
QAction* compareFilesAction = actionCollection()->action("compare_files");
if (selectedUrlsCount == 2) {
KRun::run("dolphin %u", KUrl::List(), this);
}
- void DolphinMainWindow::openNewTab()
+ void DolphinMainWindow::openNewActivatedTab()
{
- 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();
- 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();
- }
+ m_tabWidget->openNewActivatedTab();
}
void DolphinMainWindow::openNewTab(const KUrl& primaryUrl, const KUrl& secondaryUrl)
{
- QWidget* focusWidget = QApplication::focusWidget();
-
- DolphinTabPage* tabPage = new DolphinTabPage(primaryUrl, secondaryUrl, this);
- m_viewTab.append(tabPage);
-
- connect(tabPage, SIGNAL(activeViewChanged()),
- this, SLOT(activeViewChanged()));
-
- // The places-selector from the URL navigator should only be shown
- // if the places dock is invisible
- QDockWidget* placesDock = findChild<QDockWidget*>("placesDock");
- const bool placesSelectorVisible = !placesDock || !placesDock->isVisible();
- tabPage->setPlacesSelectorVisible(placesSelectorVisible);
-
- DolphinViewContainer* primaryContainer = tabPage->primaryViewContainer();
- connectViewSignals(primaryContainer);
-
- if (tabPage->splitViewEnabled()) {
- DolphinViewContainer* secondaryContainer = tabPage->secondaryViewContainer();
- connectViewSignals(secondaryContainer);
- }
-
- tabPage->hide();
-
- m_tabBar->addTab(QIcon::fromTheme(KIO::iconNameForUrl(primaryUrl)),
- squeezedText(tabName(primaryUrl)));
-
- if (m_viewTab.count() > 1) {
- actionCollection()->action("close_tab")->setEnabled(true);
- actionCollection()->action("activate_prev_tab")->setEnabled(true);
- actionCollection()->action("activate_next_tab")->setEnabled(true);
- m_tabBar->show();
- m_tabBar->blockSignals(false);
- }
-
- if (focusWidget) {
- // The DolphinViewContainer grabbed the keyboard focus. As the tab is opened
- // in background, assure that the previous focused widget gets the focus back.
- focusWidget->setFocus();
- }
+ m_tabWidget->openNewTab(primaryUrl, secondaryUrl);
}
void DolphinMainWindow::openNewActivatedTab(const KUrl& primaryUrl, const KUrl& secondaryUrl)
{
- openNewTab(primaryUrl, secondaryUrl);
- setActiveTab(m_viewTab.count() - 1);
- }
-
- void DolphinMainWindow::openNewActivatedTab(int index)
- {
- Q_ASSERT(index >= 0);
- const DolphinTabPage* tabPage = m_viewTab.at(index);
- openNewActivatedTab(tabPage->activeViewContainer()->url());
- }
-
- void DolphinMainWindow::activateNextTab()
- {
- if (m_viewTab.count() >= 2) {
- const int tabIndex = (m_tabBar->currentIndex() + 1) % m_tabBar->count();
- setActiveTab(tabIndex);
- }
- }
-
- void DolphinMainWindow::activatePrevTab()
- {
- if (m_viewTab.count() >= 2) {
- int tabIndex = m_tabBar->currentIndex() - 1;
- if (tabIndex == -1) {
- tabIndex = m_tabBar->count() - 1;
- }
- setActiveTab(tabIndex);
- }
+ m_tabWidget->openNewActivatedTab(primaryUrl, secondaryUrl);
}
void DolphinMainWindow::openInNewTab()
}
if (!newWindowUrl.isEmpty()) {
- KRun::run("dolphin %u", KUrl::List() << newWindowUrl, this);
+ KRun::run("dolphin %u", QList<QUrl>() << newWindowUrl, this);
}
}
{
KXmlGuiWindow::showEvent(event);
- if (!m_activeViewContainer && m_viewTab.count() > 0) {
- // If we have no active view container yet, we set the primary view container
- // of the first tab as active view container.
- setActiveTab(0);
- }
-
if (!event->spontaneous()) {
m_activeViewContainer->view()->setFocus();
}
closedByUser = false;
}
- if (m_viewTab.count() > 1 && GeneralSettings::confirmClosingMultipleTabs() && closedByUser) {
+ if (m_tabWidget->count() > 1 && GeneralSettings::confirmClosingMultipleTabs() && closedByUser) {
// Ask the user if he really wants to quit and close all tabs.
// Open a confirmation dialog with 3 buttons:
// KDialog::Yes -> Quit
// KDialog::No -> Close only the current tab
// KDialog::Cancel -> do nothing
- KDialog *dialog = new KDialog(this, Qt::Dialog);
- dialog->setCaption(i18nc("@title:window", "Confirmation"));
- dialog->setButtons(KDialog::Yes | KDialog::No | KDialog::Cancel);
+ QDialog *dialog = new QDialog(this, Qt::Dialog);
+ dialog->setWindowTitle(i18nc("@title:window", "Confirmation"));
dialog->setModal(true);
- dialog->setButtonGuiItem(KDialog::Yes, KStandardGuiItem::quit());
- dialog->setButtonGuiItem(KDialog::No, KGuiItem(i18n("C&lose Current Tab"), KIcon("tab-close")));
- dialog->setButtonGuiItem(KDialog::Cancel, KStandardGuiItem::cancel());
- dialog->setDefaultButton(KDialog::Yes);
+ QDialogButtonBox* buttons = new QDialogButtonBox(QDialogButtonBox::Yes | QDialogButtonBox::No | QDialogButtonBox::Cancel);
+ KGuiItem::assign(buttons->button(QDialogButtonBox::Yes), KStandardGuiItem::quit());
+ KGuiItem::assign(buttons->button(QDialogButtonBox::No), KGuiItem(i18n("C&lose Current Tab"), QIcon::fromTheme("tab-close")));
+ KGuiItem::assign(buttons->button(QDialogButtonBox::Cancel), KStandardGuiItem::cancel());
+ buttons->button(QDialogButtonBox::Yes)->setDefault(true);
bool doNotAskAgainCheckboxResult = false;
const int result = KMessageBox::createKMessageBox(dialog,
+ buttons,
QMessageBox::Warning,
i18n("You have multiple tabs open in this window, are you sure you want to quit?"),
QStringList(),
}
switch (result) {
- case KDialog::Yes:
+ case QDialogButtonBox::Yes:
// Quit
break;
- case KDialog::No:
+ case QDialogButtonBox::No:
// Close only the current tab
- closeTab();
+ m_tabWidget->closeTab();
default:
event->ignore();
return;
void DolphinMainWindow::saveProperties(KConfigGroup& group)
{
- const int tabCount = m_viewTab.count();
- group.writeEntry("Tab Count", tabCount);
- group.writeEntry("Active Tab Index", m_tabBar->currentIndex());
-
- for (int i = 0; i < tabCount; ++i) {
- const DolphinTabPage* tabPage = m_viewTab.at(i);
- group.writeEntry("Tab " % QString::number(i), tabPage->saveState());
- }
+ m_tabWidget->saveProperties(group);
}
void DolphinMainWindow::readProperties(const KConfigGroup& group)
{
- const int tabCount = group.readEntry("Tab Count", 1);
- for (int i = 0; i < tabCount; ++i) {
- const QByteArray state = group.readEntry("Tab " % QString::number(i), QByteArray());
- DolphinTabPage* tabPage = m_viewTab.at(i);
- tabPage->restoreState(state);
-
- // openNewTab() needs to be called only tabCount - 1 times
- if (i != tabCount - 1) {
- openNewTab();
- }
- }
-
- const int index = group.readEntry("Active Tab Index", 0);
- m_tabBar->setCurrentIndex(index);
+ m_tabWidget->readProperties(group);
}
void DolphinMainWindow::updateNewMenu()
void DolphinMainWindow::toggleSplitView()
{
- DolphinTabPage* tabPage = m_viewTab.at(m_tabIndex);
+ DolphinTabPage* tabPage = m_tabWidget->currentTabPage();
tabPage->setSplitViewEnabled(!tabPage->splitViewEnabled());
- if (tabPage->splitViewEnabled()) {
- connectViewSignals(tabPage->secondaryViewContainer());
- }
-
updateViewActions();
}
GeneralSettings::setLockPanels(newLockState);
}
- void DolphinMainWindow::slotPlacesPanelVisibilityChanged(bool visible)
- {
- foreach (DolphinTabPage* tabPage, m_viewTab) {
- // The Places selector in the location bar should be shown if and only if the Places panel is hidden.
- tabPage->setPlacesSelectorVisible(!visible);
- }
- }
-
void DolphinMainWindow::goBack()
{
KUrlNavigator* urlNavigator = m_activeViewContainer->urlNavigator();
void DolphinMainWindow::compareFiles()
{
- const KFileItemList items = m_viewTab.at(m_tabIndex)->selectedItems();
+ const KFileItemList items = m_tabWidget->currentTabPage()->selectedItems();
if (items.count() != 2) {
// The action is disabled in this case, but it could have been triggered
// via D-Bus, see https://bugs.kde.org/show_bug.cgi?id=325517
const KUrl url = container->url();
DolphinSettingsDialog* settingsDialog = new DolphinSettingsDialog(url, this);
- connect(settingsDialog, SIGNAL(settingsChanged()), this, SLOT(refreshViews()));
+ connect(settingsDialog, &DolphinSettingsDialog::settingsChanged, this, &DolphinMainWindow::refreshViews);
settingsDialog->setAttribute(Qt::WA_DeleteOnClose);
settingsDialog->show();
m_settingsDialog = settingsDialog;
}
}
- void DolphinMainWindow::setActiveTab(int index)
- {
- Q_ASSERT(index >= 0);
- Q_ASSERT(index < m_viewTab.count());
- if (index == m_tabIndex) {
- return;
- }
-
- m_tabBar->setCurrentIndex(index);
-
- // hide current tab content
- if (m_tabIndex >= 0) {
- DolphinTabPage* hiddenTabPage = m_viewTab.at(m_tabIndex);
- hiddenTabPage->hide();
- m_centralWidgetLayout->removeWidget(hiddenTabPage);
- }
-
- // show active tab content
- m_tabIndex = index;
-
- DolphinTabPage* tabPage = m_viewTab.at(index);
- m_centralWidgetLayout->addWidget(tabPage, 1);
- tabPage->show();
-
- setActiveViewContainer(tabPage->activeViewContainer());
- }
-
- void DolphinMainWindow::closeTab()
- {
- closeTab(m_tabBar->currentIndex());
- }
-
- void DolphinMainWindow::closeTab(int index)
- {
- Q_ASSERT(index >= 0);
- Q_ASSERT(index < m_viewTab.count());
- if (m_viewTab.count() == 1) {
- // the last tab may never get closed
- return;
- }
-
- if (index == m_tabIndex) {
- // The tab that should be closed is the active tab. Activate the
- // previous tab before closing the tab.
- m_tabBar->setCurrentIndex((index > 0) ? index - 1 : 1);
- }
-
- DolphinTabPage* tabPage = m_viewTab.at(index);
-
- if (tabPage->splitViewEnabled()) {
- emit rememberClosedTab(tabPage->primaryViewContainer()->url(),
- tabPage->secondaryViewContainer()->url());
- } else {
- emit rememberClosedTab(tabPage->primaryViewContainer()->url(), KUrl());
- }
-
- // delete tab
- m_viewTab.removeAt(index);
- tabPage->deleteLater();
-
- m_tabBar->blockSignals(true);
- m_tabBar->removeTab(index);
-
- if (m_tabIndex > index) {
- m_tabIndex--;
- Q_ASSERT(m_tabIndex >= 0);
- }
-
- // if only one tab is left, also remove the tab entry so that
- // closing the last tab is not possible
- if (m_viewTab.count() < 2) {
- actionCollection()->action("close_tab")->setEnabled(false);
- actionCollection()->action("activate_prev_tab")->setEnabled(false);
- actionCollection()->action("activate_next_tab")->setEnabled(false);
- m_tabBar->hide();
- } else {
- m_tabBar->blockSignals(false);
- }
- }
-
- void DolphinMainWindow::detachTab(int index)
- {
- Q_ASSERT(index >= 0);
-
- const QString separator(QLatin1Char(' '));
- QString command = QLatin1String("dolphin");
-
- const DolphinTabPage* tabPage = m_viewTab.at(index);
- command += separator + tabPage->primaryViewContainer()->url().url();
- if (tabPage->splitViewEnabled()) {
- command += separator + tabPage->secondaryViewContainer()->url().url();
- command += separator + QLatin1String("-split");
- }
-
- KRun::runCommand(command, this);
-
- closeTab(index);
- }
-
- void DolphinMainWindow::slotTabMoved(int from, int to)
- {
- m_viewTab.move(from, to);
- m_tabIndex = m_tabBar->currentIndex();
- }
-
void DolphinMainWindow::handleUrl(const KUrl& url)
{
delete m_lastHandleUrlStatJob;
// stat the URL to see if it is a dir or not
m_lastHandleUrlStatJob = KIO::stat(url, KIO::HideProgressInfo);
if (m_lastHandleUrlStatJob->ui()) {
- m_lastHandleUrlStatJob->ui()->setWindow(this);
+ KJobWidgets::setWindow(m_lastHandleUrlStatJob, this);
}
- connect(m_lastHandleUrlStatJob, SIGNAL(result(KJob*)),
- this, SLOT(slotHandleUrlStatFinished(KJob*)));
+ connect(m_lastHandleUrlStatJob, &KIO::Job::result,
+ this, &DolphinMainWindow::slotHandleUrlStatFinished);
} else {
new KRun(url, this); // Automatically deletes itself after being finished
}
}
- void DolphinMainWindow::tabDropEvent(int tab, QDropEvent* event)
- {
- const KUrl::List urls = KUrl::List::fromMimeData(event->mimeData());
- if (!urls.isEmpty() && tab != -1) {
- const DolphinView* view = m_viewTab.at(tab)->activeViewContainer()->view();
-
- QString error;
- DragAndDropHelper::dropUrls(view->rootItem(), view->url(), event, error);
- if (!error.isEmpty()) {
- activeViewContainer()->showMessage(error, DolphinViewContainer::Error);
- }
- }
- }
-
void DolphinMainWindow::slotWriteStateChanged(bool isFolderWritable)
{
newFileMenu()->setEnabled(isFolderWritable);
switch (command) {
case DolphinContextMenu::OpenParentFolderInNewWindow: {
- KRun::run("dolphin %u", KUrl::List() << item.url().upUrl(), this);
+
+ KRun::run("dolphin %u", QList<QUrl>() << KIO::upUrl(item.url()), this);
break;
}
case DolphinContextMenu::OpenParentFolderInNewTab:
- openNewTab(item.url().upUrl());
+ openNewTab(KIO::upUrl(item.url()));
break;
case DolphinContextMenu::None:
// Add "Go" menu
KMenu* goMenu = new KMenu(i18nc("@action:inmenu", "Go"), menu);
- connect(menu, SIGNAL(aboutToHide()), goMenu, SLOT(deleteLater()));
+ connect(menu, &KMenu::aboutToHide, goMenu, &KMenu::deleteLater);
goMenu->addAction(ac->action(KStandardAction::name(KStandardAction::Back)));
goMenu->addAction(ac->action(KStandardAction::name(KStandardAction::Forward)));
goMenu->addAction(ac->action(KStandardAction::name(KStandardAction::Up)));
// Add "Tool" menu
KMenu* toolsMenu = new KMenu(i18nc("@action:inmenu", "Tools"), menu);
- connect(menu, SIGNAL(aboutToHide()), toolsMenu, SLOT(deleteLater()));
+ connect(menu, &KMenu::aboutToHide, toolsMenu, &KMenu::deleteLater);
toolsMenu->addAction(ac->action("show_filter_bar"));
toolsMenu->addAction(ac->action("compare_files"));
toolsMenu->addAction(ac->action("open_terminal"));
// Add "Help" menu
KMenu* helpMenu = new KMenu(i18nc("@action:inmenu", "Help"), menu);
- connect(menu, SIGNAL(aboutToHide()), helpMenu, SLOT(deleteLater()));
+ connect(menu, &KMenu::aboutToHide, helpMenu, &KMenu::deleteLater);
helpMenu->addAction(ac->action(KStandardAction::name(KStandardAction::HelpContents)));
helpMenu->addAction(ac->action(KStandardAction::name(KStandardAction::WhatsThis)));
helpMenu->addSeparator();
}
}
- void DolphinMainWindow::activeViewChanged()
- {
- const DolphinTabPage* tabPage = m_viewTab.at(m_tabIndex);
- setActiveViewContainer(tabPage->activeViewContainer());
- }
-
void DolphinMainWindow::closedTabsCountChanged(unsigned int count)
{
actionCollection()->action("undo_close_tab")->setEnabled(count > 0);
}
- void DolphinMainWindow::setActiveViewContainer(DolphinViewContainer* viewContainer)
+ void DolphinMainWindow::activeViewChanged(DolphinViewContainer* viewContainer)
{
+ DolphinViewContainer* oldViewContainer = m_activeViewContainer;
Q_ASSERT(viewContainer);
- Q_ASSERT((viewContainer == m_viewTab.at(m_tabIndex)->primaryViewContainer()) ||
- (viewContainer == m_viewTab.at(m_tabIndex)->secondaryViewContainer()));
- if (m_activeViewContainer == viewContainer) {
- return;
- }
m_activeViewContainer = viewContainer;
+
+ if (oldViewContainer) {
+ // Disconnect all signals between the old view container (container,
+ // view and url navigator) and main window.
+ oldViewContainer->disconnect(this);
+ oldViewContainer->view()->disconnect(this);
+ oldViewContainer->urlNavigator()->disconnect(this);
+ }
+
+ connectViewSignals(viewContainer);
+
m_actionHandler->setCurrentView(viewContainer->view());
updateHistory();
updateViewActions();
updateGoActions();
- const KUrl url = m_activeViewContainer->url();
- setUrlAsCaption(url);
- m_tabBar->setTabText(m_tabIndex, squeezedText(tabName(url)));
- m_tabBar->setTabIcon(m_tabIndex, QIcon::fromTheme(KIO::iconNameForUrl(url)));
-
+ const KUrl url = viewContainer->url();
emit urlChanged(url);
}
+ void DolphinMainWindow::tabCountChanged(int count)
+ {
+ const bool enableTabActions = (count > 1);
+ actionCollection()->action("close_tab")->setEnabled(enableTabActions);
+ actionCollection()->action("activate_next_tab")->setEnabled(enableTabActions);
+ actionCollection()->action("activate_prev_tab")->setEnabled(enableTabActions);
+ }
+
+ void DolphinMainWindow::setUrlAsCaption(const KUrl& url)
+ {
+ QString caption;
+ if (!url.isLocalFile()) {
+ caption.append(url.protocol() + " - ");
+ if (url.hasHost()) {
+ caption.append(url.host() + " - ");
+ }
+ }
+
+ const QString fileName = url.fileName().isEmpty() ? "/" : url.fileName();
+ caption.append(fileName);
+
+ setCaption(caption);
+ }
+
void DolphinMainWindow::setupActions()
{
// setup 'File' menu
m_newFileMenu = new DolphinNewFileMenu(actionCollection(), this);
- KMenu* menu = m_newFileMenu->menu();
+ QMenu* menu = m_newFileMenu->menu();
menu->setTitle(i18nc("@title:menu Create new folder, file, link, etc.", "Create New"));
- menu->setIcon(KIcon("document-new"));
+ menu->setIcon(QIcon::fromTheme("document-new"));
m_newFileMenu->setDelayed(false);
- connect(menu, SIGNAL(aboutToShow()),
- this, SLOT(updateNewMenu()));
+ connect(menu, &QMenu::aboutToShow,
+ this, &DolphinMainWindow::updateNewMenu);
- KAction* newWindow = actionCollection()->addAction("new_window");
- newWindow->setIcon(KIcon("window-new"));
+ QAction* newWindow = actionCollection()->addAction("new_window");
+ newWindow->setIcon(QIcon::fromTheme("window-new"));
newWindow->setText(i18nc("@action:inmenu File", "New &Window"));
newWindow->setShortcut(Qt::CTRL | Qt::Key_N);
- connect(newWindow, SIGNAL(triggered()), this, SLOT(openNewMainWindow()));
+ connect(newWindow, &QAction::triggered, this, &DolphinMainWindow::openNewMainWindow);
- KAction* newTab = actionCollection()->addAction("new_tab");
- newTab->setIcon(KIcon("tab-new"));
+ QAction* newTab = actionCollection()->addAction("new_tab");
+ newTab->setIcon(QIcon::fromTheme("tab-new"));
newTab->setText(i18nc("@action:inmenu File", "New Tab"));
- newTab->setShortcut(KShortcut(Qt::CTRL | Qt::Key_T, Qt::CTRL | Qt::SHIFT | Qt::Key_N));
- connect(newTab, SIGNAL(triggered()), this, SLOT(openNewActivatedTab()));
+ newTab->setShortcuts(QList<QKeySequence>() << QKeySequence(Qt::CTRL | Qt::Key_T) << QKeySequence(Qt::CTRL | Qt::SHIFT | Qt::Key_N));
- connect(newTab, &QAction::triggered, this, static_cast<void(DolphinMainWindow::*)()>(&DolphinMainWindow::openNewTab));
++ connect(newTab, &QAction::triggered, this, static_cast<void(DolphinMainWindow::*)()>(&DolphinMainWindow::openNewActivatedTab));
- KAction* closeTab = actionCollection()->addAction("close_tab");
- closeTab->setIcon(KIcon("tab-close"));
+ QAction* closeTab = actionCollection()->addAction("close_tab");
+ closeTab->setIcon(QIcon::fromTheme("tab-close"));
closeTab->setText(i18nc("@action:inmenu File", "Close Tab"));
closeTab->setShortcut(Qt::CTRL | Qt::Key_W);
closeTab->setEnabled(false);
- connect(closeTab, &QAction::triggered, this, static_cast<void(DolphinMainWindow::*)()>(&DolphinMainWindow::closeTab));
- connect(closeTab, SIGNAL(triggered()), m_tabWidget, SLOT(closeTab()));
++ connect(closeTab, &QAction::triggered, m_tabWidget, static_cast<void(DolphinTabWidget::*)()>(&DolphinTabWidget::closeTab));
KStandardAction::quit(this, SLOT(quit()), actionCollection());
// need to remove shift+del from cut action, else the shortcut for deletejob
// doesn't work
- KAction* cut = KStandardAction::cut(this, SLOT(cut()), actionCollection());
- KShortcut cutShortcut = cut->shortcut();
- cutShortcut.remove(Qt::SHIFT | Qt::Key_Delete, KShortcut::KeepEmpty);
- cut->setShortcut(cutShortcut);
+ QAction* cut = KStandardAction::cut(this, SLOT(cut()), actionCollection());
+ auto cutShortcuts = cut->shortcuts();
+ cutShortcuts.removeAll(QKeySequence(Qt::SHIFT | Qt::Key_Delete));
+ cut->setShortcuts(cutShortcuts);
KStandardAction::copy(this, SLOT(copy()), actionCollection());
- KAction* paste = KStandardAction::paste(this, SLOT(paste()), actionCollection());
+ QAction* paste = KStandardAction::paste(this, SLOT(paste()), actionCollection());
// The text of the paste-action is modified dynamically by Dolphin
// (e. g. to "Paste One Folder"). To prevent that the size of the toolbar changes
// due to the long text, the text "Paste" is used:
KStandardAction::find(this, SLOT(find()), actionCollection());
- KAction* selectAll = actionCollection()->addAction("select_all");
+ QAction* selectAll = actionCollection()->addAction("select_all");
selectAll->setText(i18nc("@action:inmenu Edit", "Select All"));
selectAll->setShortcut(Qt::CTRL | Qt::Key_A);
- connect(selectAll, SIGNAL(triggered()), this, SLOT(selectAll()));
+ connect(selectAll, &QAction::triggered, this, &DolphinMainWindow::selectAll);
- KAction* invertSelection = actionCollection()->addAction("invert_selection");
+ QAction* invertSelection = actionCollection()->addAction("invert_selection");
invertSelection->setText(i18nc("@action:inmenu Edit", "Invert Selection"));
invertSelection->setShortcut(Qt::CTRL | Qt::SHIFT | Qt::Key_A);
- connect(invertSelection, SIGNAL(triggered()), this, SLOT(invertSelection()));
+ connect(invertSelection, &QAction::triggered, this, &DolphinMainWindow::invertSelection);
// setup 'View' menu
// (note that most of it is set up in DolphinViewActionHandler)
- KAction* split = actionCollection()->addAction("split_view");
+ QAction* split = actionCollection()->addAction("split_view");
split->setShortcut(Qt::Key_F3);
- connect(split, SIGNAL(triggered()), this, SLOT(toggleSplitView()));
+ connect(split, &QAction::triggered, this, &DolphinMainWindow::toggleSplitView);
- KAction* reload = actionCollection()->addAction("reload");
+ QAction* reload = actionCollection()->addAction("reload");
reload->setText(i18nc("@action:inmenu View", "Reload"));
reload->setShortcut(Qt::Key_F5);
- reload->setIcon(KIcon("view-refresh"));
- connect(reload, SIGNAL(triggered()), this, SLOT(reloadView()));
+ reload->setIcon(QIcon::fromTheme("view-refresh"));
+ connect(reload, &QAction::triggered, this, &DolphinMainWindow::reloadView);
- KAction* stop = actionCollection()->addAction("stop");
+ QAction* stop = actionCollection()->addAction("stop");
stop->setText(i18nc("@action:inmenu View", "Stop"));
stop->setToolTip(i18nc("@info", "Stop loading"));
- stop->setIcon(KIcon("process-stop"));
- connect(stop, SIGNAL(triggered()), this, SLOT(stopLoading()));
+ stop->setIcon(QIcon::fromTheme("process-stop"));
+ connect(stop, &QAction::triggered, this, &DolphinMainWindow::stopLoading);
KToggleAction* editableLocation = actionCollection()->add<KToggleAction>("editable_location");
editableLocation->setText(i18nc("@action:inmenu Navigation Bar", "Editable Location"));
editableLocation->setShortcut(Qt::Key_F6);
- connect(editableLocation, SIGNAL(triggered()), this, SLOT(toggleEditLocation()));
+ connect(editableLocation, &KToggleAction::triggered, this, &DolphinMainWindow::toggleEditLocation);
- KAction* replaceLocation = actionCollection()->addAction("replace_location");
+ QAction* replaceLocation = actionCollection()->addAction("replace_location");
replaceLocation->setText(i18nc("@action:inmenu Navigation Bar", "Replace Location"));
replaceLocation->setShortcut(Qt::CTRL | Qt::Key_L);
- connect(replaceLocation, SIGNAL(triggered()), this, SLOT(replaceLocation()));
+ connect(replaceLocation, &QAction::triggered, this, &DolphinMainWindow::replaceLocation);
// setup 'Go' menu
- KAction* backAction = KStandardAction::back(this, SLOT(goBack()), actionCollection());
- connect(backAction, SIGNAL(triggered(Qt::MouseButtons,Qt::KeyboardModifiers)), this, SLOT(goBack(Qt::MouseButtons)));
- KShortcut backShortcut = backAction->shortcut();
- backShortcut.setAlternate(Qt::Key_Backspace);
- backAction->setShortcut(backShortcut);
+ QAction* backAction = KStandardAction::back(this, SLOT(goBack()), actionCollection());
+ auto backShortcuts = backAction->shortcuts();
+ backShortcuts.append(QKeySequence(Qt::Key_Backspace));
+ backAction->setShortcuts(backShortcuts);
DolphinRecentTabsMenu* recentTabsMenu = new DolphinRecentTabsMenu(this);
actionCollection()->addAction("closed_tabs", recentTabsMenu);
- connect(this, SIGNAL(rememberClosedTab(KUrl,KUrl)),
- recentTabsMenu, SLOT(rememberClosedTab(KUrl,KUrl)));
- connect(recentTabsMenu, SIGNAL(restoreClosedTab(KUrl,KUrl)),
- this, SLOT(openNewActivatedTab(KUrl,KUrl)));
+ connect(m_tabWidget, SIGNAL(rememberClosedTab(KUrl,QByteArray)),
+ recentTabsMenu, SLOT(rememberClosedTab(KUrl,QByteArray)));
+ connect(recentTabsMenu, SIGNAL(restoreClosedTab(QByteArray)),
+ m_tabWidget, SLOT(restoreClosedTab(QByteArray)));
connect(recentTabsMenu, SIGNAL(closedTabsCountChanged(uint)),
this, SLOT(closedTabsCountChanged(uint)));
- KAction* undoCloseTab = actionCollection()->addAction("undo_close_tab");
+ QAction* undoCloseTab = actionCollection()->addAction("undo_close_tab");
undoCloseTab->setText(i18nc("@action:inmenu File", "Undo close tab"));
undoCloseTab->setShortcut(Qt::CTRL | Qt::SHIFT | Qt::Key_T);
- undoCloseTab->setIcon(KIcon("edit-undo"));
+ undoCloseTab->setIcon(QIcon::fromTheme("edit-undo"));
undoCloseTab->setEnabled(false);
connect(undoCloseTab, SIGNAL(triggered()), recentTabsMenu, SLOT(undoCloseTab()));
- KAction* forwardAction = KStandardAction::forward(this, SLOT(goForward()), actionCollection());
- connect(forwardAction, SIGNAL(triggered(Qt::MouseButtons,Qt::KeyboardModifiers)), this, SLOT(goForward(Qt::MouseButtons)));
-
- KAction* upAction = KStandardAction::up(this, SLOT(goUp()), actionCollection());
- connect(upAction, SIGNAL(triggered(Qt::MouseButtons,Qt::KeyboardModifiers)), this, SLOT(goUp(Qt::MouseButtons)));
-
- KAction* homeAction = KStandardAction::home(this, SLOT(goHome()), actionCollection());
- connect(homeAction, SIGNAL(triggered(Qt::MouseButtons,Qt::KeyboardModifiers)), this, SLOT(goHome(Qt::MouseButtons)));
+ KStandardAction::forward(this, SLOT(goForward()), actionCollection());
+ KStandardAction::up(this, SLOT(goUp()), actionCollection());
+ KStandardAction::home(this, SLOT(goHome()), actionCollection());
// setup 'Tools' menu
- KAction* showFilterBar = actionCollection()->addAction("show_filter_bar");
+ QAction* showFilterBar = actionCollection()->addAction("show_filter_bar");
showFilterBar->setText(i18nc("@action:inmenu Tools", "Show Filter Bar"));
- showFilterBar->setIcon(KIcon("view-filter"));
+ showFilterBar->setIcon(QIcon::fromTheme("view-filter"));
showFilterBar->setShortcut(Qt::CTRL | Qt::Key_I);
- connect(showFilterBar, SIGNAL(triggered()), this, SLOT(showFilterBar()));
+ connect(showFilterBar, &QAction::triggered, this, &DolphinMainWindow::showFilterBar);
- KAction* compareFiles = actionCollection()->addAction("compare_files");
+ QAction* compareFiles = actionCollection()->addAction("compare_files");
compareFiles->setText(i18nc("@action:inmenu Tools", "Compare Files"));
- compareFiles->setIcon(KIcon("kompare"));
+ compareFiles->setIcon(QIcon::fromTheme("kompare"));
compareFiles->setEnabled(false);
- connect(compareFiles, SIGNAL(triggered()), this, SLOT(compareFiles()));
+ connect(compareFiles, &QAction::triggered, this, &DolphinMainWindow::compareFiles);
- KAction* openTerminal = actionCollection()->addAction("open_terminal");
+ QAction* openTerminal = actionCollection()->addAction("open_terminal");
openTerminal->setText(i18nc("@action:inmenu Tools", "Open Terminal"));
- openTerminal->setIcon(KIcon("utilities-terminal"));
+ openTerminal->setIcon(QIcon::fromTheme("utilities-terminal"));
openTerminal->setShortcut(Qt::SHIFT | Qt::Key_F4);
- connect(openTerminal, SIGNAL(triggered()), this, SLOT(openTerminal()));
+ connect(openTerminal, &QAction::triggered, this, &DolphinMainWindow::openTerminal);
// setup 'Settings' menu
KToggleAction* showMenuBar = KStandardAction::showMenubar(0, 0, actionCollection());
- connect(showMenuBar, SIGNAL(triggered(bool)), // Fixes #286822
- this, SLOT(toggleShowMenuBar()), Qt::QueuedConnection);
+ connect(showMenuBar, &KToggleAction::triggered, // Fixes #286822
+ this, &DolphinMainWindow::toggleShowMenuBar, Qt::QueuedConnection);
KStandardAction::preferences(this, SLOT(editSettings()), actionCollection());
// not in menu actions
QList<QKeySequence> nextTabKeys;
- nextTabKeys.append(KStandardShortcut::tabNext().primary());
+ nextTabKeys.append(KStandardShortcut::tabNext().first()); //TODO: is this correct
nextTabKeys.append(QKeySequence(Qt::CTRL | Qt::Key_Tab));
QList<QKeySequence> prevTabKeys;
- prevTabKeys.append(KStandardShortcut::tabPrev().primary());
+ prevTabKeys.append(KStandardShortcut::tabPrev().first()); //TODO: is this correct
prevTabKeys.append(QKeySequence(Qt::CTRL | Qt::SHIFT | Qt::Key_Tab));
- KAction* activateNextTab = actionCollection()->addAction("activate_next_tab");
+ QAction* activateNextTab = actionCollection()->addAction("activate_next_tab");
activateNextTab->setIconText(i18nc("@action:inmenu", "Next Tab"));
activateNextTab->setText(i18nc("@action:inmenu", "Activate Next Tab"));
activateNextTab->setEnabled(false);
- connect(activateNextTab, &QAction::triggered, this, &DolphinMainWindow::activateNextTab);
- connect(activateNextTab, SIGNAL(triggered()), m_tabWidget, SLOT(activateNextTab()));
++ connect(activateNextTab, &QAction::triggered, m_tabWidget, &DolphinTabWidget::activateNextTab);
activateNextTab->setShortcuts(QApplication::isRightToLeft() ? prevTabKeys : nextTabKeys);
- KAction* activatePrevTab = actionCollection()->addAction("activate_prev_tab");
+ QAction* activatePrevTab = actionCollection()->addAction("activate_prev_tab");
activatePrevTab->setIconText(i18nc("@action:inmenu", "Previous Tab"));
activatePrevTab->setText(i18nc("@action:inmenu", "Activate Previous Tab"));
activatePrevTab->setEnabled(false);
- connect(activatePrevTab, &QAction::triggered, this, &DolphinMainWindow::activatePrevTab);
- connect(activatePrevTab, SIGNAL(triggered()), m_tabWidget, SLOT(activatePrevTab()));
++ connect(activatePrevTab, &QAction::triggered, m_tabWidget, &DolphinTabWidget::activatePrevTab);
activatePrevTab->setShortcuts(QApplication::isRightToLeft() ? nextTabKeys : prevTabKeys);
// for context menu
- KAction* openInNewTab = actionCollection()->addAction("open_in_new_tab");
+ QAction* 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()));
+ openInNewTab->setIcon(QIcon::fromTheme("tab-new"));
+ connect(openInNewTab, &QAction::triggered, this, &DolphinMainWindow::openInNewTab);
- KAction* openInNewTabs = actionCollection()->addAction("open_in_new_tabs");
+ QAction* openInNewTabs = actionCollection()->addAction("open_in_new_tabs");
openInNewTabs->setText(i18nc("@action:inmenu", "Open in New Tabs"));
- openInNewTabs->setIcon(KIcon("tab-new"));
- connect(openInNewTabs, SIGNAL(triggered()), this, SLOT(openInNewTab()));
+ openInNewTabs->setIcon(QIcon::fromTheme("tab-new"));
+ connect(openInNewTabs, &QAction::triggered, this, &DolphinMainWindow::openInNewTab);
- KAction* openInNewWindow = actionCollection()->addAction("open_in_new_window");
+ QAction* 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()));
+ openInNewWindow->setIcon(QIcon::fromTheme("window-new"));
+ connect(openInNewWindow, &QAction::triggered, this, &DolphinMainWindow::openInNewWindow);
}
void DolphinMainWindow::setupDockWidgets()
KDualAction* lockLayoutAction = actionCollection()->add<KDualAction>("lock_panels");
lockLayoutAction->setActiveText(i18nc("@action:inmenu Panels", "Unlock Panels"));
- lockLayoutAction->setActiveIcon(KIcon("object-unlocked"));
+ lockLayoutAction->setActiveIcon(QIcon::fromTheme("object-unlocked"));
lockLayoutAction->setInactiveText(i18nc("@action:inmenu Panels", "Lock Panels"));
- lockLayoutAction->setInactiveIcon(KIcon("object-locked"));
+ lockLayoutAction->setInactiveIcon(QIcon::fromTheme("object-locked"));
lockLayoutAction->setActive(lock);
- connect(lockLayoutAction, SIGNAL(triggered()), this, SLOT(togglePanelLockState()));
+ connect(lockLayoutAction, &KDualAction::triggered, this, &DolphinMainWindow::togglePanelLockState);
// Setup "Information"
DolphinDockWidget* infoDock = new DolphinDockWidget(i18nc("@title:window", "Information"));
infoDock->setLocked(lock);
infoDock->setObjectName("infoDock");
infoDock->setAllowedAreas(Qt::LeftDockWidgetArea | Qt::RightDockWidgetArea);
- Panel* infoPanel = new InformationPanel(infoDock);
+ InformationPanel* infoPanel = new InformationPanel(infoDock);
infoPanel->setCustomContextMenuActions(QList<QAction*>() << lockLayoutAction);
- connect(infoPanel, SIGNAL(urlActivated(KUrl)), this, SLOT(handleUrl(KUrl)));
+ connect(infoPanel, &InformationPanel::urlActivated, this, &DolphinMainWindow::handleUrl);
infoDock->setWidget(infoPanel);
QAction* infoAction = infoDock->toggleViewAction();
- createPanelAction(KIcon("dialog-information"), Qt::Key_F11, infoAction, "show_information_panel");
+ createPanelAction(QIcon::fromTheme("dialog-information"), Qt::Key_F11, infoAction, "show_information_panel");
addDockWidget(Qt::RightDockWidgetArea, infoDock);
- connect(this, SIGNAL(urlChanged(KUrl)),
- infoPanel, SLOT(setUrl(KUrl)));
- connect(this, SIGNAL(selectionChanged(KFileItemList)),
- infoPanel, SLOT(setSelection(KFileItemList)));
- connect(this, SIGNAL(requestItemInfo(KFileItem)),
- infoPanel, SLOT(requestDelayedItemInfo(KFileItem)));
+ connect(this, &DolphinMainWindow::urlChanged,
+ infoPanel, &InformationPanel::setUrl);
+ connect(this, &DolphinMainWindow::selectionChanged,
+ infoPanel, &InformationPanel::setSelection);
+ connect(this, &DolphinMainWindow::requestItemInfo,
+ infoPanel, &InformationPanel::requestDelayedItemInfo);
// Setup "Folders"
DolphinDockWidget* foldersDock = new DolphinDockWidget(i18nc("@title:window", "Folders"));
foldersDock->setWidget(foldersPanel);
QAction* foldersAction = foldersDock->toggleViewAction();
- createPanelAction(KIcon("folder"), Qt::Key_F7, foldersAction, "show_folders_panel");
+ createPanelAction(QIcon::fromTheme("folder"), Qt::Key_F7, foldersAction, "show_folders_panel");
addDockWidget(Qt::LeftDockWidgetArea, foldersDock);
- connect(this, SIGNAL(urlChanged(KUrl)),
- foldersPanel, SLOT(setUrl(KUrl)));
- connect(foldersPanel, SIGNAL(folderActivated(KUrl)),
- this, SLOT(changeUrl(KUrl)));
+ connect(this, &DolphinMainWindow::urlChanged,
+ foldersPanel, &FoldersPanel::setUrl);
+ connect(foldersPanel, &FoldersPanel::folderActivated,
+ this, &DolphinMainWindow::changeUrl);
connect(foldersPanel, SIGNAL(folderMiddleClicked(KUrl)),
this, SLOT(openNewTab(KUrl)));
- connect(foldersPanel, SIGNAL(errorMessage(QString)),
- this, SLOT(slotPanelErrorMessage(QString)));
+ connect(foldersPanel, &FoldersPanel::errorMessage,
+ this, &DolphinMainWindow::slotPanelErrorMessage);
// Setup "Terminal"
#ifndef Q_OS_WIN
terminalDock->setLocked(lock);
terminalDock->setObjectName("terminalDock");
terminalDock->setAllowedAreas(Qt::TopDockWidgetArea | Qt::BottomDockWidgetArea);
- Panel* terminalPanel = new TerminalPanel(terminalDock);
+ TerminalPanel* terminalPanel = new TerminalPanel(terminalDock);
terminalPanel->setCustomContextMenuActions(QList<QAction*>() << lockLayoutAction);
terminalDock->setWidget(terminalPanel);
- connect(terminalPanel, SIGNAL(hideTerminalPanel()), terminalDock, SLOT(hide()));
- connect(terminalPanel, SIGNAL(changeUrl(KUrl)), this, SLOT(slotTerminalDirectoryChanged(KUrl)));
- connect(terminalDock, SIGNAL(visibilityChanged(bool)),
- terminalPanel, SLOT(dockVisibilityChanged()));
+ connect(terminalPanel, &TerminalPanel::hideTerminalPanel, terminalDock, &DolphinDockWidget::hide);
+ connect(terminalPanel, &TerminalPanel::changeUrl, this, &DolphinMainWindow::slotTerminalDirectoryChanged);
+ connect(terminalDock, &DolphinDockWidget::visibilityChanged,
+ terminalPanel, &TerminalPanel::dockVisibilityChanged);
QAction* terminalAction = terminalDock->toggleViewAction();
- createPanelAction(KIcon("utilities-terminal"), Qt::Key_F4, terminalAction, "show_terminal_panel");
+ createPanelAction(QIcon::fromTheme("utilities-terminal"), Qt::Key_F4, terminalAction, "show_terminal_panel");
addDockWidget(Qt::BottomDockWidgetArea, terminalDock);
- connect(this, SIGNAL(urlChanged(KUrl)),
- terminalPanel, SLOT(setUrl(KUrl)));
+ connect(this, &DolphinMainWindow::urlChanged,
+ terminalPanel, &TerminalPanel::setUrl);
#endif
if (GeneralSettings::version() < 200) {
placesDock->setWidget(placesPanel);
QAction* placesAction = placesDock->toggleViewAction();
- createPanelAction(KIcon("bookmarks"), Qt::Key_F9, placesAction, "show_places_panel");
+ createPanelAction(QIcon::fromTheme("bookmarks"), Qt::Key_F9, placesAction, "show_places_panel");
addDockWidget(Qt::LeftDockWidgetArea, placesDock);
- connect(placesPanel, SIGNAL(placeActivated(KUrl)),
- this, SLOT(slotPlaceActivated(KUrl)));
+ connect(placesPanel, &PlacesPanel::placeActivated,
+ this, &DolphinMainWindow::slotPlaceActivated);
connect(placesPanel, SIGNAL(placeMiddleClicked(KUrl)),
this, SLOT(openNewTab(KUrl)));
- connect(placesPanel, SIGNAL(errorMessage(QString)),
- this, SLOT(slotPanelErrorMessage(QString)));
- connect(this, SIGNAL(urlChanged(KUrl)),
- placesPanel, SLOT(setUrl(KUrl)));
- connect(placesDock, SIGNAL(visibilityChanged(bool)),
- m_tabWidget, SLOT(slotPlacesPanelVisibilityChanged(bool)));
- connect(this, SIGNAL(settingsChanged()),
- placesPanel, SLOT(readSettings()));
+ connect(placesPanel, &PlacesPanel::errorMessage,
+ this, &DolphinMainWindow::slotPanelErrorMessage);
+ connect(this, &DolphinMainWindow::urlChanged,
+ placesPanel, &PlacesPanel::setUrl);
+ connect(placesDock, &DolphinDockWidget::visibilityChanged,
- this, &DolphinMainWindow::slotPlacesPanelVisibilityChanged);
++ m_tabWidget, &DolphinTabWidget::slotPlacesPanelVisibilityChanged);
+ connect(this, &DolphinMainWindow::settingsChanged,
+ placesPanel, &PlacesPanel::readSettings);
+ m_tabWidget->slotPlacesPanelVisibilityChanged(placesPanel->isVisible());
+
// Add actions into the "Panels" menu
KActionMenu* panelsMenu = new KActionMenu(i18nc("@action:inmenu View", "Panels"), this);
actionCollection()->addAction("panels", panelsMenu);
Q_ASSERT(!m_controlButton);
m_controlButton = new QToolButton(this);
- m_controlButton->setIcon(KIcon("applications-system"));
+ m_controlButton->setIcon(QIcon::fromTheme("applications-system"));
m_controlButton->setText(i18nc("@action", "Control"));
m_controlButton->setPopupMode(QToolButton::InstantPopup);
m_controlButton->setToolButtonStyle(toolBar()->toolButtonStyle());
KMenu* controlMenu = new KMenu(m_controlButton);
- connect(controlMenu, SIGNAL(aboutToShow()), this, SLOT(updateControlMenu()));
+ connect(controlMenu, &KMenu::aboutToShow, this, &DolphinMainWindow::updateControlMenu);
m_controlButton->setMenu(controlMenu);
toolBar()->addWidget(m_controlButton);
- connect(toolBar(), SIGNAL(iconSizeChanged(QSize)),
- m_controlButton, SLOT(setIconSize(QSize)));
- connect(toolBar(), SIGNAL(toolButtonStyleChanged(Qt::ToolButtonStyle)),
- m_controlButton, SLOT(setToolButtonStyle(Qt::ToolButtonStyle)));
+ connect(toolBar(), &KToolBar::iconSizeChanged,
+ m_controlButton, &QToolButton::setIconSize);
+ connect(toolBar(), &KToolBar::toolButtonStyleChanged,
+ m_controlButton, &QToolButton::setToolButtonStyle);
// The added widgets are owned by the toolbar and may get deleted when e.g. the toolbar
// gets edited. In this case we must add them again. The adding is done asynchronously by
// m_updateToolBarTimer.
- connect(m_controlButton, SIGNAL(destroyed()), this, SLOT(slotControlButtonDeleted()));
+ connect(m_controlButton, &QToolButton::destroyed, this, &DolphinMainWindow::slotControlButtonDeleted);
m_updateToolBarTimer = new QTimer(this);
m_updateToolBarTimer->setInterval(500);
- connect(m_updateToolBarTimer, SIGNAL(timeout()), this, SLOT(updateToolBar()));
+ connect(m_updateToolBarTimer, &QTimer::timeout, this, &DolphinMainWindow::updateToolBar);
}
void DolphinMainWindow::deleteControlButton()
void DolphinMainWindow::refreshViews()
{
- foreach (DolphinTabPage* tabPage, m_viewTab) {
- tabPage->refreshViews();
- }
+ m_tabWidget->refreshViews();
if (GeneralSettings::modifiedStartupSettings()) {
// The startup settings have been changed by the user (see bug #254947).
// Synchronize the split-view setting with the active view:
const bool splitView = GeneralSettings::splitView();
- m_viewTab.at(m_tabIndex)->setSplitViewEnabled(splitView);
+ m_tabWidget->currentTabPage()->setSplitViewEnabled(splitView);
updateSplitAction();
}
void DolphinMainWindow::connectViewSignals(DolphinViewContainer* container)
{
- connect(container, SIGNAL(showFilterBarChanged(bool)),
- this, SLOT(updateFilterBarAction(bool)));
- connect(container, SIGNAL(writeStateChanged(bool)),
- this, SLOT(slotWriteStateChanged(bool)));
+ connect(container, &DolphinViewContainer::showFilterBarChanged,
+ this, &DolphinMainWindow::updateFilterBarAction);
+ connect(container, &DolphinViewContainer::writeStateChanged,
+ this, &DolphinMainWindow::slotWriteStateChanged);
const DolphinView* view = container->view();
- connect(view, SIGNAL(selectionChanged(KFileItemList)),
- this, SLOT(slotSelectionChanged(KFileItemList)));
- connect(view, SIGNAL(requestItemInfo(KFileItem)),
- this, SLOT(slotRequestItemInfo(KFileItem)));
+ connect(view, &DolphinView::selectionChanged,
+ this, &DolphinMainWindow::slotSelectionChanged);
+ connect(view, &DolphinView::requestItemInfo,
+ this, &DolphinMainWindow::slotRequestItemInfo);
connect(view, SIGNAL(tabRequested(KUrl)),
this, SLOT(openNewTab(KUrl)));
- connect(view, SIGNAL(requestContextMenu(QPoint,KFileItem,KUrl,QList<QAction*>)),
- this, SLOT(openContextMenu(QPoint,KFileItem,KUrl,QList<QAction*>)));
- connect(view, SIGNAL(directoryLoadingStarted()),
- this, SLOT(enableStopAction()));
- connect(view, SIGNAL(directoryLoadingCompleted()),
- this, SLOT(disableStopAction()));
- connect(view, SIGNAL(goBackRequested()),
- this, SLOT(goBack()));
- connect(view, SIGNAL(goForwardRequested()),
- this, SLOT(goForward()));
+ connect(view, &DolphinView::requestContextMenu,
+ this, &DolphinMainWindow::openContextMenu);
+ connect(view, &DolphinView::directoryLoadingStarted,
+ this, &DolphinMainWindow::enableStopAction);
+ connect(view, &DolphinView::directoryLoadingCompleted,
+ this, &DolphinMainWindow::disableStopAction);
+ connect(view, &DolphinView::goBackRequested,
+ this, static_cast<void(DolphinMainWindow::*)()>(&DolphinMainWindow::goBack));
+ connect(view, &DolphinView::goForwardRequested,
+ this, static_cast<void(DolphinMainWindow::*)()>(&DolphinMainWindow::goForward));
const KUrlNavigator* navigator = container->urlNavigator();
- connect(navigator, SIGNAL(urlChanged(KUrl)),
- this, SLOT(changeUrl(KUrl)));
- connect(navigator, SIGNAL(historyChanged()),
- this, SLOT(updateHistory()));
- connect(navigator, SIGNAL(editableStateChanged(bool)),
- this, SLOT(slotEditableStateChanged(bool)));
+ connect(navigator, &KUrlNavigator::urlChanged,
+ this, &DolphinMainWindow::changeUrl);
+ connect(navigator, &KUrlNavigator::historyChanged,
+ this, &DolphinMainWindow::updateHistory);
+ connect(navigator, &KUrlNavigator::editableStateChanged,
+ this, &DolphinMainWindow::slotEditableStateChanged);
connect(navigator, SIGNAL(tabRequested(KUrl)),
this, SLOT(openNewTab(KUrl)));
}
void DolphinMainWindow::updateSplitAction()
{
QAction* splitAction = actionCollection()->action("split_view");
- const DolphinTabPage* tabPage = m_viewTab.at(m_tabIndex);
+ const DolphinTabPage* tabPage = m_tabWidget->currentTabPage();
if (tabPage->splitViewEnabled()) {
if (tabPage->primaryViewActive()) {
splitAction->setText(i18nc("@action:intoolbar Close left view", "Close"));
} else {
splitAction->setText(i18nc("@action:intoolbar Split view", "Split"));
splitAction->setToolTip(i18nc("@info", "Split view"));
- splitAction->setIcon(KIcon("view-right-new"));
+ splitAction->setIcon(QIcon::fromTheme("view-right-new"));
}
}
- QString DolphinMainWindow::tabName(const KUrl& url) const
- {
- QString name;
- if (url.equals(KUrl("file:///"))) {
- name = '/';
- } else {
- name = url.fileName();
- if (name.isEmpty()) {
- name = url.protocol();
- } else {
- // Make sure that a '&' inside the directory name is displayed correctly
- // and not misinterpreted as a keyboard shortcut in QTabBar::setTabText()
- name.replace('&', "&&");
- }
- }
- return name;
- }
-
bool DolphinMainWindow::isKompareInstalled() const
{
static bool initialized = false;
return installed;
}
- void DolphinMainWindow::setUrlAsCaption(const KUrl& url)
- {
- QString caption;
- if (!url.isLocalFile()) {
- caption.append(url.protocol() + " - ");
- if (url.hasHost()) {
- caption.append(url.host() + " - ");
- }
- }
-
- const QString fileName = url.fileName().isEmpty() ? "/" : url.fileName();
- caption.append(fileName);
-
- setCaption(caption);
- }
-
- QString DolphinMainWindow::squeezedText(const QString& text) const
- {
- const QFontMetrics fm = fontMetrics();
- return fm.elidedText(text, Qt::ElideMiddle, fm.maxWidth() * 10);
- }
-
-void DolphinMainWindow::createPanelAction(const KIcon& icon,
+void DolphinMainWindow::createPanelAction(const QIcon& icon,
const QKeySequence& shortcut,
QAction* dockAction,
const QString& actionName)
{
- KAction* panelAction = actionCollection()->addAction(actionName);
+ QAction* panelAction = actionCollection()->addAction(actionName);
panelAction->setCheckable(true);
panelAction->setChecked(dockAction->isChecked());
panelAction->setText(dockAction->text());
panelAction->setIcon(icon);
panelAction->setShortcut(shortcut);
- connect(panelAction, SIGNAL(triggered()), dockAction, SLOT(trigger()));
- connect(dockAction, SIGNAL(toggled(bool)), panelAction, SLOT(setChecked(bool)));
+ connect(panelAction, &QAction::triggered, dockAction, &QAction::trigger);
+ connect(dockAction, &QAction::toggled, panelAction, &QAction::setChecked);
}
DolphinMainWindow::UndoUiInterface::UndoUiInterface() :
}
}
-#include "dolphinmainwindow.moc"
#include <ksortablelist.h>
#include <kxmlguiwindow.h>
#include <KIcon>
+#include <KUrl>
#include <QList>
#include <QWeakPointer>
class DolphinViewActionHandler;
class DolphinApplication;
class DolphinSettingsDialog;
- class DolphinTabBar;
class DolphinViewContainer;
class DolphinRemoteEncoding;
- class DolphinTabPage;
+ class DolphinTabWidget;
-class KAction;
class KFileItem;
class KFileItemList;
class KJob;
class KNewFileMenu;
- class QSplitter;
-class KUrl;
class QToolButton;
- class QVBoxLayout;
+class QIcon;
/**
* @short Main window for Dolphin.
*/
void settingsChanged();
- /**
- * Is emitted when a tab has been closed.
- */
- void rememberClosedTab(const KUrl& primaryUrl, const KUrl& secondaryUrl);
-
protected:
/** @see QWidget::showEvent() */
virtual void showEvent(QShowEvent* event);
*/
void togglePanelLockState();
- /**
- * Is invoked if the Places panel got visible/invisible and takes care
- * that the places-selector of all views is only shown if the Places panel
- * is invisible.
- */
- void slotPlacesPanelVisibilityChanged(bool visible);
-
/** Goes back one step of the URL history. */
void goBack();
/** Open a new main window. */
void openNewMainWindow();
- /** Opens a new view with the current URL that is part of a tab. */
- void openNewTab();
+ /**
+ * Opens a new view with the current URL that is part of a tab and
+ * activates it.
+ */
+ void openNewActivatedTab();
/**
* Opens a new tab in the background showing the URL \a primaryUrl and the
*/
void openNewActivatedTab(const KUrl& primaryUrl, const KUrl& secondaryUrl = KUrl());
- /**
- * Opens a new tab showing the url from tab at the given \a index and
- * activates the tab.
- */
- void openNewActivatedTab(int index);
-
- void activateNextTab();
-
- void activatePrevTab();
-
/**
* Opens the selected folder in a new tab.
*/
*/
void showCommand(CommandType command);
- /**
- * Activates the tab with the index \a index, which means that the current view
- * is replaced by the view of the given tab.
- */
- void setActiveTab(int index);
-
- /** Closes the currently active tab. */
- void closeTab();
-
- /**
- * Closes the tab with the index \a index and activates the tab with index - 1.
- */
- void closeTab(int index);
-
- /**
- * Opens the tab with the index \a index in a new Dolphin instance and closes
- * this tab.
- */
- void detachTab(int index);
-
- /**
- * Is connected to the QTabBar signal tabMoved(int from, int to).
- * Reorders the list of tabs after a tab was moved in the tab bar
- * and sets m_tabIndex to the new index of the current tab.
- */
- void slotTabMoved(int from, int to);
-
/**
* If the URL can be listed, open it in the current view, otherwise
* run it through KRun.
*/
void slotHandleUrlStatFinished(KJob* job);
- /**
- * Is connected to the KTabBar signal receivedDropEvent.
- * Allows dragging and dropping files onto tabs.
- */
- void tabDropEvent(int tab, QDropEvent* event);
-
/**
* Is invoked when the write state of a folder has been changed and
* enables/disables the "Create New..." menu entry.
*/
void slotPlaceActivated(const KUrl& url);
- void activeViewChanged();
+ /**
+ * Is called if the another view has been activated by changing the current
+ * tab or activating another view in split-view mode.
+ *
+ * Activates the given view, which means that all menu actions are applied
+ * to this view. When having a split view setup, the nonactive view is
+ * usually shown in darker colors.
+ */
+ void activeViewChanged(DolphinViewContainer* viewContainer);
void closedTabsCountChanged(unsigned int count);
- private:
/**
- * Activates the given view, which means that
- * all menu actions are applied to this view. When
- * having a split view setup, the nonactive view
- * is usually shown in darker colors.
+ * Is called if a new tab has been opened or a tab has been closed to
+ * enable/disable the tab actions.
*/
- void setActiveViewContainer(DolphinViewContainer* view);
+ void tabCountChanged(int count);
+ /**
+ * Sets the window caption to url.fileName() if this is non-empty,
+ * "/" if the URL is "file:///", and url.protocol() otherwise.
+ */
+ void setUrlAsCaption(const KUrl& url);
+
+ private:
void setupActions();
void setupDockWidgets();
void updateEditActions();
*/
void updateSplitAction();
- /** Returns the name of the tab for the URL \a url. */
- QString tabName(const KUrl& url) const;
-
-
bool isKompareInstalled() const;
- /**
- * Sets the window caption to url.fileName() if this is non-empty,
- * "/" if the URL is "file:///", and url.protocol() otherwise.
- */
- void setUrlAsCaption(const KUrl& url);
-
- QString squeezedText(const QString& text) const;
-
/**
* Creates an action for showing/hiding a panel, that is accessible
* in "Configure toolbars..." and "Configure shortcuts...". This is necessary
* as the action for toggling the dock visibility is done by Qt which
* is no KAction instance.
*/
- void createPanelAction(const KIcon& icon,
+ void createPanelAction(const QIcon &icon,
const QKeySequence& shortcut,
QAction* dockAction,
const QString& actionName);
};
KNewFileMenu* m_newFileMenu;
- DolphinTabBar* m_tabBar;
+ DolphinTabWidget* m_tabWidget;
DolphinViewContainer* m_activeViewContainer;
- QVBoxLayout* m_centralWidgetLayout;
int m_id;
- int m_tabIndex;
- QList<DolphinTabPage*> m_viewTab;
-
DolphinViewActionHandler* m_actionHandler;
DolphinRemoteEncoding* m_remoteEncoding;
QWeakPointer<DolphinSettingsDialog> m_settingsDialog;
#include <KLocalizedString>
#include <KAcceleratorManager>
--#include <KMimeType>
++#include <kio/global.h>
#include <KMenu>
DolphinRecentTabsMenu::DolphinRecentTabsMenu(QObject* parent) :
- KActionMenu(KIcon("edit-undo"), i18n("Recently Closed Tabs"), parent)
+ KActionMenu(QIcon::fromTheme("edit-undo"), i18n("Recently Closed Tabs"), parent)
{
setDelayed(false);
setEnabled(false);
m_clearListAction = new QAction(i18n("Empty Recently Closed Tabs"), this);
- m_clearListAction->setIcon(KIcon("edit-clear-list"));
+ m_clearListAction->setIcon(QIcon::fromTheme("edit-clear-list"));
addAction(m_clearListAction);
addSeparator();
this, SLOT(handleAction(QAction*)));
}
- void DolphinRecentTabsMenu::rememberClosedTab(const KUrl& primaryUrl, const KUrl& secondaryUrl)
+ void DolphinRecentTabsMenu::rememberClosedTab(const KUrl& url, const QByteArray& state)
{
QAction* action = new QAction(menu());
- action->setText(primaryUrl.path());
-
- const QString iconName = KMimeType::iconNameForUrl(primaryUrl);
+ action->setText(url.path());
+ action->setData(state);
- const QString iconName = KMimeType::iconNameForUrl(url);
- action->setIcon(KIcon(iconName));
++ const QString iconName = KIO::iconNameForUrl(url);
+ action->setIcon(QIcon::fromTheme(iconName));
- KUrl::List urls;
- urls << primaryUrl;
- urls << secondaryUrl;
- action->setData(QVariant::fromValue(urls));
-
// Add the closed tab menu entry after the separator and
// "Empty Recently Closed Tabs" entry
if (menu()->actions().size() == 2) {
}
emit closedTabsCountChanged(0);
} else {
- const KUrl::List urls = action->data().value<KUrl::List>();
+ const QByteArray state = action->data().value<QByteArray>();
removeAction(action);
delete action;
action = 0;
- if (urls.count() == 2) {
- emit restoreClosedTab(urls.first(), urls.last());
- }
+ emit restoreClosedTab(state);
emit closedTabsCountChanged(menu()->actions().size() - 2);
}
--- /dev/null
-#include <KIcon>
+ /***************************************************************************
+ * Copyright (C) 2014 by Emmanuel Pescosta <emmanuelpescosta099@gmail.com> *
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ * This program is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
+ * GNU General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU General Public License *
+ * along with this program; if not, write to the *
+ * Free Software Foundation, Inc., *
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA *
+ ***************************************************************************/
+
+ #include "dolphintabwidget.h"
+
+ #include "dolphintabbar.h"
+ #include "dolphintabpage.h"
+ #include "dolphinviewcontainer.h"
+ #include "dolphin_generalsettings.h"
+ #include "views/draganddrophelper.h"
+
+ #include <QApplication>
+ #include <KConfigGroup>
- addTab(tabPage, KIcon(KMimeType::iconNameForUrl(primaryUrl)), tabName(primaryUrl));
++#include <kio/global.h>
+ #include <KRun>
+
+ DolphinTabWidget::DolphinTabWidget(QWidget* parent) :
+ QTabWidget(parent),
+ m_placesSelectorVisible(true)
+ {
+ connect(this, SIGNAL(tabCloseRequested(int)),
+ this, SLOT(closeTab(int)));
+ connect(this, SIGNAL(currentChanged(int)),
+ this, SLOT(currentTabChanged(int)));
+
+ DolphinTabBar* tabBar = new DolphinTabBar(this);
+ connect(tabBar, SIGNAL(openNewActivatedTab(int)),
+ this, SLOT(openNewActivatedTab(int)));
+ connect(tabBar, SIGNAL(tabDropEvent(int,QDropEvent*)),
+ this, SLOT(tabDropEvent(int,QDropEvent*)));
+ connect(tabBar, SIGNAL(tabDetachRequested(int)),
+ this, SLOT(detachTab(int)));
+ tabBar->hide();
+
+ setTabBar(tabBar);
+ setDocumentMode(true);
+ setElideMode(Qt::ElideRight);
+ setUsesScrollButtons(true);
+ }
+
+ DolphinTabPage* DolphinTabWidget::currentTabPage() const
+ {
+ return tabPageAt(currentIndex());
+ }
+
+ DolphinTabPage* DolphinTabWidget::tabPageAt(const int index) const
+ {
+ return static_cast<DolphinTabPage*>(widget(index));
+ }
+
+ void DolphinTabWidget::saveProperties(KConfigGroup& group) const
+ {
+ const int tabCount = count();
+ group.writeEntry("Tab Count", tabCount);
+ group.writeEntry("Active Tab Index", currentIndex());
+
+ for (int i = 0; i < tabCount; ++i) {
+ const DolphinTabPage* tabPage = tabPageAt(i);
+ group.writeEntry("Tab Data " % QString::number(i), tabPage->saveState());
+ }
+ }
+
+ void DolphinTabWidget::readProperties(const KConfigGroup& group)
+ {
+ const int tabCount = group.readEntry("Tab Count", 0);
+ for (int i = 0; i < tabCount; ++i) {
+ if (i >= count()) {
+ openNewActivatedTab();
+ }
+ if (group.hasKey("Tab Data " % QString::number(i))) {
+ // Tab state created with Dolphin > 4.14.x
+ const QByteArray state = group.readEntry("Tab Data " % QString::number(i), QByteArray());
+ tabPageAt(i)->restoreState(state);
+ } else {
+ // Tab state created with Dolphin <= 4.14.x
+ const QByteArray state = group.readEntry("Tab " % QString::number(i), QByteArray());
+ tabPageAt(i)->restoreStateV1(state);
+ }
+ }
+
+ const int index = group.readEntry("Active Tab Index", 0);
+ setCurrentIndex(index);
+ }
+
+ void DolphinTabWidget::refreshViews()
+ {
+ const int tabCount = count();
+ for (int i = 0; i < tabCount; ++i) {
+ tabPageAt(i)->refreshViews();
+ }
+ }
+
+ void DolphinTabWidget::openNewActivatedTab()
+ {
+ const DolphinViewContainer* oldActiveViewContainer = currentTabPage()->activeViewContainer();
+ Q_ASSERT(oldActiveViewContainer);
+
+ const bool isUrlEditable = oldActiveViewContainer->urlNavigator()->isUrlEditable();
+
+ openNewActivatedTab(oldActiveViewContainer->url());
+
+ DolphinViewContainer* newActiveViewContainer = currentTabPage()->activeViewContainer();
+ Q_ASSERT(newActiveViewContainer);
+
+ // The URL navigator of the new tab should have the same editable state
+ // as the current tab
+ KUrlNavigator* navigator = newActiveViewContainer->urlNavigator();
+ 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 DolphinTabWidget::openNewActivatedTab(const KUrl& primaryUrl, const KUrl& secondaryUrl)
+ {
+ openNewTab(primaryUrl, secondaryUrl);
+ setCurrentIndex(count() - 1);
+ }
+
+ void DolphinTabWidget::openNewTab(const KUrl& primaryUrl, const KUrl& secondaryUrl)
+ {
+ QWidget* focusWidget = QApplication::focusWidget();
+
+ DolphinTabPage* tabPage = new DolphinTabPage(primaryUrl, secondaryUrl, this);
+ tabPage->setPlacesSelectorVisible(m_placesSelectorVisible);
+ connect(tabPage, SIGNAL(activeViewChanged(DolphinViewContainer*)),
+ this, SIGNAL(activeViewChanged(DolphinViewContainer*)));
+ connect(tabPage, SIGNAL(activeViewUrlChanged(KUrl)),
+ this, SLOT(tabUrlChanged(KUrl)));
- tabBar()->setTabIcon(index, KIcon(KMimeType::iconNameForUrl(url)));
++ addTab(tabPage, QIcon::fromTheme(KIO::iconNameForUrl(primaryUrl)), tabName(primaryUrl));
+
+ if (focusWidget) {
+ // The DolphinViewContainer grabbed the keyboard focus. As the tab is opened
+ // in background, assure that the previous focused widget gets the focus back.
+ focusWidget->setFocus();
+ }
+ }
+
+ void DolphinTabWidget::openDirectories(const QList<KUrl>& dirs)
+ {
+ const bool hasSplitView = GeneralSettings::splitView();
+
+ // Open each directory inside a new tab. If the "split view" option has been enabled,
+ // always show two directories within one tab.
+ QList<KUrl>::const_iterator it = dirs.constBegin();
+ while (it != dirs.constEnd()) {
+ const KUrl& primaryUrl = *(it++);
+ if (hasSplitView && (it != dirs.constEnd())) {
+ const KUrl& secondaryUrl = *(it++);
+ openNewTab(primaryUrl, secondaryUrl);
+ } else {
+ openNewTab(primaryUrl);
+ }
+ }
+ }
+
+ void DolphinTabWidget::openFiles(const QList<KUrl>& files)
+ {
+ if (files.isEmpty()) {
+ return;
+ }
+
+ // Get all distinct directories from 'files' and open a tab
+ // for each directory. If the "split view" option is enabled, two
+ // directories are shown inside one tab (see openDirectories()).
+ QList<KUrl> dirs;
+ foreach (const KUrl& url, files) {
+ const KUrl dir(url.directory());
+ if (!dirs.contains(dir)) {
+ dirs.append(dir);
+ }
+ }
+
+ const int oldTabCount = count();
+ openDirectories(dirs);
+ const int tabCount = count();
+
+ // Select the files. Although the files can be split between several
+ // tabs, there is no need to split 'files' accordingly, as
+ // the DolphinView will just ignore invalid selections.
+ for (int i = oldTabCount; i < tabCount; ++i) {
+ DolphinTabPage* tabPage = tabPageAt(i);
+ tabPage->markUrlsAsSelected(files);
+ tabPage->markUrlAsCurrent(files.first());
+ }
+ }
+
+ void DolphinTabWidget::closeTab()
+ {
+ closeTab(currentIndex());
+ }
+
+ void DolphinTabWidget::closeTab(const int index)
+ {
+ Q_ASSERT(index >= 0);
+ Q_ASSERT(index < count());
+
+ if (count() < 2) {
+ // Never close the last tab.
+ return;
+ }
+
+ DolphinTabPage* tabPage = tabPageAt(index);
+ emit rememberClosedTab(tabPage->activeViewContainer()->url(), tabPage->saveState());
+
+ removeTab(index);
+ tabPage->deleteLater();
+ }
+
+ void DolphinTabWidget::activateNextTab()
+ {
+ const int index = currentIndex() + 1;
+ setCurrentIndex(index < count() ? index : 0);
+ }
+
+ void DolphinTabWidget::activatePrevTab()
+ {
+ const int index = currentIndex() - 1;
+ setCurrentIndex(index >= 0 ? index : (count() - 1));
+ }
+
+ void DolphinTabWidget::slotPlacesPanelVisibilityChanged(bool visible)
+ {
+ // The places-selector from the URL navigator should only be shown
+ // if the places dock is invisible
+ m_placesSelectorVisible = !visible;
+
+ const int tabCount = count();
+ for (int i = 0; i < tabCount; ++i) {
+ DolphinTabPage* tabPage = tabPageAt(i);
+ tabPage->setPlacesSelectorVisible(m_placesSelectorVisible);
+ }
+ }
+
+ void DolphinTabWidget::restoreClosedTab(const QByteArray& state)
+ {
+ openNewActivatedTab();
+ currentTabPage()->restoreState(state);
+ }
+
+ void DolphinTabWidget::detachTab(int index)
+ {
+ Q_ASSERT(index >= 0);
+
+ const QString separator(QLatin1Char(' '));
+ QString command = QLatin1String("dolphin");
+
+ const DolphinTabPage* tabPage = tabPageAt(index);
+ command += separator + tabPage->primaryViewContainer()->url().url();
+ if (tabPage->splitViewEnabled()) {
+ command += separator + tabPage->secondaryViewContainer()->url().url();
+ command += separator + QLatin1String("-split");
+ }
+
+ KRun::runCommand(command, this);
+
+ closeTab(index);
+ }
+
+ void DolphinTabWidget::openNewActivatedTab(int index)
+ {
+ Q_ASSERT(index >= 0);
+ const DolphinTabPage* tabPage = tabPageAt(index);
+ openNewActivatedTab(tabPage->activeViewContainer()->url());
+ }
+
+ void DolphinTabWidget::tabDropEvent(int index, QDropEvent* event)
+ {
+ if (index >= 0) {
+ const DolphinView* view = tabPageAt(index)->activeViewContainer()->view();
+
+ QString error;
+ DragAndDropHelper::dropUrls(view->rootItem(), view->url(), event, error);
+ if (!error.isEmpty()) {
+ currentTabPage()->activeViewContainer()->showMessage(error, DolphinViewContainer::Error);
+ }
+ }
+ }
+
+ void DolphinTabWidget::tabUrlChanged(const KUrl& url)
+ {
+ const int index = indexOf(qobject_cast<QWidget*>(sender()));
+ if (index >= 0) {
+ tabBar()->setTabText(index, tabName(url));
++ tabBar()->setTabIcon(index, QIcon::fromTheme(KIO::iconNameForUrl(url)));
+
+ // Emit the currentUrlChanged signal if the url of the current tab has been changed.
+ if (index == currentIndex()) {
+ emit currentUrlChanged(url);
+ }
+ }
+ }
+
+ void DolphinTabWidget::currentTabChanged(int index)
+ {
+ DolphinViewContainer* viewContainer = tabPageAt(index)->activeViewContainer();
+ emit activeViewChanged(viewContainer);
+ emit currentUrlChanged(viewContainer->url());
+ }
+
+ void DolphinTabWidget::tabInserted(int index)
+ {
+ QTabWidget::tabInserted(index);
+
+ if (count() > 1) {
+ tabBar()->show();
+ }
+
+ emit tabCountChanged(count());
+ }
+
+ void DolphinTabWidget::tabRemoved(int index)
+ {
+ QTabWidget::tabRemoved(index);
+
+ // If only one tab is left, then remove the tab entry so that
+ // closing the last tab is not possible.
+ if (count() < 2) {
+ tabBar()->hide();
+ }
+
+ emit tabCountChanged(count());
+ }
+
+ QString DolphinTabWidget::tabName(const KUrl& url) const
+ {
+ QString name;
+ if (url.equals(KUrl("file:///"))) {
+ name = '/';
+ } else {
+ name = url.fileName();
+ if (name.isEmpty()) {
+ name = url.protocol();
+ } else {
+ // Make sure that a '&' inside the directory name is displayed correctly
+ // and not misinterpreted as a keyboard shortcut in QTabBar::setTabText()
+ name.replace('&', "&&");
+ }
+ }
+ return name;
+ }
#include <QBoxLayout>
#include <QTimer>
#include <QScrollBar>
+#include <QMimeData>
#include <KDesktopFile>
#include <KFileItemDelegate>
#include <KIO/PreviewJob>
#include <KMessageWidget>
#include <KNewFileMenu>
-#include <konqmimedata.h>
#include <konq_operations.h>
#include <KShell>
#include <KUrl>
m_topLayout->setMargin(0);
m_urlNavigator = new KUrlNavigator(new KFilePlacesModel(this), url, this);
- connect(m_urlNavigator, SIGNAL(urlsDropped(KUrl,QDropEvent*)),
- this, SLOT(dropUrls(KUrl,QDropEvent*)));
- connect(m_urlNavigator, SIGNAL(activated()),
- this, SLOT(activate()));
- connect(m_urlNavigator->editor(), SIGNAL(completionModeChanged(KGlobalSettings::Completion)),
- this, SLOT(saveUrlCompletionMode(KGlobalSettings::Completion)));
+ connect(m_urlNavigator, &KUrlNavigator::urlsDropped,
+ this, &DolphinViewContainer::dropUrls);
+ connect(m_urlNavigator, &KUrlNavigator::activated,
+ this, &DolphinViewContainer::activate);
+ connect(m_urlNavigator->editor(), &KUrlComboBox::completionModeChanged,
+ this, &DolphinViewContainer::saveUrlCompletionMode);
const GeneralSettings* settings = GeneralSettings::self();
m_urlNavigator->setUrlEditable(settings->editableUrl());
m_urlNavigator->setShowFullPath(settings->showFullPath());
m_urlNavigator->setHomeUrl(KUrl(settings->homeUrl()));
KUrlComboBox* editor = m_urlNavigator->editor();
- editor->setCompletionMode(KGlobalSettings::Completion(settings->urlCompletionMode()));
+ editor->setCompletionMode(KCompletion::CompletionMode(settings->urlCompletionMode()));
m_searchBox = new DolphinSearchBox(this);
m_searchBox->hide();
- connect(m_searchBox, SIGNAL(activated()), this, SLOT(activate()));
- connect(m_searchBox, SIGNAL(closeRequest()), this, SLOT(closeSearchBox()));
- connect(m_searchBox, SIGNAL(searchRequest()), this, SLOT(startSearching()));
- connect(m_searchBox, SIGNAL(returnPressed(QString)), this, SLOT(requestFocus()));
+ 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);
m_messageWidget = new KMessageWidget(this);
m_messageWidget->setCloseButtonVisible(true);
m_messageWidget->hide();
m_view = new DolphinView(url, this);
- connect(m_view, SIGNAL(urlChanged(KUrl)), m_urlNavigator, SLOT(setUrl(KUrl)));
- connect(m_view, SIGNAL(urlChanged(KUrl)), m_messageWidget, SLOT(hide()));
- connect(m_view, SIGNAL(directoryLoadingCompleted()), m_messageWidget, SLOT(hide()));
- connect(m_view, SIGNAL(writeStateChanged(bool)), this, SIGNAL(writeStateChanged(bool)));
- connect(m_view, SIGNAL(requestItemInfo(KFileItem)), this, SLOT(showItemInfo(KFileItem)));
- connect(m_view, SIGNAL(itemActivated(KFileItem)), this, SLOT(slotItemActivated(KFileItem)));
- connect(m_view, SIGNAL(itemsActivated(KFileItemList)), this, SLOT(slotItemsActivated(KFileItemList)));
- connect(m_view, SIGNAL(redirection(KUrl,KUrl)), this, SLOT(redirect(KUrl,KUrl)));
- connect(m_view, SIGNAL(directoryLoadingStarted()), this, SLOT(slotDirectoryLoadingStarted()));
- connect(m_view, SIGNAL(directoryLoadingCompleted()), this, SLOT(slotDirectoryLoadingCompleted()));
- connect(m_view, SIGNAL(directoryLoadingCanceled()), this, SLOT(slotDirectoryLoadingCanceled()));
- connect(m_view, SIGNAL(itemCountChanged()), this, SLOT(delayedStatusBarUpdate()));
- connect(m_view, SIGNAL(directoryLoadingProgress(int)), this, SLOT(updateDirectoryLoadingProgress(int)));
- connect(m_view, SIGNAL(directorySortingProgress(int)), this, SLOT(updateDirectorySortingProgress(int)));
- connect(m_view, SIGNAL(selectionChanged(KFileItemList)), this, SLOT(delayedStatusBarUpdate()));
- connect(m_view, SIGNAL(urlAboutToBeChanged(KUrl)), this, SLOT(slotViewUrlAboutToBeChanged(KUrl)));
- connect(m_view, SIGNAL(errorMessage(QString)), this, SLOT(showErrorMessage(QString)));
- connect(m_view, SIGNAL(urlIsFileError(KUrl)), this, SLOT(slotUrlIsFileError(KUrl)));
- connect(m_view, SIGNAL(activated()), this, SLOT(activate()));
-
- connect(m_urlNavigator, SIGNAL(urlAboutToBeChanged(KUrl)),
- this, SLOT(slotUrlNavigatorLocationAboutToBeChanged(KUrl)));
- connect(m_urlNavigator, SIGNAL(urlChanged(KUrl)),
- this, SLOT(slotUrlNavigatorLocationChanged(KUrl)));
- connect(m_urlNavigator, SIGNAL(historyChanged()),
- this, SLOT(slotHistoryChanged()));
- connect(m_urlNavigator, SIGNAL(returnPressed()),
- this, SLOT(slotReturnPressed()));
+ connect(m_view, &DolphinView::urlChanged,
+ m_urlNavigator, &KUrlNavigator::setUrl);
+ connect(m_view, &DolphinView::urlChanged,
+ m_messageWidget, &KMessageWidget::hide);
++ connect(m_view, &DolphinView::directoryLoadingCompleted,
++ m_messageWidget, &KMessageWidget::hide);
+ connect(m_view, &DolphinView::writeStateChanged,
+ this, &DolphinViewContainer::writeStateChanged);
+ connect(m_view, &DolphinView::requestItemInfo,
+ this, &DolphinViewContainer::showItemInfo);
+ connect(m_view, &DolphinView::itemActivated,
+ this, &DolphinViewContainer::slotItemActivated);
+ connect(m_view, &DolphinView::itemsActivated,
+ this, &DolphinViewContainer::slotItemsActivated);
+ connect(m_view, &DolphinView::redirection,
+ this, &DolphinViewContainer::redirect);
+ connect(m_view, &DolphinView::directoryLoadingStarted,
+ this, &DolphinViewContainer::slotDirectoryLoadingStarted);
+ connect(m_view, &DolphinView::directoryLoadingCompleted,
+ this, &DolphinViewContainer::slotDirectoryLoadingCompleted);
+ connect(m_view, &DolphinView::directoryLoadingCanceled,
+ this, &DolphinViewContainer::slotDirectoryLoadingCanceled);
+ connect(m_view, &DolphinView::itemCountChanged,
+ this, &DolphinViewContainer::delayedStatusBarUpdate);
+ connect(m_view, &DolphinView::directoryLoadingProgress,
+ this, &DolphinViewContainer::updateDirectoryLoadingProgress);
+ connect(m_view, &DolphinView::directorySortingProgress,
+ this, &DolphinViewContainer::updateDirectorySortingProgress);
+ connect(m_view, &DolphinView::selectionChanged,
+ this, &DolphinViewContainer::delayedStatusBarUpdate);
+ connect(m_view, &DolphinView::urlAboutToBeChanged,
+ this, &DolphinViewContainer::slotViewUrlAboutToBeChanged);
+ connect(m_view, &DolphinView::errorMessage,
+ this, &DolphinViewContainer::showErrorMessage);
+ connect(m_view, &DolphinView::urlIsFileError,
+ this, &DolphinViewContainer::slotUrlIsFileError);
+ connect(m_view, &DolphinView::activated,
+ this, &DolphinViewContainer::activate);
+
+ connect(m_urlNavigator, &KUrlNavigator::urlAboutToBeChanged,
+ this, &DolphinViewContainer::slotUrlNavigatorLocationAboutToBeChanged);
+ connect(m_urlNavigator, &KUrlNavigator::urlChanged,
+ this, &DolphinViewContainer::slotUrlNavigatorLocationChanged);
+ connect(m_urlNavigator, &KUrlNavigator::historyChanged,
+ this, &DolphinViewContainer::slotHistoryChanged);
+ connect(m_urlNavigator, &KUrlNavigator::returnPressed,
+ this, &DolphinViewContainer::slotReturnPressed);
// Initialize status bar
m_statusBar = new DolphinStatusBar(this);
m_statusBar->setUrl(m_view->url());
m_statusBar->setZoomLevel(m_view->zoomLevel());
- connect(m_view, SIGNAL(urlChanged(KUrl)), m_statusBar, SLOT(setUrl(KUrl)));
- connect(m_view, SIGNAL(zoomLevelChanged(int,int)), m_statusBar, SLOT(setZoomLevel(int)));
- connect(m_view, SIGNAL(infoMessage(QString)), m_statusBar, SLOT(setText(QString)));
- connect(m_view, SIGNAL(operationCompletedMessage(QString)), m_statusBar, SLOT(setText(QString)));
- connect(m_statusBar, SIGNAL(stopPressed()), this, SLOT(stopDirectoryLoading()));
- connect(m_statusBar, SIGNAL(zoomLevelChanged(int)), this, SLOT(slotStatusBarZoomLevelChanged(int)));
+ connect(m_view, &DolphinView::urlChanged,
+ m_statusBar, &DolphinStatusBar::setUrl);
+ connect(m_view, &DolphinView::zoomLevelChanged,
+ m_statusBar, &DolphinStatusBar::setZoomLevel);
+ connect(m_view, &DolphinView::infoMessage,
+ m_statusBar, &DolphinStatusBar::setText);
+ connect(m_view, &DolphinView::operationCompletedMessage,
+ m_statusBar, &DolphinStatusBar::setText);
+ connect(m_statusBar, &DolphinStatusBar::stopPressed,
+ this, &DolphinViewContainer::stopDirectoryLoading);
+ connect(m_statusBar, &DolphinStatusBar::zoomLevelChanged,
+ this, &DolphinViewContainer::slotStatusBarZoomLevelChanged);
m_statusBarTimer = new QTimer(this);
m_statusBarTimer->setSingleShot(true);
m_statusBarTimer->setInterval(300);
- connect(m_statusBarTimer, SIGNAL(timeout()), this, SLOT(updateStatusBar()));
+ connect(m_statusBarTimer, &QTimer::timeout, this, &DolphinViewContainer::updateStatusBar);
KIO::FileUndoManager* undoManager = KIO::FileUndoManager::self();
- connect(undoManager, SIGNAL(jobRecordingFinished(CommandType)),
- this, SLOT(delayedStatusBarUpdate()));
+ connect(undoManager, &KIO::FileUndoManager::jobRecordingFinished,
+ this, &DolphinViewContainer::delayedStatusBarUpdate);
// Initialize filter bar
m_filterBar = new FilterBar(this);
m_filterBar->setVisible(settings->filterBar());
- connect(m_filterBar, SIGNAL(filterChanged(QString)),
- this, SLOT(setNameFilter(QString)));
- connect(m_filterBar, SIGNAL(closeRequest()),
- this, SLOT(closeFilterBar()));
- connect(m_filterBar, SIGNAL(focusViewRequest()),
- this, SLOT(requestFocus()));
- connect(m_view, SIGNAL(urlChanged(KUrl)),
- m_filterBar, SLOT(slotUrlChanged()));
+ connect(m_filterBar, &FilterBar::filterChanged,
+ this, &DolphinViewContainer::setNameFilter);
+ connect(m_filterBar, &FilterBar::closeRequest,
+ this, &DolphinViewContainer::closeFilterBar);
+ connect(m_filterBar, &FilterBar::focusViewRequest,
+ this, &DolphinViewContainer::requestFocus);
+ connect(m_view, &DolphinView::urlChanged,
+ m_filterBar, &FilterBar::slotUrlChanged);
m_topLayout->addWidget(m_urlNavigator);
m_topLayout->addWidget(m_searchBox);
const int unwrappedWidth = m_messageWidget->sizeHint().width();
m_messageWidget->setWordWrap(unwrappedWidth > size().width());
+ if (m_messageWidget->isVisible()) {
+ m_messageWidget->hide();
+ }
m_messageWidget->animatedShow();
}
return;
}
- item.run();
+ new KRun(item.targetUrl(), this);
}
void DolphinViewContainer::slotItemsActivated(const KFileItemList& items)
m_view->setFocus();
}
-void DolphinViewContainer::saveUrlCompletionMode(KGlobalSettings::Completion completion)
+void DolphinViewContainer::saveUrlCompletionMode(KCompletion::CompletionMode completion)
{
GeneralSettings::setUrlCompletionMode(completion);
}
m_urlNavigator->saveLocationState(locationState);
}
-#include "dolphinviewcontainer.moc"
if (m_roleEditor) {
emit roleEditingCanceled(index(), current, data().value(current));
- disconnect(m_roleEditor, SIGNAL(roleEditingCanceled(QByteArray,QVariant)),
- this, SLOT(slotRoleEditingCanceled(QByteArray,QVariant)));
- disconnect(m_roleEditor, SIGNAL(roleEditingFinished(QByteArray,QVariant)),
- this, SLOT(slotRoleEditingFinished(QByteArray,QVariant)));
+ disconnect(m_roleEditor, &KItemListRoleEditor::roleEditingCanceled,
+ this, &KStandardItemListWidget::slotRoleEditingCanceled);
+ disconnect(m_roleEditor, &KItemListRoleEditor::roleEditingFinished,
+ this, &KStandardItemListWidget::slotRoleEditingFinished);
if (m_oldRoleEditor) {
m_oldRoleEditor->deleteLater();
m_roleEditor->setTextCursor(cursor);
}
- connect(m_roleEditor, SIGNAL(roleEditingCanceled(QByteArray,QVariant)),
- this, SLOT(slotRoleEditingCanceled(QByteArray,QVariant)));
- connect(m_roleEditor, SIGNAL(roleEditingFinished(QByteArray,QVariant)),
- this, SLOT(slotRoleEditingFinished(QByteArray,QVariant)));
+ connect(m_roleEditor, &KItemListRoleEditor::roleEditingCanceled,
+ this, &KStandardItemListWidget::slotRoleEditingCanceled);
+ connect(m_roleEditor, &KItemListRoleEditor::roleEditingFinished,
+ this, &KStandardItemListWidget::slotRoleEditingFinished);
// Adjust the geometry of the editor
QRectF rect = roleEditingRect(current);
const KUrl itemUrl = data().value("url").value<KUrl>();
m_isCut = clipboard->isCut(itemUrl);
- connect(clipboard, SIGNAL(cutItemsChanged()),
- this, SLOT(slotCutItemsChanged()));
+ connect(clipboard, &KFileItemClipboard::cutItemsChanged,
+ this, &KStandardItemListWidget::slotCutItemsChanged);
}
void KStandardItemListWidget::hideEvent(QHideEvent* event)
{
- disconnect(KFileItemClipboard::instance(), SIGNAL(cutItemsChanged()),
- this, SLOT(slotCutItemsChanged()));
+ disconnect(KFileItemClipboard::instance(), &KFileItemClipboard::cutItemsChanged,
+ this, &KStandardItemListWidget::slotCutItemsChanged);
KItemListWidget::hideEvent(event);
}
const int textLength = line.textStart() + line.textLength();
if (textLength < nameText.length()) {
// Elide the last line of the text
- QString lastTextLine = nameText.mid(line.textStart());
- lastTextLine = m_customizedFontMetrics.elidedText(lastTextLine,
- Qt::ElideRight,
- maxWidth);
- const QString elidedText = nameText.left(line.textStart()) + lastTextLine;
- nameTextInfo->staticText.setText(elidedText);
-
- const qreal lastLineWidth = m_customizedFontMetrics.boundingRect(lastTextLine).width();
+ qreal elidingWidth = maxWidth;
+ qreal lastLineWidth;
+ do {
+ QString lastTextLine = nameText.mid(line.textStart());
+ lastTextLine = m_customizedFontMetrics.elidedText(lastTextLine,
+ Qt::ElideRight,
+ elidingWidth);
+ const QString elidedText = nameText.left(line.textStart()) + lastTextLine;
+ nameTextInfo->staticText.setText(elidedText);
+
+ lastLineWidth = m_customizedFontMetrics.boundingRect(lastTextLine).width();
+
+ // We do the text eliding in a loop with decreasing width (1 px / iteration)
+ // to avoid problems related to different width calculation code paths
+ // within Qt. (see bug 337104)
+ elidingWidth -= 1.0;
+ } while (lastLineWidth > maxWidth);
+
nameWidth = qMax(nameWidth, lastLineWidth);
}
break;
void KStandardItemListWidget::closeRoleEditor()
{
- disconnect(m_roleEditor, SIGNAL(roleEditingCanceled(QByteArray,QVariant)),
- this, SLOT(slotRoleEditingCanceled(QByteArray,QVariant)));
- disconnect(m_roleEditor, SIGNAL(roleEditingFinished(QByteArray,QVariant)),
- this, SLOT(slotRoleEditingFinished(QByteArray,QVariant)));
+ disconnect(m_roleEditor, &KItemListRoleEditor::roleEditingCanceled,
+ this, &KStandardItemListWidget::slotRoleEditingCanceled);
+ disconnect(m_roleEditor, &KItemListRoleEditor::roleEditingFinished,
+ this, &KStandardItemListWidget::slotRoleEditingFinished);
if (m_roleEditor->hasFocus()) {
// If the editing was not ended by a FocusOut event, we have
return option.padding * 6;
}
-#include "kstandarditemlistwidget.moc"
m_zoomSlider->setPageStep(1);
m_zoomSlider->setRange(ZoomLevelInfo::minimumLevel(), ZoomLevelInfo::maximumLevel());
- connect(m_zoomSlider, SIGNAL(valueChanged(int)), this, SIGNAL(zoomLevelChanged(int)));
- connect(m_zoomSlider, SIGNAL(valueChanged(int)), this, SLOT(updateZoomSliderToolTip(int)));
- connect(m_zoomSlider, SIGNAL(sliderMoved(int)), this, SLOT(showZoomSliderToolTip(int)));
+ connect(m_zoomSlider, &QSlider::valueChanged, this, &DolphinStatusBar::zoomLevelChanged);
+ connect(m_zoomSlider, &QSlider::valueChanged, this, &DolphinStatusBar::updateZoomSliderToolTip);
+ connect(m_zoomSlider, &QSlider::sliderMoved, this, &DolphinStatusBar::showZoomSliderToolTip);
// Initialize space information
m_spaceInfo = new StatusBarSpaceInfo(this);
m_stopButton->setAutoRaise(true);
m_stopButton->setToolTip(i18nc("@tooltip", "Stop loading"));
m_stopButton->hide();
- connect(m_stopButton, SIGNAL(clicked()), this, SIGNAL(stopPressed()));
+ connect(m_stopButton, &QToolButton::clicked, this, &DolphinStatusBar::stopPressed);
m_progressTextLabel = new QLabel(this);
m_progressTextLabel->hide();
m_showProgressBarTimer = new QTimer(this);
m_showProgressBarTimer->setInterval(500);
m_showProgressBarTimer->setSingleShot(true);
- connect(m_showProgressBarTimer, SIGNAL(timeout()), this, SLOT(updateProgressInfo()));
+ connect(m_showProgressBarTimer, &QTimer::timeout, this, &DolphinStatusBar::updateProgressInfo);
m_resetToDefaultTextTimer = new QTimer(this);
m_resetToDefaultTextTimer->setInterval(ResetToDefaultTimeout);
m_resetToDefaultTextTimer->setSingleShot(true);
- connect(m_resetToDefaultTextTimer, SIGNAL(timeout()), this, SLOT(slotResetToDefaultText()));
+ connect(m_resetToDefaultTextTimer, &QTimer::timeout, this, &DolphinStatusBar::slotResetToDefaultText);
// Initialize top layout and size policies
const int fontHeight = QFontMetrics(m_label->font()).height();
const int zoomSliderHeight = m_zoomSlider->minimumSizeHint().height();
const int contentHeight = qMax(fontHeight, zoomSliderHeight);
+ QFontMetrics fontMetrics(m_label->font());
+
m_label->setFixedHeight(contentHeight);
m_label->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed);
- m_zoomSlider->setFixedHeight(contentHeight);
- m_zoomSlider->setMaximumWidth(150);
+ m_zoomSlider->setMaximumWidth(fontMetrics.averageCharWidth() * 15);
m_spaceInfo->setFixedHeight(contentHeight);
- m_spaceInfo->setMaximumWidth(150);
+ m_spaceInfo->setMaximumWidth(fontMetrics.averageCharWidth() * 15);
m_spaceInfo->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed);
m_progressBar->setFixedHeight(contentHeight);
- m_progressBar->setMaximumWidth(150);
+ m_progressBar->setMaximumWidth(fontMetrics.averageCharWidth() * 15);
QHBoxLayout* topLayout = new QHBoxLayout(this);
topLayout->setMargin(0);
m_zoomSlider->setVisible(showZoomSlider);
}
-#include "dolphinstatusbar.moc"
#include <QItemSelection>
#include <QTimer>
#include <QScrollBar>
+#include <QPointer>
+#include <QMenu>
#include <KDesktopFile>
#include <KProtocolManager>
#include <kitemviews/kitemlistselectionmanager.h>
#include <kitemviews/kitemlistview.h>
#include <kitemviews/kitemlistcontroller.h>
+#include <KIO/CopyJob>
#include <KIO/DeleteJob>
#include <KIO/JobUiDelegate>
#include <KIO/NetAccess>
#include <KIO/PreviewJob>
+#include <KIO/Paste>
#include <KJob>
#include <KMenu>
+#include <KGlobal>
#include <KMessageBox>
-#include <konq_fileitemcapabilities.h>
+#include <KJobWidgets>
#include <konq_operations.h>
-#include <konqmimedata.h>
#include <KToggleAction>
#include <KUrl>
#include "zoomlevelinfo.h"
#ifdef HAVE_BALOO
- #include <baloo/indexerconfig.h>
+ #include <Baloo/IndexerConfig>
#endif
namespace {
// When a new item has been created by the "Create New..." menu, the item should
// get selected and it must be assured that the item will get visible. As the
// creation is done asynchronously, several signals must be checked:
- connect(&DolphinNewFileMenuObserver::instance(), SIGNAL(itemCreated(KUrl)),
- this, SLOT(observeCreatedItem(KUrl)));
+ connect(&DolphinNewFileMenuObserver::instance(), &DolphinNewFileMenuObserver::itemCreated,
+ this, &DolphinView::observeCreatedItem);
m_selectionChangedTimer = new QTimer(this);
m_selectionChangedTimer->setSingleShot(true);
m_selectionChangedTimer->setInterval(300);
- connect(m_selectionChangedTimer, SIGNAL(timeout()),
- this, SLOT(emitSelectionChangedSignal()));
+ connect(m_selectionChangedTimer, &QTimer::timeout,
+ this, &DolphinView::emitSelectionChangedSignal);
m_model = new KFileItemModel(this);
m_view = new DolphinItemListView();
m_container = new KItemListContainer(controller, this);
m_container->installEventFilter(this);
setFocusProxy(m_container);
- connect(m_container->horizontalScrollBar(), SIGNAL(valueChanged(int)), this, SLOT(hideToolTip()));
- connect(m_container->verticalScrollBar(), SIGNAL(valueChanged(int)), this, SLOT(hideToolTip()));
+ connect(m_container->horizontalScrollBar(), &QScrollBar::valueChanged, this, &DolphinView::hideToolTip);
+ connect(m_container->verticalScrollBar(), &QScrollBar::valueChanged, this, &DolphinView::hideToolTip);
controller->setSelectionBehavior(KItemListController::MultiSelection);
- connect(controller, SIGNAL(itemActivated(int)), this, SLOT(slotItemActivated(int)));
- connect(controller, SIGNAL(itemsActivated(KItemSet)), this, SLOT(slotItemsActivated(KItemSet)));
- connect(controller, SIGNAL(itemMiddleClicked(int)), this, SLOT(slotItemMiddleClicked(int)));
- connect(controller, SIGNAL(itemContextMenuRequested(int,QPointF)), this, SLOT(slotItemContextMenuRequested(int,QPointF)));
- connect(controller, SIGNAL(viewContextMenuRequested(QPointF)), this, SLOT(slotViewContextMenuRequested(QPointF)));
- connect(controller, SIGNAL(headerContextMenuRequested(QPointF)), this, SLOT(slotHeaderContextMenuRequested(QPointF)));
- connect(controller, SIGNAL(mouseButtonPressed(int,Qt::MouseButtons)), this, SLOT(slotMouseButtonPressed(int,Qt::MouseButtons)));
- connect(controller, SIGNAL(itemHovered(int)), this, SLOT(slotItemHovered(int)));
- connect(controller, SIGNAL(itemUnhovered(int)), this, SLOT(slotItemUnhovered(int)));
- connect(controller, SIGNAL(itemDropEvent(int,QGraphicsSceneDragDropEvent*)), this, SLOT(slotItemDropEvent(int,QGraphicsSceneDragDropEvent*)));
- connect(controller, SIGNAL(escapePressed()), this, SLOT(stopLoading()));
- connect(controller, SIGNAL(modelChanged(KItemModelBase*,KItemModelBase*)), this, SLOT(slotModelChanged(KItemModelBase*,KItemModelBase*)));
-
- connect(m_model, SIGNAL(directoryLoadingStarted()), this, SLOT(slotDirectoryLoadingStarted()));
- connect(m_model, SIGNAL(directoryLoadingCompleted()), this, SLOT(slotDirectoryLoadingCompleted()));
- connect(m_model, SIGNAL(directoryLoadingCanceled()), this, SIGNAL(directoryLoadingCanceled()));
- connect(m_model, SIGNAL(directoryLoadingProgress(int)), this, SIGNAL(directoryLoadingProgress(int)));
- connect(m_model, SIGNAL(directorySortingProgress(int)), this, SIGNAL(directorySortingProgress(int)));
- connect(m_model, SIGNAL(itemsChanged(KItemRangeList,QSet<QByteArray>)),
- this, SLOT(slotItemsChanged()));
- connect(m_model, SIGNAL(itemsRemoved(KItemRangeList)), this, SIGNAL(itemCountChanged()));
- connect(m_model, SIGNAL(itemsInserted(KItemRangeList)), this, SIGNAL(itemCountChanged()));
- connect(m_model, SIGNAL(infoMessage(QString)), this, SIGNAL(infoMessage(QString)));
- connect(m_model, SIGNAL(errorMessage(QString)), this, SIGNAL(errorMessage(QString)));
- connect(m_model, SIGNAL(directoryRedirection(KUrl,KUrl)), this, SLOT(slotDirectoryRedirection(KUrl,KUrl)));
- connect(m_model, SIGNAL(urlIsFileError(KUrl)), this, SIGNAL(urlIsFileError(KUrl)));
+ connect(controller, &KItemListController::itemActivated, this, &DolphinView::slotItemActivated);
+ connect(controller, &KItemListController::itemsActivated, this, &DolphinView::slotItemsActivated);
+ connect(controller, &KItemListController::itemMiddleClicked, this, &DolphinView::slotItemMiddleClicked);
+ connect(controller, &KItemListController::itemContextMenuRequested, this, &DolphinView::slotItemContextMenuRequested);
+ connect(controller, &KItemListController::viewContextMenuRequested, this, &DolphinView::slotViewContextMenuRequested);
+ connect(controller, &KItemListController::headerContextMenuRequested, this, &DolphinView::slotHeaderContextMenuRequested);
+ connect(controller, &KItemListController::mouseButtonPressed, this, &DolphinView::slotMouseButtonPressed);
+ connect(controller, &KItemListController::itemHovered, this, &DolphinView::slotItemHovered);
+ connect(controller, &KItemListController::itemUnhovered, this, &DolphinView::slotItemUnhovered);
+ connect(controller, &KItemListController::itemDropEvent, this, &DolphinView::slotItemDropEvent);
+ connect(controller, &KItemListController::escapePressed, this, &DolphinView::stopLoading);
+ connect(controller, &KItemListController::modelChanged, this, &DolphinView::slotModelChanged);
+
+ connect(m_model, &KFileItemModel::directoryLoadingStarted, this, &DolphinView::slotDirectoryLoadingStarted);
+ connect(m_model, &KFileItemModel::directoryLoadingCompleted, this, &DolphinView::slotDirectoryLoadingCompleted);
+ connect(m_model, &KFileItemModel::directoryLoadingCanceled, this, &DolphinView::directoryLoadingCanceled);
+ connect(m_model, &KFileItemModel::directoryLoadingProgress, this, &DolphinView::directoryLoadingProgress);
+ connect(m_model, &KFileItemModel::directorySortingProgress, this, &DolphinView::directorySortingProgress);
+ connect(m_model, &KFileItemModel::itemsChanged,
+ this, &DolphinView::slotItemsChanged);
+ connect(m_model, &KFileItemModel::itemsRemoved, this, &DolphinView::itemCountChanged);
+ connect(m_model, &KFileItemModel::itemsInserted, this, &DolphinView::itemCountChanged);
+ connect(m_model, &KFileItemModel::infoMessage, this, &DolphinView::infoMessage);
+ connect(m_model, &KFileItemModel::errorMessage, this, &DolphinView::errorMessage);
+ connect(m_model, &KFileItemModel::directoryRedirection, this, &DolphinView::slotDirectoryRedirection);
+ connect(m_model, &KFileItemModel::urlIsFileError, this, &DolphinView::urlIsFileError);
m_view->installEventFilter(this);
- connect(m_view, SIGNAL(sortOrderChanged(Qt::SortOrder,Qt::SortOrder)),
- this, SLOT(slotSortOrderChangedByHeader(Qt::SortOrder,Qt::SortOrder)));
- connect(m_view, SIGNAL(sortRoleChanged(QByteArray,QByteArray)),
- this, SLOT(slotSortRoleChangedByHeader(QByteArray,QByteArray)));
- connect(m_view, SIGNAL(visibleRolesChanged(QList<QByteArray>,QList<QByteArray>)),
- this, SLOT(slotVisibleRolesChangedByHeader(QList<QByteArray>,QList<QByteArray>)));
- connect(m_view, SIGNAL(roleEditingCanceled(int,QByteArray,QVariant)),
- this, SLOT(slotRoleEditingCanceled()));
- connect(m_view->header(), SIGNAL(columnWidthChanged(QByteArray,qreal,qreal)),
- this, SLOT(slotHeaderColumnWidthChanged(QByteArray,qreal,qreal)));
+ connect(m_view, &DolphinItemListView::sortOrderChanged,
+ this, &DolphinView::slotSortOrderChangedByHeader);
+ connect(m_view, &DolphinItemListView::sortRoleChanged,
+ this, &DolphinView::slotSortRoleChangedByHeader);
+ connect(m_view, &DolphinItemListView::visibleRolesChanged,
+ this, &DolphinView::slotVisibleRolesChangedByHeader);
+ connect(m_view, &DolphinItemListView::roleEditingCanceled,
+ this, &DolphinView::slotRoleEditingCanceled);
+ connect(m_view->header(), &KItemListHeader::columnWidthChanged,
+ this, &DolphinView::slotHeaderColumnWidthChanged);
KItemListSelectionManager* selectionManager = controller->selectionManager();
- connect(selectionManager, SIGNAL(selectionChanged(KItemSet,KItemSet)),
- this, SLOT(slotSelectionChanged(KItemSet,KItemSet)));
+ connect(selectionManager, &KItemListSelectionManager::selectionChanged,
+ this, &DolphinView::slotSelectionChanged);
m_toolTipManager = new ToolTipManager(this);
m_versionControlObserver = new VersionControlObserver(this);
m_versionControlObserver->setModel(m_model);
- connect(m_versionControlObserver, SIGNAL(infoMessage(QString)), this, SIGNAL(infoMessage(QString)));
- connect(m_versionControlObserver, SIGNAL(errorMessage(QString)), this, SIGNAL(errorMessage(QString)));
- connect(m_versionControlObserver, SIGNAL(operationCompletedMessage(QString)), this, SIGNAL(operationCompletedMessage(QString)));
+ connect(m_versionControlObserver, &VersionControlObserver::infoMessage, this, &DolphinView::infoMessage);
+ connect(m_versionControlObserver, &VersionControlObserver::errorMessage, this, &DolphinView::errorMessage);
+ connect(m_versionControlObserver, &VersionControlObserver::operationCompletedMessage, this, &DolphinView::operationCompletedMessage);
applyViewProperties();
m_topLayout->addWidget(m_container);
const KFileItemList itemList = selectedItems();
m_selectedUrls.clear();
- m_selectedUrls = itemList.urlList();
+ m_selectedUrls = KUrl::List(itemList.urlList());
ViewProperties props(viewPropertiesUrl());
props.setHiddenFilesShown(show);
const KFileItemList itemList = selectedItems();
m_selectedUrls.clear();
- m_selectedUrls = itemList.urlList();
+ m_selectedUrls = KUrl::List(itemList.urlList());
setUrl(url());
loadDirectory(url(), true);
hideToolTip();
- disconnect(m_view, SIGNAL(roleEditingFinished(int,QByteArray,QVariant)),
- this, SLOT(slotRoleEditingFinished(int,QByteArray,QVariant)));
+ disconnect(m_view, &DolphinItemListView::roleEditingFinished,
+ this, &DolphinView::slotRoleEditingFinished);
// It is important to clear the items from the model before
// applying the view properties, otherwise expensive operations
hideToolTip();
- connect(m_view, SIGNAL(roleEditingFinished(int,QByteArray,QVariant)),
- this, SLOT(slotRoleEditingFinished(int,QByteArray,QVariant)));
+ connect(m_view, &DolphinItemListView::roleEditingFinished,
+ this, &DolphinView::slotRoleEditingFinished);
} else {
RenameDialog* dialog = new RenameDialog(this, items);
dialog->setAttribute(Qt::WA_DeleteOnClose);
void DolphinView::trashSelectedItems()
{
const KUrl::List list = simplifiedSelectedUrls();
- KonqOperations::del(this, KonqOperations::TRASH, list);
+ KIO::JobUiDelegate uiDelegate;
+ uiDelegate.setWindow(window());
+ if (uiDelegate.askDeleteConfirmation(list, KIO::JobUiDelegate::Trash, KIO::JobUiDelegate::DefaultConfirmation)) {
+ KIO::Job* job = KIO::trash(list);
+ KIO::FileUndoManager::self()->recordJob(KIO::FileUndoManager::Trash, list, KUrl("trash:/"), job);
+ KJobWidgets::setWindow(job, this);
+ connect(job, &KIO::Job::result,
+ this, &DolphinView::slotTrashFileFinished);
+ }
}
void DolphinView::deleteSelectedItems()
{
const KUrl::List list = simplifiedSelectedUrls();
- const bool del = KonqOperations::askDeleteConfirmation(list,
- KonqOperations::DEL,
- KonqOperations::DEFAULT_CONFIRMATION,
- this);
- if (del) {
+ KIO::JobUiDelegate uiDelegate;
+ uiDelegate.setWindow(window());
+ if (uiDelegate.askDeleteConfirmation(list, KIO::JobUiDelegate::Delete, KIO::JobUiDelegate::DefaultConfirmation)) {
KIO::Job* job = KIO::del(list);
- if (job->ui()) {
- job->ui()->setWindow(this);
- }
- connect(job, SIGNAL(result(KJob*)),
- this, SLOT(slotDeleteFileFinished(KJob*)));
+ KJobWidgets::setWindow(job, this);
+ connect(job, &KIO::Job::result,
+ this, &DolphinView::slotDeleteFileFinished);
}
}
void DolphinView::cutSelectedItems()
{
QMimeData* mimeData = selectionMimeData();
- KonqMimeData::addIsCutSelection(mimeData, true);
+ KIO::setClipboardDataCut(mimeData, true);
QApplication::clipboard()->setMimeData(mimeData);
}
// Mark the dropped urls as selected.
m_clearSelectionBeforeSelectingNewItems = true;
m_markFirstNewlySelectedItemAsCurrent = true;
- connect(op, SIGNAL(aboutToCreate(KUrl::List)), this, SLOT(slotAboutToCreate(KUrl::List)));
+ connect(op, static_cast<void(KonqOperations::*)(const KUrl::List&)>(&KonqOperations::aboutToCreate), this, &DolphinView::slotAboutToCreate);
}
setActive(true);
void DolphinView::slotModelChanged(KItemModelBase* current, KItemModelBase* previous)
{
if (previous != 0) {
- disconnect(previous, SIGNAL(directoryLoadingCompleted()), this, SLOT(slotDirectoryLoadingCompleted()));
+ Q_ASSERT(qobject_cast<KFileItemModel*>(previous));
+ KFileItemModel* fileItemModel = static_cast<KFileItemModel*>(previous);
+ disconnect(fileItemModel, &KFileItemModel::directoryLoadingCompleted, this, &DolphinView::slotDirectoryLoadingCompleted);
m_versionControlObserver->setModel(0);
}
if (current) {
Q_ASSERT(qobject_cast<KFileItemModel*>(current));
- connect(current, SIGNAL(loadingCompleted()), this, SLOT(slotDirectoryLoadingCompleted()));
-
KFileItemModel* fileItemModel = static_cast<KFileItemModel*>(current);
+ connect(fileItemModel, &KFileItemModel::directoryLoadingCompleted, this, &DolphinView::slotDirectoryLoadingCompleted);
m_versionControlObserver->setModel(fileItemModel);
}
}
markUrlAsCurrent(urls.first());
m_markFirstNewlySelectedItemAsCurrent = false;
}
- m_selectedUrls << KDirModel::simplifiedUrlList(urls);
+ m_selectedUrls << KUrl::List(KDirModel::simplifiedUrlList(urls));
}
}
void DolphinView::restoreState(QDataStream& stream)
{
+ // Read the version number of the view state and check if the version is supported.
+ quint32 version = 0;
+ stream >> version;
+ if (version != 1) {
+ // The version of the view state isn't supported, we can't restore it.
+ return;
+ }
+
// Restore the current item that had the keyboard focus
stream >> m_currentItemUrl;
void DolphinView::saveState(QDataStream& stream)
{
+ stream << quint32(1); // View state version
+
// Save the current item that has the keyboard focus
const int currentIndex = m_container->controller()->selectionManager()->currentItem();
if (currentIndex != -1) {
m_view->scrollToItem(currentIndex);
m_scrollToCurrentItem = false;
}
-
- m_currentItemUrl = KUrl();
} else {
selectionManager->setCurrentItem(0);
}
+
+ m_currentItemUrl = KUrl();
}
if (!m_restoredContentsPosition.isNull()) {
}
}
+void DolphinView::slotTrashFileFinished(KJob* job)
+{
+ if (job->error() == 0) {
+ emit operationCompletedMessage(i18nc("@info:status", "Trash operation completed."));
+ } else if (job->error() != KIO::ERR_USER_CANCELED) {
+ emit errorMessage(job->errorString());
+ }
+}
+
void DolphinView::slotDeleteFileFinished(KJob* job)
{
if (job->error() == 0) {
void DolphinView::slotRoleEditingCanceled()
{
- disconnect(m_view, SIGNAL(roleEditingFinished(int,QByteArray,QVariant)),
- this, SLOT(slotRoleEditingFinished(int,QByteArray,QVariant)));
+ disconnect(m_view, &DolphinItemListView::roleEditingFinished,
+ this, &DolphinView::slotRoleEditingFinished);
}
void DolphinView::slotRoleEditingFinished(int index, const QByteArray& role, const QVariant& value)
{
- disconnect(m_view, SIGNAL(roleEditingFinished(int,QByteArray,QVariant)),
- this, SLOT(slotRoleEditingFinished(int,QByteArray,QVariant)));
+ disconnect(m_view, &DolphinItemListView::roleEditingFinished,
+ this, &DolphinView::slotRoleEditingFinished);
if (index < 0 || index >= m_model->count()) {
return;
if (op && !newNameExistsAlready) {
// Only connect the renamingFailed signal if there is no item with the new name
// in the model yet, see bug 328262.
- connect(op, SIGNAL(renamingFailed(KUrl,KUrl)), SLOT(slotRenamingFailed(KUrl,KUrl)));
+ connect(op, &KonqOperations::renamingFailed, this, &DolphinView::slotRenamingFailed);
}
}
}
if (op) {
m_clearSelectionBeforeSelectingNewItems = true;
m_markFirstNewlySelectedItemAsCurrent = true;
- connect(op, SIGNAL(aboutToCreate(KUrl::List)), this, SLOT(slotAboutToCreate(KUrl::List)));
+ connect(op, static_cast<void(KonqOperations::*)(const KUrl::List&)>(&KonqOperations::aboutToCreate), this, &DolphinView::slotAboutToCreate);
}
}
return url;
}
-#include "dolphinview.moc"