Changeset View
Changeset View
Standalone View
Standalone View
sidebar/SidebarMode.cpp
Show First 20 Lines • Show All 253 Lines • ▼ Show 20 Line(s) | 222 | public: | |||
---|---|---|---|---|---|
254 | void setActionMenuVisible(SidebarMode* sidebarMode, const bool &actionMenuVisible) | 254 | void setActionMenuVisible(SidebarMode* sidebarMode, const bool &actionMenuVisible) | ||
255 | { | 255 | { | ||
256 | if (m_actionMenuVisible == actionMenuVisible) { | 256 | if (m_actionMenuVisible == actionMenuVisible) { | ||
257 | return; | 257 | return; | ||
258 | } | 258 | } | ||
259 | m_actionMenuVisible = actionMenuVisible; | 259 | m_actionMenuVisible = actionMenuVisible; | ||
260 | emit sidebarMode->actionMenuVisibleChanged(); | 260 | emit sidebarMode->actionMenuVisibleChanged(); | ||
261 | } | 261 | } | ||
262 | bool m_introPageVisible = true; | ||||
262 | }; | 263 | }; | ||
263 | 264 | | |||
264 | SidebarMode::SidebarMode( QObject *parent, const QVariantList& ) | 265 | SidebarMode::SidebarMode( QObject *parent, const QVariantList& ) | ||
265 | : BaseMode( parent ) | 266 | : BaseMode( parent ) | ||
266 | , d( new Private() ) | 267 | , d( new Private() ) | ||
267 | { | 268 | { | ||
268 | qApp->setAttribute(Qt::AA_DontCreateNativeWidgetSiblings); | 269 | qApp->setAttribute(Qt::AA_DontCreateNativeWidgetSiblings); | ||
269 | d->aboutIcon = new KAboutData( QStringLiteral("SidebarView"), i18n( "Sidebar View" ), | 270 | d->aboutIcon = new KAboutData( QStringLiteral("SidebarView"), i18n( "Sidebar View" ), | ||
▲ Show 20 Lines • Show All 129 Lines • ▼ Show 20 Line(s) | 399 | { | |||
399 | d->subCategoryToolTipManager->hideToolTip(); | 400 | d->subCategoryToolTipManager->hideToolTip(); | ||
400 | } | 401 | } | ||
401 | 402 | | |||
402 | void SidebarMode::loadMostUsed(int index) | 403 | void SidebarMode::loadMostUsed(int index) | ||
403 | { | 404 | { | ||
404 | const QModelIndex idx = d->mostUsedModel->index(index, 0); | 405 | const QModelIndex idx = d->mostUsedModel->index(index, 0); | ||
405 | d->moduleView->closeModules(); | 406 | d->moduleView->closeModules(); | ||
406 | d->moduleView->loadModule( idx ); | 407 | d->moduleView->loadModule( idx ); | ||
408 | setIntroPageVisible(false); | ||||
407 | } | 409 | } | ||
408 | 410 | | |||
409 | void SidebarMode::showActionMenu(const QPoint &position) | 411 | void SidebarMode::showActionMenu(const QPoint &position) | ||
410 | { | 412 | { | ||
411 | QMenu *menu = new QMenu(); | 413 | QMenu *menu = new QMenu(); | ||
412 | connect(menu, &QMenu::aboutToHide, this, [this] () { d->setActionMenuVisible(this, false); } ); | 414 | connect(menu, &QMenu::aboutToHide, this, [this] () { d->setActionMenuVisible(this, false); } ); | ||
413 | menu->setAttribute(Qt::WA_DeleteOnClose); | 415 | menu->setAttribute(Qt::WA_DeleteOnClose); | ||
414 | 416 | | |||
415 | const QStringList actionList { QStringLiteral("configure"), QStringLiteral("help_contents"), QStringLiteral("help_about_app"), QStringLiteral("help_about_kde") }; | 417 | const QStringList actionList { QStringLiteral("configure"), QStringLiteral("help_contents"), QStringLiteral("help_about_app"), QStringLiteral("help_about_kde") }; | ||
416 | for (const QString &actionName : actionList) { | 418 | for (const QString &actionName : actionList) { | ||
417 | menu->addAction(d->collection->action(actionName)); | 419 | menu->addAction(d->collection->action(actionName)); | ||
418 | } | 420 | } | ||
419 | 421 | | |||
420 | menu->popup(position); | 422 | menu->popup(position); | ||
421 | d->setActionMenuVisible(this, true); | 423 | d->setActionMenuVisible(this, true); | ||
422 | } | 424 | } | ||
423 | 425 | | |||
424 | void SidebarMode::changeModule( const QModelIndex& activeModule ) | 426 | void SidebarMode::changeModule( const QModelIndex& activeModule ) | ||
mart: this should be a bool property setter | |||||
425 | { | 427 | { | ||
426 | d->moduleView->closeModules(); | 428 | d->moduleView->closeModules(); | ||
427 | 429 | | |||
430 | if (!activeModule.isValid()) { | ||||
431 | return; | ||||
432 | } | ||||
433 | | ||||
428 | const int subRows = d->searchModel->rowCount(activeModule); | 434 | const int subRows = d->searchModel->rowCount(activeModule); | ||
429 | if ( subRows < 2) { | 435 | if ( subRows < 2) { | ||
430 | d->moduleView->loadModule( activeModule ); | 436 | d->moduleView->loadModule( activeModule ); | ||
431 | } else { | 437 | } else { | ||
432 | d->moduleView->loadModule( d->searchModel->index(0, 0, activeModule) ); | 438 | d->moduleView->loadModule( d->searchModel->index(0, 0, activeModule) ); | ||
433 | } | 439 | } | ||
434 | 440 | | |||
435 | d->subCategoryModel->setParentIndex( activeModule ); | 441 | d->subCategoryModel->setParentIndex( activeModule ); | ||
436 | } | 442 | } | ||
437 | 443 | | |||
438 | void SidebarMode::moduleLoaded() | 444 | void SidebarMode::moduleLoaded() | ||
439 | { | 445 | { | ||
440 | d->placeHolderWidget->hide(); | 446 | d->placeHolderWidget->hide(); | ||
441 | d->moduleView->show(); | 447 | d->moduleView->show(); | ||
442 | } | 448 | } | ||
443 | 449 | | |||
444 | int SidebarMode::activeCategory() const | 450 | int SidebarMode::activeCategory() const | ||
445 | { | 451 | { | ||
446 | return d->searchModel->mapFromSource(d->searchModel->sourceModel()->index(d->activeCategory, 0)).row(); | 452 | return d->searchModel->mapFromSource(d->searchModel->sourceModel()->index(d->activeCategory, 0)).row(); | ||
447 | } | 453 | } | ||
448 | 454 | | |||
449 | void SidebarMode::setActiveCategory(int cat) | 455 | void SidebarMode::setActiveCategory(int cat) | ||
450 | { | 456 | { | ||
451 | const QModelIndex idx = d->searchModel->index(cat, 0); | 457 | const QModelIndex idx = d->searchModel->index(cat, 0); | ||
452 | const int newCategoryRow = d->searchModel->mapToSource(idx).row(); | 458 | int newCategoryRow; | ||
459 | if (cat != -1) { | ||||
460 | setIntroPageVisible(false); | ||||
461 | newCategoryRow = d->searchModel->mapToSource(idx).row(); | ||||
462 | } else { | ||||
463 | newCategoryRow = cat; | ||||
464 | } | ||||
453 | 465 | | |||
454 | if (d->activeCategory == newCategoryRow) { | 466 | if (d->activeCategory == newCategoryRow) { | ||
455 | return; | 467 | return; | ||
456 | } | 468 | } | ||
457 | if( !d->moduleView->resolveChanges() ) { | 469 | if( !d->moduleView->resolveChanges() ) { | ||
458 | return; | 470 | return; | ||
459 | } | 471 | } | ||
460 | 472 | | |||
Show All 17 Lines | 483 | { | |||
478 | } | 490 | } | ||
479 | 491 | | |||
480 | d->activeSubCategory = cat; | 492 | d->activeSubCategory = cat; | ||
481 | d->moduleView->closeModules(); | 493 | d->moduleView->closeModules(); | ||
482 | d->moduleView->loadModule( d->subCategoryModel->index(cat, 0) ); | 494 | d->moduleView->loadModule( d->subCategoryModel->index(cat, 0) ); | ||
483 | emit activeSubCategoryChanged(); | 495 | emit activeSubCategoryChanged(); | ||
484 | } | 496 | } | ||
485 | 497 | | |||
498 | void SidebarMode::setIntroPageVisible(const bool &introPageVisible) | ||||
499 | { | ||||
500 | if (d->m_introPageVisible == introPageVisible) { | ||||
501 | return; | ||||
502 | } | ||||
503 | | ||||
504 | if (introPageVisible) { | ||||
505 | setActiveCategory(-1); | ||||
GB_2: Yes, here. | |||||
506 | d->placeHolderWidget->show(); | ||||
507 | d->moduleView->hide(); | ||||
508 | } else { | ||||
509 | d->placeHolderWidget->hide(); | ||||
510 | d->moduleView->show(); | ||||
511 | } | ||||
512 | | ||||
513 | d->m_introPageVisible = introPageVisible; | ||||
514 | emit introPageVisibleChanged(); | ||||
515 | } | ||||
516 | | ||||
486 | int SidebarMode::width() const | 517 | int SidebarMode::width() const | ||
487 | { | 518 | { | ||
488 | return d->mainWidget->width(); | 519 | return d->mainWidget->width(); | ||
489 | } | 520 | } | ||
490 | 521 | | |||
491 | bool SidebarMode::actionMenuVisible() const | 522 | bool SidebarMode::actionMenuVisible() const | ||
492 | { | 523 | { | ||
493 | return d->m_actionMenuVisible; | 524 | return d->m_actionMenuVisible; | ||
494 | } | 525 | } | ||
495 | 526 | | |||
496 | int SidebarMode::activeSubCategory() const | 527 | int SidebarMode::activeSubCategory() const | ||
497 | { | 528 | { | ||
498 | return d->activeSubCategory; | 529 | return d->activeSubCategory; | ||
499 | } | 530 | } | ||
500 | 531 | | |||
532 | bool SidebarMode::introPageVisible() const | ||||
533 | { | ||||
534 | return (d->m_introPageVisible); | ||||
535 | } | ||||
536 | | ||||
501 | void SidebarMode::initWidget() | 537 | void SidebarMode::initWidget() | ||
502 | { | 538 | { | ||
503 | // Create the widgets | 539 | // Create the widgets | ||
504 | 540 | | |||
505 | if (!KMainWindow::memberList().isEmpty()) { | 541 | if (!KMainWindow::memberList().isEmpty()) { | ||
506 | KXmlGuiWindow *mainWindow = qobject_cast<KXmlGuiWindow *>(KMainWindow::memberList().first()); | 542 | KXmlGuiWindow *mainWindow = qobject_cast<KXmlGuiWindow *>(KMainWindow::memberList().first()); | ||
507 | if (mainWindow) { | 543 | if (mainWindow) { | ||
508 | d->collection = mainWindow->actionCollection(); | 544 | d->collection = mainWindow->actionCollection(); | ||
▲ Show 20 Lines • Show All 104 Lines • Show Last 20 Lines |
this should be a bool property setter