Changeset View
Changeset View
Standalone View
Standalone View
src/plasma/corona.cpp
Show First 20 Lines • Show All 366 Lines • ▼ Show 20 Line(s) | 366 | } else { | |||
---|---|---|---|---|---|
367 | bool unlocked = d->immutability == Types::Mutable; | 367 | bool unlocked = d->immutability == Types::Mutable; | ||
368 | action->setText(unlocked ? i18n("Lock Widgets") : i18n("Unlock Widgets")); | 368 | action->setText(unlocked ? i18n("Lock Widgets") : i18n("Unlock Widgets")); | ||
369 | action->setIcon(QIcon::fromTheme(unlocked ? QStringLiteral("object-locked") : QStringLiteral("object-unlocked"))); | 369 | action->setIcon(QIcon::fromTheme(unlocked ? QStringLiteral("object-locked") : QStringLiteral("object-unlocked"))); | ||
370 | action->setEnabled(true); | 370 | action->setEnabled(true); | ||
371 | action->setVisible(true); | 371 | action->setVisible(true); | ||
372 | } | 372 | } | ||
373 | } | 373 | } | ||
374 | 374 | | |||
375 | action = d->actions.action(QStringLiteral("edit mode")); | ||||
376 | if (action) { | ||||
377 | switch (d->immutability) { | ||||
378 | case Types::UserImmutable: | ||||
broulik: Why is this switch to explicitly stating all the cases?
The action is always visible and… | |||||
ah, it wanted to be setVisible(false) in case of systemimmutable, so they should be all different mart: ah, it wanted to be setVisible(false) in case of systemimmutable, so they should be all… | |||||
379 | action->setEnabled(false); | ||||
broulik: fall-through? | |||||
380 | action->setVisible(true); | ||||
381 | break; | ||||
382 | case Types::SystemImmutable: | ||||
383 | action->setEnabled(false); | ||||
384 | action->setVisible(false); | ||||
385 | break; | ||||
386 | case Types::Mutable: | ||||
387 | default: | ||||
388 | action->setEnabled(true); | ||||
389 | action->setVisible(true); | ||||
390 | break; | ||||
391 | } | ||||
392 | } | ||||
393 | | ||||
375 | if (d->immutability != Types::SystemImmutable) { | 394 | if (d->immutability != Types::SystemImmutable) { | ||
376 | KConfigGroup cg(config(), "General"); | 395 | KConfigGroup cg(config(), "General"); | ||
377 | 396 | | |||
378 | // we call the dptr member directly for locked since isImmutable() | 397 | // we call the dptr member directly for locked since isImmutable() | ||
379 | // also checks kiosk and parent containers | 398 | // also checks kiosk and parent containers | ||
380 | cg.writeEntry("immutability", (int)d->immutability); | 399 | cg.writeEntry("immutability", (int)d->immutability); | ||
381 | requestConfigSync(); | 400 | requestConfigSync(); | ||
382 | } | 401 | } | ||
383 | 402 | | |||
384 | if (d->immutability != Types::Mutable) { | 403 | if (d->immutability != Types::Mutable) { | ||
385 | d->editMode = false; | 404 | setEditMode(false); | ||
386 | emit editModeChanged(); | | |||
387 | } | 405 | } | ||
388 | } | 406 | } | ||
389 | 407 | | |||
390 | void Corona::setEditMode(bool edit) | 408 | void Corona::setEditMode(bool edit) | ||
391 | { | 409 | { | ||
392 | if (d->immutability != Plasma::Types::Mutable || edit == d->editMode) { | 410 | if (edit == d->editMode || (edit && d->immutability != Plasma::Types::Mutable)) { | ||
393 | return; | 411 | return; | ||
394 | } | 412 | } | ||
395 | 413 | | |||
414 | QAction *editAction = d->actions.action(QStringLiteral("edit mode")); | ||||
415 | if (editAction) { | ||||
416 | if (edit) { | ||||
417 | editAction->setText(i18n("Finish Customizing Layout")); | ||||
418 | } else { | ||||
419 | editAction->setText(i18n("Customize Layout...")); | ||||
This isn't just editing editing widgets; maybe "Enter Edit Mode" ? That would make the name better correspond with the text of the opposite state too. Alternatives:
ngraham: This isn't just editing editing widgets; maybe "Enter Edit Mode" ? That would make the name… | |||||
What about...
GB_2: What about...
- "Switch to Edit Mode"/"Leave Edit Mode"
- "Enter Edit Mode"/"Exit Edit Mode"… | |||||
GB_2: Missing ellipsis (...) | |||||
420 | } | ||||
421 | } | ||||
422 | | ||||
396 | d->editMode = edit; | 423 | d->editMode = edit; | ||
397 | emit editModeChanged(); | 424 | emit editModeChanged(edit); | ||
398 | } | 425 | } | ||
399 | 426 | | |||
400 | bool Corona::isEditMode() const | 427 | bool Corona::isEditMode() const | ||
401 | { | 428 | { | ||
402 | return d->editMode; | 429 | return d->editMode; | ||
403 | } | 430 | } | ||
404 | 431 | | |||
405 | QList<Plasma::Types::Location> Corona::freeEdges(int screen) const | 432 | QList<Plasma::Types::Location> Corona::freeEdges(int screen) const | ||
▲ Show 20 Lines • Show All 56 Lines • ▼ Show 20 Line(s) | 476 | { | |||
462 | lockAction->setIcon(QIcon::fromTheme(QStringLiteral("object-locked"))); | 489 | lockAction->setIcon(QIcon::fromTheme(QStringLiteral("object-locked"))); | ||
463 | lockAction->setData(Plasma::Types::ControlAction); | 490 | lockAction->setData(Plasma::Types::ControlAction); | ||
464 | lockAction->setShortcut(QKeySequence(QStringLiteral("alt+d, l"))); | 491 | lockAction->setShortcut(QKeySequence(QStringLiteral("alt+d, l"))); | ||
465 | lockAction->setShortcutContext(Qt::ApplicationShortcut); | 492 | lockAction->setShortcutContext(Qt::ApplicationShortcut); | ||
466 | 493 | | |||
467 | //fake containment/applet actions | 494 | //fake containment/applet actions | ||
468 | KActionCollection *containmentActions = AppletPrivate::defaultActions(q); //containment has to start with applet stuff | 495 | KActionCollection *containmentActions = AppletPrivate::defaultActions(q); //containment has to start with applet stuff | ||
469 | ContainmentPrivate::addDefaultActions(containmentActions); //now it's really containment | 496 | ContainmentPrivate::addDefaultActions(containmentActions); //now it's really containment | ||
497 | | ||||
498 | QAction *editAction = actions.add<QAction>(QStringLiteral("edit mode")); | ||||
499 | QObject::connect(editAction, &QAction::triggered, q, [this] () { | ||||
500 | q->setEditMode(!q->isEditMode()); | ||||
501 | }); | ||||
502 | editAction->setText(i18n("Customize Layout...")); | ||||
GB_2: Missing ellipsis (...) | |||||
Given how easy it is to get these out of sync, can I suggest removing all the code to update editAction's text from Corona::setEditMode and put it in a connect here. It'll keep the editAction logic altogether. davidedmundson: Given how easy it is to get these out of sync, can I suggest removing all the code to update… | |||||
503 | editAction->setAutoRepeat(true); | ||||
504 | editAction->setIcon(QIcon::fromTheme(QStringLiteral("document-edit"))); | ||||
505 | editAction->setData(Plasma::Types::ControlAction); | ||||
506 | editAction->setShortcut(QKeySequence(QStringLiteral("alt+d, e"))); | ||||
507 | editAction->setShortcutContext(Qt::ApplicationShortcut); | ||||
470 | } | 508 | } | ||
471 | 509 | | |||
472 | void CoronaPrivate::toggleImmutability() | 510 | void CoronaPrivate::toggleImmutability() | ||
473 | { | 511 | { | ||
474 | if (immutability == Types::Mutable) { | 512 | if (immutability == Types::Mutable) { | ||
475 | q->setImmutability(Types::UserImmutable); | 513 | q->setImmutability(Types::UserImmutable); | ||
476 | } else { | 514 | } else { | ||
477 | q->setImmutability(Types::Mutable); | 515 | q->setImmutability(Types::Mutable); | ||
▲ Show 20 Lines • Show All 221 Lines • Show Last 20 Lines |
Why is this switch to explicitly stating all the cases?
The action is always visible and enabled only when Mutable