コード例 #1
0
ファイル: style.cpp プロジェクト: Tayyib/uludag
void Style::testStyle()
{
    // Read entire XML into DOM Tree
    QFile file(selectedStyle);
    file.open(IO_ReadOnly);
    dom.setContent(file.readAll());
    file.close();

    // attach to dcop
    DCOPClient *client = kapp->dcopClient();
    if (!client->isAttached())
        client->attach();

    // kicker settings
    KConfig *kickerConf = new KConfig("kickerrc");
    kickerConf->setGroup("General");

    QDomElement Kicker = dom.elementsByTagName("kicker").item(0).toElement();

    kickerConf->writeEntry("LegacyKMenu", !checkKickoff->isChecked());
    kickerConf->writeEntry("Transparent", getProperty(Kicker, "Transparent", "value"));
    kickerConf->writeEntry("SizePercentage", getProperty(Kicker, "SizePercentage", "value"));
    kickerConf->writeEntry("CustomSize", getProperty(Kicker, "CustomSize", "value"));
    kickerConf->writeEntry("Position", getProperty(Kicker, "Position", "value"));
    kickerConf->writeEntry("Alignment", getProperty(Kicker, "Alignment", "value"));
    kickerConf->sync();
    delete kickerConf;

    // restart kicker
    client->send("kicker", "kicker", "restart()", "");

    // kwin settings
    KConfig *kwinConf = new KConfig("kwinrc");
    kwinConf->setGroup("Style");

    QDomElement KWin = dom.elementsByTagName("kwin").item(0).toElement();

    kwinConf->writeEntry("PluginLib", getProperty(KWin, "PluginLib", "value"));
    kwinConf->sync();
    delete kwinConf;

    // restart kwin
    client->send("kwin", "KWinInterface", "reconfigure()", "");

    // widget settings
    KConfig *globalConf = new KConfig("kdeglobals");
    globalConf->setGroup("General");

    QDomElement Widget = dom.elementsByTagName("widget").item(0).toElement();

    globalConf->writeEntry("widgetStyle", getProperty(Widget, "widgetStyle", "value"));
    globalConf->sync();
    delete globalConf;

    KIPC::sendMessageAll(KIPC::StyleChanged);
}
コード例 #2
0
ファイル: dcopref.cpp プロジェクト: serghei/kde3-kdelibs
bool DCOPRef::sendInternal(const QCString &fun, const QCString &args, const QByteArray &data)
{
    if(isNull())
    {
        qWarning("DCOPRef: send '%s' on null reference error", STR(fun));
        return false;
    }
    Q_UNUSED(data);
    QCString sig = fun;
    if(fun.find('(') == -1)
    {
        sig += args;
        if(args.find("<unknown") != -1)
            qWarning(
                "DCOPRef: unknown type error "
                "<\"%s\",\"%s\">::send(\"%s\",%s",
                STR(m_app), STR(m_obj), STR(fun), args.data() + 1);
    }
    DCOPClient *dc = dcopClient();
    if(!dc || !dc->isAttached())
    {
        qWarning("DCOPRef::send(): no DCOP client or client not attached error");
        return false;
    }
    return dc->send(m_app, m_obj, sig, data);
}
コード例 #3
0
void DictApplet::sendCommand(const QCString &fun, const QString &data)
{
  if (waiting > 0) {
    waiting = 1;
    delayedFunc = fun.copy();
    delayedData = data;
    return;
  }

  DCOPClient *client = kapp->dcopClient();
  if (!client->isApplicationRegistered("kdict")) {
    KApplication::startServiceByDesktopName("kdict");
    waiting = 1;
    delayedFunc = fun.copy();
    delayedData = data;
    QTimer::singleShot(100, this, SLOT(sendDelayedCommand()));
    return;
  } else {
    QCStringList list = client->remoteObjects("kdict");
    if (list.findIndex("KDictIface")==-1) {
      waiting = 1;
      delayedFunc = fun.copy();
      delayedData = data;
      QTimer::singleShot(100, this, SLOT(sendDelayedCommand()));
      return;
    }
  }

  client->send("kdict","default",fun,data);
}
コード例 #4
0
ファイル: wake_laptop.cpp プロジェクト: Fat-Zer/tdeutils
KDE_EXPORT void
wake_laptop_daemon()
{
	DCOPClient      *dclient = kapp->dcopClient();
        if (!dclient || (!dclient->isAttached() && !dclient->attach())) 
		return;

	TQByteArray data;
	TQDataStream arg( data, IO_WriteOnly );
	(void) dclient->send( "kded", "klaptopdaemon", "restart()", data );
}
コード例 #5
0
ファイル: runnergui.cpp プロジェクト: ShermanHuang/kdesdk
    void RunnerGUI::doubleClickedOnDetails(int para, int /*pos*/)
    {
        static QRegExp reFileAndLine("^(.*)\\[([0-9]+)\\]:");

        QString line = m_testerWidget->details()->text(para);
        m_testerWidget->details()->setSelection(para, 0, para, line.length()-1);

        if ( reFileAndLine.search(line) != -1 )
        {
            DCOPClient client;
            client.attach();
            QByteArray data;
            QDataStream arg(&data, QIODevice::WriteOnly);
            bool ok;
            arg << QString(reFileAndLine.cap(1)) << (reFileAndLine.cap(2).toInt(&ok) - 1);
            client.send("kdevelop-*", "KDevPartController", "editDocument(QString,int)", data);
            client.send("kdevelop-*", "MainWindow", "raise()", "");

            client.detach();
        }
    }
コード例 #6
0
ファイル: kerp_client.cpp プロジェクト: BackupTheBerlios/kerp
int main(int argc, char **argv)
{
    KApplication app(argc, argv, "kerp_client", false);

    // get our DCOP client and attach so that we may use it
    DCOPClient *client = app.dcopClient();
    client->attach();

    // do a 'send' for now
    QByteArray data;
    QDataStream ds(data, IO_WriteOnly);
    if (argc > 1)
        ds << QString(argv[1]);
    else
        ds << QString("http://www.kde.org");
    client->send("kerp", "kerpIface", "openURL(QString)", data);

    return app.exec();
}
コード例 #7
0
void KRootPixmap::enableExports()
{
#ifdef Q_WS_X11
    kdDebug(270) << k_lineinfo << "activating background exports.\n";
    DCOPClient *client = kapp->dcopClient();
    if(!client->isAttached())
        client->attach();
    QByteArray data;
    QDataStream args(data, IO_WriteOnly);
    args << 1;

    QCString appname("kdesktop");
    int screen_number = DefaultScreen(qt_xdisplay());
    if(screen_number)
        appname.sprintf("kdesktop-screen-%d", screen_number);

    client->send(appname, "KBackgroundIface", "setExport(int)", data);
#endif
}
コード例 #8
0
void DictApplet::sendDelayedCommand()
{
  if (waiting > 100) {   // timeout after ten seconds
    waiting = 0;
    return;
  }

  DCOPClient *client = kapp->dcopClient();
  if (!client->isApplicationRegistered("kdict")) {
    waiting++;
    QTimer::singleShot(100, this, SLOT(sendDelayedCommand()));
    return;
  } else {
    QCStringList list = client->remoteObjects("kdict");
    if (list.findIndex("KDictIface")==-1) {
      waiting++;
      QTimer::singleShot(100, this, SLOT(sendDelayedCommand()));
      return;
    }
  }

  client->send("kdict","default",delayedFunc,delayedData);
  waiting = 0;
}
コード例 #9
0
void KTheme::apply()
{
    kdDebug() << "Going to apply theme: " << m_name << endl;

    QString themeDir = m_kgd->findResourceDir( "themes", m_name + "/" + m_name + ".xml") + m_name + "/";
    kdDebug() << "Theme dir: " << themeDir << endl;

    // 2. Background theme

    QDomNodeList desktopList = m_dom.elementsByTagName( "desktop" );
    KConfig desktopConf( "kdesktoprc" );
    desktopConf.setGroup( "Background Common" );

    for ( uint i = 0; i <= desktopList.count(); i++ )
    {
        QDomElement desktopElem = desktopList.item( i ).toElement();
        if ( !desktopElem.isNull() )
        {
            // TODO optimize, don't write several times the common section
            bool common = static_cast<bool>( desktopElem.attribute( "common", "true" ).toUInt() );
            desktopConf.writeEntry( "CommonDesktop", common );
            desktopConf.writeEntry( "DeskNum", desktopElem.attribute( "number", "0" ).toUInt() );

            desktopConf.setGroup( QString( "Desktop%1" ).arg( i ) );
            desktopConf.writeEntry( "BackgroundMode", getProperty( desktopElem, "mode", "id" ) );
            desktopConf.writeEntry( "Color1", QColor( getProperty( desktopElem, "color1", "rgb" ) ) );
            desktopConf.writeEntry( "Color2", QColor( getProperty( desktopElem, "color2", "rgb" ) ) );
            desktopConf.writeEntry( "BlendMode", getProperty( desktopElem, "blending", "mode" ) );
            desktopConf.writeEntry( "BlendBalance", getProperty( desktopElem, "blending", "balance" ) );
            desktopConf.writeEntry( "ReverseBlending",
                                    static_cast<bool>( getProperty( desktopElem, "blending", "reverse" ).toUInt() ) );
            desktopConf.writeEntry( "Pattern", getProperty( desktopElem, "pattern", "name" ) );
            desktopConf.writeEntry( "Wallpaper",
                                    unprocessFilePath( "desktop", getProperty( desktopElem, "wallpaper", "url" ) ) );
            desktopConf.writeEntry( "WallpaperMode", getProperty( desktopElem, "wallpaper", "mode" ) );

            if ( common )
                break;          // stop here
        }
    }

    // 11. Screensaver
    QDomElement saverElem = m_dom.elementsByTagName( "screensaver" ).item( 0 ).toElement();

    if ( !saverElem.isNull() )
    {
        desktopConf.setGroup( "ScreenSaver" );
        desktopConf.writeEntry( "Saver", saverElem.attribute( "name" ) );
    }

    desktopConf.sync();         // TODO sync and signal only if <desktop> elem present
    // reconfigure kdesktop. kdesktop will notify all clients
    DCOPClient *client = kapp->dcopClient();
    if ( !client->isAttached() )
        client->attach();
    client->send("kdesktop", "KBackgroundIface", "configure()", "");
    // FIXME Xinerama

    // 3. Icons
    QDomElement iconElem = m_dom.elementsByTagName( "icons" ).item( 0 ).toElement();
    if ( !iconElem.isNull() )
    {
        KConfig * iconConf = KGlobal::config();
        iconConf->setGroup( "Icons" );
        iconConf->writeEntry( "Theme", iconElem.attribute( "name", "crystalsvg" ), true, true );

        QDomNodeList iconList = iconElem.childNodes();
        for ( uint i = 0; i < iconList.count(); i++ )
        {
            QDomElement iconSubElem = iconList.item( i ).toElement();
            QString object = iconSubElem.attribute( "object" );
            if ( object == "desktop" )
                iconConf->setGroup( "DesktopIcons" );
            else if ( object == "mainToolbar" )
                iconConf->setGroup( "MainToolbarIcons" );
            else if ( object == "panel" )
                iconConf->setGroup( "PanelIcons" );
            else if ( object == "small" )
                iconConf->setGroup( "SmallIcons" );
            else if ( object == "toolbar" )
                iconConf->setGroup( "ToolbarIcons" );

            QString iconName = iconSubElem.tagName();
            if ( iconName.contains( "Color" ) )
            {
                QColor iconColor = QColor( iconSubElem.attribute( "rgb" ) );
                iconConf->writeEntry( iconName, iconColor, true, true );
            }
            else if ( iconName.contains( "Value" ) || iconName == "Size" )
                iconConf->writeEntry( iconName, iconSubElem.attribute( "value" ).toUInt(), true, true );
            else if ( iconName.contains( "Effect" ) )
                iconConf->writeEntry( iconName, iconSubElem.attribute( "name" ), true, true );
            else
                iconConf->writeEntry( iconName, static_cast<bool>( iconSubElem.attribute( "value" ).toUInt() ), true, true );
        }
        iconConf->sync();

        for ( int i = 0; i < KIcon::LastGroup; i++ )
            KIPC::sendMessageAll( KIPC::IconChanged, i );
        KService::rebuildKSycoca( m_parent );
    }

    // 4. Sounds
    QDomElement soundsElem = m_dom.elementsByTagName( "sounds" ).item( 0 ).toElement();
    if ( !soundsElem.isNull() )
    {
        KConfig soundConf( "knotify.eventsrc" );
        KConfig kwinSoundConf( "kwin.eventsrc" );
        QDomNodeList eventList = soundsElem.elementsByTagName( "event" );
        for ( uint i = 0; i < eventList.count(); i++ )
        {
            QDomElement eventElem = eventList.item( i ).toElement();
            QString object = eventElem.attribute( "object" );

            if ( object == "global" )
            {
                soundConf.setGroup( eventElem.attribute( "name" ) );
                soundConf.writeEntry( "soundfile", unprocessFilePath( "sounds", eventElem.attribute( "url" ) ) );
                soundConf.writeEntry( "presentation", soundConf.readNumEntry( "presentation" ) | 1 );
            }
            else if ( object == "kwin" )
            {
                kwinSoundConf.setGroup( eventElem.attribute( "name" ) );
                kwinSoundConf.writeEntry( "soundfile", unprocessFilePath( "sounds", eventElem.attribute( "url" ) ) );
                kwinSoundConf.writeEntry( "presentation", soundConf.readNumEntry( "presentation" ) | 1 );
            }
        }

        soundConf.sync();
        kwinSoundConf.sync();
        client->send("knotify", "", "reconfigure()", "");
        // TODO signal kwin sounds change?
    }

    // 5. Colors
    QDomElement colorsElem = m_dom.elementsByTagName( "colors" ).item( 0 ).toElement();

    if ( !colorsElem.isNull() )
    {
        QDomNodeList colorList = colorsElem.childNodes();
        KConfig * colorConf = KGlobal::config();

        QString sCurrentScheme = locateLocal("data", "kdisplay/color-schemes/thememgr.kcsrc");
        KSimpleConfig *colorScheme = new KSimpleConfig( sCurrentScheme );
        colorScheme->setGroup("Color Scheme" );

        for ( uint i = 0; i < colorList.count(); i++ )
        {
            QDomElement colorElem = colorList.item( i ).toElement();
            QString object = colorElem.attribute( "object" );
            if ( object == "global" )
                colorConf->setGroup( "General" );
            else if ( object == "kwin" )
                colorConf->setGroup( "WM" );

            QString colName = colorElem.tagName();
            QColor curColor = QColor( colorElem.attribute( "rgb" ) );
            colorConf->writeEntry( colName, curColor, true, true ); // kdeglobals
            colorScheme->writeEntry( colName, curColor ); // thememgr.kcsrc
        }

        colorConf->setGroup( "KDE" );
        colorConf->writeEntry( "colorScheme", "thememgr.kcsrc", true, true );
        colorConf->writeEntry( "contrast", colorsElem.attribute( "contrast", "7" ), true, true );
        colorScheme->writeEntry( "contrast", colorsElem.attribute( "contrast", "7" ) );
        colorConf->sync();
        delete colorScheme;

        KIPC::sendMessageAll( KIPC::PaletteChanged );
    }

    // 6.Cursors
    QDomElement cursorsElem = m_dom.elementsByTagName( "cursors" ).item( 0 ).toElement();

    if ( !cursorsElem.isNull() )
    {
        KConfig mouseConf( "kcminputrc" );
        mouseConf.setGroup( "Mouse" );
        mouseConf.writeEntry( "cursorTheme", cursorsElem.attribute( "name" ));
        // FIXME is there a way to notify KDE of cursor changes?
    }

    // 7. KWin
    QDomElement wmElem = m_dom.elementsByTagName( "wm" ).item( 0 ).toElement();

    if ( !wmElem.isNull() )
    {
        KConfig kwinConf( "kwinrc" );
        kwinConf.setGroup( "Style" );
        QString type = wmElem.attribute( "type" );
        if ( type == "builtin" )
            kwinConf.writeEntry( "PluginLib", wmElem.attribute( "name" ) );
        //else // TODO support custom themes
        QDomNodeList buttons = wmElem.elementsByTagName ("buttons");
        if ( buttons.count() > 0 )
        {
            kwinConf.writeEntry( "CustomButtonPositions", true );
            kwinConf.writeEntry( "ButtonsOnLeft", getProperty( wmElem, "buttons", "left" ) );
            kwinConf.writeEntry( "ButtonsOnRight", getProperty( wmElem, "buttons", "right" ) );
        }
        else
        {
            kwinConf.writeEntry( "CustomButtonPositions", false );
        }
        kwinConf.writeEntry( "BorderSize", getProperty( wmElem, "border", "size" ) );

        kwinConf.sync();
        client->send( "kwin", "", "reconfigure()", "" );
    }

    // 8. Konqueror
    QDomElement konqElem = m_dom.elementsByTagName( "konqueror" ).item( 0 ).toElement();

    if ( !konqElem.isNull() )
    {
        KConfig konqConf( "konquerorrc" );
        konqConf.setGroup( "Settings" );
        konqConf.writeEntry( "BgImage", unprocessFilePath( "konqueror", getProperty( konqElem, "wallpaper", "url" ) ) );
        konqConf.writeEntry( "BgColor", QColor( getProperty( konqElem, "bgcolor", "rgb" ) ) );

        konqConf.sync();
        client->send("konqueror*", "KonquerorIface", "reparseConfiguration()", ""); // FIXME seems not to work :(
    }

    // 9. Kicker
    QDomElement panelElem = m_dom.elementsByTagName( "panel" ).item( 0 ).toElement();

    if ( !panelElem.isNull() )
    {
        KConfig kickerConf( "kickerrc" );
        kickerConf.setGroup( "General" );
        QString kickerBgUrl = getProperty( panelElem, "background", "url" );
        if ( !kickerBgUrl.isEmpty() )
        {
            kickerConf.writeEntry( "UseBackgroundTheme", true );
            kickerConf.writeEntry( "BackgroundTheme", unprocessFilePath( "panel", kickerBgUrl ) );
            kickerConf.writeEntry( "ColorizeBackground",
                                   static_cast<bool>( getProperty( panelElem, "background", "colorize" ).toUInt() ) );
        }
        kickerConf.writeEntry( "Transparent",
                               static_cast<bool>( getProperty( panelElem, "transparent", "value" ).toUInt() ) );

        kickerConf.writeEntry( "Position", static_cast<int> (getProperty( panelElem, "position", "value" ).toUInt() ));

        kickerConf.writeEntry( "ShowLeftHideButton", static_cast<bool>( getProperty( panelElem, "showlefthidebutton", "value").toInt()));

        kickerConf.writeEntry( "ShowRightHideButton", static_cast<bool>( getProperty( panelElem, "showrighthidebutton", "value").toInt()));

        kickerConf.sync();
        client->send("kicker", "Panel", "configure()", "");
    }

    // 10. Widget style
    QDomElement widgetsElem = m_dom.elementsByTagName( "widgets" ).item( 0 ).toElement();

    if ( !widgetsElem.isNull() )
    {
        KConfig * widgetConf = KGlobal::config();
        widgetConf->setGroup( "General" );
        widgetConf->writeEntry( "widgetStyle", widgetsElem.attribute( "name" ), true, true );
        widgetConf->sync();
        KIPC::sendMessageAll( KIPC::StyleChanged );
    }

    // 12. Fonts
    QDomElement fontsElem = m_dom.elementsByTagName( "fonts" ).item( 0 ).toElement();
    if ( !fontsElem.isNull() )
    {
        KConfig * fontsConf = KGlobal::config();
        KConfig * kde1xConf = new KSimpleConfig( QDir::homeDirPath() + "/.kderc" );
        kde1xConf->setGroup( "General" );

        QDomNodeList fontList = fontsElem.childNodes();
        for ( uint i = 0; i < fontList.count(); i++ )
        {
            QDomElement fontElem = fontList.item( i ).toElement();
            QString fontName  = fontElem.tagName();
            QString fontValue = fontElem.attribute( "value" );
            QString fontObject = fontElem.attribute( "object" );

            if ( fontObject == "FMSettings" ) {
                desktopConf.setGroup( fontObject );
                desktopConf.writeEntry( fontName, fontValue, true, true );
                desktopConf.sync();
            }
            else {
                fontsConf->setGroup( fontObject );
                fontsConf->writeEntry( fontName, fontValue, true, true );
            }
            kde1xConf->writeEntry( fontName, fontValue, true, true );
        }

        fontsConf->sync();
        kde1xConf->sync();
        KIPC::sendMessageAll( KIPC::FontChanged );
    }

}
コード例 #10
0
ファイル: kcmkonsole.cpp プロジェクト: serghei/kde3-kdebase
void KCMKonsole::save()
{
    if(dialog->SchemaEditor1->isModified())
    {
        dialog->TabWidget2->showPage(dialog->tab_2);
        dialog->SchemaEditor1->querySave();
    }

    if(dialog->SessionEditor1->isModified())
    {
        dialog->TabWidget2->showPage(dialog->tab_3);
        dialog->SessionEditor1->querySave();
    }

    KConfig config("konsolerc");
    config.setDesktopGroup();

    config.writeEntry("TerminalSizeHint", dialog->terminalSizeHintCB->isChecked());
    bool bidiNew = dialog->bidiCB->isChecked();
    config.writeEntry("EnableBidi", bidiNew);
    config.writeEntry("MatchTabWinTitle", dialog->matchTabWinTitleCB->isChecked());
    config.writeEntry("WarnQuit", dialog->warnCB->isChecked());
    config.writeEntry("CtrlDrag", dialog->ctrldragCB->isChecked());
    config.writeEntry("CutToBeginningOfLine", dialog->cutToBeginningOfLineCB->isChecked());
    config.writeEntry("AllowResize", dialog->allowResizeCB->isChecked());
    bool xonXoffNew = dialog->xonXoffCB->isChecked();
    config.writeEntry("XonXoff", xonXoffNew);
    config.writeEntry("BlinkingCursor", dialog->blinkingCB->isChecked());
    config.writeEntry("has frame", dialog->frameCB->isChecked());
    config.writeEntry("LineSpacing", dialog->line_spacingSB->value());
    config.writeEntry("SilenceSeconds", dialog->silence_secondsSB->value());
    config.writeEntry("wordseps", dialog->word_connectorLE->text());

    config.writeEntry("schema", dialog->SchemaEditor1->schema());

    config.sync();

    emit changed(false);

    DCOPClient *dcc = kapp->dcopClient();
    dcc->send("konsole-*", "konsole", "reparseConfiguration()", QByteArray());
    dcc->send("kdesktop", "default", "configure()", QByteArray());
    dcc->send("klauncher", "klauncher", "reparseConfiguration()", QByteArray());

    if(xonXoffOrig != xonXoffNew)
    {
        xonXoffOrig = xonXoffNew;
        KMessageBox::information(this, i18n("The Ctrl+S/Ctrl+Q flow control setting will only affect "
                                            "newly started Konsole sessions.\n"
                                            "The 'stty' command can be used to change the flow control "
                                            "settings of existing Konsole sessions."));
    }

    if(bidiNew && !bidiOrig)
    {
        KMessageBox::information(this, i18n("You have chosen to enable "
                                            "bidirectional text rendering by "
                                            "default.\n"
                                            "Note that bidirectional text may "
                                            "not always be shown correctly, "
                                            "especially when selecting parts of "
                                            "text written right-to-left. This "
                                            "is a known issue which cannot be "
                                            "resolved at the moment due to the "
                                            "nature of text handling in "
                                            "console-based applications."));
    }
    bidiOrig = bidiNew;
}