本文整理汇总了C++中KConfig::setGroup方法的典型用法代码示例。如果您正苦于以下问题:C++ KConfig::setGroup方法的具体用法?C++ KConfig::setGroup怎么用?C++ KConfig::setGroup使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类KConfig
的用法示例。
在下文中一共展示了KConfig::setGroup方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: KTMainWindow
mainWidget::mainWidget(const char *name) : KTMainWindow(name) {
md = new mainDlg(this);
md->init();
QPopupMenu *file = new QPopupMenu;
CHECK_PTR( file );
file->insertItem(i18n("&Save"), md, SLOT(save()) );
file->insertSeparator();
file->insertItem(i18n("&Preferences..."), md, SLOT(properties()) );
file->insertSeparator();
file->insertItem(i18n("&Quit"), md, SLOT(quit()) );
QPopupMenu *user = new QPopupMenu;
CHECK_PTR(user);
user->insertItem(i18n("&Edit..."), md, SLOT(useredit()) );
user->insertItem(i18n("&Delete..."), md, SLOT(userdel()) );
user->insertItem(i18n("&Add..."), md, SLOT(useradd()) );
user->insertItem(i18n("&Set password..."), md, SLOT(setpwd()) );
QPopupMenu *group = new QPopupMenu;
CHECK_PTR(group);
group->insertItem(i18n("&Edit..."), md, SLOT(grpedit()) );
group->insertItem(i18n("&Delete..."), md, SLOT(grpdel()) );
group->insertItem(i18n("&Add..."), md, SLOT(grpadd()) );
QString tmp;
tmp.sprintf(i18n("KUser version %s\n"
"KDE project\n"
"This program was created by\n"
"Denis Pershin\n"
"[email protected]\n"
"Copyright 1997(c)"), _KU_VERSION);
QPopupMenu *help = kapp->getHelpMenu(true, tmp);
menubar = new KMenuBar( this );
CHECK_PTR( menubar );
menubar->insertItem(i18n("&File"), file );
menubar->insertItem(i18n("&User"), user );
menubar->insertItem(i18n("&Group"), group );
menubar->insertSeparator();
menubar->insertItem(i18n("&Help"), help );
setMenu(menubar);
toolbar = new KToolBar(this, "toolbar");
QPixmap pix;
pix = kapp->getIconLoader()->loadIcon("useradd.xpm");
toolbar->insertButton(pix, 0, SIGNAL(clicked()), md, SLOT(useradd()), TRUE, i18n("Add user"));
pix = kapp->getIconLoader()->loadIcon("userdel.xpm");
toolbar->insertButton(pix, 0, SIGNAL(clicked()), md, SLOT(userdel()), TRUE, i18n("Delete user"));
pix = kapp->getIconLoader()->loadIcon("useredit.xpm");
toolbar->insertButton(pix, 0, SIGNAL(clicked()), md, SLOT(useredit()), TRUE, i18n("Edit user"));
toolbar->insertSeparator();
pix = kapp->getIconLoader()->loadIcon("grpadd.xpm");
toolbar->insertButton(pix, 0, SIGNAL(clicked()), md, SLOT(grpadd()), TRUE, i18n("Add group"));
pix = kapp->getIconLoader()->loadIcon("grpdel.xpm");
toolbar->insertButton(pix, 0, SIGNAL(clicked()), md, SLOT(grpdel()), TRUE, i18n("Delete group"));
pix = kapp->getIconLoader()->loadIcon("grpedit.xpm");
toolbar->insertButton(pix, 0, SIGNAL(clicked()), md, SLOT(grpedit()), TRUE, i18n("Edit group"));
toolbar->setBarPos(KToolBar::Top);
addToolBar(toolbar);
sbar = new KStatusBar(this);
sbar->insertItem("Reading config", 0);
setStatusBar(sbar);
setView(md);
resize(500, 400);
// restore geometry settings
KConfig *config = KApplication::getKApplication()->getConfig();
config->setGroup( "Appearance" );
QString geom = config->readEntry( "Geometry" );
if (!geom.isEmpty()) {
int width, height;
sscanf( geom, "%dx%d", &width, &height );
resize( width, height );
}
sbar->changeItem(i18n("Ready"), 0);
}
示例2: setName
MrmlPart::MrmlPart( QWidget *parentWidget, const char * /* widgetName */,
QObject *parent, const char *name,
const QStringList& /* args */ )
: KParts::ReadOnlyPart( parent, name ),
m_job( 0L ),
m_status( NeedCollection )
{
m_sessionId = QString::number( s_sessionId++ ).prepend("kmrml_");
setName( "MRML Part" );
m_browser = new Browser( this, "mrml browserextension");
setInstance( PartFactory::instance(), true ); // do load plugins :)
KConfig *config = PartFactory::instance()->config();
config->setGroup("MRML Settings");
QVBox *box = new QVBox( parentWidget, "main mrml box" );
m_view = new MrmlView( box, "MrmlView" );
connect( m_view, SIGNAL( activated( const KURL&, ButtonState )),
this, SLOT( slotActivated( const KURL&, ButtonState )));
connect( m_view, SIGNAL( onItem( const KURL& )),
this, SLOT( slotSetStatusBar( const KURL& )));
m_panel = new QHGroupBox( box, "buttons box" );
QGrid *comboGrid = new QGrid( 2, m_panel, "combo grid" );
comboGrid->setSpacing( KDialog::spacingHint() );
(void) new QLabel( i18n("Server to query:"), comboGrid );
m_hostCombo = new KComboBox( false, comboGrid, "host combo" );
initHostCombo();
connect( m_hostCombo, SIGNAL( activated( const QString& ) ),
SLOT( slotHostComboActivated( const QString& )));
(void) new QLabel( i18n("Search in collection:"), comboGrid );
m_collectionCombo = new CollectionCombo( comboGrid, "collection-combo" );
// will be re-set in initCollections(), but we need to set it here to
// prevent crashes when the connection to the server fails
m_collectionCombo->setCollections( &m_collections );
m_algoButton = new QPushButton( QString::null, m_panel );
m_algoButton->setPixmap( SmallIcon("configure") );
m_algoButton->setFixedSize( m_algoButton->sizeHint() );
connect( m_algoButton, SIGNAL( clicked() ),
SLOT( slotConfigureAlgorithm() ));
QToolTip::add( m_algoButton, i18n("Configure algorithm") );
QWidget *spacer = new QWidget( m_panel );
spacer->setSizePolicy( QSizePolicy( QSizePolicy::MinimumExpanding,
QSizePolicy::Minimum ) );
int resultSize = config->readNumEntry( "Result-size", 20 );
m_resultSizeInput = new KIntNumInput( resultSize, m_panel );
m_resultSizeInput->setRange( 1, 100 );
m_resultSizeInput->setLabel( i18n("Maximum result images:") );
QVBox *tmp = new QVBox( m_panel );
m_random = new QCheckBox( i18n("Random search"), tmp );
m_startButton = new QPushButton( QString::null, tmp );
connect( m_startButton, SIGNAL( clicked() ), SLOT( slotStartClicked() ));
setStatus( NeedCollection );
setWidget( box );
// setXMLFile( "mrml_part.rc" );
slotSetStatusBar( QString::null );
enableServerDependentWidgets( false );
}
示例3: loadStyle
void KCMStyle::loadStyle( KConfig& config )
{
cbStyle->clear();
// Create a dictionary of WidgetStyle to Name and Desc. mappings,
// as well as the config page info
styleEntries.clear();
styleEntries.setAutoDelete(true);
QString strWidgetStyle;
QStringList list = KGlobal::dirs()->findAllResources("themes", "*.themerc", true, true);
for (QStringList::iterator it = list.begin(); it != list.end(); ++it)
{
KSimpleConfig config( *it, true );
if ( !(config.hasGroup("KDE") && config.hasGroup("Misc")) )
continue;
config.setGroup("KDE");
strWidgetStyle = config.readEntry("WidgetStyle");
if (strWidgetStyle.isNull())
continue;
// We have a widgetstyle, so lets read the i18n entries for it...
StyleEntry* entry = new StyleEntry;
config.setGroup("Misc");
entry->name = config.readEntry("Name");
entry->desc = config.readEntry("Comment", i18n("No description available."));
entry->configPage = config.readEntry("ConfigPage", QString::null);
// Check if this style should be shown
config.setGroup("Desktop Entry");
entry->hidden = config.readBoolEntry("Hidden", false);
// Insert the entry into our dictionary.
styleEntries.insert(strWidgetStyle.lower(), entry);
}
// Obtain all style names
QStringList allStyles = QStyleFactory::keys();
// Get translated names, remove all hidden style entries.
QStringList styles;
StyleEntry* entry;
for (QStringList::iterator it = allStyles.begin(); it != allStyles.end(); it++)
{
QString id = (*it).lower();
// Find the entry.
if ( (entry = styleEntries.find(id)) != 0 )
{
// Do not add hidden entries
if (entry->hidden)
continue;
styles += entry->name;
nameToStyleKey[entry->name] = id;
}
else
{
styles += (*it); //Fall back to the key (but in original case)
nameToStyleKey[*it] = id;
}
}
// Sort the style list, and add it to the combobox
styles.sort();
cbStyle->insertStringList( styles );
// Find out which style is currently being used
config.setGroup( "General" );
QString defaultStyle = KStyle::defaultStyle();
QString cfgStyle = config.readEntry( "widgetStyle", defaultStyle );
// Select the current style
// Do not use cbStyle->listBox() as this may be NULL for some styles when
// they use QPopupMenus for the drop-down list!
// ##### Since Trolltech likes to seemingly copy & paste code,
// QStringList::findItem() doesn't have a Qt::StringComparisonMode field.
// We roll our own (yuck)
cfgStyle = cfgStyle.lower();
int item = 0;
for( int i = 0; i < cbStyle->count(); i++ )
{
QString id = nameToStyleKey[cbStyle->text(i)];
item = i;
if ( id == cfgStyle ) // ExactMatch
break;
else if ( id.contains( cfgStyle ) )
break;
else if ( id.contains( QApplication::style().className() ) )
break;
item = 0;
}
cbStyle->setCurrentItem( item );
m_bStyleDirty = false;
switchStyle( currentStyle() ); // make resets visible
//.........这里部分代码省略.........
示例4: loadEffects
void KCMStyle::loadEffects( KConfig& config )
{
// Load effects.
config.setGroup("KDE");
cbEnableEffects->setChecked( config.readBoolEntry( "EffectsEnabled", false) );
if ( config.readBoolEntry( "EffectAnimateCombo", false) )
comboComboEffect->setCurrentItem( 1 );
else
comboComboEffect->setCurrentItem( 0 );
if ( config.readBoolEntry( "EffectAnimateTooltip", false) )
comboTooltipEffect->setCurrentItem( 1 );
else if ( config.readBoolEntry( "EffectFadeTooltip", false) )
comboTooltipEffect->setCurrentItem( 2 );
else
comboTooltipEffect->setCurrentItem( 0 );
if ( config.readBoolEntry( "EffectAnimateMenu", false) )
comboMenuEffect->setCurrentItem( 1 );
else if ( config.readBoolEntry( "EffectFadeMenu", false) )
comboMenuEffect->setCurrentItem( 2 );
else
comboMenuEffect->setCurrentItem( 0 );
comboMenuHandle->setCurrentItem(config.readNumEntry("InsertTearOffHandle", 0));
// KStyle Menu transparency and drop-shadow options...
QSettings settings;
QString effectEngine = settings.readEntry("/KStyle/Settings/MenuTransparencyEngine", "Disabled");
#ifdef HAVE_XRENDER
if (effectEngine == "XRender") {
comboMenuEffectType->setCurrentItem(2);
comboMenuEffect->setCurrentItem(3);
} else if (effectEngine == "SoftwareBlend") {
comboMenuEffectType->setCurrentItem(1);
comboMenuEffect->setCurrentItem(3);
#else
if (effectEngine == "XRender" || effectEngine == "SoftwareBlend") {
comboMenuEffectType->setCurrentItem(1); // Software Blend
comboMenuEffect->setCurrentItem(3);
#endif
} else if (effectEngine == "SoftwareTint") {
comboMenuEffectType->setCurrentItem(0);
comboMenuEffect->setCurrentItem(3);
} else
comboMenuEffectType->setCurrentItem(0);
if (comboMenuEffect->currentItem() != 3) // If not translucency...
menuPreview->setPreviewMode( MenuPreview::Tint );
else if (comboMenuEffectType->currentItem() == 0)
menuPreview->setPreviewMode( MenuPreview::Tint );
else
menuPreview->setPreviewMode( MenuPreview::Blend );
slOpacity->setValue( (int)(100 * settings.readDoubleEntry("/KStyle/Settings/MenuOpacity", 0.90)) );
// Menu Drop-shadows...
cbMenuShadow->setChecked( settings.readBoolEntry("/KStyle/Settings/MenuDropShadow", false) );
if (cbEnableEffects->isChecked()) {
containerFrame->setEnabled( true );
menuContainer->setEnabled( comboMenuEffect->currentItem() == 3 );
} else {
menuContainer->setEnabled( false );
containerFrame->setEnabled( false );
}
m_bEffectsDirty = false;
}
void KCMStyle::menuEffectTypeChanged()
{
MenuPreview::PreviewMode mode;
if (comboMenuEffect->currentItem() != 3)
mode = MenuPreview::Tint;
else if (comboMenuEffectType->currentItem() == 0)
mode = MenuPreview::Tint;
else
mode = MenuPreview::Blend;
menuPreview->setPreviewMode(mode);
m_bEffectsDirty = true;
}
示例5: if
DeviceSettings::DeviceSettings( QWidget *parent, QString dev, bool wifi )
: DeviceSettingsDlg( parent ),
_dev( dev ),
_wifi( wifi )
{
// ip validator
rx = new QRegExp( "\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}" );
validator = new QRegExpValidator( *rx, this );
ipaddr->setValidator( validator );
defaultgw->setValidator( validator );
broadcast->setValidator( validator );
netmask->setValidator( validator );
// if ipaddr is changed we should recalculate broadcast and netmask
// for now we just clear it.
connect( ipaddr, SIGNAL( textChanged( const QString& ) ),
this, SLOT( slotIPChanged() ) );
// fill automatic types, for now only DHCP is supported
automaticCombo->insertItem( "DHCP" );
// fill dnsListBox
dnsListBox->clear();
QStringList dnsList = getDnsList();
QStringList::ConstIterator end = dnsList.end();
for ( QStringList::ConstIterator it = dnsList.begin();
it != end; ++it ) {
dnsListBox->insertItem( *it );
}
connect( addDnsButton, SIGNAL( clicked() ),
this, SLOT( addDns() ) );
connect( removeDnsButton, SIGNAL( clicked() ),
this, SLOT( removeDns() ) );
// get device information from kernel.
struct sockaddr_in *sin;
struct ifreq ifr;
int skfd = sockets_open();
strcpy( ifr.ifr_name, _dev.ascii() );
// IP
ioctl( skfd, SIOCGIFADDR, &ifr );
sin = (struct sockaddr_in *)&ifr.ifr_addr;
ipaddr->setText( inet_ntoa( sin->sin_addr ) );
// Broadcast
ioctl( skfd, SIOCGIFBRDADDR, &ifr );
sin = (struct sockaddr_in *)&ifr.ifr_addr;
broadcast->setText( inet_ntoa( sin->sin_addr ) );
// Netmask
ioctl( skfd, SIOCGIFNETMASK, &ifr );
sin = (struct sockaddr_in *)&ifr.ifr_addr;
netmask->setText( inet_ntoa( sin->sin_addr ) );
connect( automaticButton, SIGNAL( toggled( bool ) ),
this, SLOT( automaticToggled( bool ) ) );
connect( manualButton, SIGNAL( toggled( bool ) ),
this, SLOT( manualToggled( bool ) ) );
connect( applyButton, SIGNAL( clicked() ),
this, SLOT( slotApply() ) );
connect( cancelButton, SIGNAL( clicked() ),
this, SLOT( slotCancel() ) );
KConfig *config = new KConfig( "tasmanetrc" );
config->setGroup( _dev );
QString _connType = config->readEntry( "ConnectionType", "Automatic" );
defaultgw->setText( config->readEntry( "DefaultGateway", "" ) );
if ( _connType == "Automatic" ) {
automaticButton->setChecked( true );
}
else if ( _connType == "Manual" ) {
manualButton->setChecked( true );
}
delete config;
}