diff --git a/krusader/BookMan/krbookmark.cpp b/krusader/BookMan/krbookmark.cpp index 307794ba..a8ef705a 100644 --- a/krusader/BookMan/krbookmark.cpp +++ b/krusader/BookMan/krbookmark.cpp @@ -1,122 +1,122 @@ /***************************************************************************** * Copyright (C) 2002 Shie Erlich * * Copyright (C) 2002 Rafi Yanai * * * * 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 package 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 package; if not, write to the Free Software * * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA * *****************************************************************************/ #include "krbookmark.h" #include "../krglobal.h" -#include "../krtrashhandler.h" #include "../Archive/krarchandler.h" +#include "../VFS/krtrashhandler.h" #include #include #include #define BM_NAME(X) (QString("Bookmark:")+X) static const char* NAME_TRASH = I18N_NOOP("Trash bin"); static const char* NAME_VIRTUAL = I18N_NOOP("Virtual Filesystem"); static const char* NAME_LAN = I18N_NOOP("Local Network"); KrBookmark::KrBookmark(QString name, QUrl url, KActionCollection *parent, QString icon, QString actionName) : QAction(parent), _url(url), _icon(icon), _folder(false), _separator(false), _autoDelete(true) { QString actName = actionName.isNull() ? BM_NAME(name) : BM_NAME(actionName); setText(name); parent->addAction(actName, this); connect(this, SIGNAL(triggered()), this, SLOT(activatedProxy())); // do we have an icon? if (!icon.isEmpty()) setIcon(QIcon::fromTheme(icon)); else { // what kind of a url is it? if (_url.isLocalFile()) { setIcon(QIcon::fromTheme("folder")); } else { // is it an archive? if (KRarcHandler::isArchive(_url)) setIcon(QIcon::fromTheme("application-x-tar")); else setIcon(QIcon::fromTheme("folder-html")); } } } KrBookmark::KrBookmark(QString name, QString icon) : QAction(QIcon::fromTheme(icon), name, 0), _icon(icon), _folder(true), _separator(false), _autoDelete(false) { setIcon(QIcon::fromTheme(icon == "" ? "folder" : icon)); } KrBookmark::~KrBookmark() { if (_autoDelete) { QListIterator it(_children); while (it.hasNext()) delete it.next(); _children.clear(); } } KrBookmark* KrBookmark::getExistingBookmark(QString actionName, KActionCollection *collection) { return static_cast(collection->action(BM_NAME(actionName))); } KrBookmark* KrBookmark::trash(KActionCollection *collection) { KrBookmark *bm = getExistingBookmark(i18n(NAME_TRASH), collection); if (!bm) bm = new KrBookmark(i18n(NAME_TRASH), QUrl("trash:/"), collection); bm->setIcon(krLoader->loadIcon(KrTrashHandler::trashIcon(), KIconLoader::Small)); return bm; } KrBookmark* KrBookmark::virt(KActionCollection *collection) { KrBookmark *bm = getExistingBookmark(i18n(NAME_VIRTUAL), collection); if (!bm) { bm = new KrBookmark(i18n(NAME_VIRTUAL), QUrl("virt:/"), collection); bm->setIcon(krLoader->loadIcon("document-open-remote", KIconLoader::Small)); } return bm; } KrBookmark* KrBookmark::lan(KActionCollection *collection) { KrBookmark *bm = getExistingBookmark(i18n(NAME_LAN), collection); if (!bm) { bm = new KrBookmark(i18n(NAME_LAN), QUrl("remote:/"), collection); bm->setIcon(krLoader->loadIcon("network-workgroup", KIconLoader::Small)); } return bm; } KrBookmark* KrBookmark::separator() { KrBookmark *bm = new KrBookmark(""); bm->_separator = true; bm->_folder = false; return bm; } void KrBookmark::activatedProxy() { emit activated(url()); } diff --git a/krusader/CMakeLists.txt b/krusader/CMakeLists.txt index f5755695..0ce38237 100644 --- a/krusader/CMakeLists.txt +++ b/krusader/CMakeLists.txt @@ -1,133 +1,132 @@ include_directories(${KF5_INCLUDES_DIRS} ${QT_INCLUDES}) configure_file(krusaderversion.h.cmake ${CMAKE_CURRENT_BINARY_DIR}/krusaderversion.h) add_subdirectory(ActionMan) add_subdirectory(Archive) add_subdirectory(BookMan) add_subdirectory(Dialogs) add_subdirectory(DiskUsage) add_subdirectory(Filter) add_subdirectory(GUI) add_subdirectory(Konfigurator) add_subdirectory(KViewer) add_subdirectory(JobMan) add_subdirectory(Locate) add_subdirectory(MountMan) add_subdirectory(Panel) add_subdirectory(Search) add_subdirectory(Splitter) add_subdirectory(UserAction) add_subdirectory(UserMenu) add_subdirectory(VFS) if(SYNCHRONIZER_ENABLED) add_subdirectory(Synchronizer) endif(SYNCHRONIZER_ENABLED) message(STATUS "${CMAKE_CURRENT_SOURCE_DIR}: skipped subdir $(KRJSDIR)") set(krusader_SRCS krglobal.cpp actionsbase.cpp tabactions.cpp kractions.cpp paneltabbar.cpp panelmanager.cpp krservices.cpp main.cpp krusaderview.cpp krusader.cpp krslots.cpp kicons.cpp - krtrashhandler.cpp krdebuglogger.cpp ) # TODO porting: missing kf5 equivalent #kde4_add_app_icon(krusader_SRCS "${CMAKE_CURRENT_SOURCE_DIR}/hi*-app-krusader_user.png") qt5_add_resources(krusader_RC_SRCS "${CMAKE_CURRENT_SOURCE_DIR}/resources.qrc" ) add_executable(krusader ${krusader_SRCS} ${krusader_RC_SRCS}) target_link_libraries(krusader Panel BookMan Dialogs DiskUsage GUI Konfigurator KViewer MountMan VFS Search Splitter UserMenu Locate UserAction ActionMan KViewer Filter Dialogs GUI Archive JobMan KF5::Notifications KF5::Parts KF5::WindowSystem Qt5::PrintSupport ) if(SYNCHRONIZER_ENABLED) target_link_libraries( krusader Synchronizer ) endif(SYNCHRONIZER_ENABLED) install(TARGETS krusader ${INSTALL_TARGETS_DEFAULT_ARGS}) install(PROGRAMS org.kde.krusader.desktop org.kde.krusader.root-mode.desktop DESTINATION ${XDG_APPS_INSTALL_DIR} ) install(FILES krusaderui.rc krusaderlisterui.rc krviewer.rc DESTINATION ${KXMLGUI_INSTALL_DIR}/krusader) install(FILES midnight_commander.color total_commander.color total_commander.keymap total_commander.keymap.info useraction_examples.xml layout.xml splash.png DESTINATION ${DATA_INSTALL_DIR}/krusader) install(FILES org.kde.krusader.appdata.xml DESTINATION ${KDE_INSTALL_METAINFODIR}) ecm_install_icons(ICONS icons/16-apps-krusader_blue.png icons/16-apps-krusader_red.png icons/16-apps-krusader_root.png icons/16-apps-krusader_user.png icons/22-apps-krusader_blue.png icons/22-apps-krusader_red.png icons/22-apps-krusader_root.png icons/22-apps-krusader_shield.png icons/22-apps-krusader_user.png icons/32-apps-krusader_blue.png icons/32-apps-krusader_red.png icons/32-apps-krusader_root.png icons/32-apps-krusader_shield.png icons/32-apps-krusader_user.png icons/48-apps-krusader_blue.png icons/48-apps-krusader_red.png icons/48-apps-krusader_root.png icons/48-apps-krusader_shield.png icons/48-apps-krusader_user.png icons/64-apps-krusader_blue.png icons/64-apps-krusader_red.png icons/64-apps-krusader_root.png icons/64-apps-krusader_shield.png icons/64-apps-krusader_user.png icons/128-apps-krusader_root.png icons/128-apps-krusader_user.png DESTINATION ${ICON_INSTALL_DIR} ) diff --git a/krusader/Panel/krpopupmenu.cpp b/krusader/Panel/krpopupmenu.cpp index 4cd47b79..e9eaac1b 100644 --- a/krusader/Panel/krpopupmenu.cpp +++ b/krusader/Panel/krpopupmenu.cpp @@ -1,424 +1,424 @@ /***************************************************************************** * Copyright (C) 2003 Shie Erlich * * Copyright (C) 2003 Rafi Yanai * * * * 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 package 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 package; if not, write to the Free Software * * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA * *****************************************************************************/ #include "krpopupmenu.h" // QtGui #include #include #include #include #include #include #include #include #include #include #include #include #include "listpanel.h" #include "krview.h" #include "krviewitem.h" #include "panelfunc.h" #include "listpanelactions.h" #include "../krservices.h" #include "../defaults.h" #include "../MountMan/kmountman.h" #include "../krusader.h" #include "../krslots.h" #include "../krusaderview.h" #include "../panelmanager.h" -#include "../krtrashhandler.h" #include "../UserAction/useractionpopupmenu.h" #include "../Archive/krarchandler.h" +#include "../VFS/krtrashhandler.h" void KrPopupMenu::run(const QPoint &pos, KrPanel *panel) { KrPopupMenu menu(panel); QAction * res = menu.exec(pos); int result = -1; if (res && res->data().canConvert()) result = res->data().toInt(); menu.performAction(result); } /** * Copied from dolphin/src/dolphincontextmenu.cpp and modified to add only compress and extract submenus. */ void KrPopupMenu::addCompressAndExtractPluginActions() { KFileItemListProperties props(_items); QVector jsonPlugins = KPluginLoader::findPlugins("kf5/kfileitemaction", [=](const KPluginMetaData& metaData) { return metaData.pluginId() == "compressfileitemaction" || metaData.pluginId() == "extractfileitemaction"; }); foreach (const KPluginMetaData &jsonMetadata, jsonPlugins) { KAbstractFileItemActionPlugin* abstractPlugin = KPluginLoader(jsonMetadata.fileName()) .factory()->create(); if (abstractPlugin) { abstractPlugin->setParent(this); addActions(abstractPlugin->actions(props, this)); } } } KrPopupMenu::KrPopupMenu(KrPanel *thePanel, QWidget *parent) : QMenu(parent), panel(thePanel), empty(false), multipleSelections(false), actions(0), _item(0) { KrViewItemList items; panel->view->getSelectedKrViewItems(&items); for (KrViewItemList::Iterator it = items.begin(); it != items.end(); ++it) { vfile *file = panel->func->files()->getVfile(((*it)->name())); QUrl url = file->vfile_getUrl(); _items.append(KFileItem(url, file->vfile_getMime(), file->vfile_getMode())); } if (items.empty()) { addCreateNewMenu(); addSeparator(); addEmptyMenuEntries(); return; } else if (items.size() > 1) { multipleSelections = true; } QSet protocols; for (int i = 0; i < items.size(); ++i) { protocols.insert(panel->func->getVFile(items[i])->vfile_getUrl().scheme()); } const bool inTrash = protocols.contains("trash"); const bool trashOnly = inTrash && protocols.count() == 1; KrViewItem *item = items.first(); vfile *vf = panel->func->getVFile(item); _item = &_items.first(); // ------------ the OPEN/BROWSE option - open preferred service QAction * openAct = addAction(i18n("Open/Run")); openAct->setData(QVariant(OPEN_ID)); if (!multipleSelections) { // meaningful only if one file is selected openAct->setIcon(item->icon()); openAct->setText(vf->vfile_isExecutable() && !vf->vfile_isDir() ? i18n("Run") : i18n("Open")); // open in a new tab (if folder) if (vf->vfile_isDir()) { QAction * openTab = addAction(i18n("Open in New Tab")); openTab->setData(QVariant(OPEN_TAB_ID)); openTab->setIcon(krLoader->loadIcon("tab-new", KIconLoader::Panel)); openTab->setText(i18n("Open in New Tab")); } QUrl arcPath = panel->func->browsableArchivePath(vf->vfile_getName()); if (!arcPath.isEmpty()) { bool theArchiveMustBeBrowsedAsADirectory = KConfigGroup(krConfig, "Archives").readEntry("ArchivesAsDirectories", _ArchivesAsDirectories) && KRarcHandler::arcSupported(vf->vfile_getMime()); if (!theArchiveMustBeBrowsedAsADirectory) { // Add an option to browse the archive QAction *browseAct = addAction(i18n("Browse")); browseAct->setData(QVariant(BROWSE_ID)); browseAct->setIcon(krLoader->loadIcon("", KIconLoader::Panel)); browseAct->setText(i18n("Browse Archive")); } } addSeparator(); } // ------------- Preview - local vfs only ? if (panel->func->files()->isLocal()) { // create the preview popup QStringList names; panel->gui->getSelectedNames(&names); preview.setUrls(panel->func->files() ->getUrls(names)); QAction *pAct = addMenu(&preview); pAct->setData(QVariant(PREVIEW_ID)); pAct->setText(i18n("Preview")); } // -------------- Open with: try to find-out which apps can open the file // this too, is meaningful only if one file is selected or if all the files // have the same mimetype ! QString mime = panel->func->getVFile(item)->vfile_getMime(); // check if all the list have the same mimetype for (int i = 1; i < items.size(); ++i) { if (panel->func->getVFile(items[ i ]) ->vfile_getMime() != mime) { mime.clear(); break; } } if (!mime.isEmpty()) { offers = KMimeTypeTrader::self()->query(mime); for (int i = 0; i < offers.count(); ++i) { QExplicitlySharedDataPointer service = offers[i]; if (service->isValid() && service->isApplication()) { openWith.addAction(krLoader->loadIcon(service->icon(), KIconLoader::Small), service->name())->setData(QVariant(SERVICE_LIST_ID + i)); } } openWith.addSeparator(); if (vf->vfile_isDir()) openWith.addAction(krLoader->loadIcon("utilities-terminal", KIconLoader::Small), i18n("Terminal"))->setData(QVariant(OPEN_TERM_ID)); openWith.addAction(i18n("Other..."))->setData(QVariant(CHOOSE_ID)); QAction *owAct = addMenu(&openWith); owAct->setData(QVariant(OPEN_WITH_ID)); owAct->setText(i18n("Open With")); addSeparator(); } // --------------- user actions QAction *uAct = new UserActionPopupMenu(panel->func->files()->getUrl(item->name())); addAction(uAct); uAct->setText(i18n("User Actions")); // workaround for Bug 372999: application freezes very long time if many files are selected if (_items.length() < 1000) // add compress and extract plugins (if available) addCompressAndExtractPluginActions(); // NOTE: design and usability problem here. Services disabled in kservicemenurc settings won't // be added to the menu. But Krusader does not provide a way do change these settings (only // Dolphin does). fileItemActions.setItemListProperties(KFileItemListProperties(_items)); fileItemActions.addServiceActionsTo(this); addSeparator(); // ------------- 'create new' submenu addCreateNewMenu(); addSeparator(); // ---------- COPY addAction(i18n("Copy..."))->setData(QVariant(COPY_ID)); // ------- MOVE addAction(i18n("Move..."))->setData(QVariant(MOVE_ID)); // ------- RENAME - only one file if (!multipleSelections && !inTrash) addAction(i18n("Rename"))->setData(QVariant(RENAME_ID)); // -------- MOVE TO TRASH KConfigGroup saver(krConfig, "General"); bool trash = saver.readEntry("Move To Trash", _MoveToTrash); if (trash && !inTrash) addAction(i18n("Move to Trash"))->setData(QVariant(TRASH_ID)); // -------- DELETE addAction(i18n("Delete"))->setData(QVariant(DELETE_ID)); // -------- SHRED - only one file /* if ( panel->func->files() ->vfs_getType() == vfs::VFS_NORMAL && !vf->vfile_isDir() && !multipleSelections ) addAction( i18n( "Shred" ) )->setData( QVariant( SHRED_ID ) );*/ // ---------- link handling // create new shortcut or redirect links - only on local directories: if (panel->func->files()->isLocal()) { addSeparator(); linkPopup.addAction(i18n("New Symlink..."))->setData(QVariant(NEW_SYMLINK_ID)); linkPopup.addAction(i18n("New Hardlink..."))->setData(QVariant(NEW_LINK_ID)); if (panel->func->getVFile(item)->vfile_isSymLink()) linkPopup.addAction(i18n("Redirect Link..."))->setData(QVariant(REDIRECT_LINK_ID)); QAction *linkAct = addMenu(&linkPopup); linkAct->setData(QVariant(LINK_HANDLING_ID)); linkAct->setText(i18n("Link Handling")); } addSeparator(); // ---------- calculate space if (panel->func->files()->isLocal() && (vf->vfile_isDir() || multipleSelections)) addAction(panel->gui->actions()->actCalculate); // ---------- mount/umount/eject if (panel->func->files()->isLocal() && vf->vfile_isDir() && !multipleSelections) { if (krMtMan.getStatus(panel->func->files()->getUrl(item->name()).path()) == KMountMan::MOUNTED) addAction(i18n("Unmount"))->setData(QVariant(UNMOUNT_ID)); else if (krMtMan.getStatus(panel->func->files()->getUrl(item->name()).path()) == KMountMan::NOT_MOUNTED) addAction(i18n("Mount"))->setData(QVariant(MOUNT_ID)); if (krMtMan.ejectable(panel->func->files()->getUrl(item->name()).path())) addAction(i18n("Eject"))->setData(QVariant(EJECT_ID)); } // --------- send by mail if (KrServices::supportedTools().contains("MAIL") && !vf->vfile_isDir()) { addAction(i18n("Send by Email"))->setData(QVariant(SEND_BY_EMAIL_ID)); } // --------- empty trash if (trashOnly) { addAction(i18n("Restore"))->setData(QVariant(RESTORE_TRASHED_FILE_ID)); addAction(i18n("Empty Trash"))->setData(QVariant(EMPTY_TRASH_ID)); } #ifdef SYNCHRONIZER_ENABLED // --------- synchronize if (panel->view->numSelected()) { addAction(i18n("Synchronize Selected Files..."))->setData(QVariant(SYNC_SELECTED_ID)); } #endif // --------- copy/paste addSeparator(); addAction(i18n("Copy to Clipboard"))->setData(QVariant(COPY_CLIP_ID)); addAction(i18n("Cut to Clipboard"))->setData(QVariant(MOVE_CLIP_ID)); addAction(i18n("Paste from Clipboard"))->setData(QVariant(PASTE_CLIP_ID)); addSeparator(); // --------- properties addAction(panel->gui->actions()->actProperties); } KrPopupMenu::~KrPopupMenu() { _items.clear(); if (actions) delete actions; } void KrPopupMenu::addEmptyMenuEntries() { addAction(i18n("Paste from Clipboard"))->setData(QVariant(PASTE_CLIP_ID)); } void KrPopupMenu::addCreateNewMenu() { createNewPopup.addAction(krLoader->loadIcon("folder", KIconLoader::Small), i18n("Folder..."))->setData(QVariant(MKDIR_ID)); createNewPopup.addAction(krLoader->loadIcon("text-plain", KIconLoader::Small), i18n("Text File..."))->setData(QVariant(NEW_TEXT_FILE_ID)); QAction *newAct = addMenu(&createNewPopup); newAct->setData(QVariant(CREATE_NEW_ID)); newAct->setText(i18n("Create New")); } void KrPopupMenu::performAction(int id) { switch (id) { case - 1 : // the user clicked outside of the menu return ; case OPEN_TAB_ID : // assuming only 1 file is selected (otherwise we won't get here) panel->manager()->newTab(_item->url(), panel); break; case OPEN_ID : foreach(KFileItem fi, _items) panel->func->execute(fi.name()); break; case BROWSE_ID : panel->func->goInside(_item->url().fileName()); break; case COPY_ID : panel->func->copyFiles(); break; case MOVE_ID : panel->func->moveFiles(); break; case RENAME_ID : panel->func->rename(); break; case TRASH_ID : panel->func->deleteFiles(false); break; case DELETE_ID : panel->func->deleteFiles(true); break; case EJECT_ID : krMtMan.eject(_item->url().adjusted(QUrl::StripTrailingSlash).path()); break; /* case SHRED_ID : if ( KMessageBox::warningContinueCancel( krApp, i18n("Do you really want to shred %1? Once shred, the file is gone forever.", item->name()), QString(), KStandardGuiItem::cont(), KStandardGuiItem::cancel(), "Shred" ) == KMessageBox::Continue ) KShred::shred( panel->func->files() ->vfs_getFile( item->name() ).adjusted(QUrl::RemoveTrailingSlash).path() ); break;*/ case OPEN_KONQ_ID : KToolInvocation::startServiceByDesktopName("konqueror", _item->url().toDisplayString(QUrl::PreferLocalFile)); break; case CHOOSE_ID : // open-with dialog panel->func->displayOpenWithDialog(_items.urlList()); break; case MOUNT_ID : krMtMan.mount(_item->url().adjusted(QUrl::StripTrailingSlash).path()); break; case NEW_LINK_ID : panel->func->krlink(false); break; case NEW_SYMLINK_ID : panel->func->krlink(true); break; case REDIRECT_LINK_ID : panel->func->redirectLink(); break; case EMPTY_TRASH_ID : KrTrashHandler::emptyTrash(); break; case RESTORE_TRASHED_FILE_ID : KrTrashHandler::restoreTrashedFiles(_items.urlList()); break; case UNMOUNT_ID : krMtMan.unmount(_item->url().adjusted(QUrl::StripTrailingSlash).path()); break; case COPY_CLIP_ID : panel->func->copyToClipboard(); break; case MOVE_CLIP_ID : panel->func->copyToClipboard(true); break; case PASTE_CLIP_ID : panel->func->pasteFromClipboard(); break; case SEND_BY_EMAIL_ID : { SLOTS->sendFileByEmail(_items.urlList()); break; } case MKDIR_ID : panel->func->mkdir(); break; case NEW_TEXT_FILE_ID: panel->func->editNew(); break; #ifdef SYNCHRONIZER_ENABLED case SYNC_SELECTED_ID : { QStringList selectedNames; foreach(KFileItem item, _items) selectedNames << item.name(); if (panel->otherPanel()->view->numSelected()) { KrViewItemList otherItems; panel->otherPanel()->view->getSelectedKrViewItems(&otherItems); for (KrViewItemList::Iterator it2 = otherItems.begin(); it2 != otherItems.end(); ++it2) { QString name = (*it2) ->name(); if (!selectedNames.contains(name)) selectedNames.append(name); } } SLOTS->slotSynchronizeDirs(selectedNames); } break; #endif case OPEN_TERM_ID : SLOTS->runTerminal(_item->url().path()); break; } // check if something from the open-with-offered-services was selected if (id >= SERVICE_LIST_ID) { QStringList names; panel->gui->getSelectedNames(&names); panel->func->runService(*(offers[ id - SERVICE_LIST_ID ]), panel->func->files()->getUrls(names)); } } diff --git a/krusader/VFS/CMakeLists.txt b/krusader/VFS/CMakeLists.txt index 9044d67e..b8eabc1e 100644 --- a/krusader/VFS/CMakeLists.txt +++ b/krusader/VFS/CMakeLists.txt @@ -1,25 +1,26 @@ include_directories(${KF5_INCLUDES_DIRS} ${QT_INCLUDES}) set(VFS_SRCS vfilecontainer.cpp krvfshandler.cpp virt_vfs.cpp vfs.cpp vfile.cpp default_vfs.cpp krpermhandler.cpp krquery.cpp + krtrashhandler.cpp ../../krArc/krlinecountingprocess.cpp ) add_library(VFS STATIC ${VFS_SRCS}) target_link_libraries(VFS KF5::I18n KF5::KIOCore KF5::KIOWidgets ) if(ACL_FOUND) target_link_libraries(VFS ${ACL_LIBS}) endif(ACL_FOUND) diff --git a/krusader/krtrashhandler.cpp b/krusader/VFS/krtrashhandler.cpp similarity index 97% rename from krusader/krtrashhandler.cpp rename to krusader/VFS/krtrashhandler.cpp index 82d3989a..6bde538a 100644 --- a/krusader/krtrashhandler.cpp +++ b/krusader/VFS/krtrashhandler.cpp @@ -1,125 +1,124 @@ /*************************************************************************** krtrashhandler.cpp - description ------------------- copyright : (C) 2009 + by Csaba Karai e-mail : krusader@users.sourceforge.net web site : http://krusader.sourceforge.net --------------------------------------------------------------------------- Description *************************************************************************** A db dD d8888b. db db .d8888. .d8b. d8888b. d88888b d8888b. 88 ,8P' 88 `8D 88 88 88' YP d8' `8b 88 `8D 88' 88 `8D 88,8P 88oobY' 88 88 `8bo. 88ooo88 88 88 88ooooo 88oobY' 88`8b 88`8b 88 88 `Y8b. 88~~~88 88 88 88~~~~~ 88`8b 88 `88. 88 `88. 88b d88 db 8D 88 88 88 .8D 88. 88 `88. YP YD 88 YD ~Y8888P' `8888Y' YP YP Y8888D' Y88888P 88 YD S o u r c e F i l e *************************************************************************** * * * 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. * * * ***************************************************************************/ #include "krtrashhandler.h" // QtCore #include #include #include #include #include #include #include #include #include -#include "kractions.h" +#include "krvfshandler.h" +#include "../kractions.h" #include "../krglobal.h" -#include "Panel/krpanel.h" -#include "Panel/panelfunc.h" -#include "VFS/krvfshandler.h" + KrTrashWatcher * KrTrashHandler::_trashWatcher = 0; bool KrTrashHandler::isTrashEmpty() { KConfig trashConfig("trashrc"); KConfigGroup cfg(&trashConfig, "Status"); return cfg.readEntry("Empty", false); } QString KrTrashHandler::trashIcon() { return isTrashEmpty() ? "user-trash" : "user-trash-full"; } void KrTrashHandler::emptyTrash() { KIO::JobUiDelegate uiDelegate; uiDelegate.setWindow(krMainWindow); if (!uiDelegate.askDeleteConfirmation(QList(), KIO::JobUiDelegate::EmptyTrash, KIO::JobUiDelegate::DefaultConfirmation)) return; KIO::Job *job = KIO::emptyTrash(); KJobWidgets::setWindow(job, krMainWindow); job->ui()->setAutoErrorHandlingEnabled(true); const QUrl url = QUrl("trash:/"); QObject::connect(job, &KIO::Job::result, [=]() { KrVfsHandler::instance().refreshVfs(url); }); } void KrTrashHandler::restoreTrashedFiles(const QList &urls) { if (urls.isEmpty()) return; KIO::RestoreJob *job = KIO::restoreFromTrash(urls); KJobWidgets::setWindow(job, krMainWindow); job->uiDelegate()->setAutoErrorHandlingEnabled(true); const QUrl url = urls.first().adjusted(QUrl::RemoveFilename); QObject::connect(job, &KIO::Job::result, [=]() { KrVfsHandler::instance().refreshVfs(url); }); } void KrTrashHandler::startWatcher() { if (!_trashWatcher) _trashWatcher = new KrTrashWatcher(); } void KrTrashHandler::stopWatcher() { delete _trashWatcher; _trashWatcher = 0; } KrTrashWatcher::KrTrashWatcher() { _watcher = new KDirWatch(); connect(_watcher, &KDirWatch::created, this, &KrTrashWatcher::slotTrashChanged); connect(_watcher, &KDirWatch::dirty, this, &KrTrashWatcher::slotTrashChanged); const QString trashrcFile = QDir(QStandardPaths::writableLocation(QStandardPaths::ConfigLocation)).filePath("trashrc"); _watcher->addFile(trashrcFile); _watcher->startScan(true); } KrTrashWatcher::~KrTrashWatcher() { delete _watcher; _watcher = 0; } void KrTrashWatcher::slotTrashChanged() { KrActions::actTrashBin->setIcon(QIcon::fromTheme(KrTrashHandler::trashIcon())); } diff --git a/krusader/krtrashhandler.h b/krusader/VFS/krtrashhandler.h similarity index 100% rename from krusader/krtrashhandler.h rename to krusader/VFS/krtrashhandler.h