Changeset View
Changeset View
Standalone View
Standalone View
sidebar/SidebarMode.cpp
Show First 20 Lines • Show All 368 Lines • ▼ Show 20 Line(s) | 346 | { | |||
---|---|---|---|---|---|
369 | d->mainWidget = new FocusHackWidget(); | 369 | d->mainWidget = new FocusHackWidget(); | ||
370 | d->mainWidget->installEventFilter(this); | 370 | d->mainWidget->installEventFilter(this); | ||
371 | d->mainLayout = new QHBoxLayout(d->mainWidget); | 371 | d->mainLayout = new QHBoxLayout(d->mainWidget); | ||
372 | d->mainLayout->setContentsMargins(0, 0, 0, 0); | 372 | d->mainLayout->setContentsMargins(0, 0, 0, 0); | ||
373 | d->moduleView = new ModuleView( d->mainWidget ); | 373 | d->moduleView = new ModuleView( d->mainWidget ); | ||
374 | connect( d->moduleView, &ModuleView::moduleChanged, this, &SidebarMode::moduleLoaded ); | 374 | connect( d->moduleView, &ModuleView::moduleChanged, this, &SidebarMode::moduleLoaded ); | ||
375 | d->quickWidget = nullptr; | 375 | d->quickWidget = nullptr; | ||
376 | moduleView()->setFaceType(KPageView::Plain); | 376 | moduleView()->setFaceType(KPageView::Plain); | ||
377 | if (isInfoCenterMode()) { | ||||
378 | d->moduleView->setSaveStatistics(false); | ||||
379 | d->moduleView->setApplyVisible(false); | ||||
380 | d->moduleView->setDefaultsVisible(false); | ||||
381 | d->moduleView->setResetVisible(false); | ||||
382 | } | ||||
377 | } | 383 | } | ||
378 | 384 | | |||
379 | QAction *SidebarMode::action(const QString &name) const | 385 | QAction *SidebarMode::action(const QString &name) const | ||
380 | { | 386 | { | ||
381 | if (!d->collection) { | 387 | if (!d->collection) { | ||
382 | return nullptr; | 388 | return nullptr; | ||
383 | } | 389 | } | ||
384 | 390 | | |||
▲ Show 20 Lines • Show All 58 Lines • ▼ Show 20 Line(s) | 444 | { | |||
443 | d->moduleView->closeModules(); | 449 | d->moduleView->closeModules(); | ||
444 | 450 | | |||
445 | MenuItem *mi = activeModule.data(MenuModel::MenuItemRole).value<MenuItem *>(); | 451 | MenuItem *mi = activeModule.data(MenuModel::MenuItemRole).value<MenuItem *>(); | ||
446 | 452 | | |||
447 | if (!mi) { | 453 | if (!mi) { | ||
448 | return; | 454 | return; | ||
449 | } | 455 | } | ||
450 | 456 | | |||
457 | if (homeItem()) { | ||||
458 | d->m_introPageVisible = activeModule == d->categorizedModel->mapFromSource(d->model->indexForItem(homeItem())); | ||||
459 | emit introPageVisibleChanged(); | ||||
460 | } else { | ||||
451 | setIntroPageVisible(false); | 461 | setIntroPageVisible(false); | ||
462 | } | ||||
463 | | ||||
452 | if ( mi->children().length() < 1) { | 464 | if ( mi->children().length() < 1) { | ||
453 | d->moduleView->loadModule( activeModule ); | 465 | d->moduleView->loadModule( activeModule ); | ||
454 | } else { | 466 | } else { | ||
455 | d->moduleView->loadModule( activeModule.model()->index(0, 0, activeModule) ); | 467 | d->moduleView->loadModule( activeModule.model()->index(0, 0, activeModule) ); | ||
456 | } | 468 | } | ||
457 | 469 | | |||
458 | if (activeModule.model() == d->categorizedModel) { | 470 | if (activeModule.model() == d->categorizedModel) { | ||
459 | const int newCategoryRow = activeModule.row(); | 471 | const int newCategoryRow = activeModule.row(); | ||
▲ Show 20 Lines • Show All 109 Lines • ▼ Show 20 Line(s) | |||||
569 | } | 581 | } | ||
570 | 582 | | |||
571 | void SidebarMode::setIntroPageVisible(const bool &introPageVisible) | 583 | void SidebarMode::setIntroPageVisible(const bool &introPageVisible) | ||
572 | { | 584 | { | ||
573 | if (d->m_introPageVisible == introPageVisible) { | 585 | if (d->m_introPageVisible == introPageVisible) { | ||
574 | return; | 586 | return; | ||
575 | } | 587 | } | ||
576 | 588 | | |||
589 | // TODO: eventually make the intro page of SystemSettings a KCM as well? | ||||
590 | if (homeItem()) { | ||||
davidedmundson: Yes! that would be a nicer design | |||||
591 | d->placeHolderWidget->hide(); | ||||
592 | d->moduleView->show(); | ||||
593 | if (introPageVisible) { | ||||
594 | loadModule(d->categorizedModel->mapFromSource(d->model->indexForItem(homeItem()))); | ||||
595 | } | ||||
596 | } else { | ||||
577 | if (introPageVisible) { | 597 | if (introPageVisible) { | ||
578 | d->activeCategoryRow = -1; | 598 | d->activeCategoryRow = -1; | ||
579 | emit activeCategoryRowChanged(); | 599 | emit activeCategoryRowChanged(); | ||
580 | d->activeSubCategoryRow = -1; | 600 | d->activeSubCategoryRow = -1; | ||
581 | emit activeSubCategoryRowChanged(); | 601 | emit activeSubCategoryRowChanged(); | ||
582 | d->placeHolderWidget->show(); | 602 | d->placeHolderWidget->show(); | ||
583 | d->moduleView->hide(); | 603 | d->moduleView->hide(); | ||
584 | } else { | 604 | } else { | ||
585 | d->placeHolderWidget->hide(); | 605 | d->placeHolderWidget->hide(); | ||
586 | d->moduleView->show(); | 606 | d->moduleView->show(); | ||
587 | } | 607 | } | ||
608 | } | ||||
588 | 609 | | |||
589 | d->m_introPageVisible = introPageVisible; | 610 | d->m_introPageVisible = introPageVisible; | ||
590 | emit introPageVisibleChanged(); | 611 | emit introPageVisibleChanged(); | ||
591 | } | 612 | } | ||
592 | 613 | | |||
593 | int SidebarMode::width() const | 614 | int SidebarMode::width() const | ||
594 | { | 615 | { | ||
595 | return d->mainWidget->width(); | 616 | return d->mainWidget->width(); | ||
▲ Show 20 Lines • Show All 80 Lines • ▼ Show 20 Line(s) | 635 | { | |||
676 | d->mainLayout->addWidget( d->moduleView ); | 697 | d->mainLayout->addWidget( d->moduleView ); | ||
677 | d->mainLayout->addWidget( d->placeHolderWidget ); | 698 | d->mainLayout->addWidget( d->placeHolderWidget ); | ||
678 | emit changeToolBarItems(BaseMode::NoItems); | 699 | emit changeToolBarItems(BaseMode::NoItems); | ||
679 | 700 | | |||
680 | d->toolTipManager = new ToolTipManager(d->categorizedModel, d->quickWidget, ToolTipManager::ToolTipPosition::Right); | 701 | d->toolTipManager = new ToolTipManager(d->categorizedModel, d->quickWidget, ToolTipManager::ToolTipPosition::Right); | ||
681 | d->mostUsedToolTipManager = new ToolTipManager(d->mostUsedModel, d->placeHolderWidget, ToolTipManager::ToolTipPosition::BottomCenter); | 702 | d->mostUsedToolTipManager = new ToolTipManager(d->mostUsedModel, d->placeHolderWidget, ToolTipManager::ToolTipPosition::BottomCenter); | ||
682 | 703 | | |||
683 | d->mostUsedModel->setResultModel(new ResultModel( AllResources | Agent(QStringLiteral("org.kde.systemsettings")) | HighScoredFirst | Limit(5), this)); | 704 | d->mostUsedModel->setResultModel(new ResultModel( AllResources | Agent(QStringLiteral("org.kde.systemsettings")) | HighScoredFirst | Limit(5), this)); | ||
705 | | ||||
706 | if (homeItem()) { | ||||
707 | d->placeHolderWidget->hide(); | ||||
708 | d->moduleView->show(); | ||||
709 | loadModule(d->categorizedModel->mapFromSource(d->model->indexForItem(homeItem()))); | ||||
710 | } | ||||
684 | } | 711 | } | ||
685 | 712 | | |||
686 | bool SidebarMode::eventFilter(QObject* watched, QEvent* event) | 713 | bool SidebarMode::eventFilter(QObject* watched, QEvent* event) | ||
687 | { | 714 | { | ||
688 | //FIXME: those are all workarounds around the QQuickWidget brokeness | 715 | //FIXME: those are all workarounds around the QQuickWidget brokeness | ||
689 | if ((watched == d->quickWidget || watched == d->placeHolderWidget) | 716 | if ((watched == d->quickWidget || watched == d->placeHolderWidget) | ||
690 | && event->type() == QEvent::KeyPress) { | 717 | && event->type() == QEvent::KeyPress) { | ||
691 | //allow tab navigation inside the qquickwidget | 718 | //allow tab navigation inside the qquickwidget | ||
Show All 33 Lines |
Yes! that would be a nicer design