< Development‎ | Tutorials‎ | Plasma4
Revision as of 07:03, 10 August 2010 by PhreakOnALeash (talk | contribs) (start page)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)


This page looks at the steps it takes to embed a Plasma shell inside of your application as a dashboard or summary page.

The Shell

The core of the dashboard's logic is in a KPart in kdebase-runtime, plasma-kpart. This KPart is loaded like any other ReadOnly KPart:

// this routine will find and load our Part.  it finds the Part by
// name which is a bad idea usually.. but it's alright in this
// case since our Part is made for this Shell
KService::Ptr service = KService::serviceByDesktopPath( "plasma-kpart.desktop" );

if (service)
    // now that the Part is loaded, we cast it to a Part to get
    // our hands on it
    m_part = service->createInstance<KParts::ReadOnlyPart>(0, args);
    if (m_part)
        // tell the KParts::MainWindow that this is indeed the main widget
        // If you have something better to do with the widget, this is where
        // you would do it.

        // and integrate the part's GUI with the shell's

        // For whatever reason the part didn't load
        KMessageBox::error(this, i18n("Could not instantiate our Part!"));
    // if we couldn't find our Part, we exit since the Shell by
    // itself can't do anything useful
    KMessageBox::error(this, i18n("Could not find our Part!"));
    // we return here, cause qApp->quit() only means "exit the
    // next time we enter the event loop...

This page was last edited on 11 September 2014, at 23:27. Content is available under Creative Commons License SA 4.0 unless otherwise noted.