Changeset View
Changeset View
Standalone View
Standalone View
sidebar/SidebarMode.cpp
Show First 20 Lines • Show All 228 Lines • ▼ Show 20 Line(s) | 222 | public: | |||
---|---|---|---|---|---|
229 | {} | 229 | {} | ||
230 | 230 | | |||
231 | virtual ~Private() { | 231 | virtual ~Private() { | ||
232 | delete aboutIcon; | 232 | delete aboutIcon; | ||
233 | } | 233 | } | ||
234 | 234 | | |||
235 | ToolTipManager *toolTipManager = nullptr; | 235 | ToolTipManager *toolTipManager = nullptr; | ||
236 | ToolTipManager *subCategoryToolTipManager = nullptr; | 236 | ToolTipManager *subCategoryToolTipManager = nullptr; | ||
237 | ToolTipManager *mostUsedToolTipManager = nullptr; | ||||
237 | QQuickWidget * quickWidget = nullptr; | 238 | QQuickWidget * quickWidget = nullptr; | ||
238 | KPackage::Package package; | 239 | KPackage::Package package; | ||
239 | SubcategoryModel * subCategoryModel = nullptr; | 240 | SubcategoryModel * subCategoryModel = nullptr; | ||
240 | MostUsedModel * mostUsedModel = nullptr; | 241 | MostUsedModel * mostUsedModel = nullptr; | ||
241 | FocusHackWidget * mainWidget = nullptr; | 242 | FocusHackWidget * mainWidget = nullptr; | ||
242 | QQuickWidget * placeHolderWidget = nullptr; | 243 | QQuickWidget * placeHolderWidget = nullptr; | ||
243 | QHBoxLayout * mainLayout = nullptr; | 244 | QHBoxLayout * mainLayout = nullptr; | ||
244 | KDeclarative::KDeclarative kdeclarative; | 245 | KDeclarative::KDeclarative kdeclarative; | ||
▲ Show 20 Lines • Show All 139 Lines • ▼ Show 20 Line(s) | |||||
384 | 385 | | |||
385 | void SidebarMode::requestSubCategoryToolTip(int index, const QRectF &rect) | 386 | void SidebarMode::requestSubCategoryToolTip(int index, const QRectF &rect) | ||
386 | { | 387 | { | ||
387 | if (showToolTips()) { | 388 | if (showToolTips()) { | ||
388 | d->subCategoryToolTipManager->requestToolTip(d->subCategoryModel->index(index, 0), rect.toRect()); | 389 | d->subCategoryToolTipManager->requestToolTip(d->subCategoryModel->index(index, 0), rect.toRect()); | ||
389 | } | 390 | } | ||
390 | } | 391 | } | ||
391 | 392 | | |||
393 | void SidebarMode::requestMostUsedToolTip(int index, const QRectF &rect) | ||||
394 | { | ||||
395 | if (showToolTips()) { | ||||
396 | d->mostUsedToolTipManager->requestToolTip(d->mostUsedModel->index(index, 0), rect.toRect()); | ||||
397 | } | ||||
398 | } | ||||
399 | | ||||
392 | void SidebarMode::hideToolTip() | 400 | void SidebarMode::hideToolTip() | ||
393 | { | 401 | { | ||
394 | d->toolTipManager->hideToolTip(); | 402 | d->toolTipManager->hideToolTip(); | ||
395 | } | 403 | } | ||
396 | 404 | | |||
397 | void SidebarMode::hideSubCategoryToolTip() | 405 | void SidebarMode::hideSubCategoryToolTip() | ||
398 | { | 406 | { | ||
399 | d->subCategoryToolTipManager->hideToolTip(); | 407 | d->subCategoryToolTipManager->hideToolTip(); | ||
400 | } | 408 | } | ||
401 | 409 | | |||
410 | void SidebarMode::hideMostUsedToolTip() | ||||
411 | { | ||||
412 | d->mostUsedToolTipManager->hideToolTip(); | ||||
413 | } | ||||
414 | | ||||
402 | void SidebarMode::loadMostUsed(int index) | 415 | void SidebarMode::loadMostUsed(int index) | ||
403 | { | 416 | { | ||
404 | const QModelIndex idx = d->mostUsedModel->index(index, 0); | 417 | const QModelIndex idx = d->mostUsedModel->index(index, 0); | ||
405 | d->moduleView->closeModules(); | 418 | d->moduleView->closeModules(); | ||
406 | d->moduleView->loadModule( idx ); | 419 | d->moduleView->loadModule( idx ); | ||
407 | } | 420 | } | ||
408 | 421 | | |||
409 | void SidebarMode::showActionMenu(const QPoint &position) | 422 | void SidebarMode::showActionMenu(const QPoint &position) | ||
▲ Show 20 Lines • Show All 134 Lines • ▼ Show 20 Line(s) | 556 | } else { | |||
544 | d->quickWidget->setFixedWidth(240); | 557 | d->quickWidget->setFixedWidth(240); | ||
545 | } | 558 | } | ||
546 | }); | 559 | }); | ||
547 | connect(d->quickWidget->rootObject(), SIGNAL(focusNextRequest()), d->mainWidget, SLOT(focusNext())); | 560 | connect(d->quickWidget->rootObject(), SIGNAL(focusNextRequest()), d->mainWidget, SLOT(focusNext())); | ||
548 | connect(d->quickWidget->rootObject(), SIGNAL(focusPreviousRequest()), d->mainWidget, SLOT(focusPrevious())); | 561 | connect(d->quickWidget->rootObject(), SIGNAL(focusPreviousRequest()), d->mainWidget, SLOT(focusPrevious())); | ||
549 | 562 | | |||
550 | d->quickWidget->installEventFilter(this); | 563 | d->quickWidget->installEventFilter(this); | ||
551 | 564 | | |||
552 | d->toolTipManager = new ToolTipManager(d->searchModel, d->quickWidget); | | |||
553 | d->subCategoryToolTipManager = new ToolTipManager(d->subCategoryModel, d->quickWidget); | | |||
554 | | ||||
555 | d->placeHolderWidget = new QQuickWidget(d->mainWidget); | 565 | d->placeHolderWidget = new QQuickWidget(d->mainWidget); | ||
556 | d->placeHolderWidget->quickWindow()->setTitle(i18n("Most Used")); | 566 | d->placeHolderWidget->quickWindow()->setTitle(i18n("Most Used")); | ||
557 | d->placeHolderWidget->setResizeMode(QQuickWidget::SizeRootObjectToView); | 567 | d->placeHolderWidget->setResizeMode(QQuickWidget::SizeRootObjectToView); | ||
558 | d->placeHolderWidget->engine()->rootContext()->setContextObject(new KLocalizedContext(d->placeHolderWidget)); | 568 | d->placeHolderWidget->engine()->rootContext()->setContextObject(new KLocalizedContext(d->placeHolderWidget)); | ||
559 | d->placeHolderWidget->engine()->rootContext()->setContextProperty(QStringLiteral("systemsettings"), this); | 569 | d->placeHolderWidget->engine()->rootContext()->setContextProperty(QStringLiteral("systemsettings"), this); | ||
560 | d->placeHolderWidget->setSource(QUrl::fromLocalFile(d->package.filePath("ui", QStringLiteral("introPage.qml")))); | 570 | d->placeHolderWidget->setSource(QUrl::fromLocalFile(d->package.filePath("ui", QStringLiteral("introPage.qml")))); | ||
561 | connect(d->placeHolderWidget->rootObject(), SIGNAL(focusNextRequest()), d->mainWidget, SLOT(focusNext())); | 571 | connect(d->placeHolderWidget->rootObject(), SIGNAL(focusNextRequest()), d->mainWidget, SLOT(focusNext())); | ||
562 | connect(d->placeHolderWidget->rootObject(), SIGNAL(focusPreviousRequest()), d->mainWidget, SLOT(focusPrevious())); | 572 | connect(d->placeHolderWidget->rootObject(), SIGNAL(focusPreviousRequest()), d->mainWidget, SLOT(focusPrevious())); | ||
563 | d->placeHolderWidget->installEventFilter(this); | 573 | d->placeHolderWidget->installEventFilter(this); | ||
564 | 574 | | |||
565 | d->mainLayout->addWidget( d->quickWidget ); | 575 | d->mainLayout->addWidget( d->quickWidget ); | ||
566 | d->moduleView->hide(); | 576 | d->moduleView->hide(); | ||
567 | d->mainLayout->addWidget( d->moduleView ); | 577 | d->mainLayout->addWidget( d->moduleView ); | ||
568 | d->mainLayout->addWidget( d->placeHolderWidget ); | 578 | d->mainLayout->addWidget( d->placeHolderWidget ); | ||
569 | emit changeToolBarItems(BaseMode::NoItems); | 579 | emit changeToolBarItems(BaseMode::NoItems); | ||
570 | 580 | | |||
581 | d->toolTipManager = new ToolTipManager(d->searchModel, d->quickWidget, ToolTipManager::ToolTipPosition::Right); | ||||
ngraham: Is there a strong reason to move these around? | |||||
I want to have all the initializations of tooltip managers in one place. I couldn't add the third manager there because the placeHolderWidget is not initialized yet tienisto: I want to have all the initializations of tooltip managers in one place. I couldn't add the… | |||||
582 | d->subCategoryToolTipManager = new ToolTipManager(d->subCategoryModel, d->quickWidget, ToolTipManager::ToolTipPosition::Right); | ||||
583 | d->mostUsedToolTipManager = new ToolTipManager(d->mostUsedModel, d->placeHolderWidget, ToolTipManager::ToolTipPosition::BottomCenter); | ||||
584 | | ||||
571 | d->mostUsedModel->setResultModel(new ResultModel( AllResources | Agent(QStringLiteral("org.kde.systemsettings")) | HighScoredFirst | Limit(5), this)); | 585 | d->mostUsedModel->setResultModel(new ResultModel( AllResources | Agent(QStringLiteral("org.kde.systemsettings")) | HighScoredFirst | Limit(5), this)); | ||
572 | } | 586 | } | ||
573 | 587 | | |||
574 | bool SidebarMode::eventFilter(QObject* watched, QEvent* event) | 588 | bool SidebarMode::eventFilter(QObject* watched, QEvent* event) | ||
575 | { | 589 | { | ||
576 | //FIXME: those are all workarounds around the QQuickWidget brokeness | 590 | //FIXME: those are all workarounds around the QQuickWidget brokeness | ||
577 | if ((watched == d->quickWidget || watched == d->placeHolderWidget) | 591 | if ((watched == d->quickWidget || watched == d->placeHolderWidget) | ||
578 | && event->type() == QEvent::KeyPress) { | 592 | && event->type() == QEvent::KeyPress) { | ||
Show All 34 Lines |
Is there a strong reason to move these around?