Changeset View
Changeset View
Standalone View
Standalone View
src/panels/folders/folderspanel.cpp
Show All 22 Lines | |||||
23 | #include "dolphin_generalsettings.h" | 23 | #include "dolphin_generalsettings.h" | ||
24 | #include "foldersitemlistwidget.h" | 24 | #include "foldersitemlistwidget.h" | ||
25 | #include "global.h" | 25 | #include "global.h" | ||
26 | #include "kitemviews/kfileitemlistview.h" | 26 | #include "kitemviews/kfileitemlistview.h" | ||
27 | #include "kitemviews/kfileitemmodel.h" | 27 | #include "kitemviews/kfileitemmodel.h" | ||
28 | #include "kitemviews/kitemlistcontainer.h" | 28 | #include "kitemviews/kitemlistcontainer.h" | ||
29 | #include "kitemviews/kitemlistcontroller.h" | 29 | #include "kitemviews/kitemlistcontroller.h" | ||
30 | #include "kitemviews/kitemlistselectionmanager.h" | 30 | #include "kitemviews/kitemlistselectionmanager.h" | ||
31 | #include "treeviewcontextmenu.h" | | |||
32 | #include "views/draganddrophelper.h" | 31 | #include "views/draganddrophelper.h" | ||
33 | 32 | | |||
34 | #include <KJobWidgets> | 33 | #include <KJobWidgets> | ||
35 | #include <KJobUiDelegate> | 34 | #include <KJobUiDelegate> | ||
36 | #include <KIO/CopyJob> | 35 | #include <KIO/CopyJob> | ||
37 | #include <KIO/DropJob> | 36 | #include <KIO/DropJob> | ||
38 | #include <KIO/FileUndoManager> | 37 | #include <KIO/FileUndoManager> | ||
39 | #include <KIO/RenameFileDialog> | 38 | #include <KIO/RenameFileDialog> | ||
39 | #include <KLocalizedString> | ||||
40 | #include <QAction> | ||||
41 | #include <QMenu> | ||||
40 | 42 | | |||
41 | #include <QApplication> | 43 | #include <QApplication> | ||
42 | #include <QBoxLayout> | 44 | #include <QBoxLayout> | ||
43 | #include <QGraphicsSceneDragDropEvent> | 45 | #include <QGraphicsSceneDragDropEvent> | ||
44 | #include <QGraphicsView> | 46 | #include <QGraphicsView> | ||
45 | #include <QPropertyAnimation> | 47 | #include <QPropertyAnimation> | ||
46 | #include <QTimer> | 48 | #include <QTimer> | ||
47 | 49 | | |||
▲ Show 20 Lines • Show All 159 Lines • ▼ Show 20 Line(s) | |||||
207 | void FoldersPanel::slotItemMiddleClicked(int index) | 209 | void FoldersPanel::slotItemMiddleClicked(int index) | ||
208 | { | 210 | { | ||
209 | const KFileItem item = m_model->fileItem(index); | 211 | const KFileItem item = m_model->fileItem(index); | ||
210 | if (!item.isNull()) { | 212 | if (!item.isNull()) { | ||
211 | emit folderMiddleClicked(item.url()); | 213 | emit folderMiddleClicked(item.url()); | ||
212 | } | 214 | } | ||
213 | } | 215 | } | ||
214 | 216 | | |||
217 | QList<QAction *> FoldersPanel::folderPanelContextMenuActions() | ||||
218 | { | ||||
219 | QList<QAction *> actions; | ||||
220 | | ||||
221 | QAction* showHiddenFilesAction = new QAction(i18nc("@action:inmenu", "Show Hidden Files"), this); | ||||
222 | showHiddenFilesAction->setCheckable(true); | ||||
223 | showHiddenFilesAction->setChecked(showHiddenFiles()); | ||||
224 | actions.append(showHiddenFilesAction); | ||||
225 | connect(showHiddenFilesAction, &QAction::toggled, this, &FoldersPanel::setShowHiddenFiles); | ||||
226 | | ||||
227 | // insert 'Limit to Home Directory' | ||||
228 | QAction* limitFoldersPanelToHomeAction = new QAction(i18nc("@action:inmenu", "Limit to Home Directory"), this); | ||||
229 | limitFoldersPanelToHomeAction->setCheckable(true); | ||||
230 | limitFoldersPanelToHomeAction->setChecked(limitFoldersPanelToHome()); | ||||
231 | actions.append(limitFoldersPanelToHomeAction); | ||||
232 | connect(limitFoldersPanelToHomeAction, &QAction::toggled, this, &FoldersPanel::setLimitFoldersPanelToHome); | ||||
233 | | ||||
234 | // TODO: Temporary disabled. Horizontal autoscrolling will be implemented later either | ||||
235 | // in KItemViews or manually as part of the FoldersPanel | ||||
236 | /* | ||||
237 | // insert 'Automatic Scrolling' | ||||
238 | QAction* autoScrollingAction = new QAction(i18nc("@action:inmenu", "Automatic Scrolling"), this); | ||||
239 | autoScrollingAction->setCheckable(true); | ||||
240 | autoScrollingAction->setChecked(autoScrolling()); | ||||
241 | connect(autoScrollingAction, &QAction::toggled, this, &FoldersPanel::setAutoScrolling); | ||||
242 | actions->addAction(autoScrollingAction); | ||||
243 | */ | ||||
244 | | ||||
245 | const QList<QAction*> customActions = customContextMenuActions(); | ||||
246 | if (!customActions.isEmpty()) { | ||||
247 | QAction *separatorAction = new QAction(); | ||||
248 | separatorAction->setSeparator(true); | ||||
249 | actions.append(separatorAction); | ||||
250 | for (QAction* action: customActions) { | ||||
251 | actions.append(action); | ||||
252 | } | ||||
253 | } | ||||
254 | | ||||
255 | return actions; | ||||
256 | } | ||||
257 | | ||||
215 | void FoldersPanel::slotItemContextMenuRequested(int index, const QPointF& pos) | 258 | void FoldersPanel::slotItemContextMenuRequested(int index, const QPointF& pos) | ||
216 | { | 259 | { | ||
217 | const KFileItem fileItem = m_model->fileItem(index); | 260 | const KFileItem fileItem = m_model->fileItem(index); | ||
261 | const KFileItemList list({fileItem}); | ||||
218 | 262 | | |||
219 | QPointer<TreeViewContextMenu> contextMenu = new TreeViewContextMenu(this, fileItem); | 263 | requestOpenContextMenu(pos.toPoint(), fileItem, fileItem.url(), folderPanelContextMenuActions(), list); | ||
220 | contextMenu.data()->open(pos.toPoint()); | | |||
221 | if (contextMenu.data()) { | | |||
222 | delete contextMenu.data(); | | |||
223 | } | | |||
224 | } | 264 | } | ||
225 | 265 | | |||
226 | void FoldersPanel::slotViewContextMenuRequested(const QPointF& pos) | 266 | void FoldersPanel::slotViewContextMenuRequested(const QPointF& pos) | ||
227 | { | 267 | { | ||
228 | QPointer<TreeViewContextMenu> contextMenu = new TreeViewContextMenu(this, KFileItem()); | 268 | QMenu* popup = new QMenu(this); | ||
229 | contextMenu.data()->open(pos.toPoint()); | 269 | popup->addActions(folderPanelContextMenuActions()); | ||
230 | if (contextMenu.data()) { | 270 | | ||
231 | delete contextMenu.data(); | 271 | QPointer<QMenu> popupPtr = popup; | ||
272 | popup->exec(pos.toPoint()); | ||||
273 | if (popupPtr.data()) { | ||||
274 | popupPtr.data()->deleteLater(); | ||||
232 | } | 275 | } | ||
233 | } | 276 | } | ||
234 | 277 | | |||
235 | void FoldersPanel::slotItemDropEvent(int index, QGraphicsSceneDragDropEvent* event) | 278 | void FoldersPanel::slotItemDropEvent(int index, QGraphicsSceneDragDropEvent* event) | ||
236 | { | 279 | { | ||
237 | if (index >= 0) { | 280 | if (index >= 0) { | ||
238 | KFileItem destItem = m_model->fileItem(index); | 281 | KFileItem destItem = m_model->fileItem(index); | ||
239 | if (destItem.isNull()) { | 282 | if (destItem.isNull()) { | ||
▲ Show 20 Lines • Show All 124 Lines • Show Last 20 Lines |