Changeset View
Changeset View
Standalone View
Standalone View
sidebar/SidebarMode.cpp
Show First 20 Lines • Show All 270 Lines • ▼ Show 20 Line(s) | 270 | if (m_actionMenuVisible == actionMenuVisible) { | |||
---|---|---|---|---|---|
271 | return; | 271 | return; | ||
272 | } | 272 | } | ||
273 | m_actionMenuVisible = actionMenuVisible; | 273 | m_actionMenuVisible = actionMenuVisible; | ||
274 | emit sidebarMode->actionMenuVisibleChanged(); | 274 | emit sidebarMode->actionMenuVisibleChanged(); | ||
275 | } | 275 | } | ||
276 | bool m_introPageVisible = true; | 276 | bool m_introPageVisible = true; | ||
277 | }; | 277 | }; | ||
278 | 278 | | |||
279 | SidebarMode::SidebarMode( QObject *parent, const QVariantList& ) | 279 | SidebarMode::SidebarMode( QObject *parent, const QVariantList &args ) | ||
280 | : BaseMode( parent ) | 280 | : BaseMode( parent, args ) | ||
281 | , d( new Private() ) | 281 | , d( new Private() ) | ||
282 | { | 282 | { | ||
283 | qApp->setAttribute(Qt::AA_DontCreateNativeWidgetSiblings); | 283 | qApp->setAttribute(Qt::AA_DontCreateNativeWidgetSiblings); | ||
284 | d->aboutIcon = new KAboutData( QStringLiteral("SidebarView"), i18n( "Sidebar View" ), | 284 | d->aboutIcon = new KAboutData( QStringLiteral("SidebarView"), i18n( "Sidebar View" ), | ||
285 | QStringLiteral("1.0"), i18n( "Provides a categorized sidebar for control modules." ), | 285 | QStringLiteral("1.0"), i18n( "Provides a categorized sidebar for control modules." ), | ||
286 | KAboutLicense::GPL, i18n( "(c) 2017, Marco Martin" ) ); | 286 | KAboutLicense::GPL, i18n( "(c) 2017, Marco Martin" ) ); | ||
287 | d->aboutIcon->addAuthor( i18n( "Marco Martin" ), i18n( "Author" ), QStringLiteral("mart@kde.org") ); | 287 | d->aboutIcon->addAuthor( i18n( "Marco Martin" ), i18n( "Author" ), QStringLiteral("mart@kde.org") ); | ||
288 | d->aboutIcon->addAuthor( i18n( "Ben Cooksley" ), i18n( "Author" ), QStringLiteral("bcooksley@kde.org") ); | 288 | d->aboutIcon->addAuthor( i18n( "Ben Cooksley" ), i18n( "Author" ), QStringLiteral("bcooksley@kde.org") ); | ||
▲ Show 20 Lines • Show All 80 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 (applicationMode() == BaseMode::InfoCenter) { | ||||
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 62 Lines • ▼ Show 20 Line(s) | 444 | { | |||
447 | d->moduleView->closeModules(); | 453 | d->moduleView->closeModules(); | ||
448 | 454 | | |||
449 | MenuItem *mi = activeModule.data(MenuModel::MenuItemRole).value<MenuItem *>(); | 455 | MenuItem *mi = activeModule.data(MenuModel::MenuItemRole).value<MenuItem *>(); | ||
450 | 456 | | |||
451 | if (!mi) { | 457 | if (!mi) { | ||
452 | return; | 458 | return; | ||
453 | } | 459 | } | ||
454 | 460 | | |||
461 | if (homeItem()) { | ||||
462 | d->m_introPageVisible = activeModule == d->categorizedModel->mapFromSource(d->model->indexForItem(homeItem())); | ||||
463 | emit introPageVisibleChanged(); | ||||
464 | } else { | ||||
455 | setIntroPageVisible(false); | 465 | setIntroPageVisible(false); | ||
466 | } | ||||
467 | | ||||
456 | if ( mi->children().length() < 1) { | 468 | if ( mi->children().length() < 1) { | ||
457 | d->moduleView->loadModule( activeModule ); | 469 | d->moduleView->loadModule( activeModule ); | ||
458 | } else { | 470 | } else { | ||
459 | d->moduleView->loadModule( activeModule.model()->index(0, 0, activeModule) ); | 471 | d->moduleView->loadModule( activeModule.model()->index(0, 0, activeModule) ); | ||
460 | } | 472 | } | ||
461 | 473 | | |||
462 | if (activeModule.model() == d->categorizedModel) { | 474 | if (activeModule.model() == d->categorizedModel) { | ||
463 | const int newCategoryRow = activeModule.row(); | 475 | const int newCategoryRow = activeModule.row(); | ||
▲ Show 20 Lines • Show All 106 Lines • ▼ Show 20 Line(s) | |||||
570 | } | 582 | } | ||
571 | 583 | | |||
572 | void SidebarMode::setIntroPageVisible(const bool &introPageVisible) | 584 | void SidebarMode::setIntroPageVisible(const bool &introPageVisible) | ||
573 | { | 585 | { | ||
574 | if (d->m_introPageVisible == introPageVisible) { | 586 | if (d->m_introPageVisible == introPageVisible) { | ||
575 | return; | 587 | return; | ||
576 | } | 588 | } | ||
577 | 589 | | |||
590 | // TODO: Make the intro page of SystemSettings a KCM as well | ||||
591 | if (homeItem()) { | ||||
592 | d->placeHolderWidget->hide(); | ||||
593 | d->moduleView->show(); | ||||
594 | if (introPageVisible) { | ||||
595 | loadModule(d->categorizedModel->mapFromSource(d->model->indexForItem(homeItem()))); | ||||
596 | } | ||||
597 | } else { | ||||
578 | if (introPageVisible) { | 598 | if (introPageVisible) { | ||
579 | d->activeCategoryRow = -1; | 599 | d->activeCategoryRow = -1; | ||
580 | emit activeCategoryRowChanged(); | 600 | emit activeCategoryRowChanged(); | ||
581 | d->activeSubCategoryRow = -1; | 601 | d->activeSubCategoryRow = -1; | ||
582 | emit activeSubCategoryRowChanged(); | 602 | emit activeSubCategoryRowChanged(); | ||
583 | d->placeHolderWidget->show(); | 603 | d->placeHolderWidget->show(); | ||
584 | d->moduleView->hide(); | 604 | d->moduleView->hide(); | ||
585 | } else { | 605 | } else { | ||
586 | d->placeHolderWidget->hide(); | 606 | d->placeHolderWidget->hide(); | ||
587 | d->moduleView->show(); | 607 | d->moduleView->show(); | ||
588 | } | 608 | } | ||
609 | } | ||||
589 | 610 | | |||
590 | d->m_introPageVisible = introPageVisible; | 611 | d->m_introPageVisible = introPageVisible; | ||
591 | emit introPageVisibleChanged(); | 612 | emit introPageVisibleChanged(); | ||
592 | } | 613 | } | ||
593 | 614 | | |||
594 | int SidebarMode::width() const | 615 | int SidebarMode::width() const | ||
595 | { | 616 | { | ||
596 | return d->mainWidget->width(); | 617 | return d->mainWidget->width(); | ||
▲ Show 20 Lines • Show All 80 Lines • ▼ Show 20 Line(s) | 636 | { | |||
677 | d->mainLayout->addWidget( d->moduleView ); | 698 | d->mainLayout->addWidget( d->moduleView ); | ||
678 | d->mainLayout->addWidget( d->placeHolderWidget ); | 699 | d->mainLayout->addWidget( d->placeHolderWidget ); | ||
679 | emit changeToolBarItems(BaseMode::NoItems); | 700 | emit changeToolBarItems(BaseMode::NoItems); | ||
680 | 701 | | |||
681 | d->toolTipManager = new ToolTipManager(d->categorizedModel, d->quickWidget, ToolTipManager::ToolTipPosition::Right); | 702 | d->toolTipManager = new ToolTipManager(d->categorizedModel, d->quickWidget, ToolTipManager::ToolTipPosition::Right); | ||
682 | d->mostUsedToolTipManager = new ToolTipManager(d->mostUsedModel, d->placeHolderWidget, ToolTipManager::ToolTipPosition::BottomCenter); | 703 | d->mostUsedToolTipManager = new ToolTipManager(d->mostUsedModel, d->placeHolderWidget, ToolTipManager::ToolTipPosition::BottomCenter); | ||
683 | 704 | | |||
684 | d->mostUsedModel->setResultModel(new ResultModel( AllResources | Agent(QStringLiteral("org.kde.systemsettings")) | HighScoredFirst | Limit(5), this)); | 705 | d->mostUsedModel->setResultModel(new ResultModel( AllResources | Agent(QStringLiteral("org.kde.systemsettings")) | HighScoredFirst | Limit(5), this)); | ||
706 | | ||||
707 | if (homeItem()) { | ||||
708 | d->placeHolderWidget->hide(); | ||||
709 | d->moduleView->show(); | ||||
710 | loadModule(d->categorizedModel->mapFromSource(d->model->indexForItem(homeItem()))); | ||||
711 | } | ||||
685 | } | 712 | } | ||
686 | 713 | | |||
687 | bool SidebarMode::eventFilter(QObject* watched, QEvent* event) | 714 | bool SidebarMode::eventFilter(QObject* watched, QEvent* event) | ||
688 | { | 715 | { | ||
689 | //FIXME: those are all workarounds around the QQuickWidget brokeness | 716 | //FIXME: those are all workarounds around the QQuickWidget brokeness | ||
690 | if ((watched == d->quickWidget || watched == d->placeHolderWidget) | 717 | if ((watched == d->quickWidget || watched == d->placeHolderWidget) | ||
691 | && event->type() == QEvent::KeyPress) { | 718 | && event->type() == QEvent::KeyPress) { | ||
692 | //allow tab navigation inside the qquickwidget | 719 | //allow tab navigation inside the qquickwidget | ||
Show All 33 Lines |