Changeset View
Standalone View
virtualdesktops.cpp
Show First 20 Lines • Show All 230 Lines • ▼ Show 20 Line(s) | |||||
231 | { | 231 | { | ||
232 | } | 232 | } | ||
233 | 233 | | |||
234 | VirtualDesktopManager::~VirtualDesktopManager() | 234 | VirtualDesktopManager::~VirtualDesktopManager() | ||
235 | { | 235 | { | ||
236 | s_manager = NULL; | 236 | s_manager = NULL; | ||
237 | } | 237 | } | ||
238 | 238 | | |||
239 | void VirtualDesktopManager::setRootInfo(NETRootInfo *info) | ||||
240 | { | ||||
241 | m_rootInfo = info; | ||||
242 | | ||||
243 | // Nothing will be connected to rootInfo | ||||
244 | if (m_rootInfo) { | ||||
245 | for (auto *vd : m_desktops) { | ||||
246 | connect(vd, &VirtualDesktop::nameChanged, this, | ||||
davidedmundson: we can get rid of this connect if we move the statement at ~468 to be outside if (m_rootInfo) | |||||
247 | [this, vd]() { | ||||
248 | if (m_rootInfo) { | ||||
249 | m_rootInfo->setDesktopName(vd->x11DesktopNumber(), vd->name().toUtf8().data()); | ||||
250 | } | ||||
251 | } | ||||
252 | ); | ||||
253 | m_rootInfo->setDesktopName(vd->x11DesktopNumber(), vd->name().toUtf8().data()); | ||||
254 | } | ||||
255 | } | ||||
256 | } | ||||
257 | | ||||
239 | QString VirtualDesktopManager::name(uint desktop) const | 258 | QString VirtualDesktopManager::name(uint desktop) const | ||
240 | { | 259 | { | ||
260 | if (m_desktops.length() > desktop - 1) { | ||||
261 | return m_desktops[desktop - 1]->name(); | ||||
262 | } | ||||
263 | | ||||
241 | if (!m_rootInfo) { | 264 | if (!m_rootInfo) { | ||
242 | return defaultName(desktop); | 265 | return defaultName(desktop); | ||
243 | } | 266 | } | ||
244 | return QString::fromUtf8(m_rootInfo->desktopName(desktop)); | 267 | return QString::fromUtf8(m_rootInfo->desktopName(desktop)); | ||
245 | } | 268 | } | ||
246 | 269 | | |||
247 | uint VirtualDesktopManager::above(uint id, bool wrap) const | 270 | uint VirtualDesktopManager::above(uint id, bool wrap) const | ||
248 | { | 271 | { | ||
▲ Show 20 Lines • Show All 207 Lines • ▼ Show 20 Line(s) | 455 | { | |||
456 | for (uint i = actualNumber; i < (uint)m_desktops.count(); ++i) { | 479 | for (uint i = actualNumber; i < (uint)m_desktops.count(); ++i) { | ||
457 | m_desktops[i]->setX11DesktopNumber(i + 1); | 480 | m_desktops[i]->setX11DesktopNumber(i + 1); | ||
458 | if (m_rootInfo) { | 481 | if (m_rootInfo) { | ||
459 | m_rootInfo->setDesktopName(i + 1, m_desktops[i]->name().toUtf8().data()); | 482 | m_rootInfo->setDesktopName(i + 1, m_desktops[i]->name().toUtf8().data()); | ||
460 | } | 483 | } | ||
461 | } | 484 | } | ||
462 | 485 | | |||
463 | m_desktops.insert(actualNumber - 1, vd); | 486 | m_desktops.insert(actualNumber - 1, vd); | ||
487 | | ||||
graesslin: Unrelated empty line | |||||
464 | save(); | 488 | save(); | ||
465 | 489 | | |||
466 | updateRootInfo(); | 490 | updateRootInfo(); | ||
467 | emit desktopCreated(vd); | 491 | emit desktopCreated(vd); | ||
468 | emit countChanged(m_desktops.count()-1, m_desktops.count()); | 492 | emit countChanged(m_desktops.count()-1, m_desktops.count()); | ||
469 | return vd; | 493 | return vd; | ||
470 | } | 494 | } | ||
471 | 495 | | |||
472 | void VirtualDesktopManager::removeVirtualDesktop(const QByteArray &id) | 496 | void VirtualDesktopManager::removeVirtualDesktop(const QByteArray &id) | ||
473 | { | 497 | { | ||
474 | //don't end up without any desktop | 498 | //don't end up without any desktop | ||
475 | if (m_desktops.count() == 1) { | 499 | if (m_desktops.count() == 1) { | ||
476 | return; | 500 | return; | ||
477 | } | 501 | } | ||
478 | auto desktop = desktopForId(id); | 502 | auto desktop = desktopForId(id); | ||
479 | if (!desktop) { | 503 | if (!desktop) { | ||
480 | return; | 504 | return; | ||
481 | } | 505 | } | ||
482 | 506 | | |||
483 | const uint oldCurrent = m_current->x11DesktopNumber(); | 507 | const uint oldCurrent = m_current->x11DesktopNumber(); | ||
484 | const uint i = desktop->x11DesktopNumber() - 1; | 508 | const uint i = desktop->x11DesktopNumber() - 1; | ||
485 | m_desktops.remove(i); | 509 | m_desktops.remove(i); | ||
510 | m_deskopsToRemoveFromConfig << desktop->x11DesktopNumber(); | ||||
486 | 511 | | |||
487 | for (uint j = i; j < (uint)m_desktops.count(); ++j) { | 512 | for (uint j = i; j < (uint)m_desktops.count(); ++j) { | ||
488 | m_desktops[j]->setX11DesktopNumber(j + 1); | 513 | m_desktops[j]->setX11DesktopNumber(j + 1); | ||
489 | if (m_rootInfo) { | 514 | if (m_rootInfo) { | ||
490 | m_rootInfo->setDesktopName(j + 1, m_desktops[j]->name().toUtf8().data()); | 515 | m_rootInfo->setDesktopName(j + 1, m_desktops[j]->name().toUtf8().data()); | ||
491 | } | 516 | } | ||
492 | } | 517 | } | ||
493 | 518 | | |||
▲ Show 20 Lines • Show All 59 Lines • ▼ Show 20 Line(s) | 577 | if (m_current) { | |||
553 | uint oldCurrent = current(); | 578 | uint oldCurrent = current(); | ||
554 | uint newCurrent = qMin(oldCurrent, count); | 579 | uint newCurrent = qMin(oldCurrent, count); | ||
555 | m_current = m_desktops.at(newCurrent - 1); | 580 | m_current = m_desktops.at(newCurrent - 1); | ||
556 | if (oldCurrent != newCurrent) { | 581 | if (oldCurrent != newCurrent) { | ||
557 | emit currentChanged(oldCurrent, newCurrent); | 582 | emit currentChanged(oldCurrent, newCurrent); | ||
558 | } | 583 | } | ||
559 | } | 584 | } | ||
560 | for (auto desktop : desktopsToRemove) { | 585 | for (auto desktop : desktopsToRemove) { | ||
586 | m_deskopsToRemoveFromConfig << desktop->x11DesktopNumber(); | ||||
561 | emit desktopRemoved(desktop); | 587 | emit desktopRemoved(desktop); | ||
562 | desktop->deleteLater(); | 588 | desktop->deleteLater(); | ||
563 | } | 589 | } | ||
564 | } else { | 590 | } else { | ||
565 | while (uint(m_desktops.count()) < count) { | 591 | while (uint(m_desktops.count()) < count) { | ||
566 | auto vd = new VirtualDesktop(this); | 592 | auto vd = new VirtualDesktop(this); | ||
567 | vd->setX11DesktopNumber(m_desktops.count() + 1); | 593 | const int x11Number = m_desktops.count() + 1; | ||
594 | vd->setX11DesktopNumber(x11Number); | ||||
595 | vd->setName(defaultName(x11Number)); | ||||
568 | if (!m_isLoading) { | 596 | if (!m_isLoading) { | ||
569 | vd->setId(QUuid::createUuid().toString().toUtf8()); | 597 | vd->setId(QUuid::createUuid().toString().toUtf8()); | ||
570 | } | 598 | } | ||
571 | m_desktops << vd; | 599 | m_desktops << vd; | ||
572 | newDesktops << vd; | 600 | newDesktops << vd; | ||
601 | | ||||
graesslin: unrelated addition of empty line | |||||
573 | if (m_rootInfo) { | 602 | if (m_rootInfo) { | ||
574 | connect(vd, &VirtualDesktop::nameChanged, this, | 603 | connect(vd, &VirtualDesktop::nameChanged, this, | ||
575 | [this, vd]() { | 604 | [this, vd]() { | ||
576 | if (m_rootInfo) { | 605 | if (m_rootInfo) { | ||
577 | m_rootInfo->setDesktopName(vd->x11DesktopNumber(), vd->name().toUtf8().data()); | 606 | m_rootInfo->setDesktopName(vd->x11DesktopNumber(), vd->name().toUtf8().data()); | ||
578 | } | 607 | } | ||
579 | } | 608 | } | ||
580 | ); | 609 | ); | ||
581 | m_rootInfo->setDesktopName(vd->x11DesktopNumber(), vd->name().toUtf8().data()); | 610 | m_rootInfo->setDesktopName(vd->x11DesktopNumber(), vd->name().toUtf8().data()); | ||
582 | } | 611 | } | ||
583 | } | 612 | } | ||
584 | } | 613 | } | ||
585 | 614 | | |||
586 | updateRootInfo(); | 615 | updateRootInfo(); | ||
587 | 616 | | |||
617 | if (!m_isLoading) { | ||||
588 | save(); | 618 | save(); | ||
619 | } | ||||
589 | for (auto vd : newDesktops) { | 620 | for (auto vd : newDesktops) { | ||
I don't understand this change. The method save has a protection to not do anything when calling save from loading. graesslin: I don't understand this change. The method save has a protection to not do anything when… | |||||
uhm, where? (tough didn't work as without this saving desktop names gets corrupted and autotests fail without it mart: uhm, where? (tough didn't work as without this saving desktop names gets corrupted and… | |||||
From VirtualDesktopManager::save: if (s_loadingDesktopSettings) { return; } s_loadingDesktopSettings is set to true at start of VirtualDesktopManager::load and back to false at the end of the method. Given that this was identical to the newly introduced m_isLoading it got removed in 92b5ddf94c6b472d928c20e4d4bc5407b086e44b graesslin: From VirtualDesktopManager::save:
```
if (s_loadingDesktopSettings) {
return… | |||||
590 | emit desktopCreated(vd); | 621 | emit desktopCreated(vd); | ||
591 | } | 622 | } | ||
592 | emit countChanged(oldCount, m_desktops.count()); | 623 | emit countChanged(oldCount, m_desktops.count()); | ||
593 | } | 624 | } | ||
594 | 625 | | |||
595 | 626 | | |||
596 | uint VirtualDesktopManager::rows() const | 627 | uint VirtualDesktopManager::rows() const | ||
597 | { | 628 | { | ||
598 | return grid().height(); | 629 | return grid().height(); | ||
davidedmundson: so is m_rows the canonical source or this?
| |||||
hmm, thinking about it should probably be m_rows.. mart: hmm, thinking about it should probably be m_rows..
m_rows is the number of rows it's configured… | |||||
599 | } | 630 | } | ||
600 | 631 | | |||
601 | void VirtualDesktopManager::setRows(uint rows) | 632 | void VirtualDesktopManager::setRows(uint rows) | ||
602 | { | 633 | { | ||
603 | if (static_cast<uint>(grid().height()) == rows || rows == 0 || rows > count()) { | 634 | if (static_cast<uint>(grid().height()) == rows || rows == 0 || rows > count()) { | ||
604 | return; | 635 | return; | ||
605 | } | 636 | } | ||
606 | 637 | | |||
607 | int columns = count() / rows; | 638 | m_rows = rows; | ||
608 | if (count() % rows > 0) { | 639 | | ||
640 | int columns = count() / m_rows; | ||||
641 | if (count() % m_rows > 0) { | ||||
609 | columns++; | 642 | columns++; | ||
610 | } | 643 | } | ||
611 | if (m_rootInfo) { | 644 | if (m_rootInfo) { | ||
612 | m_rootInfo->setDesktopLayout(NET::OrientationHorizontal, columns, rows, NET::DesktopLayoutCornerTopLeft); | 645 | m_rootInfo->setDesktopLayout(NET::OrientationHorizontal, columns, m_rows, NET::DesktopLayoutCornerTopLeft); | ||
613 | m_rootInfo->activate(); | 646 | m_rootInfo->activate(); | ||
614 | } | 647 | } | ||
615 | 648 | | |||
616 | updateLayout(); | 649 | updateLayout(); | ||
617 | 650 | | |||
618 | //rowsChanged will be emitted by setNETDesktopLayout called by updateLayout | 651 | //rowsChanged will be emitted by setNETDesktopLayout called by updateLayout | ||
619 | } | 652 | } | ||
620 | 653 | | |||
Show All 10 Lines | 655 | { | |||
631 | m_rootInfo->setDesktopViewport(n, *viewports); | 664 | m_rootInfo->setDesktopViewport(n, *viewports); | ||
632 | delete[] viewports; | 665 | delete[] viewports; | ||
633 | // Make sure the layout is still valid | 666 | // Make sure the layout is still valid | ||
634 | updateLayout(); | 667 | updateLayout(); | ||
635 | } | 668 | } | ||
636 | 669 | | |||
637 | void VirtualDesktopManager::updateLayout() | 670 | void VirtualDesktopManager::updateLayout() | ||
638 | { | 671 | { | ||
639 | int width = 0; | 672 | m_rows = qMin(m_rows, count()); | ||
640 | int height = 0; | 673 | int columns = count() / m_rows; | ||
graesslin: Can we be sure that this is never 0? | |||||
almost, (the only place is not checking is when taking it from rootinfo) mart: almost, (the only place is not checking is when taking it from rootinfo)
will add a qmax there… | |||||
641 | Qt::Orientation orientation = Qt::Horizontal; | 674 | Qt::Orientation orientation = Qt::Horizontal; | ||
675 | | ||||
graesslin: unrelated addition of empty line | |||||
642 | if (m_rootInfo) { | 676 | if (m_rootInfo) { | ||
643 | // TODO: Is there a sane way to avoid overriding the existing grid? | 677 | // TODO: Is there a sane way to avoid overriding the existing grid? | ||
644 | width = m_rootInfo->desktopLayoutColumnsRows().width(); | 678 | columns = m_rootInfo->desktopLayoutColumnsRows().width(); | ||
645 | height = m_rootInfo->desktopLayoutColumnsRows().height(); | 679 | m_rows = m_rootInfo->desktopLayoutColumnsRows().height(); | ||
646 | orientation = m_rootInfo->desktopLayoutOrientation() == NET::OrientationHorizontal ? Qt::Horizontal : Qt::Vertical; | 680 | orientation = m_rootInfo->desktopLayoutOrientation() == NET::OrientationHorizontal ? Qt::Horizontal : Qt::Vertical; | ||
647 | } | 681 | } | ||
648 | if (width == 0 && height == 0) { | 682 | | ||
683 | if (columns == 0) { | ||||
649 | // Not given, set default layout | 684 | // Not given, set default layout | ||
650 | height = count() == 1u ? 1 : 2; | 685 | m_rows = count() == 1u ? 1 : 2; | ||
686 | columns = count() / m_rows; | ||||
651 | } | 687 | } | ||
652 | setNETDesktopLayout(orientation, | 688 | setNETDesktopLayout(orientation, | ||
653 | width, height, 0 //rootInfo->desktopLayoutCorner() // Not really worth implementing right now. | 689 | columns, m_rows, 0 //rootInfo->desktopLayoutCorner() // Not really worth implementing right now. | ||
654 | ); | 690 | ); | ||
655 | } | 691 | } | ||
656 | 692 | | |||
657 | static bool s_loadingDesktopSettings = false; | 693 | static bool s_loadingDesktopSettings = false; | ||
658 | 694 | | |||
659 | void VirtualDesktopManager::load() | 695 | void VirtualDesktopManager::load() | ||
660 | { | 696 | { | ||
661 | s_loadingDesktopSettings = true; | 697 | s_loadingDesktopSettings = true; | ||
662 | if (!m_config) { | 698 | if (!m_config) { | ||
663 | return; | 699 | return; | ||
664 | } | 700 | } | ||
665 | //FIXME: how to avoid this? | 701 | //FIXME: how to avoid this? | ||
666 | m_isLoading = true; | 702 | m_isLoading = true; | ||
zzag: Wasn't it removed in another revision? Also, unrelated whitespace change. | |||||
mart: doesn't seem to compare it correctly against master? | |||||
667 | QString groupname; | 703 | QString groupname; | ||
668 | if (screen_number == 0) { | 704 | if (screen_number == 0) { | ||
669 | groupname = QStringLiteral("Desktops"); | 705 | groupname = QStringLiteral("Desktops"); | ||
670 | } else { | 706 | } else { | ||
671 | groupname.sprintf("Desktops-screen-%d", screen_number); | 707 | groupname.sprintf("Desktops-screen-%d", screen_number); | ||
672 | } | 708 | } | ||
673 | KConfigGroup group(m_config, groupname); | 709 | KConfigGroup group(m_config, groupname); | ||
674 | const int n = group.readEntry("Number", 1); | 710 | const int n = group.readEntry("Number", 1); | ||
675 | setCount(n); | 711 | setCount(n); | ||
676 | 712 | | |||
677 | for (int i = 1; i <= n; i++) { | 713 | for (int i = 1; i <= n; i++) { | ||
678 | QString s = group.readEntry(QStringLiteral("Name_%1").arg(i), i18n("Desktop %1", i)); | 714 | QString s = group.readEntry(QStringLiteral("Name_%1").arg(i), i18n("Desktop %1", i)); | ||
715 | | ||||
graesslin: Unrelated empty line | |||||
679 | if (m_rootInfo) { | 716 | if (m_rootInfo) { | ||
680 | m_rootInfo->setDesktopName(i, s.toUtf8().data()); | 717 | m_rootInfo->setDesktopName(i, s.toUtf8().data()); | ||
681 | } | 718 | } | ||
682 | m_desktops[i-1]->setName(s.toUtf8().data()); | 719 | m_desktops[i-1]->setName(s.toUtf8().data()); | ||
683 | 720 | | |||
684 | QString sId = group.readEntry(QStringLiteral("Id_%1").arg(i), QString()); | 721 | QString sId = group.readEntry(QStringLiteral("Id_%1").arg(i), QString()); | ||
685 | 722 | | |||
686 | //load gets called 2 times, see workspace.cpp line 416 and BUG 385260 | 723 | //load gets called 2 times, see workspace.cpp line 416 and BUG 385260 | ||
687 | if (m_desktops[i-1]->id().isEmpty()) { | 724 | if (m_desktops[i-1]->id().isEmpty()) { | ||
688 | if (sId.isEmpty()) { | 725 | if (sId.isEmpty()) { | ||
689 | sId = QUuid::createUuid().toString(); | 726 | sId = QUuid::createUuid().toString(); | ||
690 | } | 727 | } | ||
691 | m_desktops[i-1]->setId(sId.toUtf8().data()); | 728 | m_desktops[i-1]->setId(sId.toUtf8().data()); | ||
692 | } else { | 729 | } else { | ||
693 | Q_ASSERT(sId.isEmpty() || m_desktops[i-1]->id() == sId.toUtf8().data()); | 730 | Q_ASSERT(sId.isEmpty() || m_desktops[i-1]->id() == sId.toUtf8().data()); | ||
694 | } | 731 | } | ||
695 | 732 | | |||
696 | // TODO: update desktop focus chain, why? | 733 | // TODO: update desktop focus chain, why? | ||
697 | // m_desktopFocusChain.value()[i-1] = i; | 734 | // m_desktopFocusChain.value()[i-1] = i; | ||
698 | } | 735 | } | ||
699 | 736 | | |||
700 | if (m_rootInfo) { | | |||
701 | int rows = group.readEntry<int>("Rows", 2); | 737 | int rows = group.readEntry<int>("Rows", 2); | ||
702 | rows = qBound(1, rows, n); | 738 | m_rows = qBound(1, rows, n); | ||
739 | | ||||
740 | if (m_rootInfo) { | ||||
703 | // avoid weird cases like having 3 rows for 4 desktops, where the last row is unused | 741 | // avoid weird cases like having 3 rows for 4 desktops, where the last row is unused | ||
704 | int columns = n / rows; | 742 | int columns = n / m_rows; | ||
705 | if (n % rows > 0) { | 743 | if (n % m_rows > 0) { | ||
706 | columns++; | 744 | columns++; | ||
707 | } | 745 | } | ||
708 | m_rootInfo->setDesktopLayout(NET::OrientationHorizontal, columns, rows, NET::DesktopLayoutCornerTopLeft); | 746 | m_rootInfo->setDesktopLayout(NET::OrientationHorizontal, columns, m_rows, NET::DesktopLayoutCornerTopLeft); | ||
709 | m_rootInfo->activate(); | 747 | m_rootInfo->activate(); | ||
710 | } | 748 | } | ||
711 | 749 | | |||
712 | s_loadingDesktopSettings = false; | 750 | s_loadingDesktopSettings = false; | ||
713 | m_isLoading = false; | 751 | m_isLoading = false; | ||
714 | } | 752 | } | ||
715 | 753 | | |||
716 | void VirtualDesktopManager::save() | 754 | void VirtualDesktopManager::save() | ||
717 | { | 755 | { | ||
718 | if (s_loadingDesktopSettings) { | 756 | if (s_loadingDesktopSettings) { | ||
719 | return; | 757 | return; | ||
720 | } | 758 | } | ||
721 | if (!m_config) { | 759 | if (!m_config) { | ||
722 | return; | 760 | return; | ||
723 | } | 761 | } | ||
724 | QString groupname; | 762 | QString groupname; | ||
725 | if (screen_number == 0) { | 763 | if (screen_number == 0) { | ||
726 | groupname = QStringLiteral("Desktops"); | 764 | groupname = QStringLiteral("Desktops"); | ||
727 | } else { | 765 | } else { | ||
728 | groupname.sprintf("Desktops-screen-%d", screen_number); | 766 | groupname.sprintf("Desktops-screen-%d", screen_number); | ||
729 | } | 767 | } | ||
730 | KConfigGroup group(m_config, groupname); | 768 | KConfigGroup group(m_config, groupname); | ||
731 | 769 | | |||
770 | for (const int i : m_deskopsToRemoveFromConfig) { | ||||
I don't see why it would be an issue given we only load entries up to the value in "Number" anyway? If you do want to remove them, I'd rather something that uses the group as the data source. Then we don't need other changes and managing a second set of data. I think the current code breaks if you remove + add without calling save inbetween. Something along the lines of: for (int i = count() + 1; group.hasEntry("Id_" + i; i++) { group.deleteEntry("Id_" + i); } davidedmundson: I don't see why it would be an issue given we only load entries up to the value in "Number"… | |||||
zzag: Extra whitespace before `group`. | |||||
mart: indentation seems correct? | |||||
771 | group.deleteEntry(QStringLiteral("Id_%1").arg(i)); | ||||
772 | group.deleteEntry(QStringLiteral("Name_%1").arg(i)); | ||||
773 | } | ||||
774 | m_deskopsToRemoveFromConfig.clear(); | ||||
775 | | ||||
zzag: Extra empty line. | |||||
732 | group.writeEntry("Number", count()); | 776 | group.writeEntry("Number", count()); | ||
733 | for (uint i = 1; i <= count(); ++i) { | 777 | for (uint i = 1; i <= count(); ++i) { | ||
734 | QString s = name(i); | 778 | QString s = name(i); | ||
735 | const QString defaultvalue = defaultName(i); | 779 | const QString defaultvalue = defaultName(i); | ||
736 | if (s.isEmpty()) { | 780 | if (s.isEmpty()) { | ||
737 | s = defaultvalue; | 781 | s = defaultvalue; | ||
738 | if (m_rootInfo) { | 782 | if (m_rootInfo) { | ||
739 | m_rootInfo->setDesktopName(i, s.toUtf8().data()); | 783 | m_rootInfo->setDesktopName(i, s.toUtf8().data()); | ||
740 | } | 784 | } | ||
741 | } | 785 | } | ||
742 | 786 | | |||
743 | if (s != defaultvalue) { | 787 | if (s != defaultvalue) { | ||
744 | group.writeEntry(QStringLiteral("Name_%1").arg(i), s); | 788 | group.writeEntry(QStringLiteral("Name_%1").arg(i), s); | ||
745 | } else { | 789 | } else { | ||
746 | QString currentvalue = group.readEntry(QStringLiteral("Name_%1").arg(i), QString()); | 790 | QString currentvalue = group.readEntry(QStringLiteral("Name_%1").arg(i), QString()); | ||
747 | if (currentvalue != defaultvalue) { | 791 | if (currentvalue != defaultvalue) { | ||
748 | group.deleteEntry(QStringLiteral("Name_%1").arg(i)); | 792 | group.deleteEntry(QStringLiteral("Name_%1").arg(i)); | ||
749 | } | 793 | } | ||
750 | } | 794 | } | ||
751 | group.writeEntry(QStringLiteral("Id_%1").arg(i), m_desktops[i-1]->id()); | 795 | group.writeEntry(QStringLiteral("Id_%1").arg(i), m_desktops[i-1]->id()); | ||
752 | } | 796 | } | ||
753 | 797 | | |||
798 | group.writeEntry("Rows", m_rows); | ||||
799 | | ||||
754 | // Save to disk | 800 | // Save to disk | ||
755 | group.sync(); | 801 | group.sync(); | ||
756 | } | 802 | } | ||
757 | 803 | | |||
758 | QString VirtualDesktopManager::defaultName(int desktop) const | 804 | QString VirtualDesktopManager::defaultName(int desktop) const | ||
759 | { | 805 | { | ||
760 | return i18n("Desktop %1", desktop); | 806 | return i18n("Desktop %1", desktop); | ||
761 | } | 807 | } | ||
Show All 13 Lines | 810 | { | |||
775 | while (width * height < count) { | 821 | while (width * height < count) { | ||
776 | if (orientation == Qt::Horizontal) { | 822 | if (orientation == Qt::Horizontal) { | ||
777 | ++width; | 823 | ++width; | ||
778 | } else { | 824 | } else { | ||
779 | ++height; | 825 | ++height; | ||
780 | } | 826 | } | ||
781 | } | 827 | } | ||
782 | 828 | | |||
829 | m_rows = height; | ||||
830 | | ||||
783 | m_grid.update(QSize(width, height), orientation, m_desktops); | 831 | m_grid.update(QSize(width, height), orientation, m_desktops); | ||
784 | // TODO: why is there no call to m_rootInfo->setDesktopLayout? | 832 | // TODO: why is there no call to m_rootInfo->setDesktopLayout? | ||
785 | emit layoutChanged(width, height); | 833 | emit layoutChanged(width, height); | ||
786 | emit rowsChanged(height); | 834 | emit rowsChanged(height); | ||
787 | } | 835 | } | ||
788 | 836 | | |||
789 | void VirtualDesktopManager::initShortcuts() | 837 | void VirtualDesktopManager::initShortcuts() | ||
790 | { | 838 | { | ||
▲ Show 20 Lines • Show All 109 Lines • Show Last 20 Lines |
we can get rid of this connect if we move the statement at ~468 to be outside if (m_rootInfo)