Changeset View
Changeset View
Standalone View
Standalone View
src/panels/places/placespanel.cpp
Show First 20 Lines • Show All 58 Lines • ▼ Show 20 Line(s) | 56 | PlacesPanel::PlacesPanel(QWidget* parent) : | |||
---|---|---|---|---|---|
59 | m_model(nullptr), | 59 | m_model(nullptr), | ||
60 | m_view(nullptr), | 60 | m_view(nullptr), | ||
61 | m_storageSetupFailedUrl(), | 61 | m_storageSetupFailedUrl(), | ||
62 | m_triggerStorageSetupButton(), | 62 | m_triggerStorageSetupButton(), | ||
63 | m_itemDropEventIndex(-1), | 63 | m_itemDropEventIndex(-1), | ||
64 | m_itemDropEventMimeData(nullptr), | 64 | m_itemDropEventMimeData(nullptr), | ||
65 | m_itemDropEvent(nullptr) | 65 | m_itemDropEvent(nullptr) | ||
66 | { | 66 | { | ||
67 | } | 67 | } | ||
elvisangelaccio: Why drop "Show" from the label though? | |||||
This puts its text in line with the hidden files entry that is just "Hidden Files". rizzitello: This puts its text in line with the hidden files entry that is just "Hidden Files".
| |||||
Maybe. Places Panel's context menu says "Show All Entries", not "All Entries", though. cfeck: Maybe. Places Panel's context menu says "Show All Entries", not "All Entries", though. | |||||
It no longer does with this diff. They actions match (as they were one before my last update) rizzitello: It no longer does with this diff. They actions match (as they were one before my last update) | |||||
Oh, you are re-using the action, that's nice. I will retract all my comments and let maintainer decide. I would prefer 'Show Hidden Files" and "Show Hidden Places" for clarity over brevity. We also say "Show Menubar", "Show Filter Bar", etc. cfeck: Oh, you are re-using the action, that's nice. I will retract all my comments and let maintainer… | |||||
cfeck: What Elvis meant was `Hidden Places` → `Show Hidden Places`. | |||||
68 | 68 | | |||
69 | PlacesPanel::~PlacesPanel() | 69 | PlacesPanel::~PlacesPanel() | ||
70 | { | 70 | { | ||
71 | } | 71 | } | ||
72 | 72 | | |||
73 | void PlacesPanel::proceedWithTearDown() | 73 | void PlacesPanel::proceedWithTearDown() | ||
74 | { | 74 | { | ||
75 | m_model->proceedWithTearDown(); | 75 | m_model->proceedWithTearDown(); | ||
▲ Show 20 Lines • Show All 177 Lines • ▼ Show 20 Line(s) | 245 | } else { | |||
253 | } | 253 | } | ||
254 | 254 | | |||
255 | if (action == editAction) { | 255 | if (action == editAction) { | ||
256 | editEntry(index); | 256 | editEntry(index); | ||
257 | } else if (action == removeAction) { | 257 | } else if (action == removeAction) { | ||
258 | m_model->deleteItem(index); | 258 | m_model->deleteItem(index); | ||
259 | } else if (action == hideAction) { | 259 | } else if (action == hideAction) { | ||
260 | item->setHidden(hideAction->isChecked()); | 260 | item->setHidden(hideAction->isChecked()); | ||
261 | if (!m_model->hiddenCount()) { | ||||
262 | showHiddenEntries(false); | ||||
263 | } | ||||
261 | } else if (action == openInNewWindowAction) { | 264 | } else if (action == openInNewWindowAction) { | ||
262 | Dolphin::openNewWindow({KFilePlacesModel::convertedUrl(m_model->data(index).value("url").toUrl())}, this); | 265 | Dolphin::openNewWindow({KFilePlacesModel::convertedUrl(m_model->data(index).value("url").toUrl())}, this); | ||
263 | } else if (action == openInNewTabAction) { | 266 | } else if (action == openInNewTabAction) { | ||
264 | // TriggerItem does set up the storage first and then it will | 267 | // TriggerItem does set up the storage first and then it will | ||
265 | // emit the slotItemMiddleClicked signal, because of Qt::MiddleButton. | 268 | // emit the slotItemMiddleClicked signal, because of Qt::MiddleButton. | ||
266 | triggerItem(index, Qt::MiddleButton); | 269 | triggerItem(index, Qt::MiddleButton); | ||
267 | } else if (action == mountAction) { | 270 | } else if (action == mountAction) { | ||
268 | m_model->requestStorageSetup(index); | 271 | m_model->requestStorageSetup(index); | ||
Show All 13 Lines | |||||
282 | } | 285 | } | ||
283 | 286 | | |||
284 | void PlacesPanel::slotViewContextMenuRequested(const QPointF& pos) | 287 | void PlacesPanel::slotViewContextMenuRequested(const QPointF& pos) | ||
285 | { | 288 | { | ||
286 | QMenu menu(this); | 289 | QMenu menu(this); | ||
287 | 290 | | |||
288 | QAction* addAction = menu.addAction(QIcon::fromTheme(QStringLiteral("document-new")), i18nc("@item:inmenu", "Add Entry...")); | 291 | QAction* addAction = menu.addAction(QIcon::fromTheme(QStringLiteral("document-new")), i18nc("@item:inmenu", "Add Entry...")); | ||
289 | 292 | | |||
290 | QAction* showAllAction = nullptr; | 293 | QAction* showAllAction = menu.addAction(i18nc("@item:inmenu", "Show Hidden Places")); | ||
291 | if (m_model->hiddenCount() > 0) { | | |||
One more thing: the new action needs to be added only if we have hidden entries, like we do here. This means we need one more public method in PlacesPanel elvisangelaccio: One more thing: the new action needs to be added only if we have hidden entries, like we do… | |||||
292 | showAllAction = menu.addAction(QIcon::fromTheme(QStringLiteral("visibility")), i18nc("@item:inmenu", "Show All Entries")); | | |||
293 | showAllAction->setCheckable(true); | 294 | showAllAction->setCheckable(true); | ||
294 | showAllAction->setChecked(m_model->hiddenItemsShown()); | 295 | showAllAction->setChecked(m_model->hiddenItemsShown()); | ||
295 | } | 296 | showAllAction->setIcon(QIcon::fromTheme(m_model->hiddenItemsShown() ? QStringLiteral("visibility") : QStringLiteral("hint"))); | ||
297 | showAllAction->setEnabled(m_model->hiddenCount()); | ||||
296 | 298 | | |||
297 | buildGroupContextMenu(&menu, m_controller->indexCloseToMousePressedPosition()); | 299 | buildGroupContextMenu(&menu, m_controller->indexCloseToMousePressedPosition()); | ||
298 | 300 | | |||
299 | QMenu* iconSizeSubMenu = new QMenu(i18nc("@item:inmenu", "Icon Size"), &menu); | 301 | QMenu* iconSizeSubMenu = new QMenu(i18nc("@item:inmenu", "Icon Size"), &menu); | ||
300 | 302 | | |||
301 | struct IconSizeInfo | 303 | struct IconSizeInfo | ||
302 | { | 304 | { | ||
303 | int size; | 305 | int size; | ||
Show All 31 Lines | 336 | foreach (QAction* action, customContextMenuActions()) { | |||
335 | menu.addAction(action); | 337 | menu.addAction(action); | ||
336 | } | 338 | } | ||
337 | 339 | | |||
338 | QAction* action = menu.exec(pos.toPoint()); | 340 | QAction* action = menu.exec(pos.toPoint()); | ||
339 | if (action) { | 341 | if (action) { | ||
340 | if (action == addAction) { | 342 | if (action == addAction) { | ||
341 | addEntry(); | 343 | addEntry(); | ||
342 | } else if (action == showAllAction) { | 344 | } else if (action == showAllAction) { | ||
343 | m_model->setHiddenItemsShown(showAllAction->isChecked()); | 345 | showHiddenEntries(showAllAction->isChecked()); | ||
344 | } else if (iconSizeActionMap.contains(action)) { | 346 | } else if (iconSizeActionMap.contains(action)) { | ||
345 | m_view->setIconSize(iconSizeActionMap.value(action)); | 347 | m_view->setIconSize(iconSizeActionMap.value(action)); | ||
346 | } | 348 | } | ||
347 | } | 349 | } | ||
348 | 350 | | |||
349 | selectClosestItem(); | 351 | selectClosestItem(); | ||
350 | } | 352 | } | ||
351 | 353 | | |||
352 | QAction *PlacesPanel::buildGroupContextMenu(QMenu *menu, int index) | 354 | QAction *PlacesPanel::buildGroupContextMenu(QMenu *menu, int index) | ||
353 | { | 355 | { | ||
354 | if (index == -1) { | 356 | if (index == -1) { | ||
355 | return nullptr; | 357 | return nullptr; | ||
356 | } | 358 | } | ||
357 | 359 | | |||
358 | KFilePlacesModel::GroupType groupType = m_model->groupType(index); | 360 | KFilePlacesModel::GroupType groupType = m_model->groupType(index); | ||
359 | QAction *hideGroupAction = menu->addAction(QIcon::fromTheme(QStringLiteral("hint")), i18nc("@item:inmenu", "Hide Section '%1'", m_model->item(index)->group())); | 361 | QAction *hideGroupAction = menu->addAction(QIcon::fromTheme(QStringLiteral("hint")), i18nc("@item:inmenu", "Hide Section '%1'", m_model->item(index)->group())); | ||
360 | hideGroupAction->setCheckable(true); | 362 | hideGroupAction->setCheckable(true); | ||
361 | hideGroupAction->setChecked(m_model->isGroupHidden(groupType)); | 363 | hideGroupAction->setChecked(m_model->isGroupHidden(groupType)); | ||
362 | 364 | | |||
363 | connect(hideGroupAction, &QAction::triggered, this, [this, groupType, hideGroupAction]{ | 365 | connect(hideGroupAction, &QAction::triggered, this, [this, groupType, hideGroupAction]{ | ||
364 | m_model->setGroupHidden(groupType, hideGroupAction->isChecked()); | 366 | m_model->setGroupHidden(groupType, hideGroupAction->isChecked()); | ||
367 | if (!m_model->hiddenCount()) { | ||||
368 | showHiddenEntries(false); | ||||
369 | } | ||||
365 | }); | 370 | }); | ||
366 | 371 | | |||
367 | return hideGroupAction; | 372 | return hideGroupAction; | ||
368 | } | 373 | } | ||
369 | 374 | | |||
370 | void PlacesPanel::slotItemDropEvent(int index, QGraphicsSceneDragDropEvent* event) | 375 | void PlacesPanel::slotItemDropEvent(int index, QGraphicsSceneDragDropEvent* event) | ||
371 | { | 376 | { | ||
372 | if (index < 0) { | 377 | if (index < 0) { | ||
▲ Show 20 Lines • Show All 163 Lines • ▼ Show 20 Line(s) | 540 | if (!url.isEmpty()) { | |||
536 | if (button == Qt::MiddleButton) { | 541 | if (button == Qt::MiddleButton) { | ||
537 | emit placeMiddleClicked(KFilePlacesModel::convertedUrl(url)); | 542 | emit placeMiddleClicked(KFilePlacesModel::convertedUrl(url)); | ||
538 | } else { | 543 | } else { | ||
539 | emit placeActivated(KFilePlacesModel::convertedUrl(url)); | 544 | emit placeActivated(KFilePlacesModel::convertedUrl(url)); | ||
540 | } | 545 | } | ||
541 | } | 546 | } | ||
542 | } | 547 | } | ||
543 | } | 548 | } | ||
549 | | ||||
550 | void PlacesPanel::showHiddenEntries(bool shown) | ||||
551 | { | ||||
552 | m_model->setHiddenItemsShown(shown); | ||||
553 | emit showHiddenEntriesChanged(shown); | ||||
554 | } | ||||
555 | | ||||
556 | int PlacesPanel::hiddenListCount() | ||||
557 | { | ||||
558 | if(!m_model) { | ||||
elvisangelaccio: Coding style: space before/after the parentheses | |||||
559 | return 0; | ||||
560 | } | ||||
561 | return m_model->hiddenCount(); | ||||
562 | } |
Why drop "Show" from the label though?