예제 #1
0
void AddAppletDialog::addApplet(AppletWidget* applet)
{
    if (!applet)
    {
        return;
    }

    QPoint prevInsertionPoint = Kicker::the()->insertionPoint();
    Kicker::the()->setInsertionPoint(m_insertionPoint);

    const QWidget* appletContainer = 0;

    if (applet->info().type() == AppletInfo::Applet)
    {
        appletContainer = m_containerArea->addApplet(applet->info());

        if (applet->info().isUniqueApplet() &&
            PluginManager::the()->hasInstance(applet->info()))
        {
            applet->hide();

            // reset the odd/even colouring from this item on down in the list
            bool odd = applet->odd();
            AppletWidget::List::const_iterator it = m_appletWidgetList.find(applet);
            for (; it != m_appletWidgetList.constEnd(); ++it)
            {
                if ((*it)->isHidden())
                {
                    continue;
                }

                (*it)->setOdd(odd);
                odd = !odd;
            }
        }
    }
    else if (applet->info().type() & AppletInfo::Button)
    {
        appletContainer = m_containerArea->addButton(applet->info());
    }

    if (appletContainer)
    {
        ExtensionContainer* ec =
           dynamic_cast<ExtensionContainer*>(m_containerArea->topLevelWidget());

        if (ec)
        {
            // unhide the panel and keep it unhidden for at least the time the
            // helper tip will be there
            ec->unhideIfHidden(KickerSettings::mouseOversSpeed() + 2500);
        }

        new AddAppletVisualFeedback(applet, appletContainer,
                                    m_containerArea->popupDirection());
    }

    Kicker::the()->setInsertionPoint(prevInsertionPoint);
}
예제 #2
0
void MenuManager::kmenuAccelActivated()
{
    if(m_kmenu->isVisible())
    {
        m_kmenu->hide();
        return;
    }

    m_kmenu->initialize();

    if(m_kbuttons.isEmpty())
    {
        // no button to use, make it behave like a desktop menu
        QPoint p;
        // Popup the K-menu at the center of the screen.
        QDesktopWidget *desktop = KApplication::desktop();
        QRect r = desktop->screenGeometry(desktop->screenNumber(QCursor::pos()));
        // kMenu->rect() is not valid before showing, use sizeHint()
        p = r.center() - QRect(QPoint(0, 0), m_kmenu->sizeHint()).center();
        m_kmenu->popup(p);

        // when the cursor is in the area where the menu pops up,
        // the item under the cursor gets selected. The single shot
        // avoids this from happening by allowing the item to be selected
        // when the event loop is enterred, and then resetting it.
        QTimer::singleShot(0, this, SLOT(slotSetKMenuItemActive()));
    }
    else
    {
        // We need the kmenu's size to place it at the right position.
        // We cannot rely on the popup menu's current size(), if it wasn't
        // shown before, so we resize it here according to its sizeHint().
        const QSize size = m_kmenu->sizeHint();
        m_kmenu->resize(size.width(), size.height());

        PanelPopupButton *button = findKButtonFor(m_kmenu);

        // let's unhide the panel while we're at it. traverse the widget
        // hierarchy until we find the panel, if any
        QObject *menuParent = button->parent();
        while(menuParent)
        {
            ExtensionContainer *ext = dynamic_cast< ExtensionContainer * >(menuParent);

            if(ext)
            {
                ext->unhideIfHidden();
                // make sure it's unhidden before we use it to figure out
                // where to popup
                qApp->processEvents();
                break;
            }

            menuParent = menuParent->parent();
        }

        button->showMenu();
    }
}
예제 #3
0
void ExtensionManager::removeAllContainers()
{
    while (!_containers.isEmpty())
    {
        ExtensionContainer* e = _containers.first();
        _containers.remove(e);
        e->deleteLater(); // Wait till we return to the main event loop
    }

    saveContainerConfig();
}
예제 #4
0
    void getAllConfigurationElements( OutputIterator & output ) const
    {
        // Retrieves all connected extensions.
        typedef std::vector< ::boost::shared_ptr< Extension > > ExtensionContainer;
        typedef std::back_insert_iterator< ExtensionContainer > Inserter;

        ExtensionContainer  extensions;
        Inserter            inserter(extensions);

        getAllExtensions( inserter );

        // Walk through the collected extensions to extract configuration elements.
        for( ExtensionContainer::const_iterator i = extensions.begin(); i != extensions.end(); ++i )
        {
            ::boost::shared_ptr< Extension >   extension( *i );
            if ( extension->isEnable() )
            {
                std::copy( extension->begin(), extension->end(), output);
            }
            OSLM_DEBUG_IF("getAllConfigurationElements for point=" <<  extension->getPoint() <<
                    " extension" << extension->getIdentifier() << "extension disabled", !extension->isEnable())
        }
    }
예제 #5
0
void ExtensionManager::addExtension( const TQString& desktopFile )
{
    PluginManager* pm = PluginManager::the();
    ExtensionContainer *e = pm->createExtensionContainer(desktopFile,
                                                         false, // is not startup
                                                         TQString::null, // no config
                                                         uniqueId());
    

    kdDebug(1210) << "ExtensionManager::addExtension" << endl;

    if (e)
    {
        e->readConfig();
        // as a new panel, the position will be set to the preferred position
        // we just need to make sure this works with the rest of the panel layout
        e->setPosition(initialPanelPosition(e->position()));
        kdDebug(1210)<<"after e->readConfig(): pos="<<e->position()<<endl;
        addContainer(e);
        e->show();
        e->writeConfig();
        saveContainerConfig();
    }
}
예제 #6
0
void ExtensionManager::initialize()
{
    m_loadingContainers = true;

//    kdDebug(1210) << "ExtensionManager::loadContainerConfig()" << endl;
    TDEConfig* config = TDEGlobal::config();
    PluginManager* pm = PluginManager::the();

    // set up the "main" panel
    if (config->hasGroup("Main Panel"))
    {
        config->setGroup("Main Panel");
        if (config->hasKey("DesktopFile"))
        {
            m_mainPanel = pm->createExtensionContainer(config->readPathEntry("DesktopFile"),
                                                       true, config->readPathEntry("ConfigFile"),
                                                       "Main Panel");
        }
    }

    if (!m_mainPanel)
    {
        // fall back to a regular ol' PanelExtension
        m_mainPanel = pm->createExtensionContainer(
                            "childpanelextension.desktop",
                            true,
                            TQString(kapp->aboutData()->appName()) + "rc",
                            "Main Panel");
    }

    if (!m_mainPanel)
    {
        KMessageBox::error(0, i18n("The TDE panel (kicker) could not load the main panel "
                                   "due to a problem with your installation. "),
                           i18n("Fatal Error!"));
        exit(1);
    }

    configureMenubar(true);

    Kicker::the()->setMainWidget(m_mainPanel);

    m_mainPanel->readConfig();
    m_mainPanel->show();
    kapp->processEvents();

    // read extension list
    config->setGroup("General");
    TQStringList elist = config->readListEntry("Extensions2");

    // now restore the extensions
    TQStringList::iterator itEnd = elist.end();
    for (TQStringList::iterator it = elist.begin(); it !=  elist.end(); ++it)
    {
        // last container?
        TQStringList::iterator lastcheck(it);
        lastcheck++;
        if (lastcheck == elist.end()) {
            m_loadingContainers = false;
        }

        // extension id
        TQString extensionId(*it);

        // create a matching applet container
        if (extensionId.find("Extension") == -1)
        {
            continue;
        }

        // is there a config group for this extension?
        if (!config->hasGroup(extensionId))
        {
            continue;
        }

        // set config group
        config->setGroup(extensionId);

        ExtensionContainer* e = pm->createExtensionContainer(config->readPathEntry("DesktopFile"),
                                                             true, // is startup
                                                             config->readPathEntry("ConfigFile"),
                                                             extensionId);
        if (e)
        {
            addContainer(e);
            e->readConfig();
            e->show();
            kapp->processEvents();
        }
    }
    m_loadingContainers = false;

    pm->clearUntrustedLists();
    connect(Kicker::the(), TQT_SIGNAL(configurationChanged()), TQT_SLOT(configurationChanged()));
    DCOPRef r( "ksmserver", "ksmserver" );
    r.send( "resumeStartup", TQCString( "kicker" ));
}
예제 #7
0
void ExtensionManager::initialize()
{
//    kDebug(1210) << "ExtensionManager::loadContainerConfig()";
    KSharedConfig::Ptr config = KGlobal::config();
    PluginManager* pm = PluginManager::self();

    // set up the "main" panel
    if (config->hasGroup("Main Panel"))
    {
		KConfigGroup cg(config,"Main Panel");
        if (cg.hasKey("DesktopFile"))
        {
            m_mainPanel = pm->createExtensionContainer(cg.readPathEntry("DesktopFile", false),
                                                       true, cg.readPathEntry("ConfigFile", false),
                                                       "Main Panel");
        }
    }

    if (!m_mainPanel)
    {
        // fall back to a regular ol' PanelExtension
        m_mainPanel = pm->createExtensionContainer(
                            "childpanelextension.desktop",
                            true,
                            QString(KGlobal::mainComponent().aboutData()->appName()) + "rc",
                            "Main Panel");
    }

    if (!m_mainPanel)
    {
        KMessageBox::error(0, i18n("The KDE panel (kicker) could not load the main panel "
                                   "due to a problem with your installation. "),
                           i18n("Fatal Error"));
        exit(1);
    }

    configureMenubar(true);

    m_mainPanel->readConfig();
    m_mainPanel->show();
    kapp->processEvents();

    // read extension list
	KConfigGroup cg2(config, "General");
    QStringList elist = cg2.readEntry("Extensions2", QStringList() );

    // now restore the extensions
    foreach (QString extensionId, elist)
    {
        // create a matching applet container
        if (extensionId.indexOf("Extension") == -1)
        {
            continue;
        }

        // is there a config group for this extension?
        if (!config->hasGroup(extensionId))
        {
            continue;
        }

        // set config group
		KConfigGroup cg3(config, extensionId);

        ExtensionContainer* e =
            pm->createExtensionContainer(cg3.readPathEntry("DesktopFile", false),
                                         true, // is startup
                                         cg3.readPathEntry("ConfigFile", false),
                                         extensionId);

        if (e)
        {
            addContainer(e);
            e->readConfig();
            e->show();
            kapp->processEvents();
        }
    }

    pm->clearUntrustedLists();
    connect(Kicker::self(), SIGNAL(configurationChanged()), SLOT(configurationChanged()));

    QDBusInterface dbus("org.kde.ksmserver", "/ksmserver");
    dbus.call("resumeStartup", "kicker");
}