File indexing completed on 2024-04-21 05:01:48

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