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