当前位置: 首页>>代码示例>>C++>>正文


C++ KConfig::hasKey方法代码示例

本文整理汇总了C++中KConfig::hasKey方法的典型用法代码示例。如果您正苦于以下问题:C++ KConfig::hasKey方法的具体用法?C++ KConfig::hasKey怎么用?C++ KConfig::hasKey使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在KConfig的用法示例。


在下文中一共展示了KConfig::hasKey方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: it

void K3bCddbOptionTab::apply()
{
  KConfig* c = kapp->config();

  c->setGroup( "Cddb" );

  c->writeEntry( "use remote cddb", m_checkRemoteCddb->isChecked() );
  c->writeEntry( "use local cddb query", m_checkUseLocalCddb->isChecked() );
  c->writeEntry( "save cddb entries locally", m_checkSaveLocalEntries->isChecked() );
  c->writeEntry( "use manual cgi path", m_checkManualCgiPath->isChecked() );
  c->writeEntry( "cgi path", m_editManualCgiPath->text() );

  QStringList cddbServer;
  QStringList localCddbDirs;

  QListViewItemIterator it( m_viewLocalDir );
  while( it.current() ) {
    localCddbDirs.append( it.current()->text(0) );
    ++it;
  }

  QListViewItemIterator it1( m_viewCddbServer );
  while( it1.current() ) {
    cddbServer.append( it1.current()->text(0) + " " + it1.current()->text(1) + ":" + it1.current()->text(2) );
    ++it1;
  }

  // new config
  c->writeEntry( "cddb server", cddbServer );

  // old config <= 0.7.3
  if( c->hasKey( "http server" ) )
    c->deleteEntry( "http server" );
  if( c->hasKey( "cddbp server" ) )
    c->deleteEntry( "cddbp server" );

  c->writePathEntry( "local cddb dirs", localCddbDirs );
}
开发者ID:,项目名称:,代码行数:38,代码来源:

示例2: QLabel

void
MoodPlugin::init()
{
	toolbar=new KToolBar((QMainWindow*)ktagebuchapp,QMainWindow::Top);
	new QLabel(i18n("Mood :"),toolbar);
	combobox=new KComboBox(toolbar);
	
	KConfig *config = ktagebuchapp->getConfig();
	config->setGroup("Mood Plugin");
	if (!config->hasKey("moods"))
		mPrefs->save();
	QStringList strList=QStringList(config->readListEntry("moods"));
	for (QStringList::Iterator it=strList.begin();it!=strList.end();++it){
	    combobox->insertItem(i18n(*it));
	}
	combobox->show();	
	loadEntry();
}
开发者ID:RainerBlessing,项目名称:KTagebuch,代码行数:18,代码来源:moodplugin.cpp

示例3:

/**
 * read the configfile
 */
void
PingCfgDlg::readConfig()
{
  QString s;
  KConfig *kc = kapp->getConfig();

  kc->setGroup(configGroupName);
  
  if (kc->hasKey("binaryType")) {
    s = kc->readEntry("binaryType");
    if (!stricmp(s, "nslookup")) {
      cfgNslookupBtn->setChecked(TRUE);
    } else {
      cfgPingBtn->setChecked(TRUE);
    }
  } else {
    cfgPingBtn->setChecked(TRUE);
  }
}
开发者ID:kthxbyte,项目名称:KDE1-Linaro,代码行数:22,代码来源:PingDlg.cpp

示例4: KTopLevelWidget


//.........这里部分代码省略.........
  /*
  QToolTip::add( doneButton, trans->translate(
		 "Click here when you think you placed all the balls.") );
		 */

  QString tmps;
  stat = new KStatusBar( this );
  tmps.sprintf( "aaaaaaaa" );
  stat->insertItem( (const char *) tmps, SSCORE );
  tmps.sprintf( "aaaaaaaaaaa" );
  stat->insertItem( (const char *) tmps, SBALLS );
  tmps.sprintf( "aaaaaaa" );
  stat->insertItem( (const char *) tmps, SRUN );
  tmps.sprintf( "aaaaaaaaaa" );
  stat->insertItem( (const char *) tmps, SSIZE );
  setStatusBar( stat );

  tool = new KToolBar( this );
  tool->insertButton( loader->loadIcon("exit.xpm"),
		      ID_QUIT, TRUE, trans->translate("Quit") );
  tool->insertButton( loader->loadIcon("reload.xpm"),
		      ID_NEW, TRUE, trans->translate("New") );
  tool->insertButton( loader->loadIcon("giveup.xpm"),
		      ID_GIVEUP, TRUE, trans->translate("Give up") );
  tool->insertButton( loader->loadIcon("done.xpm"),
		      ID_DONE, TRUE, trans->translate("Done") );
  tool->insertSeparator();
  tool->insertButton( loader->loadIcon("help.xpm"), ID_HELP, TRUE,
		      trans->translate("Help") );
  connect( tool, SIGNAL(clicked(int)), SLOT(callBack(int)) );
  addToolBar( tool );
  tool->setBarPos( KToolBar::Top );
  tool->show();
  
  /*
     Game initializations
  */
  running = FALSE;
  gameBoard = NULL;

  KConfig *kConf;
  int j;
  kConf = KApplication::getKApplication()->getConfig();
  kConf->setGroup( "KBlackBox Setup" );
  if (kConf->hasKey( "Balls" )) {
    i = kConf->readNumEntry( "Balls" );
    balls = i;
    switch (i) {
    case 4: ballsm->setItemChecked( balls1id, TRUE ); break;
    case 6: ballsm->setItemChecked( balls2id, TRUE ); break;
    case 8: ballsm->setItemChecked( balls3id, TRUE ); break;
    }
  } else {
    balls = 4;
    ballsm->setItemChecked( balls1id, TRUE );
  }
  if ((kConf->hasKey( "Width" )) &&
      (kConf->hasKey( "Balls" ))) {
    i = kConf->readNumEntry( "Width" );
    j = kConf->readNumEntry( "Height" );
    gr->setSize( i+4, j+4 ); // +4 is the space for "lasers" and an edge...
    gameBoard = new RectOnArray( gr->numC(), gr->numR() );
    switch (i) {
    case 8: sizesm->setItemChecked( sizes1id, TRUE ); break;
    case 10: sizesm->setItemChecked( sizes2id, TRUE ); break;
    case 12: sizesm->setItemChecked( sizes3id, TRUE ); break;
    }
  } else {
    gr->setSize( 8+4, 8+4 ); // +4 is the space for "lasers" and an edge...
    gameBoard = new RectOnArray( gr->numC(), gr->numR() );
    sizesm->setItemChecked( sizes1id, TRUE );
  }
  if (kConf->hasKey( "tutorial" )) {
    tutorial = (bool) kConf->readNumEntry( "tutorial" );
  } else tutorial = FALSE;
  options->setItemChecked( tut1id, tutorial );

  QString s, s1;
  int pos;
  setMinSize();
  gameResize();
  if (kConf->hasKey( "appsize" )) {
    s = kConf->readEntry( "appsize" );
    debug("%s", (const char *) s);
    pos = s.find( 'x' );
    s1 = s.right( s.length() - pos - 1 );
    s.truncate( pos - 1 );
    //    debug("%s", (const char *) s);
    //    debug("%s", (const char *) s1);
    resize( s.toInt(), s1.toInt() );
  }

  setScore( 0 );
  ballsPlaced = 0;
  updateStats();

  setView( gr );

  newGame();
}
开发者ID:xwizard,项目名称:kde1,代码行数:101,代码来源:kbbgame.cpp

示例5: aboutData


//.........这里部分代码省略.........

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

    // 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"));
开发者ID:serghei,项目名称:kde3-kdebase,代码行数:67,代码来源:main.cpp

示例6: CommandDlg

/*
 * Constructor
 */
PingDlg::PingDlg(QString commandName, 
		 QWidget* parent, const char* name)
  : CommandDlg(commandName, parent, name)
{
  KConfig *kc = kapp->getConfig();

  layout1 = new QBoxLayout(commandBinOK, 
			   QBoxLayout::TopToBottom, SEPARATION);
  CHECK_PTR(layout1);
  
  layout2 = new QBoxLayout(QBoxLayout::LeftToRight, SEPARATION);
  CHECK_PTR(layout2);
  layout1->addLayout(layout2, 0);
  
  // Frame for options
  frame1 = new QFrame(commandBinOK, "frame_1");
  CHECK_PTR(frame1);
  frame1->setFrameStyle(QFrame::Box | QFrame::Sunken);
  layout1->addWidget(frame1, 0);
  
  layout3 = new QBoxLayout(frame1, QBoxLayout::LeftToRight, SEPARATION/2);
  CHECK_PTR(layout3);
  
  // Make the layout of CommandDlg
  layout2->addWidget(commandLbl1);
  layout2->addWidget(commandArgs);
  layout2->addSpacing(2*SEPARATION);
  layout2->addWidget(commandGoBtn);
  layout2->addWidget(commandStopBtn);
  
  // Layout of options
  layout3->addStretch(10);
  
  pingCb1 = new QCheckBox(i18n("Make host &name resolution"), frame1, "cb_1");
  pingCb1->setChecked(TRUE);
  pingCb1->adjustSize();
  pingCb1->setFixedSize(pingCb1->width(), 2*fontMetrics().height());
  layout3->addWidget(pingCb1, 0);
  
  layout3->addStretch(10);
  layout3->activate();
  
  layout1->addWidget(commandTextArea, 10);
  layout1->activate();

  /*
   * Look at the command binary to see which widget to display
   */
  kc->setGroup(configGroupName);
  if (!kc->hasKey("path")) {
    // It's the first execution, 
    // so we have to search for the pathname
    kc->writeEntry("path", commandName);
    checkBinaryAndDisplayWidget();
    if (commandFound) {
      // All is OK : we can enable this tab.
      if (!kc->hasKey("enable")) {
	kc->writeEntry("enable", 1);
      }
    }
  } else {
    checkBinaryAndDisplayWidget();
  }
  
  // Commit changes in configfile (if needed)
  kc->sync();
}
开发者ID:kthxbyte,项目名称:KDE1-Linaro,代码行数:70,代码来源:PingDlg.cpp

示例7: readInConfiguration

void kPanel::readInConfiguration(){

   KConfig *config = KApplication::getKApplication()->getConfig();
   config->setGroup("kpanelButtons");

   QStrList button;
   QStrList buttondelta;
   QString button_entry_value;

   config->readListEntry("Buttons", button);
   QString a;

   config->readListEntry("ButtonDelta", buttondelta);

   float x;
   float y;
   float real_space;
   if (orientation == vertical){
     real_space = height() - bound_bottom_right + bound_top_left
       - panel_button->y() - panel_button->height();
     x = margin; y = panel_button->y() + panel_button->height();
   }
   else{
     real_space = width() - bound_bottom_right + bound_top_left
       - panel_button->x() - panel_button->width();
     y = margin; x = panel_button->x() + panel_button->width();
   }

   int num = -1;
   float delta = 0;
   QString tmp;

   int control = 1;
   float controldelta = -1;

   if (config->hasKey("control"))
     control = config->readNumEntry("control");

   if (config->hasKey("controldelta"))
     controldelta = QString(config->readEntry("controldelta")).toFloat();

   if (controldelta >= 0){
     bound_top_left = 0;
     bound_bottom_right = 0;
   }

   while (num < 0 ||
	  !button_entry_value.isNull()){

     if (num>=0){
       if (button_entry_value == "system"){
 	// the unremovable kde_button!
 	if (orientation == horizontal){
 	  kde_button->move((int)(x + delta * real_space / 10000) , (int)y);
 	  x = kde_button->x() + kde_button->width();
 	}
 	else {
 	  kde_button->move((int)x, (int)(y + delta * real_space / 10000));
 	  y = kde_button->y() + kde_button->height();
 	}
       }
       else {

	 if (orientation == horizontal)
	   x += delta * real_space / 10000;
	 else
	   y +=delta * real_space / 10000;

	 PMenuItem* pmi = 0;
	
	 bool buttonAdded = false;
	 if (button_entry_value == "windowlist"){
	     addButtonInternal(0, (int)x, (int)y, "windowlist");
	     buttonAdded = true;
	     has_windowlist_button = true;
	 }
	 // --sven: kdisknav button start --
	 else if (button_entry_value == "kdisknav"){
	     addButtonInternal(0, (int)x, (int)y, "kdisknav");
	     buttonAdded = true;
	     has_kdisknav_button = true;
	 }
         // --sven: kdisknav button end --
	 else {
	   pmi = pmenu->searchItem( button_entry_value);
	   if (pmi){
	     addButtonInternal(pmi, (int)x, (int)y);
	     buttonAdded = true;
	   }
	 }
	
	 if (buttonAdded){
	   if (orientation == horizontal)
	     x += entries[nbuttons-1].button->width();
	   else
	     y += entries[nbuttons-1].button->height();
	
	 }
       }
     }
//.........这里部分代码省略.........
开发者ID:xwizard,项目名称:kde1,代码行数:101,代码来源:props.C

示例8: readConfiguration

void KMDITitleLabel::readConfiguration(){
  KConfig* config;
  QString key;
//  int i;

  killTimers();

  config = new("KConfig") KConfig(KApplication::kde_configdir() + "/kwmrc",
                       KApplication::localconfigdir() + "/kwmrc");

  // this belongs in kapp....
  config->setGroup("WM");
  activeTitleBlend = config->readColorEntry( 
    "activeBlend",&black);
  inactiveTitleBlend = config->readColorEntry(
    "inactiveBlend",&kapp->backgroundColor);

  config->setGroup( "General" );

  //BORDER = 4;

  key = config->readEntry("WindowMoveType");
  if( key == "Transparent")
    options.WindowMoveType = TRANSPARENT;
  else if( key == "Opaque")
    options.WindowMoveType = OPAQUE;
  else{
    config->writeEntry("WindowMoveType","Transparent");
    options.WindowMoveType = TRANSPARENT;
  }

  key = config->readEntry("WindowResizeType");
  if( key == "Transparent")
    options.WindowResizeType = TRANSPARENT;
  else if( key == "Opaque")
    options.WindowResizeType = OPAQUE;
  else{
    config->writeEntry("WindowResizeType","Transparent");
    options.WindowResizeType = TRANSPARENT;
  }

  key = config->readEntry("FocusPolicy");
  if( key == "ClickToFocus")
    options.FocusPolicy = CLICK_TO_FOCUS;
  else if( key == "FocusFollowsMouse" || key == "FocusFollowMouse")
    options.FocusPolicy = FOCUS_FOLLOWS_MOUSE;
  else if( key == "ClassicFocusFollowsMouse" || key == "ClassicFocusFollowMouse")
    options.FocusPolicy = CLASSIC_FOCUS_FOLLOWS_MOUSE;
  else if( key == "ClassicSloppyFocus")
    options.FocusPolicy = CLASSIC_SLOPPY_FOCUS;
  else{
    config->writeEntry("FocusPolicy","ClickToFocus");
    options.FocusPolicy = CLICK_TO_FOCUS;
  }

  key = config->readEntry("AltTabMode");
  if( key == "KDE")
    options.AltTabMode = KDE_STYLE;
  else if( key == "CDE")
    options.AltTabMode = CDE_STYLE;
  else{
    config->writeEntry("AltTabMode","KDE");
    options.AltTabMode = KDE_STYLE;
  }

  if (CLASSIC_FOCUS)
    options.AltTabMode = CDE_STYLE;

  key = config->readEntry("TitlebarLook");
  if( key == "shadedHorizontal")
    options.TitlebarLook = H_SHADED;
  else if( key == "shadedVertical")
    options.TitlebarLook = V_SHADED;
  else if( key == "plain")
    options.TitlebarLook = PLAIN;
  else if( key == "pixmap")
    options.TitlebarLook = PIXMAP;
  else{
    config->writeEntry("TitlebarLook", "shadedHorizontal");
    options.TitlebarLook = H_SHADED;
  }

  //CT 23Sep1998 - fixed the name of the titlebar pixmaps to become
  //   consistent with the buttons pixmaps definition technique

  if (options.TitlebarLook == PIXMAP) {
    *options.titlebarPixmapActive = loadIcon("activetitlebar.xpm");
    *options.titlebarPixmapInactive = loadIcon("inactivetitlebar.xpm");

    if (options.titlebarPixmapInactive->size() == QSize(0,0))
      *options.titlebarPixmapInactive = *options.titlebarPixmapActive;

    if (options.titlebarPixmapActive->size() == QSize(0,0))
      options.TitlebarLook = PLAIN;
  }

  //CT 12Jun1998 - variable animation speed from 0 (none!!) to 10 (max)
  if (config->hasKey("ResizeAnimation")) {
    options.ResizeAnimation = config->readNumEntry("ResizeAnimation");
    if( options.ResizeAnimation < 1 ) options.ResizeAnimation = 0;
//.........这里部分代码省略.........
开发者ID:,项目名称:,代码行数:101,代码来源:

示例9: if

Kopete::Away::Away() : QObject( kapp , "Kopete::Away")
{
    int dummy = 0;
    dummy = dummy; // shut up

    d = new KopeteAwayPrivate;

    // Set up the away messages
    d->awayMessage = QString::null;
    d->autoAwayMessage = QString::null;
    d->useAutoAwayMessage = false;
    d->globalAway = false;
    d->autoaway = false;
    d->useAutoAway = true;

    // Empty the list
    d->awayMessageList.clear();

    // set the XAutoLock info
#ifdef Q_WS_X11
    Display *dsp = qt_xdisplay();
#endif
    d->mouse_x = d->mouse_y=0;
    d->mouse_mask = 0;
#ifdef Q_WS_X11
    d->root = DefaultRootWindow (dsp);
    d->screen = ScreenOfDisplay (dsp, DefaultScreen (dsp));
#endif
    d->useXidle = false;
    d->useMit = false;
#ifdef HasXidle
    d->useXidle = XidleQueryExtension(qt_xdisplay(), &dummy, &dummy);
#endif
#ifdef HasScreenSaver
    if(!d->useXidle)
        d->useMit = XScreenSaverQueryExtension(qt_xdisplay(), &dummy, &dummy);
#endif
#ifdef Q_WS_X11
    d->xIdleTime = 0;
#endif
    kdDebug(14010) << k_funcinfo << "Idle detection methods:" << endl;
    kdDebug(14010) << k_funcinfo << "\tKScreensaverIface::isBlanked()" << endl;
#ifdef Q_WS_X11
    kdDebug(14010) << k_funcinfo << "\tX11 XQueryPointer()" << endl;
#endif
    if (d->useXidle)
    {
        kdDebug(14010) << k_funcinfo << "\tX11 Xidle extension" << endl;
    }
    if (d->useMit)
    {
        kdDebug(14010) << k_funcinfo << "\tX11 MIT Screensaver extension" << endl;
    }


    load();
    KSettings::Dispatcher::self()->registerInstance( KGlobal::instance(), this, SLOT( load() ) );
    // Set up the config object
    KConfig *config = KGlobal::config();
    /* Load the saved away messages */
    config->setGroup("Away Messages");

    // Away Messages
    if(config->hasKey("Messages"))
    {
        d->awayMessageList = config->readListEntry("Messages");
    }
    else if(config->hasKey("Titles"))  // Old config format
    {
        QStringList titles = config->readListEntry("Titles");  // Get the titles
        for(QStringList::iterator i = titles.begin(); i != titles.end(); ++i)
        {
            d->awayMessageList.append( config->readEntry(*i) ); // And add it to the list
        }

        /* Save this list to disk */
        save();
    }
    else
    {
        d->awayMessageList.append( i18n( "Sorry, I am busy right now" ) );
        d->awayMessageList.append( i18n( "I am gone right now, but I will be back later" ) );

        /* Save this list to disk */
        save();
    }

    // Auto away message
    if(config->hasKey("AutoAwayMessage"))
    {
        d->autoAwayMessage = config->readEntry("AutoAwayMessage");
    }
    else
    {
        d->autoAwayMessage = i18n( "I am gone right now, but I will be back later" );

        // Save the default auto away message to disk
        save();
    }

//.........这里部分代码省略.........
开发者ID:,项目名称:,代码行数:101,代码来源:

示例10: convertOldPrefs

/******************************************************************************
* If the preferences were written by a previous version of KAlarm, do any
* necessary conversions.
*/
void Preferences::convertOldPrefs()
{
    KConfig *config = KGlobal::config();
    config->setGroup(GENERAL_SECTION);
    int version = KAlarm::getVersionNumber(config->readEntry(VERSION_NUM));
    if(version >= KAlarm::Version(1, 4, 22))
        return;     // config format is up to date

    if(version <= KAlarm::Version(1, 4, 21))
    {
        // Convert KAlarm 1.4.21 preferences
        static const QString OLD_REMIND_UNITS = QString::fromLatin1("DefRemindUnits");
        config->setGroup(DEFAULTS_SECTION);
        int intUnit     = config->readNumEntry(OLD_REMIND_UNITS, 0);
        QString strUnit = (intUnit == 1) ? QString::fromLatin1("Days")
                          : (intUnit == 2) ? QString::fromLatin1("Weeks")
                          :                  QString::fromLatin1("HoursMinutes");
        config->deleteEntry(OLD_REMIND_UNITS);
        config->writeEntry(DEF_REMIND_UNITS, strUnit);
    }

    if(version <= KAlarm::Version(1, 4, 20))
    {
        // Convert KAlarm 1.4.20 preferences
        static const QString VIEW_SECTION = QString::fromLatin1("View");
        static const QString SHOW_ARCHIVED_ALARMS = QString::fromLatin1("ShowArchivedAlarms");
        static const QString SHOW_EXPIRED_ALARMS  = QString::fromLatin1("ShowExpiredAlarms");
        static const QString SHOW_ALARM_TIME      = QString::fromLatin1("ShowAlarmTime");
        static const QString SHOW_TIME_TO_ALARM   = QString::fromLatin1("ShowTimeToAlarm");
        config->setGroup(GENERAL_SECTION);
        bool showExpired = config->readBoolEntry(SHOW_EXPIRED_ALARMS, false);
        bool showTime    = config->readBoolEntry(SHOW_ALARM_TIME, true);
        bool showTimeTo  = config->readBoolEntry(SHOW_TIME_TO_ALARM, false);
        config->deleteEntry(SHOW_EXPIRED_ALARMS);
        config->deleteEntry(SHOW_ALARM_TIME);
        config->deleteEntry(SHOW_TIME_TO_ALARM);
        config->setGroup(VIEW_SECTION);
        config->writeEntry(SHOW_ARCHIVED_ALARMS, showExpired);
        config->writeEntry(SHOW_ALARM_TIME, showTime);
        config->writeEntry(SHOW_TIME_TO_ALARM, showTimeTo);
    }

    if(version <= KAlarm::Version(1, 4, 5))
    {
        // Convert KAlarm 1.4.5 preferences
        static const QString DEF_SOUND = QString::fromLatin1("DefSound");
        config->setGroup(DEFAULTS_SECTION);
        bool sound = config->readBoolEntry(DEF_SOUND, false);
        if(!sound)
            config->writeEntry(DEF_SOUND_TYPE, SoundPicker::NONE);
        config->deleteEntry(DEF_SOUND);
    }

    if(version < KAlarm::Version(1, 3, 0))
    {
        // Convert KAlarm pre-1.3 preferences
        static const QString EMAIL_ADDRESS             = QString::fromLatin1("EmailAddress");
        static const QString EMAIL_USE_CTRL_CENTRE     = QString::fromLatin1("EmailUseControlCenter");
        static const QString EMAIL_BCC_USE_CTRL_CENTRE = QString::fromLatin1("EmailBccUseControlCenter");
        QMap<QString, QString> entries = config->entryMap(GENERAL_SECTION);
        if(entries.find(EMAIL_FROM) == entries.end()
                &&  entries.find(EMAIL_USE_CTRL_CENTRE) != entries.end())
        {
            // Preferences were written by KAlarm pre-1.2.1
            config->setGroup(GENERAL_SECTION);
            bool useCC = false;
            bool bccUseCC = false;
            const bool default_emailUseControlCentre    = true;
            const bool default_emailBccUseControlCentre = true;
            useCC = config->readBoolEntry(EMAIL_USE_CTRL_CENTRE, default_emailUseControlCentre);
            // EmailBccUseControlCenter was missing in preferences written by KAlarm pre-0.9.5
            bccUseCC = config->hasKey(EMAIL_BCC_USE_CTRL_CENTRE)
                       ? config->readBoolEntry(EMAIL_BCC_USE_CTRL_CENTRE, default_emailBccUseControlCentre)
                       : useCC;
            config->writeEntry(EMAIL_FROM, (useCC ? FROM_CONTROL_CENTRE : config->readEntry(EMAIL_ADDRESS)));
            config->writeEntry(EMAIL_BCC_ADDRESS, (bccUseCC ? FROM_CONTROL_CENTRE : config->readEntry(EMAIL_BCC_ADDRESS)));
            config->deleteEntry(EMAIL_ADDRESS);
            config->deleteEntry(EMAIL_BCC_USE_CTRL_CENTRE);
            config->deleteEntry(EMAIL_USE_CTRL_CENTRE);
        }
        // Convert KAlarm 1.2 preferences
        static const QString DEF_CMD_XTERM = QString::fromLatin1("DefCmdXterm");
        config->setGroup(DEFAULTS_SECTION);
        if(config->hasKey(DEF_CMD_XTERM))
        {
            config->writeEntry(DEF_CMD_LOG_TYPE,
                               (config->readBoolEntry(DEF_CMD_XTERM, false) ? EditAlarmDlg::EXEC_IN_TERMINAL : EditAlarmDlg::DISCARD_OUTPUT));
            config->deleteEntry(DEF_CMD_XTERM);
        }
    }
    config->setGroup(GENERAL_SECTION);
    config->writeEntry(VERSION_NUM, KALARM_VERSION);
    config->sync();
}
开发者ID:serghei,项目名称:kde3-kdepim,代码行数:98,代码来源:preferences.cpp

示例11: dir

Kfm::Kfm()
{
    pKfm = this;
    pHistory = new QStrList;
    
    kapp->setTopWidget( this );

    HTMLCache::load();
    
    pIconLoader = new KIconLoader();

    // We need this in KfmGui::KfmGui(), so moved it here. DF.
    QStrList* list = pIconLoader->getDirList();
    list->clear();
    QString tmp = kapp->kde_icondir().copy();
    list->append( tmp.data() );
    tmp = KApplication::localkdedir();
    tmp += "/share/icons";
    list->append( tmp.data() );

    KConfig *config = kapp->getConfig();
    QStrList dirList;
    config->setGroup("KDE Setup");
    config->readListEntry( "IconPath", dirList, ':' );

    for (const char *it=dirList.first(); it; it = dirList.next()) {
      QDir dir( it );

      if (dir.exists())
        list->append( it );
    }

    if ( KfmGui::rooticons )
    {
	kapp->enableSessionManagement( TRUE );
	kapp->setWmCommand( "" );
	
	connect( kapp, SIGNAL( saveYourself() ), this, SLOT( slotSave() ) );
	connect( kapp, SIGNAL( shutDown() ), this, SLOT( slotShutDown() ) );

        // Global configuration
	config->setGroup("KFM Misc Defaults");
        bAllowURLProps = config->readBoolEntry( "EnablePerURLProps", false );
        bTreeViewFollowMode = config->readBoolEntry( "TreeFollowsView", false);

	config->setGroup( "SM" );
	bool flag = config->hasKey( "URLs" );
	
	QStrList urlList;
	int n = config->readListEntry( "URLs", urlList );

	if ( !flag && KfmGui::rooticons == true )
	{
	    QString home = "file:";
	    home.detach();
	    home += QDir::homeDirPath().data();
	    KfmGui *m = new KfmGui( 0L, 0L, home.data() );
	    m->show();
	}

	if ( flag )
	{
	    int i;
	    for ( i = 1; i <= n; i++ )
	    {
		KfmGui *m = new KfmGui( 0L, 0L, urlList.at( i - 1 ) );
		m->readProperties(i);
		m->show();
	    }
	}
    }

    // Install HTTP Cookies
    {
        KConfig *config = kapp->getConfig();
        config->setGroup( "Browser Settings/HTTP" );
        
        bool cookiesEnabled = config->readBoolEntry( "Cookies", true );
        if ( cookiesEnabled)
        {
            cookiejar = new KCookieJar();
                            
            cookiejar->loadConfig( config );
                                    
            QString cookieFile = kapp->localkdedir().data();
            cookieFile += "/share/apps/kfm/cookies";
            cookiejar->loadCookies( cookieFile.data() );
        }
    }

    connect( &timer, SIGNAL( timeout() ), this, SLOT( slotTouch() ) );
    // Call every hour
    timer.start( 3600000 );
}
开发者ID:kthxbyte,项目名称:KDE1-Linaro,代码行数:94,代码来源:kfmw.cpp

示例12: config


//.........这里部分代码省略.........
    rightside->addStretch();

    // single checkbox
    visEnable = new QCheckBox(i18n("Visualize progress in icon tray"), page);
    top_box->addWidget(visEnable, 0, 0);


    // let listbox claim all remaining vertical space
    top_box->setStretchFactor(box, 10);

    connect(confdlg, SIGNAL(helpClicked()), SLOT(help()));
  }

  // now add all defined teas (and their times) to the listview
  // this is done backwards because QListViewItems are inserted at the top
  listbox->clear();
  for (int i=teas.count()-1; i>=0; i--) {
    TeaListItem *item = new TeaListItem(listbox);
    item->setName(teas[i].name);
    item->setTime(teas[i].time);
    if ((unsigned int)i == current_selected)
      current_item = item;
  }

  // select first entry in listbox; if no entries present then disable right side
  if (listempty) {
    enable_controls();
    disable_properties();
    nameEdit->setText("");
    timeEdit->setValue(1);
  } else {
    listbox->setSelected(listbox->firstChild(), true);
  }

  // -------------------------

  eventEnable->setChecked(useNotify);
  popupEnable->setChecked(usePopup);
  actionEnable->setChecked(useAction);
  actionEdit->setText(action);
  actionEdit->setEnabled(useAction);
  visEnable->setChecked(useTrayVis);

  if (confdlg->exec() == QDialog::Accepted)
  {
    // activate new settings
    useNotify = eventEnable->isChecked();
    usePopup = popupEnable->isChecked();
    useAction = actionEnable->isChecked();
    action = actionEdit->text();
    useTrayVis = visEnable->isChecked();

    teas.clear();

    // Copy over teas and times from the QListView
    int i = 0;
    teas.clear();
    teas.resize(listbox->childCount());
    for (QListViewItemIterator it(listbox); it.current() != 0; ++it) {
      teas[i].name = static_cast<TeaListItem *>(it.current())->name();
      teas[i].time = static_cast<TeaListItem *>(it.current())->time();
      if (it.current() == current_item)
        current_selected = i;
      i++;
    }

    listempty = (teas.count() == 0);

    rebuildTeaMenus();

    // and store to config
    KConfig *config = kapp->config();
    // remove old-style entries from default-group (if present)
    if (config->hasKey("UserTea"))
      config->deleteEntry("UserTea");

    config->setGroup("General");
    config->writeEntry("Beep", useNotify);
    config->writeEntry("Popup", usePopup);
    config->writeEntry("UseAction", useAction);
    config->writeEntry("Action", action);
    config->writeEntry("Tea", current_selected);
    config->writeEntry("UseTrayVis", useTrayVis);
    // first get rid of all previous tea-entries from config, then write anew
    config->deleteGroup("Teas", true);          // deep remove of whole group
    config->setGroup("Teas");
    config->writeEntry("Number", teas.count());
    QString key;
    int index = 1;
    for (QValueVector<tea_struct>::ConstIterator it = teas.begin(); it != teas.end(); ++it) {
      key.sprintf("Tea%d Name", index);
      config->writeEntry(key, it->name);
      key.sprintf("Tea%d Time", index);
      config->writeEntry(key, it->time);
      index++;
    }

    config->sync();
  }
}
开发者ID:,项目名称:,代码行数:101,代码来源:

示例13: KSystemTray

TopLevel::TopLevel() : KSystemTray()
{
	setBackgroundMode(X11ParentRelative);   // what for?
	QString n, key;
	unsigned int num;

	teas.clear();

	KConfig *config = kapp->config();
	config->setGroup("Teas");

	if (config->hasKey("Number")) {
		// assuming this is a new-style config
		num = config->readNumEntry("Number", 0);
		teas.resize(num);
		QString tempstr;
		for (unsigned int index=1; index<=num; ++index) {
			key.sprintf("Tea%d Time", index);
			tempstr = config->readEntry(key, NULL);
			teas[index-1].time = tempstr.toInt();
  			key.sprintf("Tea%d Name", index);
			teas[index-1].name = config->readEntry(key, NULL);
			// FIXME: check for non-existence!
  		}
		config->setGroup("General");
	} else {
		// either old-style config or first start, so provide some sensible defaults
		// (which are the same as in old-style kteatime)
		tea_struct temp;
		temp.name = i18n("Black Tea");
		temp.time = 180;
		teas.append(temp);
		temp.name = i18n("Earl Grey");
		temp.time = 300;
		teas.append(temp);
		temp.name = i18n("Fruit Tea");
		temp.time = 480;
		teas.append(temp);

		// switch back to old-style default group
		config->setGroup(NULL);
		// look for old-style "UserTea"-entry and add that one also
		if (config->hasKey("UserTea")) {
			num = config->readNumEntry("UserTea", 150);
			temp.name = i18n("Other Tea");
			temp.time = num;
			teas.append(temp);
		}
	}
	current_selected = config->readNumEntry("Tea", 0);
	if (current_selected >= teas.count())
		current_selected = 0;

	listempty = (teas.count() == 0);


	startAct = new KAction(i18n("&Start"), "1rightarrow", 0,
	                       this, SLOT(start()), actionCollection(), "start");
	stopAct = new KAction(i18n("Sto&p"), "cancel", 0,
	                      this, SLOT(stop()), actionCollection(), "stop");
	confAct = new KAction(i18n("&Configure..."), "configure", 0,
	                      this, SLOT(config()), actionCollection(), "configure");
	anonAct = new KAction(i18n("&Anonymous..."), 0, 0,
	                      this, SLOT(anonymous()), actionCollection(), "anonymous");
//	KAction *quitAct = actionCollection()->action("file_quit");

	// create app menu (displayed on right-click)
	menu = new QPopupMenu();
	menu->setCheckable(true);
	connect(menu, SIGNAL(activated(int)), this, SLOT(teaSelected(int)));

	// this menu will be displayed when no tea is steeping, and left mouse button is clicked
	start_menu = new QPopupMenu();
	start_menu->setCheckable(true);     // menu isn't tickable, but this gives some add. spacing
	connect(start_menu, SIGNAL(activated(int)), this, SLOT(teaStartSelected(int)));

	rebuildTeaMenus();      // populate tops of menus with tea-entries from config

	KHelpMenu* help = new KHelpMenu(this, KGlobal::instance()->aboutData(), false);
	KPopupMenu* helpMnu = help->menu();

	start_menu->insertSeparator();
	anonAct->plug(start_menu);

	menu->insertSeparator();
	anonAct->plug(menu);
	startAct->plug(menu);
	stopAct->plug(menu);
	menu->insertSeparator();
	confAct->plug(menu);
	menu->insertItem(SmallIcon("help"), i18n("&Help"), helpMnu);
	menu->insertItem(SmallIcon("exit"), i18n("Quit"), kapp, SLOT(quit()));
//	quitAct->plug(menu);    // FIXME: this doesn't seem to work with above definition of quitAct?
	                        //        (need special 'quit'-method?)

	// this menu will be displayed when a tea is steeping, and left mouse button is clicked
	steeping_menu = new QPopupMenu();
//	steeping_menu->insertItem(SmallIcon("cancel"), i18n("Just &Cancel Current"), this, SLOT(stop()));
	stopAct->plug(steeping_menu);   // FIXME: can provide different text for this incarnation?

//.........这里部分代码省略.........
开发者ID:,项目名称:,代码行数:101,代码来源:


注:本文中的KConfig::hasKey方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。