Changeset View
Changeset View
Standalone View
Standalone View
sidebar/SidebarMode.cpp
Show First 20 Lines • Show All 390 Lines • ▼ Show 20 Line(s) | |||||
391 | 391 | | |||
392 | void SidebarMode::loadMostUsed(int index) | 392 | void SidebarMode::loadMostUsed(int index) | ||
393 | { | 393 | { | ||
394 | const QModelIndex idx = d->mostUsedModel->index(index, 0); | 394 | const QModelIndex idx = d->mostUsedModel->index(index, 0); | ||
395 | d->moduleView->closeModules(); | 395 | d->moduleView->closeModules(); | ||
396 | d->moduleView->loadModule( idx ); | 396 | d->moduleView->loadModule( idx ); | ||
397 | } | 397 | } | ||
398 | 398 | | |||
399 | void SidebarMode::showMostUsedPage() | ||||
400 | { | ||||
401 | d->placeHolderWidget->show(); | ||||
broulik: This leaks.
`menu->setAttribute(Qt::WA_DeleteOnClose);` | |||||
402 | d->moduleView->hide(); | ||||
broulik: `const` | |||||
403 | } | ||||
I think it's better to iterate the list of actions and then get them from the collection. This way the order is also preserved correctly: for (const QString &actionName : actionList) { menu->addAction(d->collection->action(actionName); } broulik: I think it's better to iterate the list of actions and then get them from the collection. This… | |||||
404 | | ||||
399 | void SidebarMode::changeModule( const QModelIndex& activeModule ) | 405 | void SidebarMode::changeModule( const QModelIndex& activeModule ) | ||
400 | { | 406 | { | ||
401 | d->moduleView->closeModules(); | 407 | d->moduleView->closeModules(); | ||
402 | 408 | | |||
403 | const int subRows = d->searchModel->rowCount(activeModule); | 409 | const int subRows = d->searchModel->rowCount(activeModule); | ||
Don't exec() in conjunction with QML, this is just asking for trouble. Use popup() instead broulik: Don't `exec()` in conjunction with QML, this is just asking for trouble. Use `popup()` instead | |||||
404 | if ( subRows < 2) { | 410 | if ( subRows < 2) { | ||
405 | d->moduleView->loadModule( activeModule ); | 411 | d->moduleView->loadModule( activeModule ); | ||
406 | } else { | 412 | } else { | ||
407 | d->moduleView->loadModule( d->searchModel->index(0, 0, activeModule) ); | 413 | d->moduleView->loadModule( d->searchModel->index(0, 0, activeModule) ); | ||
408 | } | 414 | } | ||
409 | 415 | | |||
410 | d->subCategoryModel->setParentIndex( activeModule ); | 416 | d->subCategoryModel->setParentIndex( activeModule ); | ||
411 | } | 417 | } | ||
▲ Show 20 Lines • Show All 153 Lines • ▼ Show 20 Line(s) | 566 | if (qqw && qqw->rootObject()) { | |||
565 | } | 571 | } | ||
566 | } | 572 | } | ||
567 | } else if (watched == d->quickWidget && event->type() == QEvent::Leave) { | 573 | } else if (watched == d->quickWidget && event->type() == QEvent::Leave) { | ||
568 | QCoreApplication::sendEvent(d->quickWidget->quickWindow(), event); | 574 | QCoreApplication::sendEvent(d->quickWidget->quickWindow(), event); | ||
569 | } else if (watched == d->mainWidget && event->type() == QEvent::Resize) { | 575 | } else if (watched == d->mainWidget && event->type() == QEvent::Resize) { | ||
570 | emit widthChanged(); | 576 | emit widthChanged(); | ||
571 | } else if (watched == d->mainWidget && event->type() == QEvent::Show) { | 577 | } else if (watched == d->mainWidget && event->type() == QEvent::Show) { | ||
572 | emit changeToolBarItems(BaseMode::NoItems); | 578 | emit changeToolBarItems(BaseMode::NoItems); | ||
573 | } | 579 | } | ||
Not a huge fan of this. broulik: Not a huge fan of this.
Can this be done in qqc2-desktop-style to be generic and fix every… | |||||
Not really, seems like the KQuickStyleItem only has access to the QML window of the menu control and also can't detect events on the rest of the QWidget window :( GB_2: Not really, seems like the KQuickStyleItem only has access to the QML window of the menu… | |||||
574 | return BaseMode::eventFilter(watched, event); | 580 | return BaseMode::eventFilter(watched, event); | ||
575 | } | 581 | } | ||
576 | 582 | | |||
577 | void SidebarMode::giveFocus() | 583 | void SidebarMode::giveFocus() | ||
578 | { | 584 | { | ||
579 | d->quickWidget->setFocus(); | 585 | d->quickWidget->setFocus(); | ||
580 | } | 586 | } | ||
581 | 587 | | |||
582 | #include "SidebarMode.moc" | 588 | #include "SidebarMode.moc" |
This leaks.
menu->setAttribute(Qt::WA_DeleteOnClose);