Logo Search packages:      
Sourcecode: synaptiks version File versions  Download package

SynaptiksDaemon::SynaptiksDaemon ( QObject *  parent,
const QList< QVariant > &  args 
)

Create a new daemon module.

Parameters:
parentthe parent object
argsignored, required by KPlugin signature

Definition at line 91 of file synaptiksdaemon.cpp.

References dumpTouchpadToConfiguration(), synaptiks::Touchpad::findTouchpad(), synaptiks::Touchpad::isSupported(), notifyError(), reparseConfiguration(), synaptiks::Touchpad::setOn(), showTouchpadState(), and touchpadOnTriggered().

                                                                       :
    KDEDModule(parent), d_ptr(new SynaptiksDaemonPrivate) {
    Q_D(SynaptiksDaemon);

    KGlobal::locale()->insertCatalog("synaptiks");

    KAboutData about("synaptiks", 0, ki18n("synaptiks"), SYNAPTIKS_VERSION,
                     ki18n("A touchpad control daemon"),
                     KAboutData::License_BSD,
                     ki18n("Copyright © 2009, 2010 Sebastian Wiesner"),
                     KLocalizedString(),
                     "http://synaptiks.lunaryorn.de/");
    about.setTranslator(ki18nc("NAME OF TRANSLATORS", "Your names"),
                        ki18nc("EMAIL OF TRANSLATORS", "Your emails"));
    about.addAuthor(ki18n("Sebastian Wiesner"), ki18n("Programmer"),
                    "basti.wiesner@gmx.net");
    d->applicationData = KComponentData(about);
    d->iconLoader = new KIconLoader(d->applicationData);

    d->config = new SynaptiksConfiguration();
    d->touchpadManager = 0;

    Touchpad *touchpad = Touchpad::findTouchpad(this);
    MouseDevicesMonitor *monitor = new MouseDevicesMonitor(this);

    QDBusConnection::sessionBus().registerObject(
        "/MouseDevicesMonitor", monitor,
        QDBusConnection::ExportScriptableContents);

    if (!touchpad) {
        if (!Touchpad::isSupported()) {
            this->notifyError(
                i18nc("@info daemon error notification",
                      "<warning>The system does not support touchpad "
                      "configuration.</warning>"));
        } else {
            this->notifyError(
                i18nc("@info daemon notification error",
                      "<warning>No configurable touchpad was "
                      "found.</warning>"));
        }
    } else {
        // create the touchpad manager
        d->touchpadManager = new TouchpadManager(touchpad, monitor, this);
        this->connect(d->touchpadManager,
                      SIGNAL(touchpadSwitched(bool, const QString&,
                                              const QVariant&)),
                      SLOT(showTouchpadState(bool, const QString&,
                                             const QVariant&)));
        this->connect(d->touchpadManager,
                      SIGNAL(touchpadError(const QString&)),
                      SLOT(notifyError(const QString&)));


        // dump settings from touchpad driver to configuration and write the
        // settings to a file to make them available to the kcmodule
        this->dumpTouchpadToConfiguration();
        d->config->setSharedConfig(KSharedConfig::openConfig(
                                       "synaptiksrc-defaults"));
        d->config->writeConfig();
        // update all defaults in the configuration scheme ...
        foreach (KConfigSkeletonItem *item, d->config->items()) {
            item->swapDefault();
        }
        // ... and finally read the actual configuration
        d->config->setSharedConfig(
            KSharedConfig::openConfig("synaptiksrc"));
        d->config->readConfig();

        // action to switch the touchpad with global shortcut
        d->globalActions = new KActionCollection(this, d->applicationData);
        KAction *touchpadOn = new KToggleAction(
            i18nc("@action:button hidden action", "Touchpad on"),
            d->globalActions);
        d->globalActions->addAction("touchpadOn", touchpadOn);
        touchpadOn->setGlobalShortcut(
            KShortcut(i18nc("touchpadOn shortcut", "Ctrl+Alt+T")));
        this->connect(touchpadOn, SIGNAL(triggered(bool)),
                      SLOT(touchpadOnTriggered(bool)));

        // initial touchpad state
        int state = d->config->touchpadStateAtStartup();
        if (state != SynaptiksConfiguration::UnchangedState) {
            touchpad->setOn(state == SynaptiksConfiguration::OnState);
        }
        // and the rest of the configuration
        this->reparseConfiguration();

        // register on session bus
        QDBusConnection::sessionBus().registerObject("/Touchpad", touchpad);
        QDBusConnection::sessionBus().registerObject(
            "/TouchpadManager", d->touchpadManager,
            QDBusConnection::ExportScriptableContents);
    }

    new SynaptiksAdaptor(this);
    QDBusConnection::sessionBus().registerService("org.kde.synaptiks");
}

Here is the call graph for this function:


Generated by  Doxygen 1.6.0   Back to index