File indexing completed on 2023-12-10 04:59:19

0001 /*
0002     The network search widget dock widget
0003 
0004     SPDX-FileCopyrightText: 2018-2023 Alexander Reinholdt <alexander.reinholdt@kdemail.net>
0005     SPDX-License-Identifier: GPL-2.0-or-later
0006 */
0007 
0008 // application specific includes
0009 #include "smb4ksharesviewdockwidget.h"
0010 #include "core/smb4khardwareinterface.h"
0011 #include "core/smb4kmounter.h"
0012 #include "core/smb4ksettings.h"
0013 #include "core/smb4kshare.h"
0014 #include "core/smb4ksynchronizer.h"
0015 #include "smb4kbookmarkdialog.h"
0016 #include "smb4kcustomsettingseditor.h"
0017 #include "smb4ksharesviewitem.h"
0018 #include "smb4ksynchronizationdialog.h"
0019 #include "smb4ktooltip.h"
0020 
0021 #if defined(Q_OS_LINUX)
0022 #include "smb4kmountsettings_linux.h"
0023 #elif defined(Q_OS_FREEBSD) || defined(Q_OS_NETBSD)
0024 #include "smb4kmountsettings_bsd.h"
0025 #endif
0026 
0027 // Qt includes
0028 #include <QActionGroup>
0029 #include <QApplication>
0030 #include <QDropEvent>
0031 #include <QMenu>
0032 
0033 // KDE includes
0034 #include <KIO/DropJob>
0035 #include <KIconLoader>
0036 #include <KJobUiDelegate>
0037 #include <KJobWidgets>
0038 #include <KLocalizedString>
0039 #include <KMessageBox>
0040 
0041 Smb4KSharesViewDockWidget::Smb4KSharesViewDockWidget(const QString &title, QWidget *parent)
0042     : QDockWidget(title, parent)
0043 {
0044     //
0045     // Set the shares view
0046     //
0047     m_sharesView = new Smb4KSharesView(this);
0048     setWidget(m_sharesView);
0049 
0050     //
0051     // The action collection
0052     //
0053     m_actionCollection = new KActionCollection(this);
0054 
0055     //
0056     // The context menu
0057     //
0058     m_contextMenu = new KActionMenu(this);
0059 
0060     //
0061     // Set up the actions
0062     //
0063     setupActions();
0064 
0065     //
0066     // Load the settings
0067     //
0068     loadSettings();
0069 
0070     //
0071     // Connections
0072     //
0073     connect(m_sharesView, SIGNAL(customContextMenuRequested(QPoint)), this, SLOT(slotContextMenuRequested(QPoint)));
0074     connect(m_sharesView, SIGNAL(itemActivated(QListWidgetItem *)), this, SLOT(slotItemActivated(QListWidgetItem *)));
0075     connect(m_sharesView, SIGNAL(itemSelectionChanged()), this, SLOT(slotItemSelectionChanged()));
0076     connect(m_sharesView, SIGNAL(acceptedDropEvent(Smb4KSharesViewItem *, QDropEvent *)), this, SLOT(slotDropEvent(Smb4KSharesViewItem *, QDropEvent *)));
0077 
0078     connect(Smb4KMounter::self(), SIGNAL(mounted(SharePtr)), this, SLOT(slotShareMounted(SharePtr)));
0079     connect(Smb4KMounter::self(), SIGNAL(unmounted(SharePtr)), this, SLOT(slotShareUnmounted(SharePtr)));
0080     connect(Smb4KMounter::self(), SIGNAL(updated(SharePtr)), this, SLOT(slotShareUpdated(SharePtr)));
0081 }
0082 
0083 Smb4KSharesViewDockWidget::~Smb4KSharesViewDockWidget()
0084 {
0085 }
0086 
0087 void Smb4KSharesViewDockWidget::loadSettings()
0088 {
0089     //
0090     // Adjust the view according to the setting chosen
0091     //
0092     switch (Smb4KSettings::sharesViewMode()) {
0093     case Smb4KSettings::EnumSharesViewMode::IconView: {
0094         m_sharesView->setViewMode(Smb4KSharesView::IconMode, Smb4KSettings::sharesViewIconSizeIconView());
0095         break;
0096     }
0097     case Smb4KSettings::EnumSharesViewMode::ListView: {
0098         m_sharesView->setViewMode(Smb4KSharesView::ListMode, Smb4KSettings::sharesViewIconSizeListView());
0099         break;
0100     }
0101     default: {
0102         break;
0103     }
0104     }
0105 
0106     //
0107     // Adjust the unmount actions if needed
0108     //
0109     if (!m_sharesView->selectedItems().isEmpty()) {
0110         QList<QListWidgetItem *> selectedItems = m_sharesView->selectedItems();
0111 
0112         if (selectedItems.size() == 1) {
0113             Smb4KSharesViewItem *item = static_cast<Smb4KSharesViewItem *>(selectedItems.first());
0114             m_actionCollection->action(QStringLiteral("unmount_action"))
0115                 ->setEnabled((!item->shareItem()->isForeign() || Smb4KMountSettings::unmountForeignShares()));
0116         } else if (selectedItems.size() > 1) {
0117             int foreign = 0;
0118 
0119             for (QListWidgetItem *selectedItem : qAsConst(selectedItems)) {
0120                 Smb4KSharesViewItem *item = static_cast<Smb4KSharesViewItem *>(selectedItem);
0121 
0122                 if (item && item->shareItem()->isForeign()) {
0123                     foreign++;
0124                 }
0125             }
0126 
0127             m_actionCollection->action(QStringLiteral("unmount_action"))
0128                 ->setEnabled(((selectedItems.size() > foreign) || Smb4KMountSettings::unmountForeignShares()));
0129         }
0130     }
0131 
0132     actionCollection()
0133         ->action(QStringLiteral("unmount_all_action"))
0134         ->setEnabled(((!onlyForeignMountedShares() || Smb4KMountSettings::unmountForeignShares()) && m_sharesView->count() != 0));
0135 }
0136 
0137 void Smb4KSharesViewDockWidget::saveSettings()
0138 {
0139     //
0140     // Not used at the moment
0141     //
0142 }
0143 
0144 KActionCollection *Smb4KSharesViewDockWidget::actionCollection()
0145 {
0146     return m_actionCollection;
0147 }
0148 
0149 void Smb4KSharesViewDockWidget::setupActions()
0150 {
0151     //
0152     // The 'View Modes' submenu and the respective actions
0153     //
0154     KActionMenu *viewModesMenu = new KActionMenu(KDE::icon(QStringLiteral("view-choose")), i18n("View Modes"), this);
0155 
0156     QActionGroup *viewModesGroup = new QActionGroup(this);
0157     viewModesGroup->setExclusive(true);
0158     connect(viewModesGroup, SIGNAL(triggered(QAction *)), this, SLOT(slotViewModeChanged(QAction *)));
0159 
0160     QAction *iconViewAction = new QAction(KDE::icon(QStringLiteral("view-list-icons")), i18n("Icon View"), this);
0161     iconViewAction->setObjectName(QStringLiteral("icon_view_action"));
0162     iconViewAction->setCheckable(true);
0163     viewModesGroup->addAction(iconViewAction);
0164     viewModesMenu->addAction(iconViewAction);
0165 
0166     QAction *listViewAction = new QAction(KDE::icon(QStringLiteral("view-list-details")), i18n("List View"), this);
0167     listViewAction->setObjectName(QStringLiteral("list_view_action"));
0168     listViewAction->setCheckable(true);
0169     viewModesGroup->addAction(listViewAction);
0170     viewModesMenu->addAction(listViewAction);
0171 
0172     switch (Smb4KSettings::sharesViewMode()) {
0173     case Smb4KSettings::EnumSharesViewMode::IconView: {
0174         iconViewAction->setChecked(true);
0175         break;
0176     }
0177     case Smb4KSettings::EnumSharesViewMode::ListView: {
0178         listViewAction->setChecked(true);
0179         break;
0180     }
0181     default: {
0182         break;
0183     }
0184     }
0185 
0186     m_actionCollection->addAction(QStringLiteral("shares_view_modes"), viewModesMenu);
0187 
0188     //
0189     // First separator
0190     //
0191     QAction *separator1 = new QAction(this);
0192     separator1->setSeparator(true);
0193 
0194     m_actionCollection->addAction(QStringLiteral("shares_separator1"), separator1);
0195 
0196     //
0197     // The Unmount action
0198     //
0199     QAction *unmountAction = new QAction(KDE::icon(QStringLiteral("media-eject")), i18n("&Unmount"), this);
0200     unmountAction->setEnabled(false);
0201     connect(unmountAction, SIGNAL(triggered(bool)), this, SLOT(slotUnmountActionTriggered(bool)));
0202 
0203     m_actionCollection->addAction(QStringLiteral("unmount_action"), unmountAction);
0204     m_actionCollection->setDefaultShortcut(unmountAction, QKeySequence(i18n("Ctrl+U")));
0205 
0206     //
0207     // The Unmount All action
0208     //
0209     QAction *unmountAllAction = new QAction(KDE::icon(QStringLiteral("system-run")), i18n("U&nmount All"), this);
0210     unmountAllAction->setEnabled(false);
0211     connect(unmountAllAction, SIGNAL(triggered(bool)), this, SLOT(slotUnmountAllActionTriggered(bool)));
0212 
0213     m_actionCollection->addAction(QStringLiteral("unmount_all_action"), unmountAllAction);
0214     m_actionCollection->setDefaultShortcut(unmountAllAction, QKeySequence(i18n("Ctrl+N")));
0215 
0216     //
0217     // Second separator
0218     //
0219     QAction *separator2 = new QAction(this);
0220     separator2->setSeparator(true);
0221 
0222     m_actionCollection->addAction(QStringLiteral("shares_separator2"), separator2);
0223 
0224     //
0225     // The Add Bookmark action
0226     //
0227     QAction *bookmarkAction = new QAction(KDE::icon(QStringLiteral("bookmark-new")), i18n("Add &Bookmark"), this);
0228     bookmarkAction->setEnabled(false);
0229     connect(bookmarkAction, SIGNAL(triggered(bool)), this, SLOT(slotBookmarkActionTriggered(bool)));
0230 
0231     m_actionCollection->addAction(QStringLiteral("bookmark_action"), bookmarkAction);
0232     m_actionCollection->setDefaultShortcut(bookmarkAction, QKeySequence(i18n("Ctrl+B")));
0233 
0234     //
0235     // Add custom options action
0236     //
0237     QAction *customAction = new QAction(KDE::icon(QStringLiteral("settings-configure")), i18n("Add &Custom Settings"), this);
0238     customAction->setEnabled(false);
0239     connect(customAction, SIGNAL(triggered(bool)), this, SLOT(slotAddCustomSettingsTriggered(bool)));
0240 
0241     m_actionCollection->addAction(QStringLiteral("custom_action"), customAction);
0242     m_actionCollection->setDefaultShortcut(customAction, QKeySequence(i18n("Ctrl+C")));
0243 
0244     //
0245     // The Synchronize action
0246     //
0247     QAction *synchronizeAction = new QAction(KDE::icon(QStringLiteral("folder-sync")), i18n("S&ynchronize"), this);
0248     synchronizeAction->setEnabled(false);
0249     connect(synchronizeAction, SIGNAL(triggered(bool)), this, SLOT(slotSynchronizeActionTriggered(bool)));
0250 
0251     m_actionCollection->addAction(QStringLiteral("synchronize_action"), synchronizeAction);
0252     m_actionCollection->setDefaultShortcut(synchronizeAction, QKeySequence(i18n("Ctrl+Y")));
0253 
0254     //
0255     // Third separator
0256     //
0257     QAction *separator3 = new QAction(this);
0258     separator3->setSeparator(true);
0259 
0260     m_actionCollection->addAction(QStringLiteral("shares_separator3"), separator3);
0261 
0262     //
0263     // The Open with Konsole action
0264     //
0265     QAction *konsoleAction = new QAction(KDE::icon(QStringLiteral("utilities-terminal")), i18n("Open with Konso&le"), this);
0266     konsoleAction->setEnabled(false);
0267     connect(konsoleAction, SIGNAL(triggered(bool)), this, SLOT(slotKonsoleActionTriggered(bool)));
0268 
0269     m_actionCollection->addAction(QStringLiteral("konsole_action"), konsoleAction);
0270     m_actionCollection->setDefaultShortcut(konsoleAction, QKeySequence(i18n("Ctrl+L")));
0271 
0272     QAction *filemanagerAction = new QAction(KDE::icon(QStringLiteral("system-file-manager")), i18n("Open with F&ile Manager"), this);
0273     filemanagerAction->setEnabled(false);
0274     connect(filemanagerAction, SIGNAL(triggered(bool)), this, SLOT(slotFileManagerActionTriggered(bool)));
0275 
0276     m_actionCollection->addAction(QStringLiteral("filemanager_action"), filemanagerAction);
0277     m_actionCollection->setDefaultShortcut(filemanagerAction, QKeySequence(i18n("Ctrl+I")));
0278 
0279     //
0280     // Plug the actions into the context menu
0281     //
0282     QList<QAction *> actionsList = m_actionCollection->actions();
0283 
0284     for (QAction *action : qAsConst(actionsList)) {
0285         m_contextMenu->addAction(action);
0286     }
0287 }
0288 
0289 void Smb4KSharesViewDockWidget::slotContextMenuRequested(const QPoint &pos)
0290 {
0291     m_contextMenu->menu()->popup(m_sharesView->viewport()->mapToGlobal(pos));
0292 }
0293 
0294 void Smb4KSharesViewDockWidget::slotItemActivated(QListWidgetItem * /*item*/)
0295 {
0296     //
0297     // Do not execute the item when keyboard modifiers were pressed
0298     // or the mouse button is not the left one.
0299     //
0300     if (QApplication::keyboardModifiers() == Qt::NoModifier) {
0301         slotFileManagerActionTriggered(false);
0302     }
0303 }
0304 
0305 void Smb4KSharesViewDockWidget::slotItemSelectionChanged()
0306 {
0307     QList<QListWidgetItem *> selectedItems = m_sharesView->selectedItems();
0308 
0309     if (selectedItems.size() == 1) {
0310         Smb4KSharesViewItem *item = static_cast<Smb4KSharesViewItem *>(selectedItems.first());
0311         bool syncRunning = Smb4KSynchronizer::self()->isRunning(QUrl::fromLocalFile(item->shareItem()->path()));
0312 
0313         m_actionCollection->action(QStringLiteral("unmount_action"))
0314             ->setEnabled((!item->shareItem()->isForeign() || Smb4KMountSettings::unmountForeignShares()));
0315         m_actionCollection->action(QStringLiteral("bookmark_action"))->setEnabled(true);
0316         m_actionCollection->action(QStringLiteral("custom_action"))->setEnabled(true);
0317 
0318         if (!item->shareItem()->isInaccessible()) {
0319             m_actionCollection->action(QStringLiteral("synchronize_action"))
0320                 ->setEnabled(!QStandardPaths::findExecutable(QStringLiteral("rsync")).isEmpty() && !syncRunning);
0321             m_actionCollection->action(QStringLiteral("konsole_action"))->setEnabled(!QStandardPaths::findExecutable(QStringLiteral("konsole")).isEmpty());
0322             m_actionCollection->action(QStringLiteral("filemanager_action"))->setEnabled(true);
0323         } else {
0324             m_actionCollection->action(QStringLiteral("synchronize_action"))->setEnabled(false);
0325             m_actionCollection->action(QStringLiteral("konsole_action"))->setEnabled(false);
0326             m_actionCollection->action(QStringLiteral("filemanager_action"))->setEnabled(false);
0327         }
0328     } else if (selectedItems.size() > 1) {
0329         int syncsRunning = 0;
0330         int inaccessible = 0;
0331         int foreign = 0;
0332 
0333         for (QListWidgetItem *selectedItem : qAsConst(selectedItems)) {
0334             Smb4KSharesViewItem *item = static_cast<Smb4KSharesViewItem *>(selectedItem);
0335 
0336             if (item) {
0337                 // Is the share synchronized at the moment?
0338                 if (Smb4KSynchronizer::self()->isRunning(QUrl::fromLocalFile(item->shareItem()->path()))) {
0339                     syncsRunning += 1;
0340                 }
0341 
0342                 // Is the share inaccessible at the moment?
0343                 if (item->shareItem()->isInaccessible()) {
0344                     inaccessible += 1;
0345                 }
0346 
0347                 // Was the share being mounted by another user?
0348                 if (item->shareItem()->isForeign()) {
0349                     foreign += 1;
0350                 }
0351             }
0352         }
0353 
0354         m_actionCollection->action(QStringLiteral("unmount_action"))
0355             ->setEnabled(((selectedItems.size() > foreign) || Smb4KMountSettings::unmountForeignShares()));
0356         m_actionCollection->action(QStringLiteral("bookmark_action"))->setEnabled(true);
0357         m_actionCollection->action(QStringLiteral("custom_action"))->setEnabled(true);
0358 
0359         if (selectedItems.size() > inaccessible) {
0360             m_actionCollection->action(QStringLiteral("synchronize_action"))
0361                 ->setEnabled(!QStandardPaths::findExecutable(QStringLiteral("rsync")).isEmpty() && (selectedItems.size() > syncsRunning));
0362             m_actionCollection->action(QStringLiteral("konsole_action"))->setEnabled(!QStandardPaths::findExecutable(QStringLiteral("konsole")).isEmpty());
0363             m_actionCollection->action(QStringLiteral("filemanager_action"))->setEnabled(true);
0364         } else {
0365             m_actionCollection->action(QStringLiteral("synchronize_action"))->setEnabled(false);
0366             m_actionCollection->action(QStringLiteral("konsole_action"))->setEnabled(false);
0367             m_actionCollection->action(QStringLiteral("filemanager_action"))->setEnabled(false);
0368         }
0369     } else {
0370         m_actionCollection->action(QStringLiteral("unmount_action"))->setEnabled(false);
0371         m_actionCollection->action(QStringLiteral("bookmark_action"))->setEnabled(false);
0372         m_actionCollection->action(QStringLiteral("custom_action"))->setEnabled(false);
0373         m_actionCollection->action(QStringLiteral("synchronize_action"))->setEnabled(false);
0374         m_actionCollection->action(QStringLiteral("konsole_action"))->setEnabled(false);
0375         m_actionCollection->action(QStringLiteral("filemanager_action"))->setEnabled(false);
0376     }
0377 }
0378 
0379 void Smb4KSharesViewDockWidget::slotDropEvent(Smb4KSharesViewItem *item, QDropEvent *e)
0380 {
0381     if (item && e) {
0382         if (e->mimeData()->hasUrls()) {
0383             if (Smb4KHardwareInterface::self()->isOnline()) {
0384                 QUrl dest = QUrl::fromLocalFile(item->shareItem()->path());
0385                 KIO::DropJob *job = KIO::drop(e, dest, KIO::DefaultFlags);
0386                 KJobWidgets::setWindow(job, m_sharesView->viewport());
0387                 job->uiDelegate()->setAutoErrorHandlingEnabled(true);
0388                 job->uiDelegate()->setAutoWarningHandlingEnabled(true);
0389             } else {
0390                 KMessageBox::error(
0391                     m_sharesView,
0392                     i18n("<qt>There is no active connection to the share <b>%1</b>! You cannot drop any files here.</qt>", item->shareItem()->displayString()));
0393             }
0394         }
0395     }
0396 }
0397 
0398 void Smb4KSharesViewDockWidget::slotViewModeChanged(QAction *action)
0399 {
0400     //
0401     // Set the new view mode
0402     //
0403     if (action->objectName() == QStringLiteral("icon_view_action")) {
0404         Smb4KSettings::setSharesViewMode(Smb4KSettings::EnumSharesViewMode::IconView);
0405     } else if (action->objectName() == QStringLiteral("list_view_action")) {
0406         Smb4KSettings::setSharesViewMode(Smb4KSettings::EnumSharesViewMode::ListView);
0407     }
0408 
0409     //
0410     // Save settings
0411     //
0412     Smb4KSettings::self()->save();
0413 
0414     //
0415     // Load the settings
0416     //
0417     loadSettings();
0418 }
0419 
0420 void Smb4KSharesViewDockWidget::slotShareMounted(const SharePtr &share)
0421 {
0422     //
0423     // Add the share to the shares view
0424     //
0425     if (share) {
0426         // Add the item
0427         (void)new Smb4KSharesViewItem(m_sharesView, share);
0428 
0429         // Sort the view
0430         m_sharesView->sortItems(Qt::AscendingOrder);
0431 
0432         //
0433         // Update the tooltip
0434         //
0435         m_sharesView->toolTip()->update();
0436 
0437         // Enable/disable the 'Unmount All' action
0438         actionCollection()
0439             ->action(QStringLiteral("unmount_all_action"))
0440             ->setEnabled(((!onlyForeignMountedShares() || Smb4KMountSettings::unmountForeignShares()) && m_sharesView->count() != 0));
0441     }
0442 }
0443 
0444 void Smb4KSharesViewDockWidget::slotShareUnmounted(const SharePtr &share)
0445 {
0446     //
0447     // Remove the share from the shares view
0448     //
0449     if (share) {
0450         // Get the item and delete it. Take care of the current item, if necessary.
0451         for (int i = 0; i < m_sharesView->count(); ++i) {
0452             Smb4KSharesViewItem *item = static_cast<Smb4KSharesViewItem *>(m_sharesView->item(i));
0453 
0454             if (item && (item->shareItem()->path() == share->path() || item->shareItem()->canonicalPath() == share->canonicalPath())) {
0455                 if (item == m_sharesView->currentItem()) {
0456                     m_sharesView->setCurrentItem(nullptr);
0457                 }
0458 
0459                 delete m_sharesView->takeItem(i);
0460                 break;
0461             } else {
0462                 continue;
0463             }
0464         }
0465 
0466         // Enable/disable the 'Unmount All' action
0467         actionCollection()
0468             ->action(QStringLiteral("unmount_all_action"))
0469             ->setEnabled(((!onlyForeignMountedShares() || Smb4KMountSettings::unmountForeignShares()) && m_sharesView->count() != 0));
0470     }
0471 }
0472 
0473 void Smb4KSharesViewDockWidget::slotShareUpdated(const SharePtr &share)
0474 {
0475     //
0476     // Get the share item and updated it
0477     //
0478     if (share) {
0479         for (int i = 0; i < m_sharesView->count(); ++i) {
0480             Smb4KSharesViewItem *item = static_cast<Smb4KSharesViewItem *>(m_sharesView->item(i));
0481 
0482             if (item && (item->shareItem()->path() == share->path() || item->shareItem()->canonicalPath() == share->canonicalPath())) {
0483                 item->update();
0484                 break;
0485             } else {
0486                 continue;
0487             }
0488         }
0489     }
0490 }
0491 
0492 void Smb4KSharesViewDockWidget::slotUnmountActionTriggered(bool checked)
0493 {
0494     Q_UNUSED(checked);
0495 
0496     QList<QListWidgetItem *> selectedItems = m_sharesView->selectedItems();
0497     QList<SharePtr> shares;
0498 
0499     for (QListWidgetItem *selectedItem : qAsConst(selectedItems)) {
0500         Smb4KSharesViewItem *item = static_cast<Smb4KSharesViewItem *>(selectedItem);
0501 
0502         if (item) {
0503             shares << item->shareItem();
0504         }
0505     }
0506 
0507     Smb4KMounter::self()->unmountShares(shares, false);
0508 }
0509 
0510 void Smb4KSharesViewDockWidget::slotUnmountAllActionTriggered(bool checked)
0511 {
0512     Q_UNUSED(checked);
0513 
0514     Smb4KMounter::self()->unmountAllShares(false);
0515 }
0516 
0517 void Smb4KSharesViewDockWidget::slotBookmarkActionTriggered(bool checked)
0518 {
0519     Q_UNUSED(checked);
0520 
0521     QList<QListWidgetItem *> selectedItems = m_sharesView->selectedItems();
0522     QList<SharePtr> shares;
0523 
0524     for (QListWidgetItem *selectedItem : qAsConst(selectedItems)) {
0525         Smb4KSharesViewItem *item = static_cast<Smb4KSharesViewItem *>(selectedItem);
0526         shares << item->shareItem();
0527     }
0528 
0529     QPointer<Smb4KBookmarkDialog> bookmarkDialog = new Smb4KBookmarkDialog();
0530 
0531     if (bookmarkDialog->setShares(shares)) {
0532         bookmarkDialog->open();
0533     }
0534 }
0535 
0536 void Smb4KSharesViewDockWidget::slotAddCustomSettingsTriggered(bool checked)
0537 {
0538     Q_UNUSED(checked);
0539 
0540     QList<QListWidgetItem *> selectedItems = m_sharesView->selectedItems();
0541 
0542     for (QListWidgetItem *selectedItem : qAsConst(selectedItems)) {
0543         Smb4KSharesViewItem *item = static_cast<Smb4KSharesViewItem *>(selectedItem);
0544 
0545         QPointer<Smb4KCustomSettingsEditor> customSettingsEditor = new Smb4KCustomSettingsEditor();
0546         if (customSettingsEditor->setNetworkItem(item->shareItem())) {
0547             customSettingsEditor->open();
0548         } else {
0549             delete customSettingsEditor;
0550         }
0551     }
0552 }
0553 
0554 void Smb4KSharesViewDockWidget::slotSynchronizeActionTriggered(bool checked)
0555 {
0556     Q_UNUSED(checked);
0557 
0558     QList<QListWidgetItem *> selectedItems = m_sharesView->selectedItems();
0559 
0560     for (QListWidgetItem *selectedItem : qAsConst(selectedItems)) {
0561         Smb4KSharesViewItem *item = static_cast<Smb4KSharesViewItem *>(selectedItem);
0562 
0563         if (item && !item->shareItem()->isInaccessible() && !Smb4KSynchronizer::self()->isRunning(QUrl::fromLocalFile(item->shareItem()->path()))) {
0564             QPointer<Smb4KSynchronizationDialog> synchronizationDialog = new Smb4KSynchronizationDialog();
0565             if (synchronizationDialog->setShare(item->shareItem())) {
0566                 synchronizationDialog->open();
0567             } else {
0568                 delete synchronizationDialog;
0569             }
0570         }
0571     }
0572 }
0573 
0574 void Smb4KSharesViewDockWidget::slotKonsoleActionTriggered(bool checked)
0575 {
0576     Q_UNUSED(checked);
0577 
0578     QList<QListWidgetItem *> selectedItems = m_sharesView->selectedItems();
0579 
0580     for (QListWidgetItem *selectedItem : qAsConst(selectedItems)) {
0581         Smb4KSharesViewItem *item = static_cast<Smb4KSharesViewItem *>(selectedItem);
0582 
0583         if (item && !item->shareItem()->isInaccessible()) {
0584             openShare(item->shareItem(), Konsole);
0585         }
0586     }
0587 }
0588 
0589 void Smb4KSharesViewDockWidget::slotFileManagerActionTriggered(bool checked)
0590 {
0591     Q_UNUSED(checked);
0592 
0593     QList<QListWidgetItem *> selectedItems = m_sharesView->selectedItems();
0594 
0595     for (QListWidgetItem *selectedItem : qAsConst(selectedItems)) {
0596         Smb4KSharesViewItem *item = static_cast<Smb4KSharesViewItem *>(selectedItem);
0597 
0598         if (item && !item->shareItem()->isInaccessible()) {
0599             openShare(item->shareItem(), FileManager);
0600         }
0601     }
0602 }