Esempio n. 1
0
void KHTMLSearchConfig::load()
{
  KConfig *config = new KConfig("khelpcenterrc", true);

  config->setGroup("htdig");
  htdigBin->lineEdit()->setText(config->readPathEntry("htdig", kapp->dirs()->findExe("htdig")));
  htsearchBin->lineEdit()->setText(config->readPathEntry("htsearch", kapp->dirs()->findExe("htsearch")));
  htmergeBin->lineEdit()->setText(config->readPathEntry("htmerge", kapp->dirs()->findExe("htmerge")));

  config->setGroup("Scope");
  indexKDE->setChecked(config->readBoolEntry("KDE", true));
  indexMan->setChecked(config->readBoolEntry("Man", false));
  indexInfo->setChecked(config->readBoolEntry("Info", false));

  QStringList l = config->readPathListEntry("Paths");
  searchPaths->clear();
  QStringList::Iterator it;
  for (it=l.begin(); it != l.end(); ++it)
    searchPaths->insertItem(*it);

  config->setGroup("Locale");
  QString lang = config->readEntry("Search Language", KGlobal::locale()->language());
  language->setCurrentItem(lang);

  emit changed(false);
}
Esempio n. 2
0
void KPrinter::loadSettings()
{
	d->m_options = d->m_impl->loadOptions();

	// load the last printer used in the current process (if any)
	// and remove the corresponding entry in the option map, as it
	// is not needed anymore
	setSearchName(option("kde-searchname"));
	d->m_options.remove("kde-searchname");

	KConfig	*conf = KGlobal::config(), *pconf = KMFactory::self()->printConfig();
	conf->setGroup("KPrinter Settings");
	pconf->setGroup("General");

	// load latest used printer from config file, if required in the options
	if (searchName().isEmpty() && pconf->readBoolEntry("UseLast", true))
		setSearchName(conf->readEntry("Printer"));

	// latest used print command
	setOption("kde-printcommand",conf->readPathEntry("PrintCommand"));

	// latest used document directory
	setDocDirectory( conf->readPathEntry( "DocDirectory" ) );
	setDocFileName( "print" );
}
Esempio n. 3
0
void DockBarExtension::loadContainerConfig()
{
    KConfig *conf = config();
    conf->setGroup("General");
    QStringList applets = conf->readListEntry("Applets");

    QStringList fail_list;
    for(QStringList::Iterator it = applets.begin(); it != applets.end(); ++it)
    {
        if(!conf->hasGroup(*it))
            continue;
        conf->setGroup(*it);
        QString cmd = conf->readPathEntry("Command");
        QString resName = conf->readPathEntry("resName");
        QString resClass = conf->readEntry("resClass");
        if(cmd.isEmpty() || resName.isEmpty() || resClass.isEmpty())
            continue;

        DockContainer *c = new DockContainer(cmd, this, resName, resClass);
        addContainer(c);

        KProcess proc;
        proc << KShell::splitArgs(cmd);
        if(!proc.start(KProcess::DontCare))
        {
            fail_list.append(cmd);
            removeContainer(c);
        }
    }
    if(!fail_list.isEmpty())
        KMessageBox::queuedMessageBox(0, KMessageBox::Information,
                                      i18n("The following dockbar applets could not be started: %1").arg(fail_list.join(", ")),
                                      i18n("kicker: information"), 0);
    saveContainerConfig();
}
Esempio n. 4
0
KTextEditor::Editor *EditorChooser::createEditor(QWidget *parentWidget, QObject *parent, const char *widgetName, const char *name,
                                                 const QString &postfix, bool fallBackToKatePart)
{

    KTextEditor::Editor *tmpEd = 0;

    KConfig *cfg = kapp->config();
    QString previousGroup = cfg->group();
    cfg->setGroup("KTEXTEDITOR:" + postfix);
    QString editor = cfg->readPathEntry("editor");
    cfg->setGroup(previousGroup);
    if(editor.isEmpty())
    {
        KConfig *config = new KConfig("default_components");
        config->setGroup("KTextEditor");
        editor = config->readPathEntry("embeddedEditor", "katepart");
        delete config;
    }

    KService::Ptr serv = KService::serviceByDesktopName(editor);
    if(serv)
    {
        tmpEd = KTextEditor::createEditor(serv->library().latin1(), parentWidget, widgetName, parent, name);
        if(tmpEd)
            return tmpEd;
    }
    if(fallBackToKatePart)
        return KTextEditor::createEditor("libkatepart", parentWidget, widgetName, parent, name);

    return 0;
}
Esempio n. 5
0
QString KMLpdManager::programName(int f)
{
	KConfig	*conf = KMFactory::self()->printConfig();
	conf->setGroup("LPD");
	switch (f)
	{
		case 0: return conf->readPathEntry("LpdCommand","/usr/sbin/lpc");
		case 1: return conf->readPathEntry("LpdQueue","lpq");
		case 2: return conf->readPathEntry("LpdRemove","lprm");
	}
	return QString::null;
}
Esempio n. 6
0
void KNotify::loadConfig()
{
    // load external player settings
    KConfig *kc = KGlobal::config();
    kc->setGroup("Misc");
    d->useExternal = kc->readBoolEntry("Use external player", false);
    d->externalPlayer = kc->readPathEntry("External player");

    // try to locate a suitable player if none is configured
    if(d->externalPlayer.isEmpty())
    {
        QStringList players;
        players << "wavplay"
                << "aplay"
                << "auplay";
        QStringList::Iterator it = players.begin();
        while(d->externalPlayer.isEmpty() && it != players.end())
        {
            d->externalPlayer = KStandardDirs::findExe(*it);
            ++it;
        }
    }

    // load default volume
    d->volume = kc->readNumEntry("Volume", 100);
}
Esempio n. 7
0
void KDevIDEExtension::createGlobalSettingsPage(KDialogBase *dlg)
{
    KConfig* config = kapp->config();
    QVBox *vbox = dlg->addVBoxPage(i18n("General"), i18n("General"), BarIcon("kdevelop", KIcon::SizeMedium) );
    gsw = new SettingsWidget(vbox, "general settings widget");

    gsw->projectsURL->setMode((int)KFile::Directory);

    config->setGroup("General Options");
    gsw->lastProjectCheckbox->setChecked(config->readBoolEntry("Read Last Project On Startup",true));
    gsw->outputFont->setFont( config->readFontEntry( "OutputViewFont" ) );
    config->setGroup("MakeOutputView");
    gsw->lineWrappingCheckBox->setChecked(config->readBoolEntry("LineWrapping",true));
    gsw->dirNavigMsgCheckBox->setChecked(config->readBoolEntry("ShowDirNavigMsg",false));
    gsw->compileOutputCombo->setCurrentItem(config->readNumEntry("CompilerOutputLevel",2));
    gsw->forceCLocaleRadio->setChecked( config->readBoolEntry( "ForceCLocale", true ) );
    gsw->userLocaleRadio->setChecked( !config->readBoolEntry( "ForceCLocale", true ) );

    config->setGroup("General Options");
    gsw->projectsURL->setURL(config->readPathEntry("DefaultProjectsDir", QDir::homeDirPath()+"/"));
    gsw->designerButtonGroup->setButton( config->readNumEntry( "DesignerApp", 0 ) );

    QString DesignerSetting = config->readEntry( "DesignerSetting", "ExternalDesigner" );
    gsw->qtDesignerRadioButton->setChecked( DesignerSetting == "ExternalDesigner" );
    gsw->seperateAppRadioButton->setChecked( DesignerSetting == "ExternalKDevDesigner" );
    gsw->embeddedDesignerRadioButton->setChecked( DesignerSetting == "EmbeddedKDevDesigner" );

    config->setGroup("TerminalEmulator");
    gsw->terminalEdit->setText( config->readEntry( "TerminalApplication", QString::fromLatin1("konsole") ) );
    bool useKDESetting = config->readBoolEntry( "UseKDESetting", true );
    gsw->useKDETerminal->setChecked( useKDESetting );
    gsw->useOtherTerminal->setChecked( !useKDESetting );
}
Esempio n. 8
0
void KadmosDialog::slFontChanged( int id )
{
    m_cbLang->clear();

    KConfig *conf = KGlobal::config ();
    KConfigGroupSaver gs( conf, CFG_GROUP_KADMOS );



    m_customClassifierPath = conf->readPathEntry( CFG_KADMOS_CLASSIFIER_PATH );

    bool enable = true;

    if( id == 0 )  /* Machine Print */
    {
        m_cbLang->insertStringList( m_ttfClassifier );
    }
    else if( id == 1 ) /* Hand Writing */
    {
        m_cbLang->insertStringList( m_handClassifier );
    }
    else if( id == 2 ) /* Norm Font */
    {
        enable = false;
    }
    m_cbLang->setEnabled( enable );
}
Esempio n. 9
0
EngineError KadmosDialog::findClassifierPath()
{
    KStandardDirs stdDir;
    EngineError err = ENG_OK;

    KConfig *conf = KGlobal::config ();
    KConfigGroupSaver gs( conf, CFG_GROUP_KADMOS );

    m_customClassifierPath = conf->readPathEntry( CFG_KADMOS_CLASSIFIER_PATH );
#if 0
    if( m_customClassifierPath == "NotFound" )
    {
        /* Wants the classifiers from the standard kde paths */
       KMessageBox::error(0, i18n("The classifier files for KADMOS could not be found.\n"
				  "OCR with KADMOS will not be possible!\n\n"
				  "Change the OCR engine in the preferences dialog."),
			  i18n("Installation Error") );
    }
    else
    {
        m_classifierPath = customPath;
    }
#endif
    return err;

}
void WebPresencePlugin::loadSettings()
{
	KConfig *kconfig = KGlobal::config();
	kconfig->setGroup( "Web Presence Plugin" );

	frequency = kconfig->readNumEntry("UploadFrequency", 15);
	resultURL = kconfig->readPathEntry("uploadURL");

	resultFormatting = WEB_UNDEFINED;

	if ( kconfig->readBoolEntry( "formatHTML", false ) ) {
		resultFormatting = WEB_HTML;
	} else if ( kconfig->readBoolEntry( "formatXHTML", false ) ) {
		resultFormatting = WEB_XHTML;
	} else if ( kconfig->readBoolEntry( "formatXML", false ) ) {
		resultFormatting = WEB_XML;
	} else if ( kconfig->readBoolEntry( "formatStylesheet", false ) ) {
		resultFormatting = WEB_CUSTOM;
		userStyleSheet = kconfig->readEntry("formatStylesheetURL");
	}

	// Default to HTML if we dont get anything useful from config file.
	if ( resultFormatting == WEB_UNDEFINED )
		resultFormatting = WEB_HTML;

	useImagesInHTML = kconfig->readBoolEntry( "useImagesHTML", false );
	useImName = kconfig->readBoolEntry("showName", true);
	userName = kconfig->readEntry("showThisName");
	showAddresses = kconfig->readBoolEntry("includeIMAddress", false);

	// Update file when settings are changed.
	slotWriteFile();
}
Esempio n. 11
0
void K3bIsoImageWritingDialog::init()
{
  if( !d->imageForced ) {
    // when opening the dialog first the default settings are loaded and afterwards we set the
    // last written image because that's what most users want
    KConfig* c = k3bcore->config();
    c->setGroup( configGroup() );
    QString image = c->readPathEntry( "last written image" );
    if( QFile::exists( image ) )
      m_editImagePath->setURL( image );
  }
}
Esempio n. 12
0
/******************************************************************************
* Read the configuration file.
* Create the client list and open all calendar files.
*/
void ADConfigData::readConfig()
{
    kdDebug(5900) << "ADConfigData::readConfig()" << endl;
    ClientInfo::clear();
    KConfig *config = KGlobal::config();
    QStringList clients = config->groupList().grep(CLIENT_GROUP_SEARCH);
    for(QStringList::Iterator cl = clients.begin();  cl != clients.end();  ++cl)
    {
        // Read this client's configuration
        config->setGroup(*cl);
        QString client = *cl;
        client.remove(CLIENT_GROUP_SEARCH);
        QString  title       = config->readEntry(TITLE_KEY, client);   // read app title (default = app name)
        QCString dcopObject  = config->readEntry(DCOP_OBJECT_KEY).local8Bit();
        bool     startClient = config->readBoolEntry(START_CLIENT_KEY, false);
        QString  calendar    = config->readPathEntry(CALENDAR_KEY);

        // Verify the configuration
        bool ok = false;
        if(client.isEmpty()  ||  KStandardDirs::findExe(client).isNull())
            kdError(5900) << "ADConfigData::readConfig(): group '" << *cl << "' deleted (client app not found)\n";
        else if(calendar.isEmpty())
            kdError(5900) << "ADConfigData::readConfig(): no calendar specified for '" << client << "'\n";
        else if(dcopObject.isEmpty())
            kdError(5900) << "ADConfigData::readConfig(): no DCOP object specified for '" << client << "'\n";
        else
        {
            ADCalendar *cal = ADCalendar::getCalendar(calendar);
            if(cal)
                kdError(5900) << "ADConfigData::readConfig(): calendar registered by multiple clients: " << calendar << endl;
            else
                ok = true;
        }
        if(!ok)
        {
            config->deleteGroup(*cl, true);
            continue;
        }

        // Create the client and calendar objects
        new ClientInfo(client.local8Bit(), title, dcopObject, calendar, startClient);
        kdDebug(5900) << "ADConfigData::readConfig(): client " << client << " : calendar " << calendar << endl;
    }

    // Remove obsolete CheckInterval entry (if it exists)
    config->setGroup("General");
    config->deleteEntry("CheckInterval");

    // Save any updates
    config->sync();
}
Esempio n. 13
0
void PanelBrowserMenu::slotOpenTerminal()
{
    KConfig * config = kapp->config();
    config->setGroup("General");
    QString term = config->readPathEntry("TerminalApplication", "konsole");

    KProcess proc;
    proc << term;
    if (term == "konsole")
      proc << "--workdir" << path();
    else
      proc.setWorkingDirectory(path());
    proc.start(KProcess::DontCare);
}
Esempio n. 14
0
void EditorChooser::readAppSetting(const QString &postfix)
{
    KConfig *cfg = kapp->config();
    QString previousGroup = cfg->group();
    cfg->setGroup("KTEXTEDITOR:" + postfix);
    QString editor = cfg->readPathEntry("editor");
    if(editor.isEmpty())
        d->chooser->editorCombo->setCurrentItem(0);
    else
    {
        int idx = d->elements.findIndex(editor);
        idx = idx + 1;
        d->chooser->editorCombo->setCurrentItem(idx);
    }
    cfg->setGroup(previousGroup);
}
Esempio n. 15
0
void CfgTerminalEmulator::load(KConfig *)
{
    KConfig *config = new KConfig("kdeglobals", true);
    config->setGroup("General");
    QString terminal = config->readPathEntry("TerminalApplication", "konsole");
    if(terminal == "konsole")
    {
        terminalLE->setText("xterm");
        terminalCB->setChecked(true);
    }
    else
    {
        terminalLE->setText(terminal);
        otherCB->setChecked(true);
    }
    delete config;

    emit changed(false);
}
Esempio n. 16
0
void ToolsConfigWidget::readGroup(const QString &group, QDict<ToolsConfigEntry> *entryDict)
{
    KConfig *config = ToolsFactory::instance()->config();
    config->setGroup("External Tools");
    QStringList list = config->readListEntry(group);

    QStringList::ConstIterator it;
    for (it = list.begin(); it != list.end(); ++it) {
        config->setGroup(group + " " + (*it));
        QString cmdline = config->readPathEntry("CommandLine");
        bool isdesktopfile = config->readBoolEntry("DesktopFile");
        bool captured = config->readBoolEntry("Captured");
        ToolsConfigEntry *entry = new ToolsConfigEntry;
        entry->menutext = (*it);
        entry->cmdline = cmdline;
        entry->isdesktopfile = isdesktopfile;
        entry->captured = captured;
        entryDict->insert(*it, entry);
    }
}
Esempio n. 17
0
void Opts::readSettings(const QString &initHost)
{

  KConfig *config = kapp->config();

  config->setGroup("Kpackage");

  //  kdDebug() << "readSettings: " << initHost << "\n";
  hostList = config->readListEntry("Host_list");
  if (!initHost.isEmpty() && !hostList.contains(initHost)) {
    hostList.prepend(initHost);
    config->writeEntry("Host_list", hostList);
  }
  hostList.sort();

  DCache = config->readNumEntry("Dir_Cache",1);
  if (DCache >2) {
    DCache = 1;
  }
  PCache = config->readNumEntry("Package_Cache",0);
  if (PCache >2) {
    PCache = 0;
  }
  CacheDir = config->readPathEntry("Cache_Directory", QDir::homeDirPath() + "/.kpackage/");

  // Backward compatability
  bool useSSH = config->readNumEntry("Use_SSH",0);
  privCmd = config->readNumEntry("Priv_Command", -1);
  
  if (privCmd == -1) {
    if (useSSH) {
      privCmd = SSHcmd;
    } else {
      privCmd = SUcmd;
    }
  }
  VerifyFL = config->readNumEntry("Verify_File_List",1);
  PkgRead = config->readNumEntry("Read_Package_files",0);
}
Esempio n. 18
0
EditorChooser::EditorChooser(QWidget *parent, const char *name) : QWidget(parent, name)
{
    d = new PrivateEditorChooser();

    // sizemanagment
    QGridLayout *grid = new QGridLayout(this, 1, 1);


    d->chooser = new EditorChooser_UI(this, name);

    grid->addWidget(d->chooser, 0, 0);


    KTrader::OfferList offers = KTrader::self()->query("text/plain", "'KTextEditor/Document' in ServiceTypes");
    KConfig *config = new KConfig("default_components");
    config->setGroup("KTextEditor");
    QString editor = config->readPathEntry("embeddedEditor");

    if(editor.isEmpty())
        editor = "katepart";

    for(KTrader::OfferList::Iterator it = offers.begin(); it != offers.end(); ++it)
    {
        if((*it)->desktopEntryName().contains(editor))
        {
            d->chooser->editorCombo->insertItem(i18n("System Default (%1)").arg((*it)->name()));
            break;
        }
    }

    for(KTrader::OfferList::Iterator it = offers.begin(); it != offers.end(); ++it)
    {
        d->chooser->editorCombo->insertItem((*it)->name());
        d->elements.append((*it)->desktopEntryName());
    }
    d->chooser->editorCombo->setCurrentItem(0);
}
Esempio n. 19
0
QString KProtocolManager::cacheDir()
{
    KConfig *cfg = http_config();
    return cfg->readPathEntry("CacheDir", KGlobal::dirs()->saveLocation("cache", "http"));
}
Esempio n. 20
0
int main(int argc, char **argv)
{
	KLocale::setMainCatalogue("kdelibs");
	KCmdLineArgs::init(argc, argv, "ktelnetservice", I18N_NOOP("telnet service"),
			   I18N_NOOP("telnet protocol handler"), "unknown");
	KCmdLineArgs::addCmdLineOptions(options);

	KApplication app;

	KCmdLineArgs *args = KCmdLineArgs::parsedArgs();
	
	if (args->count() != 1)
		return 1;

	KConfig *config = new KConfig("kdeglobals", true);
	config->setGroup("General");
	QString terminal = config->readPathEntry("TerminalApplication", "konsole");

	KURL url(args->arg(0));
	QStringList cmd;
	if (terminal == "konsole")
	    cmd << "--noclose";

	cmd << "-e";
        if ( url.protocol() == "telnet" )
            cmd << "telnet";
        else if ( url.protocol() == "ssh" )
            cmd << "ssh";
        else if ( url.protocol() == "rlogin" )
            cmd << "rlogin";
        else {
            kdError() << "Invalid protocol " << url.protocol() << endl;
            return 2;
        }
        
        if (!app.authorize("shell_access"))
        {
            KMessageBox::sorry(0, 
            	i18n("You do not have permission to access the %1 protocol.").arg(url.protocol()));
            return 3;
        }
        
	if (!url.user().isEmpty())
	{
		cmd << "-l";
		cmd << url.user();
	}

        QString host;
        if (!url.host().isEmpty())
           host = url.host(); // telnet://host
        else if (!url.path().isEmpty())
           host = url.path(); // telnet:host

        if (host.isEmpty() || host.startsWith("-"))
        {
            kdError() << "Invalid hostname " << host << endl;
            return 2;
        }

        cmd << host;
        
	if (url.port()){
            if ( url.protocol() == "ssh" )
		cmd << "-p" << QString::number(url.port());
	    else
		cmd << QString::number(url.port());
	}

	app.kdeinitExec(terminal, cmd);

	return 0;
}
void HTMLWidget::readSettings( )
{	KConfig* config = kapp->config( );
	config->setGroup( "General" );
	m_zoomFactor = config->readDoubleNumEntry( "zoomFactor", 100.0 );
	m_stylesheetURL.setPath( config->readPathEntry( "stylesheetURL" ));
}
Esempio n. 22
0
KuickShow::KuickShow( const char *name )
    : KMainWindow( 0L, name ),
      m_slideshowCycle( 1 ),
      fileWidget( 0L ),
      dialog( 0L ),
      id( 0L ),
      m_viewer( 0L ),
      oneWindowAction( 0L ),
      m_accel( 0L ),
      m_delayedRepeatItem( 0L ),
      m_slideShowStopped(false)
{
    aboutWidget = 0L;
    kdata = new KuickData;
    kdata->load();

    initImlib();
    resize( 400, 500 );

    m_slideTimer = new QTimer( this );
    connect( m_slideTimer, SIGNAL( timeout() ), SLOT( nextSlide() ));


    KConfig *kc = KGlobal::config();

    bool isDir = false; // true if we get a directory on the commandline

    // parse commandline options
    KCmdLineArgs *args = KCmdLineArgs::parsedArgs();

    // files to display
    // either a directory to display, an absolute path, a relative path, or a URL
    KURL startDir;
    startDir.setPath( QDir::currentDirPath() + '/' );

    int numArgs = args->count();
    if ( numArgs >= 10 )
    {
        // Even though the 1st i18n string will never be used, it needs to exist for plural handling - mhunter
        if ( KMessageBox::warningYesNo(
                 this,
                 i18n("Do you really want to display this 1 image at the same time? This might be quite resource intensive and could overload your computer.<br>If you choose %1, only the first image will be shown.", 
                      "Do you really want to display these %n images at the same time? This might be quite resource intensive and could overload your computer.<br>If you choose %1, only the first image will be shown.", numArgs).arg(KStdGuiItem::no().plainText()),
                 i18n("Display Multiple Images?"))
             != KMessageBox::Yes )
        {
            numArgs = 1;
        }
    }

    for ( int i = 0; i < numArgs; i++ ) {
        KURL url = args->url( i );
        KFileItem item( KFileItem::Unknown, KFileItem::Unknown, url, false );

        // for remote URLs, we don't know if it's a file or directory, but
        // FileWidget::isImage() should correct in most cases.
        // For non-local non-images, we just assume directory.

        if ( FileWidget::isImage( &item ) )
        {
            showImage( &item, true, false, true ); // show in new window, not fullscreen-forced and move to 0,0
//    showImage( &item, true, false, false ); // show in new window, not fullscreen-forced and not moving to 0,0
        }
        else if ( item.isDir() )
        {
            startDir = url;
            isDir = true;
        }

        // need to check remote files
        else if ( !url.isLocalFile() )
        {
            KMimeType::Ptr mime = KMimeType::findByURL( url );
            QString name = mime->name();
            if ( name == "application/octet-stream" ) // unknown -> stat()
                name = KIO::NetAccess::mimetype( url, this );

	    // text/* is a hack for bugs.kde.org-attached-images urls.
	    // The real problem here is that NetAccess::mimetype does a HTTP HEAD, which doesn't
	    // always return the right mimetype. The rest of KDE start a get() instead....
            if ( name.startsWith( "image/" ) || name.startsWith( "text/" ) )
            {
                FileWidget::setImage( item, true );
                showImage( &item, true, false, true );
            }
            else // assume directory, KDirLister will tell us if we can't list
            {
                startDir = url;
                isDir = true;
            }
        }
        // else // we don't handle local non-images
    }

    if ( (kdata->startInLastDir && args->count() == 0) || args->isSet( "lastfolder" )) {
        kc->setGroup( "SessionSettings");
        startDir = kc->readPathEntry( "CurrentDirectory", startDir.url() );
    }

    if ( s_viewers.isEmpty() || isDir ) {
        initGUI( startDir );
	if (!kapp->isRestored()) // during session management, readProperties() will show()
            show();
    }

    else { // don't show browser, when image on commandline
        hide();
        KStartupInfo::appStarted();
    }
}
Esempio n. 23
0
/* --| main |------------------------------------------------------ */
extern "C" int KDE_EXPORT kdemain(int argc, char *argv[])
{
    setgid(getgid());
    setuid(getuid()); // drop privileges

    // deal with shell/command ////////////////////////////
    bool histon = true;
    bool menubaron = true;
    bool tabbaron = true;
    bool frameon = true;
    bool scrollbaron = true;
    bool showtip = true;

    KAboutData aboutData("konsole", I18N_NOOP("Konsole"), KONSOLE_VERSION, description, KAboutData::License_GPL_V2,
                         "Copyright (c) 1997-2006, Lars Doelle");
    aboutData.addAuthor("Robert Knight", I18N_NOOP("Maintainer"), "*****@*****.**");
    aboutData.addAuthor("Lars Doelle", I18N_NOOP("Author"), "*****@*****.**");
    aboutData.addCredit("Kurt V. Hindenburg", I18N_NOOP("bug fixing and improvements"), "*****@*****.**");
    aboutData.addCredit("Waldo Bastian", I18N_NOOP("bug fixing and improvements"), "*****@*****.**");
    aboutData.addCredit("Stephan Binner", I18N_NOOP("bug fixing and improvements"), "*****@*****.**");
    aboutData.addCredit("Chris Machemer", I18N_NOOP("bug fixing"), "*****@*****.**");
    aboutData.addCredit("Stephan Kulow", I18N_NOOP("Solaris support and work on history"), "*****@*****.**");
    aboutData.addCredit("Alexander Neundorf", I18N_NOOP("faster startup, bug fixing"), "*****@*****.**");
    aboutData.addCredit("Peter Silva", I18N_NOOP("decent marking"), "*****@*****.**");
    aboutData.addCredit("Lotzi Boloni", I18N_NOOP("partification\n"
                                                  "Toolbar and session names"),
                        "*****@*****.**");
    aboutData.addCredit("David Faure", I18N_NOOP("partification\n"
                                                 "overall improvements"),
                        "*****@*****.**");
    aboutData.addCredit("Antonio Larrosa", I18N_NOOP("transparency"), "*****@*****.**");
    aboutData.addCredit("Matthias Ettrich", I18N_NOOP("most of main.C donated via kvt\n"
                                                      "overall improvements"),
                        "*****@*****.**");
    aboutData.addCredit("Warwick Allison", I18N_NOOP("schema and selection improvements"), "*****@*****.**");
    aboutData.addCredit("Dan Pilone", I18N_NOOP("SGI Port"), "*****@*****.**");
    aboutData.addCredit("Kevin Street", I18N_NOOP("FreeBSD port"), "*****@*****.**");
    aboutData.addCredit("Sven Fischer", I18N_NOOP("bug fixing"), "*****@*****.**");
    aboutData.addCredit("Dale M. Flaven", I18N_NOOP("bug fixing"), "*****@*****.**");
    aboutData.addCredit("Martin Jones", I18N_NOOP("bug fixing"), "*****@*****.**");
    aboutData.addCredit("Lars Knoll", I18N_NOOP("bug fixing"), "*****@*****.**");
    aboutData.addCredit("", I18N_NOOP("Thanks to many others.\n"
                                      "The above list only reflects the contributors\n"
                                      "I managed to keep track of."));

    KCmdLineArgs::init(argc, argv, &aboutData);
    KCmdLineArgs::addCmdLineOptions(options); // Add our own options.
    // 1.53 sec
    KCmdLineArgs *args = KCmdLineArgs::parsedArgs();
    KCmdLineArgs *qtargs = KCmdLineArgs::parsedArgs("qt");
    has_noxft = !args->isSet("xft");
    TEWidget::setAntialias(!has_noxft);
    TEWidget::setStandalone(true);

    // The following Qt options have no effect; warn users.
    if(qtargs->isSet("background"))
        kdWarning() << "The Qt option -bg, --background has no effect." << endl;
    if(qtargs->isSet("foreground"))
        kdWarning() << "The Qt option -fg, --foreground has no effect." << endl;
    if(qtargs->isSet("button"))
        kdWarning() << "The Qt option -btn, --button has no effect." << endl;
    if(qtargs->isSet("font"))
        kdWarning() << "The Qt option -fn, --font has no effect." << endl;

    KApplication *a = NULL;
#ifdef COMPOSITE
    if(args->isSet("real-transparency"))
    {
        char *display = 0;
        if(qtargs->isSet("display"))
            display = qtargs->getOption("display").data();

        Display *dpy = XOpenDisplay(display);
        if(!dpy)
        {
            kdError() << "cannot connect to X server " << display << endl;
            exit(1);
        }

        int screen = DefaultScreen(dpy);
        Colormap colormap = 0;
        Visual *visual = 0;
        int event_base, error_base;

        if(XRenderQueryExtension(dpy, &event_base, &error_base))
        {
            int nvi;
            XVisualInfo templ;
            templ.screen = screen;
            templ.depth = 32;
            templ.c_class = TrueColor;
            XVisualInfo *xvi = XGetVisualInfo(dpy, VisualScreenMask | VisualDepthMask | VisualClassMask, &templ, &nvi);

            for(int i = 0; i < nvi; i++)
            {
                XRenderPictFormat *format = XRenderFindVisualFormat(dpy, xvi[i].visual);
                if(format->type == PictTypeDirect && format->direct.alphaMask)
                {
                    visual = xvi[i].visual;
                    colormap = XCreateColormap(dpy, RootWindow(dpy, screen), visual, AllocNone);
                    kdDebug() << "found visual with alpha support" << endl;
                    argb_visual = true;
                    break;
                }
            }
        }
        // The QApplication ctor used is normally intended for applications not using Qt
        // as the primary toolkit (e.g. Motif apps also using Qt), with some slightly
        // unpleasant side effects (e.g. #83974). This code checks if qt-copy patch #0078
        // is applied, which allows turning this off.
        bool *qt_no_foreign_hack = static_cast< bool * >(dlsym(RTLD_DEFAULT, "qt_no_foreign_hack"));
        if(qt_no_foreign_hack)
            *qt_no_foreign_hack = true;
        // else argb_visual = false ... ? *shrug*

        if(argb_visual)
            a = new KApplication(dpy, Qt::HANDLE(visual), Qt::HANDLE(colormap));
        else
            XCloseDisplay(dpy);
    }
    if(a == NULL)
        a = new KApplication;
#else
    KApplication *a = new KApplication;
#endif

    QString dataPathBase = KStandardDirs::kde_default("data").append("konsole/");
    KGlobal::dirs()->addResourceType("wallpaper", dataPathBase + "wallpapers");

    KImageIO::registerFormats(); // add io for additional image formats
    // 2.1 secs

    QString title;
    if(args->isSet("T"))
    {
        title = QFile::decodeName(args->getOption("T"));
    }
    if(qtargs->isSet("title"))
    {
        title = QFile::decodeName(qtargs->getOption("title"));
    }

    QString term = "";
    if(args->isSet("tn"))
    {
        term = QString::fromLatin1(args->getOption("tn"));
    }
    login_shell = args->isSet("ls");

    QStrList eargs;

    const char *shell = 0;
    if(!args->getOption("e").isEmpty())
    {
        if(args->isSet("ls"))
            KCmdLineArgs::usage(i18n("You can't use BOTH -ls and -e.\n"));
        shell = strdup(args->getOption("e"));
        eargs.append(shell);
        for(int i = 0; i < args->count(); i++)
            eargs.append(args->arg(i));

        if(title.isEmpty() && (kapp->caption() == kapp->aboutData()->programName()))
        {
            title = QFile::decodeName(shell); // program executed in the title bar
        }
        showtip = false;
    }

    QCString sz = "";
    sz = args->getOption("vt_sz");
    histon = args->isSet("hist");
    menubaron = args->isSet("menubar");
    tabbaron = args->isSet("tabbar") && args->isSet("toolbar");
    frameon = args->isSet("frame");
    scrollbaron = args->isSet("scrollbar");
    QCString wname = qtargs->getOption("name");
    full_script = args->isSet("script");
    auto_close = args->isSet("close");
    fixed_size = !args->isSet("resize");

    if(!full_script)
        a->dcopClient()->setQtBridgeEnabled(false);

    QCString type = "";

    if(args->isSet("type"))
    {
        type = args->getOption("type");
    }
    if(args->isSet("types"))
    {
        QStringList types = KGlobal::dirs()->findAllResources("appdata", "*.desktop", false, true);
        types.sort();
        for(QStringList::ConstIterator it = types.begin(); it != types.end(); ++it)
        {
            QString file = *it;
            file = file.mid(file.findRev('/') + 1);
            if(file.endsWith(".desktop"))
                file = file.left(file.length() - 8);
            printf("%s\n", QFile::encodeName(file).data());
        }
        return 0;
    }
    if(args->isSet("schemas") || args->isSet("schemata"))
    {
        ColorSchemaList colors;
        colors.checkSchemas();
        for(int i = 0; i < (int)colors.count(); i++)
        {
            ColorSchema *schema = colors.find(i);
            QString relPath = schema->relPath();
            if(!relPath.isEmpty())
                printf("%s\n", QFile::encodeName(relPath).data());
        }
        return 0;
    }

    if(args->isSet("keytabs"))
    {
        QStringList lst = KGlobal::dirs()->findAllResources("data", "konsole/*.keytab");

        printf("default\n"); // 'buildin' keytab
        lst.sort();
        for(QStringList::Iterator it = lst.begin(); it != lst.end(); ++it)
        {
            QFileInfo fi(*it);
            QString file = fi.baseName();
            printf("%s\n", QFile::encodeName(file).data());
        }
        return 0;
    }

    QString workDir = QFile::decodeName(args->getOption("workdir"));

    QString keytab = "";
    if(args->isSet("keytab"))
        keytab = QFile::decodeName(args->getOption("keytab"));

    QString schema = "";
    if(args->isSet("schema"))
        schema = args->getOption("schema");

    KConfig *sessionconfig = 0;
    QString profile = "";
    if(args->isSet("profile"))
    {
        profile = args->getOption("profile");
        QString path = locate("data", "konsole/profiles/" + profile);
        if(QFile::exists(path))
            sessionconfig = new KConfig(path, true);
        else
            profile = "";
    }
    if(args->isSet("profiles"))
    {
        QStringList profiles = KGlobal::dirs()->findAllResources("data", "konsole/profiles/*", false, true);
        profiles.sort();
        for(QStringList::ConstIterator it = profiles.begin(); it != profiles.end(); ++it)
        {
            QString file = *it;
            file = file.mid(file.findRev('/') + 1);
            printf("%s\n", QFile::encodeName(file).data());
        }
        return 0;
    }


    // FIXME: more: font

    args->clear();

    int c = 0, l = 0;
    if(!sz.isEmpty())
    {
        char *ls = (char *)strchr(sz.data(), 'x');
        if(ls != NULL)
        {
            *ls = '\0';
            ls++;
            c = atoi(sz.data());
            l = atoi(ls);
        }
        else
        {
            KCmdLineArgs::usage(i18n("expected --vt_sz <#columns>x<#lines> e.g. 80x40\n"));
        }
    }

    if(!kapp->authorizeKAction("size"))
        fixed_size = true;

    // ///////////////////////////////////////////////

    // Ignore SIGHUP so that we don't get killed when
    // our parent-shell gets closed.
    signal(SIGHUP, SIG_IGN);

    putenv((char *)"COLORTERM="); // to trigger mc's color detection
    KonsoleSessionManaged ksm;

    if(a->isRestored() || !profile.isEmpty())
    {
        if(!shell)
            shell = konsole_shell(eargs);

        if(profile.isEmpty())
            sessionconfig = a->sessionConfig();
        sessionconfig->setDesktopGroup();
        int n = 1;

        QString key;
        QString sTitle;
        QString sPgm;
        QString sTerm;
        QString sIcon;
        QString sCwd;
        int n_tabbar;

        // TODO: Session management stores everything in same group,
        // should use one group / mainwindow
        while(KMainWindow::canBeRestored(n) || !profile.isEmpty())
        {
            sessionconfig->setGroup(QString("%1").arg(n));
            if(!sessionconfig->hasKey("Pgm0"))
                sessionconfig->setDesktopGroup(); // Backwards compatible

            int session_count = sessionconfig->readNumEntry("numSes");
            int counter = 0;

            wname = sessionconfig->readEntry("class", wname).latin1();

            sPgm = sessionconfig->readEntry("Pgm0", shell);
            sessionconfig->readListEntry("Args0", eargs);
            sTitle = sessionconfig->readEntry("Title0", title);
            sTerm = sessionconfig->readEntry("Term0");
            sIcon = sessionconfig->readEntry("Icon0", "konsole");
            sCwd = sessionconfig->readPathEntry("Cwd0");
            workDir = sessionconfig->readPathEntry("workdir");
            n_tabbar = QMIN(sessionconfig->readUnsignedNumEntry("tabbar", Konsole::TabBottom), 2);
            Konsole *m = new Konsole(wname, histon, menubaron, tabbaron, frameon, scrollbaron, 0 /*type*/, true, n_tabbar, workDir);

            m->newSession(sPgm, eargs, sTerm, sIcon, sTitle, sCwd);

            m->enableFullScripting(full_script);
            m->enableFixedSize(fixed_size);
            m->restore(n);
            sessionconfig->setGroup(QString("%1").arg(n));
            if(!sessionconfig->hasKey("Pgm0"))
                sessionconfig->setDesktopGroup(); // Backwards compatible
            m->makeGUI();
            m->setEncoding(sessionconfig->readNumEntry("Encoding0"));
            m->setSchema(sessionconfig->readEntry("Schema0"));
            // Use konsolerc default as tmpFont instead?
            QFont tmpFont = KGlobalSettings::fixedFont();
            m->initSessionFont(sessionconfig->readFontEntry("SessionFont0", &tmpFont));
            m->initSessionKeyTab(sessionconfig->readEntry("KeyTab0"));
            m->initMonitorActivity(sessionconfig->readBoolEntry("MonitorActivity0", false));
            m->initMonitorSilence(sessionconfig->readBoolEntry("MonitorSilence0", false));
            m->initMasterMode(sessionconfig->readBoolEntry("MasterMode0", false));
            m->initTabColor(sessionconfig->readColorEntry("TabColor0"));
            // -1 will be changed to the default history in konsolerc
            m->initHistory(sessionconfig->readNumEntry("History0", -1), sessionconfig->readBoolEntry("HistoryEnabled0", true));
            counter++;

            // show() before 2nd+ sessions are created allows --profile to
            //  initialize the TE size correctly.
            m->show();

            while(counter < session_count)
            {
                key = QString("Title%1").arg(counter);
                sTitle = sessionconfig->readEntry(key, title);
                key = QString("Args%1").arg(counter);
                sessionconfig->readListEntry(key, eargs);

                key = QString("Pgm%1").arg(counter);

                // if the -e option is passed on the command line, this overrides the program specified
                // in the profile file
                if(args->isSet("e"))
                    sPgm = (shell ? QFile::decodeName(shell) : QString::null);
                else
                    sPgm = sessionconfig->readEntry(key, shell);

                key = QString("Term%1").arg(counter);
                sTerm = sessionconfig->readEntry(key);
                key = QString("Icon%1").arg(counter);
                sIcon = sessionconfig->readEntry(key, "konsole");
                key = QString("Cwd%1").arg(counter);
                sCwd = sessionconfig->readPathEntry(key);
                m->newSession(sPgm, eargs, sTerm, sIcon, sTitle, sCwd);
                m->setSessionTitle(sTitle); // Use title as is
                key = QString("Schema%1").arg(counter);
                m->setSchema(sessionconfig->readEntry(key));
                key = QString("Encoding%1").arg(counter);
                m->setEncoding(sessionconfig->readNumEntry(key));
                key = QString("SessionFont%1").arg(counter);
                QFont tmpFont = KGlobalSettings::fixedFont();
                m->initSessionFont(sessionconfig->readFontEntry(key, &tmpFont));
                key = QString("KeyTab%1").arg(counter);
                m->initSessionKeyTab(sessionconfig->readEntry(key));
                key = QString("MonitorActivity%1").arg(counter);
                m->initMonitorActivity(sessionconfig->readBoolEntry(key, false));
                key = QString("MonitorSilence%1").arg(counter);
                m->initMonitorSilence(sessionconfig->readBoolEntry(key, false));
                key = QString("MasterMode%1").arg(counter);
                m->initMasterMode(sessionconfig->readBoolEntry(key, false));
                key = QString("TabColor%1").arg(counter);
                m->initTabColor(sessionconfig->readColorEntry(key));
                // -1 will be changed to the default history in konsolerc
                key = QString("History%1").arg(counter);
                QString key2 = QString("HistoryEnabled%1").arg(counter);
                m->initHistory(sessionconfig->readNumEntry(key, -1), sessionconfig->readBoolEntry(key2, true));
                counter++;
            }
            m->setDefaultSession(sessionconfig->readEntry("DefaultSession", "shell.desktop"));

            m->initFullScreen();
            if(!profile.isEmpty())
            {
                m->callReadPropertiesInternal(sessionconfig, 1);
                profile = "";
                // Hack to work-around sessions initialized with minimum size
                for(int i = 0; i < counter; i++)
                    m->activateSession(i);
                m->setColLin(c, l); // will use default height and width if called with (0,0)
            }
            // works only for the first one, but there won't be more.
            n++;
            m->activateSession(sessionconfig->readNumEntry("ActiveSession", 0));
            m->setAutoClose(auto_close);
        }
    }
    else
    {
        Konsole *m = new Konsole(wname, histon, menubaron, tabbaron, frameon, scrollbaron, type, false, 0, workDir);
        m->newSession((shell ? QFile::decodeName(shell) : QString::null), eargs, term, QString::null, title, workDir);
        m->enableFullScripting(full_script);
        m->enableFixedSize(fixed_size);
        // 3.8 :-(
        // exit(0);

        if(!keytab.isEmpty())
            m->initSessionKeyTab(keytab);

        if(!schema.isEmpty())
        {
            if(schema.right(7) != ".schema")
                schema += ".schema";
            m->setSchema(schema);
            m->activateSession(0); // Fixes BR83162, transp. schema + notabbar
        }

        m->setColLin(c, l); // will use default height and width if called with (0,0)

        m->initFullScreen();
        m->show();
        if(showtip)
            m->showTipOnStart();
        m->setAutoClose(auto_close);
    }

    int ret = a->exec();

    //// Temporary code, waiting for Qt to do this properly

    // Delete all toplevel widgets that have WDestructiveClose
    QWidgetList *list = QApplication::topLevelWidgets();
    // remove all toplevel widgets that have a parent (i.e. they
    // got WTopLevel explicitly), they'll be deleted by the parent
    list->first();
    while(list->current())
    {
        if(list->current()->parentWidget() != NULL || !list->current()->testWFlags(Qt::WDestructiveClose))
        {
            list->remove();
            continue;
        }
        list->next();
    }
    QWidgetListIt it(*list);
    QWidget *w;
    while((w = it.current()) != 0)
    {
        ++it;
        delete w;
    }
    delete list;

    delete a;

    return ret;
}
Esempio n. 24
0
void KNotify::notify(const QString &event, const QString &fromApp, const QString &text, QString sound, QString file, int present, int level,
                     int winId, int eventId)
{
    // kdDebug() << "event=" << event << " fromApp=" << fromApp << " text=" << text << " sound=" << sound <<
    //    " file=" << file << " present=" << present << " level=" << level <<  " winId=" << winId << " eventId=" << eventId << endl;
    if(d->inStartup)
    {
        d->startupEvents += "(" + event + ":" + fromApp + ")";
    }

    QString commandline;
    KConfig *eventsFile = NULL;
    KConfig *configFile = NULL;

    // check for valid events
    if(!event.isEmpty())
    {

        // get config file
        if(d->events.contains(fromApp))
        {
            eventsFile = d->events[fromApp];
        }
        else
        {
            eventsFile = new KConfig(locate("data", fromApp + "/eventsrc"), true, false);
            d->events.insert(fromApp, eventsFile);
        }
        if(d->configs.contains(fromApp))
        {
            configFile = d->configs[fromApp];
        }
        else
        {
            configFile = new KConfig(fromApp + ".eventsrc", true, false);
            d->configs.insert(fromApp, configFile);
        }

        if(!eventsFile->hasGroup(event) && isGlobal(event))
        {
            eventsFile = d->globalEvents;
            configFile = d->globalConfig;
        }

        eventsFile->setGroup(event);
        configFile->setGroup(event);

        // get event presentation
        if(present == -1)
            present = configFile->readNumEntry("presentation", -1);
        if(present == -1)
            present = eventsFile->readNumEntry("default_presentation", 0);

        // get sound file name
        if(present & KNotifyClient::Sound)
        {
            QString theSound = configFile->readPathEntry("soundfile");
            if(theSound.isEmpty())
                theSound = eventsFile->readPathEntry("default_sound");
            if(!theSound.isEmpty())
                sound = theSound;
        }

        // get log file name
        if(present & KNotifyClient::Logfile)
        {
            QString theFile = configFile->readPathEntry("logfile");
            if(theFile.isEmpty())
                theFile = eventsFile->readPathEntry("default_logfile");
            if(!theFile.isEmpty())
                file = theFile;
        }

        // get default event level
        if(present & KNotifyClient::Messagebox)
            level = eventsFile->readNumEntry("level", 0);

        // get command line
        if(present & KNotifyClient::Execute)
        {
            commandline = configFile->readPathEntry("commandline");
            if(commandline.isEmpty())
                commandline = eventsFile->readPathEntry("default_commandline");
        }
    }

    // emit event
    if(present & KNotifyClient::Sound) // && QFile(sound).isReadable()
        notifyBySound(sound, fromApp, eventId);

    if(present & KNotifyClient::Execute)
        notifyByExecute(commandline, event, fromApp, text, winId, eventId);

    if(present & KNotifyClient::Logfile) // && QFile(file).isWritable()
        notifyByLogfile(text, file);

    if(present & KNotifyClient::Stderr)
        notifyByStderr(text);

    if(present & KNotifyClient::Taskbar)
        notifyByTaskbar(checkWinId(fromApp, winId));

    if(present & KNotifyClient::PassivePopup)
        notifyByPassivePopup(text, fromApp, eventsFile, checkWinId(fromApp, winId));
    else if(present & KNotifyClient::Messagebox)
        notifyByMessagebox(text, level, checkWinId(fromApp, winId));

    QByteArray qbd;
    QDataStream ds(qbd, IO_WriteOnly);
    ds << event << fromApp << text << sound << file << present << level << winId << eventId;
    emitDCOPSignal("notifySignal(QString,QString,QString,QString,QString,int,int,int,int)", qbd);
}
Esempio n. 25
0
QString HTMLSearch::search(QString _lang, QString words, QString method, int matches,
			   QString format, QString sort)
{
  if (_lang == "C")
    _lang = "en";

  createConfig(_lang);

  QString result = dataPath(_lang)+"/result.html";

  // run htsearch ----------------------------------------------------
  KConfig *config = new KConfig("khelpcenterrc", true);
  KConfigGroupSaver saver(config, "htdig");
  QString exe = config->readPathEntry("htsearch", kapp->dirs()->findExe("htsearch"));
  if (exe.isEmpty())
  {
      delete config;
    return QString::null;
  }
  _proc = new KProcess();
  *_proc << exe << "-c" << dataPath(_lang)+"/htdig.conf" <<
    QString("words=%1;method=%2;matchesperpage=%3;format=%4;sort=%5").arg(words).arg(method).arg(matches).arg(format).arg(sort);

  kdDebug() << "Running htsearch" << endl;

  connect(_proc, SIGNAL(receivedStdout(KProcess *,char*,int)),
	  this, SLOT(htsearchStdout(KProcess *,char*,int)));
  connect(_proc, SIGNAL(processExited(KProcess *)),
	  this, SLOT(htsearchExited(KProcess *)));

  _htsearchRunning = true;
  _searchResult = "";

  _proc->start(KProcess::NotifyOnExit, KProcess::Stdout);

  kapp->enter_loop();

  if (!_proc->normalExit() || _proc->exitStatus() != 0)
    {
      kdDebug() << "Error running htsearch... returning now" << endl;
      delete _proc;
      delete config;
      return QString::null;
    }

  delete _proc;

  // modify the search result
  _searchResult = _searchResult.replace("http://localhost/", "file:/");
  _searchResult = _searchResult.replace("Content-type: text/html", QString::null);

  // dump the search result
  QFile f(result);
  if (f.open(IO_WriteOnly))
    {
      QTextStream ts(&f);

      ts << _searchResult << endl;

      f.close();
      delete config;
      return result;
    }
  delete config;
  return QString::null;
}
Esempio n. 26
0
void kpok::initWindow()
{
  m_blinking    = true;
  m_blinkStat   = 0;
  m_blinkingBox = 0;

  // General font stuff.  Define myFixedFont and wonFont.
  QFont myFixedFont;
  myFixedFont.setPointSize(12);
  QFont wonFont;
  wonFont.setPointSize(14);
  wonFont.setBold(true);

  topLayout = new QVBoxLayout(this, BORDER);
  QVBoxLayout* topInputLayout = new QVBoxLayout;
  topLayout->addLayout(topInputLayout);

  QHBoxLayout* betLayout = new QHBoxLayout;
  inputLayout = new QHBoxLayout;
  inputLayout->addLayout(betLayout);
  topInputLayout->addLayout(inputLayout);

  // The draw button
  drawButton = new QPushButton(this);
  drawButton->setText(i18n("&Deal"));
  connect(drawButton, SIGNAL(clicked()), this, SLOT(drawClick()));
  inputLayout->addWidget(drawButton);
  inputLayout->addStretch(1);

  // The waving text
  QFont  waveFont;
  waveFont.setPointSize(16);
  waveFont.setBold(true);
  QFontMetrics  tmp(waveFont);

  // The widget where the winner is announced.
  mWonWidget = new QWidget(this);
  inputLayout->addWidget(mWonWidget, 2);
  mWonWidget->setMinimumHeight(50); //FIXME hardcoded value for the wave
  mWonWidget->setMinimumWidth(tmp.width(i18n("You won %1").arg(KGlobal::locale()->formatMoney(100))) + 20); // workaround for width problem in wave
  QHBoxLayout* wonLayout = new QHBoxLayout(mWonWidget);
  wonLayout->setAutoAdd(true);

  wonLabel = new QLabel(mWonWidget);
  wonLabel->setFont(wonFont);
  wonLabel->setAlignment(AlignCenter);
  wonLabel->hide();
  inputLayout->addStretch(1);

  // The pot view
  potLabel = new QLabel(this);
  potLabel->setFont(myFixedFont);
  potLabel->setFrameStyle(QFrame::WinPanel | QFrame::Sunken);
  inputLayout->addWidget(potLabel, 0, AlignCenter);

  // Label widget in the lower left.
  clickToHold = new QLabel(this);
  clickToHold->hide();

  // Timers
  blinkTimer = new QTimer(this);
  connect( blinkTimer, SIGNAL(timeout()), SLOT(bTimerEvent()) );

  waveTimer = new QTimer(this);
  connect( waveTimer, SIGNAL(timeout()), SLOT(waveTimerEvent()) );

  drawTimer = new QTimer(this);
  connect (drawTimer, SIGNAL(timeout()), SLOT(drawCardsEvent()) );

  // and now the betUp/Down Buttons
  betBox = new BetBox(this, 0);
  betLayout->addWidget(betBox);
  connect(betBox, SIGNAL(betChanged(int)), this, SLOT(betChange(int)));
  connect(betBox, SIGNAL(betAdjusted()),   this, SLOT(adjustBet()));
  connect(betBox, SIGNAL(fold()),          this, SLOT(out()));

  // some tips 
  QToolTip::add(drawButton, i18n("Continue the round"));
  QToolTip::add(potLabel, i18n("The current pot"));

  // Load all cards into pixmaps first -> in the constructor.
  cardImages = new CardImages(this, 0);

  // The configuration
  KConfig* conf = kapp->config();
  conf->setGroup("General");

  // Load the card deck.
  if (conf->readBoolEntry("RandomDeck", true)) {
    cardImages->loadDeck(KCardDialog::getRandomDeck());
  } else {
    cardImages->loadDeck(conf->readPathEntry("DeckPath", KCardDialog::getDefaultDeck()));
  }
  if (conf->readBoolEntry("RandomCardDir", true)) {
    cardImages->loadCards(KCardDialog::getRandomCardDir());
  } else {
    cardImages->loadCards(conf->readPathEntry("CardPath",
				  KCardDialog::getDefaultCardDir()));
  }
}
Esempio n. 27
0
void KArtsModule::load( bool useDefaults )
{
   config->setReadDefaults( useDefaults );
	config->setGroup("Arts");
	startServer->setChecked(config->readBoolEntry("StartServer",true));
	startRealtime->setChecked(config->readBoolEntry("StartRealtime",true) &&
	                          realtimeIsPossible());
	networkTransparent->setChecked(config->readBoolEntry("NetworkTransparent",false));
	fullDuplex->setChecked(config->readBoolEntry("FullDuplex",false));
	autoSuspend->setChecked(config->readBoolEntry("AutoSuspend",true));
	suspendTime->setValue(config->readNumEntry("SuspendTime",60));
	deviceName->setText(config->readEntry("DeviceName",QString::null));
	customDevice->setChecked(!deviceName->text().isEmpty());
	hardware->addOptions->setText(config->readEntry("AddOptions",QString::null));
	hardware->customOptions->setChecked(!hardware->addOptions->text().isEmpty());
	general->latencySlider->setValue(config->readNumEntry("Latency",250));

	int rate = config->readNumEntry("SamplingRate",0);
	if(rate)
	{
		customRate->setChecked(true);
		samplingRate->setValue(rate);
	}
	else
	{
		customRate->setChecked(false);
		samplingRate->setValue(44100);
	}

	switch (config->readNumEntry("Bits", 0)) {
	case 0:
		hardware->soundQuality->setCurrentItem(0);
		break;
	case 16:
		hardware->soundQuality->setCurrentItem(1);
		break;
	case 8:
		hardware->soundQuality->setCurrentItem(2);
		break;
	}

	QString audioIO = config->readEntry("AudioIO", QString::null);
	hardware->audioIO->setCurrentItem(0);
	for(AudioIOElement *a = audioIOList.first(); a != 0; a = audioIOList.next())
	{
		if(a->name == audioIO)		// first item: "autodetect"
		  {
			hardware->audioIO->setCurrentItem(audioIOList.at() + 1);
			break;
		  }

	}

//	config->setGroup( "Mixer" );
//	general->volumeSystray->setChecked( config->readBoolEntry( "VolumeControlOnSystray", true ) );

	KConfig *midiConfig = new KConfig( "kcmmidirc", true );

	midiConfig->setGroup( "Configuration" );
	hardware->midiDevice->setCurrentItem( midiConfig->readNumEntry( "midiDevice", 0 ) );
	QString mapurl( midiConfig->readPathEntry( "mapFilename" ) );
	hardware->midiMapper->setURL( mapurl );
	hardware->midiUseMapper->setChecked( midiConfig->readBoolEntry( "useMidiMapper", false ) );
	hardware->midiMapper->setEnabled( hardware->midiUseMapper->isChecked() );

	delete midiConfig;

	updateWidgets();
   emit changed( useDefaults );
}
Esempio n. 28
0
SFileDialog::SFileDialog( QString initially, const QStringList& filter, const char* name )
:QDialog(0L,name,true)
{
  KConfig* config = kapp->config();
  config->setGroup( QString::fromLatin1("SFileDialogData:") + name );
  if ( initially.isNull() ){
    initially = config->readPathEntry( "InitiallyDir", QDir::currentDirPath() );
  }

  QStringList bookmark;
  bookmark = config->readListEntry( "Bookmarks" );

  dockManager = new KDockManager(this);

  d_dirView = new KDockWidget( dockManager, "Dock_DirView", QPixmap(dir_tree_xpm) );
  d_dirView->setCaption("Tree");

  dirView = new DirectoryView( d_dirView, 0 );
  dirView->addColumn( "" );
  dirView->header()->hide();
  d_dirView->setWidget( dirView );

  Directory* root = new Directory( dirView, "/" );
  root->setOpen(true);

  d_preview = new KDockWidget( dockManager, "Dock_Preview", QPixmap(preview_xpm) );
  d_preview->setCaption("Preview");
  preview = new Preview( d_preview );
  d_preview->setWidget( preview );

  d_fd = new KDockWidget( dockManager, "Dock_QFileDialog", QPixmap(), this );
  fd = new CustomFileDialog( d_fd );
  fd->setDir( initially );
  fd->setFilters( filter );
  fd->setBookmark( bookmark );
  fd->reparent(d_fd, QPoint(0,0));
  d_fd->setWidget( fd );

  connect( dirView, SIGNAL( folderSelected( const QString & ) ), fd, SLOT( setDir2( const QString & ) ) );
  connect( fd, SIGNAL( dirEntered( const QString & ) ), dirView, SLOT( setDir( const QString & ) ) );

  d_fd->setDockSite( KDockWidget::DockTop|KDockWidget::DockLeft|KDockWidget::DockRight|KDockWidget::DockBottom );
  d_fd->setEnableDocking(KDockWidget::DockNone);

  d_dirView->setEnableDocking(KDockWidget::DockTop|KDockWidget::DockLeft|KDockWidget::DockRight|KDockWidget::DockBottom|KDockWidget::DockCenter);
  d_preview->setEnableDocking(KDockWidget::DockTop|KDockWidget::DockLeft|KDockWidget::DockRight|KDockWidget::DockBottom|KDockWidget::DockCenter);

  d_dirView->manualDock( d_fd, KDockWidget::DockLeft, 20 );
  d_preview->manualDock( d_fd, KDockWidget::DockBottom, 70 );

  connect(fd, SIGNAL(fileHighlighted(const QString&)), preview, SLOT(showPreview(const QString&)));
  connect(fd, SIGNAL(signalDone(int)), this, SLOT(done(int)));

  connect(fd, SIGNAL(dirEntered(const QString&)), this, SLOT(changeDir(const QString&)));
  connect(dirView, SIGNAL(folderSelected(const QString&)), this, SLOT(changeDir(const QString&)));

  b_tree = new QToolButton( fd );
  QToolTip::add( b_tree, "Show/Hide Tree" );
  b_tree->setPixmap( QPixmap( dir_tree_xpm ) );
  connect( b_tree, SIGNAL(clicked()), d_dirView, SLOT(changeHideShowState()) );
  b_tree->setToggleButton(true);
  b_tree->setOn(true);
  fd->addToolButton( b_tree, true );

  b_preview = new QToolButton( fd );
  QToolTip::add( b_preview, "Show/Hide Preview" );
  b_preview->setPixmap( QPixmap( preview_xpm ) );
  connect( b_preview, SIGNAL(clicked()), d_preview, SLOT(changeHideShowState()) );
  b_preview->setToggleButton(true);
  b_preview->setOn(true);
  fd->addToolButton( b_preview );

  connect( dockManager, SIGNAL(change()), this, SLOT(dockChange()));
  connect( dockManager, SIGNAL(setDockDefaultPos(KDockWidget*)), this, SLOT(setDockDefaultPos(KDockWidget*)));
  setCaption("Open File");
  resize(550,450);
  qDebug("read config");
  dockManager->readConfig( 0L , name );
}
Esempio n. 29
0
void K3bIsoImageWritingDialog::slotStartClicked()
{
  if( !d->isIsoImage ) {
    if( KMessageBox::warningContinueCancel( this,
				   i18n("The image you selected is not a valid ISO9660 image. "
					"Are you sure you want to burn it anyway? "
					"(There may exist other valid image types that are not detected by K3b but "
					"will work fine.)"), i18n("Burn") ) == KMessageBox::Cancel )
      return;
  }

  K3bIso9660 isoFs( imagePath() );
  if( isoFs.open() ) {
    if( K3b::imageFilesize( KURL::fromPathOrURL( imagePath() ) ) < (KIO::filesize_t)(isoFs.primaryDescriptor().volumeSpaceSize*2048) ) {
      if( KMessageBox::questionYesNo( this, 
				      i18n("<p>This image has an invalid file size."
					   "If it has been downloaded make sure the download is complete."
					   "<p>Only continue if you know what you are doing."),
				      i18n("Warning"),
				      i18n("Continue"),
				      i18n("Cancel") ) == KMessageBox::No )
	return;
    }
  }

  m_md5Job->cancel();

  // save the path
  KConfig* c = k3bcore->config();
  c->setGroup( configGroup() );
  if( c->readPathEntry( "last written image" ).isEmpty() )
    c->writePathEntry( "last written image", imagePath() );

  // create a progresswidget
  K3bBurnProgressDialog dlg( kapp->mainWidget(), "burnProgress", true );

  // create the job
  K3bIso9660ImageWritingJob* job = new K3bIso9660ImageWritingJob( &dlg );

  job->setBurnDevice( m_writerSelectionWidget->writerDevice() );
  job->setSpeed( m_writerSelectionWidget->writerSpeed() );
  job->setSimulate( m_checkDummy->isChecked() );
  job->setWritingMode( m_writingModeWidget->writingMode() );
  job->setVerifyData( m_checkVerify->isChecked() );
  job->setCopies( m_checkDummy->isChecked() ? 1 : m_spinCopies->value() );
  job->setImagePath( imagePath() );

  // HACK (needed since if the medium is forced the stupid K3bIso9660ImageWritingJob defaults to cd writing)
  job->setWritingApp( K3b::GROWISOFS );

  if( !exitLoopOnHide() )
    hide();

  dlg.startJob( job );

  delete job;

  if( KConfigGroup( k3bcore->config(), "General Options" ).readBoolEntry( "keep action dialogs open", false ) &&
      !exitLoopOnHide() )
    show();
  else
    close();
}
Esempio n. 30
0
bool HTMLSearch::generateIndex(QString _lang, QWidget *parent)
{
    if (_lang == "C")
        _lang = "en";

    if (!createConfig(_lang))
        return false;

    // create progress dialog
    progress = new ProgressDialog(parent);
    progress->show();
    kapp->processEvents();

    // create files list ----------------------------------------------
    if (!saveFilesList(_lang))
        return false;

    progress->setState(1);

    // run htdig ------------------------------------------------------
    KConfig *config = new KConfig("khelpcenterrc", true);
    KConfigGroupSaver saver(config, "htdig");
    QString exe = config->readPathEntry("htdig", kapp->dirs()->findExe("htdig"));

    if (exe.isEmpty())
    {
        delete config;
        return false;
    }
    bool initial = true;
    bool done = false;
    int  count = 0;

    _filesToDig = _files.count();
    progress->setFilesToDig(_filesToDig);
    _filesDigged = 0;

    QDir d; d.mkdir(dataPath(_lang));

    while (!done)
    {
        // kill old process
        delete _proc;

        // prepare new process
        _proc = new KProcess();
        *_proc << exe  << "-v" << "-c" << dataPath(_lang)+"/htdig.conf";
        if (initial)
	{
            *_proc << "-i";
            initial = false;
	}

        kdDebug() << "Running htdig" << endl;

        connect(_proc, SIGNAL(receivedStdout(KProcess *,char*,int)),
                this, SLOT(htdigStdout(KProcess *,char*,int)));

        connect(_proc, SIGNAL(processExited(KProcess *)),
                this, SLOT(htdigExited(KProcess *)));

        _htdigRunning = true;

        // write out file
        QFile f(dataPath(_lang)+"/files");
        if (f.open(IO_WriteOnly))
	{
            QTextStream ts(&f);

            for (int i=0; i<CHUNK_SIZE; ++i, ++count)
                if (count < _filesToDig) {
                    ts << "file://" + _files[count] << endl;
                } else {
                    done = true;
                    break;
                }
            f.close();
	}
        else
	{
            kdDebug() << "Could not open `files` for writing" << endl;
            delete config;
            return false;
	}


        // execute htdig
        _proc->start(KProcess::NotifyOnExit, KProcess::Stdout );

        kapp->enter_loop();

        if (!_proc->normalExit() || _proc->exitStatus() != 0)
	{
            delete _proc;
            delete progress;
            delete config;
            return false;
	}

        // _filesDigged += CHUNK_SIZE;
        progress->setFilesDigged(_filesDigged);
        kapp->processEvents();
    }

    progress->setState(2);

    // run htmerge -----------------------------------------------------
    exe = config->readPathEntry("htmerge", kapp->dirs()->findExe("htmerge"));
    if (exe.isEmpty())
    {
        delete config;
        return false;
    }
    delete _proc;
    _proc = new KProcess();
    *_proc << exe << "-c" << dataPath(_lang)+"/htdig.conf";

    kdDebug() << "Running htmerge" << endl;

    connect(_proc, SIGNAL(processExited(KProcess *)),
            this, SLOT(htmergeExited(KProcess *)));

    _htmergeRunning = true;

    _proc->start(KProcess::NotifyOnExit, KProcess::Stdout);

    kapp->enter_loop();

    if (!_proc->normalExit() || _proc->exitStatus() != 0)
    {
        delete _proc;
        delete progress;
        delete config;
        return false;
    }

    delete _proc;

    progress->setState(3);
    kapp->processEvents();

    delete progress;
    delete config;

    return true;
}