kdialogbase.cpp
/*
* This file is part of the KDE Libraries
* Copyright (C) 1999-2001 Mirko Boehm (mirko@kde.org) and
* Espen Sand (espen@kde.org)
* Holger Freyther <freyther@kde.org>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public License
* along with this library; see the file COPYING.LIB. If not, write to
* the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301, USA.
*
*/
#include "kdialogbase.h"
#include <stdlib.h>
#include <qgrid.h>
#include <qhbox.h>
#include <qlayout.h>
#include <qtooltip.h>
#include <qvbox.h>
#include <qwhatsthis.h>
#include <qtimer.h>
#include <qfocusdata.h>
#include <kapplication.h>
#include <klocale.h>
#include <kconfig.h>
#include <kiconloader.h>
#include <kglobal.h>
#include <kglobalsettings.h>
#include <kseparator.h>
#include <kurllabel.h>
#include <kdebug.h>
#include "kdialogbase_priv.h"
#include "kdialogbase_priv.moc"
KDialogBaseTile *KDialogBase::mTile = 0;
int KDialogBaseButton::id()
{
return mKey;
}
template class QPtrList<KDialogBaseButton>;
namespace
{
struct SButton : public Qt
{
SButton()
{
box = 0;
mask = 0;
style = 0;
}
KPushButton *append( int key, const KGuiItem &item );
void resize( bool sameWidth, int margin, int spacing, int orientation );
KPushButton *button( int key );
QWidget *box;
int mask;
int style;
QPtrList<KDialogBaseButton> list;
};
}// namespace
class KDialogBase::KDialogBasePrivate {
public:
KDialogBasePrivate() : bDetails(false), bFixed(false), bSettingDetails(false), detailsWidget(0) { }
bool bDetails;
bool bFixed;
bool bSettingDetails;
QWidget *detailsWidget;
QSize incSize;
QSize minSize;
QString detailsButton;
SButton mButton;
};
KDialogBase::KDialogBase( QWidget *parent, const char *name, bool modal,
const QString &caption, int buttonMask,
ButtonCode defaultButton, bool separator,
const KGuiItem &user1, const KGuiItem &user2,
const KGuiItem &user3 )
:KDialog( parent, name, modal, WStyle_DialogBorder ),
mTopLayout(0), mMainWidget(0), mUrlHelp(0), mJanus(0), mActionSep(0),
mIsActivated(false), mShowTile(false), mMessageBoxMode(false),
mButtonOrientation(Horizontal), d(new KDialogBasePrivate)
{
setCaption( caption );
makeRelay();
connect( this, SIGNAL(layoutHintChanged()), SLOT(updateGeometry()) );
enableButtonSeparator( separator );
makeButtonBox( buttonMask, defaultButton, user1, user2, user3 );
mIsActivated = true;
setupLayout();
}
KDialogBase::KDialogBase( int dialogFace, const QString &caption,
int buttonMask, ButtonCode defaultButton,
QWidget *parent, const char *name, bool modal,
bool separator, const KGuiItem &user1,
const KGuiItem &user2, const KGuiItem &user3 )
:KDialog( parent, name, modal, WStyle_DialogBorder ),
mTopLayout(0), mMainWidget(0), mUrlHelp(0), mJanus(0), mActionSep(0),
mIsActivated(false), mShowTile(false), mMessageBoxMode(false),
mButtonOrientation(Horizontal), d(new KDialogBasePrivate)
{
setCaption( caption );
makeRelay();
connect( this, SIGNAL(layoutHintChanged()), SLOT(updateGeometry()) );
mJanus = new KJanusWidget( this, "janus", dialogFace );
connect(mJanus, SIGNAL(aboutToShowPage(QWidget *)),
this, SIGNAL(aboutToShowPage(QWidget *)));
if( !mJanus || !mJanus->isValid() ) { return; }
enableButtonSeparator( separator );
makeButtonBox( buttonMask, defaultButton, user1, user2, user3 );
mIsActivated = true;
setupLayout();
}
KDialogBase::KDialogBase( KDialogBase::DialogType dialogFace, WFlags f, QWidget *parent, const char *name,
bool modal,
const QString &caption, int buttonMask,
ButtonCode defaultButton, bool separator,
const KGuiItem &user1, const KGuiItem &user2,
const KGuiItem &user3 )
:KDialog( parent, name, modal, f ),
mTopLayout(0), mMainWidget(0), mUrlHelp(0), mJanus(0), mActionSep(0),
mIsActivated(false), mShowTile(false), mMessageBoxMode(false),
mButtonOrientation(Horizontal), d(new KDialogBasePrivate)
{
setCaption( caption );
makeRelay();
connect( this, SIGNAL(layoutHintChanged()), SLOT(updateGeometry()) );
mJanus = new KJanusWidget( this, "janus", dialogFace );
connect(mJanus, SIGNAL(aboutToShowPage(QWidget *)),
this, SIGNAL(aboutToShowPage(QWidget *)));
if( !mJanus || !mJanus->isValid() ) { return; }
enableButtonSeparator( separator );
makeButtonBox( buttonMask, defaultButton, user1, user2, user3 );
mIsActivated = true;
setupLayout();
}
KDialogBase::KDialogBase( const QString &caption, int buttonMask,
ButtonCode defaultButton, ButtonCode escapeButton,
QWidget *parent, const char *name, bool modal,
bool separator, const KGuiItem &yes,
const KGuiItem &no, const KGuiItem &cancel )
:KDialog( parent, name, modal, WStyle_DialogBorder ),
mTopLayout(0), mMainWidget(0), mUrlHelp(0), mJanus(0), mActionSep(0),
mIsActivated(false), mShowTile(false), mMessageBoxMode(true),
mButtonOrientation(Horizontal),mEscapeButton(escapeButton),
d(new KDialogBasePrivate)
{
setCaption( caption );
makeRelay();
connect( this, SIGNAL(layoutHintChanged()), SLOT(updateGeometry()) );
enableButtonSeparator( separator );
buttonMask &= Details|Yes|No|Cancel;
makeButtonBox( buttonMask, defaultButton,
no.text().isEmpty() ? KStdGuiItem::no() : no,
yes.text().isEmpty() ? KStdGuiItem::yes() : yes );
setButtonCancel( cancel.text().isEmpty() ?
KStdGuiItem::cancel() : cancel );
mIsActivated = true;
setupLayout();
}
KDialogBase::~KDialogBase()
{
delete d;
}
KPushButton *SButton::append( int key, const KGuiItem &item )
{
KDialogBaseButton *p = new KDialogBaseButton( item, key, box );
list.append( p );
return p;
}
void SButton::resize( bool sameWidth, int margin,
int spacing, int orientation )
{
KDialogBaseButton *p;
int h = 0;
int w = 0;
int t = 0;
for( p = list.first(); p; p = list.next() )
{
const QSize s( p->sizeHint() );
if( s.height() > h ) { h = s.height(); }
if( s.width() > w ) { w = s.width(); }
}
if( orientation == Horizontal )
{
for( p = list.first(); p; p = list.next() )
{
QSize s( p->sizeHint() );
if( sameWidth ) { s.setWidth( w ); }
p->setFixedWidth( s.width() );
t += s.width() + spacing;
}
box->setMinimumHeight( margin*2 + h );
box->setMinimumWidth( margin*2 + t - spacing );
}
else
{
// sameWidth has no effect here
for( p = list.first(); p; p = list.next() )
{
QSize s( p->sizeHint() );
s.setWidth( w );
p->setFixedSize( s );
t += s.height() + spacing;
}
box->setMinimumHeight( margin*2 + t - spacing );
box->setMinimumWidth( margin*2 + w );
}
}
KPushButton *SButton::button( int key )
{
KDialogBaseButton *p;
for( p = list.first(); p; p = list.next() )
{
if( p->id() == key )
{
return p;
}
}
return 0;
}
void
KDialogBase::delayedDestruct()
{
if (isVisible())
hide();
QTimer::singleShot( 0, this, SLOT(slotDelayedDestruct()));
}
void
KDialogBase::slotDelayedDestruct()
{
delete this;
}
void KDialogBase::setupLayout()
{
if( mTopLayout )
{
delete mTopLayout;
}
// mTopLayout = new QVBoxLayout( this, marginHint(), spacingHint() );
if( mButtonOrientation == Horizontal )
{
mTopLayout = new QBoxLayout( this, QBoxLayout::TopToBottom,
marginHint(), spacingHint() );
}
else
{
mTopLayout = new QBoxLayout( this, QBoxLayout::LeftToRight,
marginHint(), spacingHint() );
}
if( mUrlHelp )
{
mTopLayout->addWidget( mUrlHelp, 0, AlignRight );
}
if( mJanus )
{
mTopLayout->addWidget( mJanus, 10 );
}
else if( mMainWidget )
{
mTopLayout->addWidget( mMainWidget, 10 );
}
if ( d->detailsWidget )
{
mTopLayout->addWidget( d->detailsWidget );
}
if( mActionSep )
{
mTopLayout->addWidget( mActionSep );
}
if( d->mButton.box )
{
mTopLayout->addWidget( d->mButton.box );
}
}
void KDialogBase::setButtonBoxOrientation( int orientation )
{
if( mButtonOrientation != orientation )
{
mButtonOrientation = orientation;
if( mActionSep )
{
mActionSep->setOrientation( mButtonOrientation == Horizontal ?
QFrame::HLine : QFrame::VLine );
}
if( mButtonOrientation == Vertical )
{
enableLinkedHelp(false); // 2000-06-18 Espen: No support for this yet.
}
setupLayout();
setButtonStyle( d->mButton.style );
}
}
void KDialogBase::setEscapeButton( ButtonCode id )
{
mEscapeButton = id;
}
void KDialogBase::makeRelay()
{
if( mTile )
{
connect( mTile, SIGNAL(pixmapChanged()), SLOT(updateBackground()) );
return;
}
mTile = new KDialogBaseTile;
if( mTile )
{
connect( mTile, SIGNAL(pixmapChanged()), SLOT(updateBackground()) );
connect( qApp, SIGNAL(aboutToQuit()), mTile, SLOT(cleanup()) );
}
}
void KDialogBase::enableButtonSeparator( bool state )
{
if( state )
{
if( mActionSep )
{
return;
}
mActionSep = new KSeparator( this );
mActionSep->setFocusPolicy(QWidget::NoFocus);
mActionSep->setOrientation( mButtonOrientation == Horizontal ?
QFrame::HLine : QFrame::VLine );
mActionSep->show();
}
else
{
if( !mActionSep )
{
return;
}
delete mActionSep; mActionSep = 0;
}
if( mIsActivated )
{
setupLayout();
}
}
QFrame *KDialogBase::plainPage()
{
return ( mJanus ? mJanus->plainPage() : 0 );
}
void KDialogBase::adjustSize()
{
// if (layout())
// layout()->activate();
if( d->bFixed )
setFixedSize( sizeHint() );
else
resize( sizeHint() );
}
QSize KDialogBase::sizeHint() const
{
return d->minSize.expandedTo( minimumSizeHint() ) + d->incSize;
}
QSize KDialogBase::minimumSizeHint() const
{
const int m = marginHint();
const int s = spacingHint();
const QSize zeroByS(0, s);
QSize s1(0,0);
QSize s2(0,0);
//
// Url help area
//
if( mUrlHelp )
{
s2 = mUrlHelp->minimumSize() + zeroByS;
}
s1.rwidth() = QMAX( s1.rwidth(), s2.rwidth() );
s1.rheight() += s2.rheight();
//
// User widget
//
if( mJanus )
{
s2 = mJanus->minimumSizeHint() + zeroByS;
}
else if( mMainWidget )
{
s2 = mMainWidget->sizeHint() + zeroByS;
s2 = s2.expandedTo( mMainWidget->minimumSize() );
s2 = s2.expandedTo( mMainWidget->minimumSizeHint() );
if( s2.isEmpty() )
{
s2 = QSize( 100, 100+s );
}
}
else
{
s2 = QSize( 100, 100+s );
}
s1.rwidth() = QMAX( s1.rwidth(), s2.rwidth() );
s1.rheight() += s2.rheight();
if (d->detailsWidget && d->bDetails)
{
s2 = d->detailsWidget->sizeHint() + zeroByS;
s2 = s2.expandedTo( d->detailsWidget->minimumSize() );
s2 = s2.expandedTo( d->detailsWidget->minimumSizeHint() );
s1.rwidth() = QMAX( s1.rwidth(), s2.rwidth() );
s1.rheight() += s2.rheight();
}
//
// Button separator
//
if( mActionSep )
{
s1.rheight() += mActionSep->minimumSize().height() + s;
}
//
// The button box
//
if( d->mButton.box )
{
s2 = d->mButton.box->minimumSize();
if( mButtonOrientation == Horizontal )
{
s1.rwidth() = QMAX( s1.rwidth(), s2.rwidth() );
s1.rheight() += s2.rheight();
}
else
{
s1.rwidth() += s2.rwidth();
s1.rheight() = QMAX( s1.rheight(), s2.rheight() );
}
}
//
// Outer margings
//
s1.rheight() += 2*m;
s1.rwidth() += 2*m;
return s1;
}
void KDialogBase::disableResize()
{
setFixedSize( sizeHint() );
}
void KDialogBase::setInitialSize( const QSize &s, bool noResize )
{
d->minSize = s;
d->bFixed = noResize;
adjustSize();
}
void KDialogBase::incInitialSize( const QSize &s, bool noResize )
{
d->incSize = s;
d->bFixed = noResize;
adjustSize();
}
void KDialogBase::makeButtonBox( int buttonMask, ButtonCode defaultButton,
const KGuiItem &user1, const KGuiItem &user2,
const KGuiItem &user3 )
{
if( buttonMask == 0 )
{
d->mButton.box = 0;
return; // When we want no button box
}
if( buttonMask & Cancel ) { buttonMask &= ~Close; }
if( buttonMask & Apply ) { buttonMask &= ~Try; }
if( buttonMask & Details ) { buttonMask &= ~Default; }
if( !mMessageBoxMode )
{
mEscapeButton = (buttonMask&Cancel) ? Cancel : Close;
}
d->mButton.box = new QWidget( this );
d->mButton.mask = buttonMask;
if( d->mButton.mask & Help )
{
KPushButton *pb = d->mButton.append( Help, KStdGuiItem::help() );
connect( pb, SIGNAL(clicked()), SLOT(slotHelp()) );
}
if( d->mButton.mask & Default )
{
KPushButton *pb = d->mButton.append( Default, KStdGuiItem::defaults() );
connect( pb, SIGNAL(clicked()), SLOT(slotDefault()) );
}
if( d->mButton.mask & Details )
{
KPushButton *pb = d->mButton.append( Details, QString::null );
connect( pb, SIGNAL(clicked()), SLOT(slotDetails()) );
setDetails(false);
}
if( d->mButton.mask & User3 )
{
KPushButton *pb = d->mButton.append( User3, user3 );
connect( pb, SIGNAL(clicked()), SLOT(slotUser3()) );
}
if( d->mButton.mask & User2 )
{
KPushButton *pb = d->mButton.append( User2, user2 );
if( mMessageBoxMode )
{
connect( pb, SIGNAL(clicked()), SLOT(slotYes()) );
}
else
{
connect( pb, SIGNAL(clicked()), this, SLOT(slotUser2()) );
}
}
if( d->mButton.mask & User1 )
{
KPushButton *pb = d->mButton.append( User1, user1 );
if( mMessageBoxMode )
{
connect( pb, SIGNAL(clicked()), this, SLOT(slotNo()) );
}
else
{
connect( pb, SIGNAL(clicked()), SLOT(slotUser1()) );
}
}
if( d->mButton.mask & Ok )
{
KPushButton *pb = d->mButton.append( Ok, KStdGuiItem::ok() );
connect( pb, SIGNAL(clicked()), SLOT(slotOk()) );
}
if( d->mButton.mask & Apply )
{
KPushButton *pb = d->mButton.append( Apply, KStdGuiItem::apply() );
connect( pb, SIGNAL(clicked()), SLOT(slotApply()) );
connect( pb, SIGNAL(clicked()), SLOT(applyPressed()) );
}
if( d->mButton.mask & Try )
{
KPushButton *pb = d->mButton.append( Try,
i18n( "&Try" ) );
connect( pb, SIGNAL(clicked()), SLOT(slotTry()) );
}
if( d->mButton.mask & Cancel )
{
KPushButton *pb = d->mButton.append( Cancel, KStdGuiItem::cancel() );
connect( pb, SIGNAL(clicked()), SLOT(slotCancel()) );
}
if( d->mButton.mask & Close )
{
KPushButton *pb = d->mButton.append( Close, KStdGuiItem::close() );
connect( pb, SIGNAL(clicked()), SLOT(slotClose()) );
}
if( defaultButton != NoDefault )
{
QPushButton *pb = actionButton( defaultButton );
if( pb )
{
setButtonFocus( pb, true, false );
}
}
setButtonStyle( KGlobalSettings::buttonLayout() );
}
void KDialogBase::setButtonStyle( int style )
{
if( !d->mButton.box )
{
return;
}
if( style < 0 || style >= ActionStyleMAX ) { style = ActionStyle0; }
d->mButton.style = style;
const int *layout;
int layoutMax = 0;
if (mMessageBoxMode)
{
static const int layoutRule[5][6] =
{
{Details,Stretch,User2|Stretch,User1|Stretch,Cancel|Stretch, Details|Filler},
{Details,Stretch,User2|Stretch,User1|Stretch,Cancel|Stretch, Details|Filler},
{Details,Stretch,User2|Stretch,User1|Stretch,Cancel|Stretch, Details|Filler},
{Details|Filler,Stretch,Cancel|Stretch,User2|Stretch,User1|Stretch,Details},
{Details|Filler,Stretch,Cancel|Stretch,User2|Stretch,User1|Stretch,Details}
};
layoutMax = 6;
layout = layoutRule[ d->mButton.style ];
}
else if (mButtonOrientation == Horizontal)
{
static const int layoutRule[5][10] =
{
{Details,Help,Default,Stretch,User3,User2,User1,Ok,Apply|Try,Cancel|Close},
{Details,Help,Default,Stretch,User3,User2,User1,Cancel|Close,Apply|Try,Ok},
{Details,Help,Default,Stretch,User3,User2,User1,Apply|Try,Cancel|Close,Ok},
{Ok,Apply|Try,Cancel|Close,User3,User2,User1,Stretch,Default,Help,Details},
{Ok,Cancel|Close,Apply|Try,User3,User2,User1,Stretch,Default,Help,Details}
};
layoutMax = 10;
layout = layoutRule[ d->mButton.style ];
}
else
{
static const int layoutRule[5][10] =
{
{Ok,Apply|Try,User1,User2,User3,Stretch,Default,Cancel|Close,Help, Details},
//{Ok,Apply|Try,Cancel|Close,User1,User2,User3,Stretch, Default,Help, Details},
{Details,Help,Default,Stretch,User3,User2,User1,Cancel|Close,Apply|Try,Ok},
{Details,Help,Default,Stretch,User3,User2,User1,Apply|Try,Cancel|Close,Ok},
{Ok,Apply|Try,Cancel|Close,User3,User2,User1,Stretch,Default,Help,Details},
{Ok,Cancel|Close,Apply|Try,User3,User2,User1,Stretch,Default,Help,Details}
};
layoutMax = 10;
layout = layoutRule[ d->mButton.style ];
}
if( d->mButton.box->layout() )
{
delete d->mButton.box->layout();
}
QBoxLayout *lay;
if( mButtonOrientation == Horizontal )
{
lay = new QBoxLayout( d->mButton.box, QBoxLayout::LeftToRight, 0,
spacingHint());
}
else
{
lay = new QBoxLayout( d->mButton.box, QBoxLayout::TopToBottom, 0,
spacingHint());
}
int numButton = 0;
QPushButton *prevButton = 0;
QPushButton *newButton;
for( int i=0; i<layoutMax; ++i )
{
if(((ButtonCode) layout[i]) == Stretch) // Unconditional Stretch
{
lay->addStretch(1);
continue;
}
else if (layout[i] & Filler) // Conditional space
{
if (d->mButton.mask & layout[i])
{
newButton = actionButton( (ButtonCode) (layout[i] & ~(Stretch | Filler)));
if (newButton)
lay->addSpacing(newButton->sizeHint().width());
}
continue;
}
else if( d->mButton.mask & Help & layout[i] )
{
newButton = actionButton( Help );
lay->addWidget( newButton ); ++numButton;
}
else if( d->mButton.mask & Default & layout[i] )
{
newButton = actionButton( Default );
lay->addWidget( newButton ); ++numButton;
}
else if( d->mButton.mask & User3 & layout[i] )
{
newButton = actionButton( User3 );
lay->addWidget( newButton ); ++numButton;
}
else if( d->mButton.mask & User2 & layout[i] )
{
newButton = actionButton( User2 );
lay->addWidget( newButton ); ++numButton;
}
else if( d->mButton.mask & User1 & layout[i] )
{
newButton = actionButton( User1 );
lay->addWidget( newButton ); ++numButton;
}
else if( d->mButton.mask & Ok & layout[i] )
{
newButton = actionButton( Ok );
lay->addWidget( newButton ); ++numButton;
}
else if( d->mButton.mask & Apply & layout[i] )
{
newButton = actionButton( Apply );
lay->addWidget( newButton ); ++numButton;
}
else if( d->mButton.mask & Try & layout[i] )
{
newButton = actionButton( Try );
lay->addWidget( newButton ); ++numButton;
}
else if( d->mButton.mask & Cancel & layout[i] )
{
newButton = actionButton( Cancel );
lay->addWidget( newButton ); ++numButton;
}
else if( d->mButton.mask & Close & layout[i] )
{
newButton = actionButton( Close );
lay->addWidget( newButton ); ++numButton;
}
else if( d->mButton.mask & Details & layout[i] )
{
newButton = actionButton( Details );
lay->addWidget( newButton ); ++numButton;
}
else
{
continue;
}
// Add conditional stretch (Only added if a button was added)
if(layout[i] & Stretch)
{
lay->addStretch(1);
}
if( prevButton )
{
setTabOrder( prevButton, newButton );
}
prevButton = newButton;
}
d->mButton.resize( false, 0, spacingHint(), mButtonOrientation );
}
QPushButton *KDialogBase::actionButton( ButtonCode id )
{
return d->mButton.button(id);
}
void KDialogBase::enableButton( ButtonCode id, bool state )
{
QPushButton *pb = actionButton( id );
if( pb )
{
pb->setEnabled( state );
}
}
void KDialogBase::enableButtonOK( bool state )
{
enableButton( Ok, state );
}
void KDialogBase::enableButtonApply( bool state )
{
enableButton( Apply, state );
}
void KDialogBase::enableButtonCancel( bool state )
{
enableButton( Cancel, state );
}
void KDialogBase::showButton( ButtonCode id, bool state )
{
QPushButton *pb = actionButton( id );
if( pb )
{
state ? pb->show() : pb->hide();
}
}
void KDialogBase::showButtonOK( bool state )
{
showButton( Ok, state );
}
void KDialogBase::showButtonApply( bool state )
{
showButton( Apply, state );
}
void KDialogBase::showButtonCancel( bool state )
{
showButton( Cancel, state );
}
void KDialogBase::setButtonOKText( const QString &text,
const QString &tooltip,
const QString &quickhelp )
{
QPushButton *pb = actionButton( Ok );
if( !pb )
{
return;
}
const QString whatsThis = i18n( ""
"If you press the <b>OK</b> button, all changes\n"
"you made will be used to proceed.");
pb->setText( text.isEmpty() ? i18n("&OK") : text );
d->mButton.resize( false, 0, spacingHint(), mButtonOrientation );
QToolTip::add( pb, tooltip.isEmpty() ? i18n("Accept settings") : tooltip );
QWhatsThis::add( pb, quickhelp.isEmpty() ? whatsThis : quickhelp );
}
void KDialogBase::setButtonOK( const KGuiItem &item /* = KStdGuiItem::ok() */ )
{
setButtonGuiItem( Ok, item );
}
void KDialogBase::setButtonApplyText( const QString &text,
const QString &tooltip,
const QString &quickhelp )
{
QPushButton *pb = actionButton( Apply );
if( !pb )
{
return;
}
const QString whatsThis = i18n( ""
"When clicking <b>Apply</b>, the settings will be\n"
"handed over to the program, but the dialog\n"
"will not be closed. "
"Use this to try different settings. ");
pb->setText( text.isEmpty() ? i18n("&Apply") : text );
d->mButton.resize( false, 0, spacingHint(), mButtonOrientation );
QToolTip::add( pb, tooltip.isEmpty() ? i18n("Apply settings") : tooltip );
QWhatsThis::add( pb, quickhelp.isEmpty() ? whatsThis : quickhelp );
}
void KDialogBase::setButtonApply( const KGuiItem &item /* = KStdGuiItem::apply() */ )
{
setButtonGuiItem( Apply, item );
}
void KDialogBase::setButtonCancelText( const QString& text,
const QString& tooltip,
const QString& quickhelp )
{
QPushButton *pb = actionButton( Cancel );
if( !pb )
{
return;
}
pb->setText( text.isEmpty() ? i18n("&Cancel") : text );
d->mButton.resize( false, 0, spacingHint(), mButtonOrientation );
QToolTip::add( pb, tooltip );
QWhatsThis::add( pb, quickhelp );
}
void KDialogBase::setButtonCancel( const KGuiItem &item /* = KStdGuiItem::cancel() */ )
{
setButtonGuiItem( Cancel, item );
}
void KDialogBase::setButtonGuiItem( ButtonCode id, const KGuiItem &item )
{
KPushButton *pb = static_cast<KPushButton *>( actionButton( id ) );
if( !pb )
return;
pb->setGuiItem( item );
d->mButton.resize( false, 0, spacingHint(), mButtonOrientation );
}
void KDialogBase::setButtonText( ButtonCode id, const QString &text )
{
if (!d->bSettingDetails && (id == Details))
{
d->detailsButton = text;
setDetails(d->bDetails);
return;
}
QPushButton *pb = actionButton( id );
if( pb )
{
pb->setText( text );
d->mButton.resize( false, 0, spacingHint(), mButtonOrientation );
}
}
void KDialogBase::setButtonTip( ButtonCode id, const QString &text )
{
QPushButton *pb = actionButton( id );
if( pb )
{
if (text.isEmpty())
QToolTip::remove( pb );
else
QToolTip::add( pb, text );
}
}
void KDialogBase::setButtonWhatsThis( ButtonCode id, const QString &text )
{
QPushButton *pb = actionButton( id );
if( pb )
{
if (text.isEmpty())
QWhatsThis::remove( pb );
else
QWhatsThis::add( pb, text );
}
}
void KDialogBase::setButtonFocus( QPushButton *p,bool isDefault, bool isFocus )
{
p->setDefault( isDefault );
if( isFocus )
p->setFocus();
}
void KDialogBase::setTreeListAutoResize( bool state )
{
if( mJanus )
{
mJanus->setTreeListAutoResize( state );
}
}
void KDialogBase::setShowIconsInTreeList(bool state)
{
if( mJanus )
{
mJanus->setShowIconsInTreeList( state );
}
}
void KDialogBase::setRootIsDecorated( bool state )
{
if( mJanus )
{
mJanus->setRootIsDecorated( state );
}
}
void KDialogBase::unfoldTreeList( bool persist )
{
if( mJanus )
mJanus->unfoldTreeList( persist );
}
void KDialogBase::addWidgetBelowList( QWidget * widget )
{
if( mJanus )
mJanus->addWidgetBelowList( widget );
}
void KDialogBase::addButtonBelowList( const QString & text, QObject * recv, const char * slot )
{
if( mJanus )
mJanus->addButtonBelowList( text, recv, slot );
}
void KDialogBase::addButtonBelowList( const KGuiItem & item, QObject * recv, const char * slot )
{
if( mJanus )
mJanus->addButtonBelowList( item, recv, slot );
}
void KDialogBase::setIconListAllVisible( bool state )
{
if( mJanus )
{
mJanus->setIconListAllVisible( state );
}
}
void KDialogBase::slotHelp()
{
emit helpClicked();
if ( kapp ) // may be null when used inside designer
kapp->invokeHelp( mAnchor, mHelpApp );
}
void KDialogBase::slotDefault()
{
emit defaultClicked();
}
void KDialogBase::slotDetails()
{
setDetails(!d->bDetails);
}
void KDialogBase::setDetailsWidget(QWidget *detailsWidget)
{
delete d->detailsWidget;
d->detailsWidget = detailsWidget;
if (d->detailsWidget->parentWidget() != this)
d->detailsWidget->reparent(this, QPoint(0,0));
d->detailsWidget->hide();
if( mIsActivated )
{
setupLayout();
}
if (!d->bSettingDetails)
setDetails(d->bDetails);
}
void KDialogBase::setDetails(bool showDetails)
{
if (d->detailsButton.isEmpty())
d->detailsButton = i18n("&Details");
d->bSettingDetails = true;
d->bDetails = showDetails;
if (d->bDetails)
{
emit aboutToShowDetails();
setButtonText(Details, d->detailsButton+ " <<");
if (d->detailsWidget)
{
if (layout())
layout()->setEnabled(false);
adjustSize();
d->detailsWidget->show();
if (layout())
{
layout()->activate();
layout()->setEnabled(true);
}
}
}
else
{
setButtonText(Details, d->detailsButton+" >>");
if (d->detailsWidget)
{
d->detailsWidget->hide();
}
if (layout())
layout()->activate();
adjustSize();
}
d->bSettingDetails = false;
}
void KDialogBase::slotOk()
{
emit okClicked();
accept();
}
void KDialogBase::slotApply()
{
emit applyClicked();
}
void KDialogBase::slotTry()
{
emit tryClicked();
}
void KDialogBase::slotUser3()
{
emit user3Clicked();
}
void KDialogBase::slotUser2()
{
emit user2Clicked();
}
void KDialogBase::slotUser1()
{
emit user1Clicked();
}
void KDialogBase::slotYes()
{
emit yesClicked();
done( Yes );
}
void KDialogBase::slotNo()
{
emit noClicked();
done( No );
}
void KDialogBase::slotCancel()
{
emit cancelClicked();
done( mMessageBoxMode ? (int)Cancel : (int)Rejected );
}
void KDialogBase::slotClose()
{
emit closeClicked();
reject();
}
void KDialogBase::helpClickedSlot( const QString & )
{
slotHelp();
}
void KDialogBase::applyPressed()
{
emit apply();
}
void KDialogBase::enableLinkedHelp( bool state )
{
if( state )
{
if( mUrlHelp )
{
return;
}
mUrlHelp = new KURLLabel( this, "url" );
mUrlHelp->setText( helpLinkText() );
mUrlHelp->setFloat(true);
mUrlHelp->setUnderline(true);
if( mShowTile && mTile->get() )
{
mUrlHelp->setBackgroundPixmap(*mTile->get());
}
mUrlHelp->setMinimumHeight( fontMetrics().height() + marginHint() );
connect(mUrlHelp,SIGNAL(leftClickedURL(const QString &)),
SLOT(helpClickedSlot(const QString &)));
mUrlHelp->show();
}
else
{
if( !mUrlHelp )
{
return;
}
delete mUrlHelp; mUrlHelp = 0;
}
if( mIsActivated )
{
setupLayout();
}
}
void KDialogBase::setHelp( const QString &anchor, const QString &appname )
{
mAnchor = anchor;
mHelpApp = appname;
}
void KDialogBase::setHelpLinkText( const QString &text )
{
mHelpLinkText = text;
if( mUrlHelp )
{
mUrlHelp->setText( helpLinkText() );
}
}
QFrame *KDialogBase::addPage( const QString &itemName, const QString &header,
const QPixmap &pixmap )
{
return ( mJanus ? mJanus->addPage( itemName, header, pixmap ) : 0);
}
QFrame *KDialogBase::addPage( const QStringList &items, const QString &header,
const QPixmap &pixmap )
{
return ( mJanus ? mJanus->addPage( items, header, pixmap ) : 0);
}
QVBox *KDialogBase::addVBoxPage( const QString &itemName,
const QString &header, const QPixmap &pixmap )
{
return ( mJanus ? mJanus->addVBoxPage( itemName, header, pixmap) : 0);
}
QVBox *KDialogBase::addVBoxPage( const QStringList &items,
const QString &header, const QPixmap &pixmap )
{
return ( mJanus ? mJanus->addVBoxPage( items, header, pixmap) : 0);
}
QHBox *KDialogBase::addHBoxPage( const QString &itemName,
const QString &header,
const QPixmap &pixmap )
{
return ( mJanus ? mJanus->addHBoxPage( itemName, header, pixmap ) : 0);
}
QHBox *KDialogBase::addHBoxPage( const QStringList &items,
const QString &header,
const QPixmap &pixmap )
{
return ( mJanus ? mJanus->addHBoxPage( items, header, pixmap ) : 0);
}
QGrid *KDialogBase::addGridPage( int n, Orientation dir,
const QString &itemName,
const QString &header, const QPixmap &pixmap )
{
return ( mJanus ? mJanus->addGridPage( n, dir, itemName, header, pixmap) : 0);
}
QGrid *KDialogBase::addGridPage( int n, Orientation dir,
const QStringList &items,
const QString &header, const QPixmap &pixmap )
{
return ( mJanus ? mJanus->addGridPage( n, dir, items, header, pixmap) : 0);
}
void KDialogBase::setFolderIcon(const QStringList &path, const QPixmap &pixmap)
{
if (!mJanus)
return;
mJanus->setFolderIcon(path,pixmap);
}
QFrame *KDialogBase::makeMainWidget()
{
if( mJanus || mMainWidget )
{
printMakeMainWidgetError();
return 0;
}
QFrame *mainWidget = new QFrame( this );
setMainWidget( mainWidget );
return mainWidget;
}
QVBox *KDialogBase::makeVBoxMainWidget()
{
if( mJanus || mMainWidget )
{
printMakeMainWidgetError();
return 0;
}
QVBox *mainWidget = new QVBox( this );
mainWidget->setSpacing( spacingHint() );
setMainWidget( mainWidget );
return mainWidget;
}
QHBox *KDialogBase::makeHBoxMainWidget()
{
if( mJanus || mMainWidget )
{
printMakeMainWidgetError();
return 0;
}
QHBox *mainWidget = new QHBox( this );
mainWidget->setSpacing( spacingHint() );
setMainWidget( mainWidget );
return mainWidget;
}
QGrid *KDialogBase::makeGridMainWidget( int n, Orientation dir )
{
if( mJanus || mMainWidget )
{
printMakeMainWidgetError();
return 0;
}
QGrid *mainWidget = new QGrid( n, dir, this );
mainWidget->setSpacing( spacingHint() );
setMainWidget( mainWidget );
return mainWidget;
}
void KDialogBase::printMakeMainWidgetError()
{
if( mJanus )
{
kdDebug() << "makeMainWidget: Illegal mode (wrong constructor)" << endl;
}
else if( mMainWidget )
{
kdDebug() << "makeMainWidget: Main widget already defined" << endl;
}
}
void KDialogBase::setMainWidget( QWidget *widget )
{
if( mJanus )
{
if( mJanus->setSwallowedWidget(widget) )
{
mMainWidget = widget;
}
}
else
{
mMainWidget = widget;
if( mIsActivated )
{
setupLayout();
}
}
if( mMainWidget != NULL )
{
QFocusData* fd = focusData();
QWidget* prev = fd->last();
for( QPtrListIterator<KDialogBaseButton> it( d->mButton.list );
it != NULL;
++it )
{
if( prev != *it )
setTabOrder( prev, *it );
prev = *it;
}
}
}
QWidget *KDialogBase::mainWidget()
{
return mMainWidget;
}
bool KDialogBase::showPage( int index )
{
return ( mJanus ? mJanus->showPage(index) : false);
}
int KDialogBase::activePageIndex() const
{
return ( mJanus ? mJanus->activePageIndex() : -1);
}
int KDialogBase::pageIndex( QWidget *widget ) const
{
return ( mJanus ? mJanus->pageIndex( widget) : -1);
}
// Deprecated
QRect KDialogBase::getContentsRect() const
{
QRect r;
r.setLeft( marginHint() );
r.setTop( marginHint() + (mUrlHelp ? mUrlHelp->height() : 0) );
r.setRight( width() - marginHint() );
int h = (!mActionSep ? 0 : mActionSep->minimumSize().height()+marginHint());
if( d->mButton.box )
{
r.setBottom( height() - d->mButton.box->minimumSize().height() - h );
}
else
{
r.setBottom( height() - h );
}
return r;
}
// Deprecated
void KDialogBase::getBorderWidths(int& ulx, int& uly, int& lrx, int& lry) const
{
ulx = marginHint();
uly = marginHint();
if( mUrlHelp )
{
uly += mUrlHelp->minimumSize().height();
}
lrx = marginHint();
lry = d->mButton.box ? d->mButton.box->minimumSize().height() : 0;
if( mActionSep )
{
lry += mActionSep->minimumSize().height() + marginHint();
}
}
QSize KDialogBase::calculateSize(int w, int h) const
{
int ulx, uly, lrx, lry;
getBorderWidths(ulx, uly, lrx, lry);
return QSize(ulx+w+lrx,uly+h+lry);
}
QString KDialogBase::helpLinkText() const
{
return ( mHelpLinkText.isNull() ? i18n("Get help...") : mHelpLinkText );
}
void KDialogBase::updateGeometry()
{
if( mTopLayout )
{
mTopLayout->setMargin( marginHint() );
mTopLayout->setSpacing(spacingHint() );
}
}
void KDialogBase::keyPressEvent( QKeyEvent *e )
{
//
// Reimplemented from KDialog to remove the default behavior
// and to add F1 (help) sensitivity and some animation.
//
if( e->state() == 0 )
{
if( e->key() == Key_F1 )
{
QPushButton *pb = actionButton( Help );
if( pb )
{
pb->animateClick();
e->accept();
return;
}
}
if( e->key() == Key_Escape )
{
QPushButton *pb = actionButton( mEscapeButton );
if( pb )
{
pb->animateClick();
e->accept();
return;
}
}
}
else if( e->key() == Key_F1 && e->state() == ShiftButton )
{
QWhatsThis::enterWhatsThisMode();
e->accept();
return;
}
// accept the dialog when Ctrl-Return is pressed
else if ( e->state() == ControlButton &&
(e->key() == Key_Return || e->key() == Key_Enter) )
{
QPushButton *pb = actionButton( Ok );
if ( pb )
{
pb->animateClick();
e->accept();
return;
}
}
//
// Do the default action instead. Note KDialog::keyPressEvent is bypassed
//
QDialog::keyPressEvent(e);
}
void KDialogBase::hideEvent( QHideEvent *ev )
{
emit hidden();
if (!ev->spontaneous())
{
emit finished();
}
}
void KDialogBase::closeEvent( QCloseEvent *e )
{
QPushButton *pb = actionButton( mEscapeButton );
if( pb && isShown() ) {
pb->animateClick();
} else {
QDialog::closeEvent( e );
}
}
void KDialogBase::cancel()
{
switch ( mEscapeButton ) {
case Ok:
slotOk();
break;
case User1: // == No
if ( mMessageBoxMode )
slotNo();
else
slotUser1();
break;
case User2: // == Yes
if ( mMessageBoxMode )
slotYes();
else
slotUser2();
break;
case User3:
slotUser3();
break;
case Close:
slotClose();
break;
case Cancel:
default:
slotCancel();
}
}
bool KDialogBase::haveBackgroundTile()
{
return ( !mTile || mTile->get() );
}
// Deprecated. For compatibility only.
const QPixmap *KDialogBase::getBackgroundTile() { return backgroundTile(); }
const QPixmap *KDialogBase::backgroundTile()
{
return ( mTile ? mTile->get() : 0);
}
void KDialogBase::setBackgroundTile( const QPixmap *pix )
{
if( mTile )
{
mTile->set( pix );
}
}
void KDialogBase::updateBackground()
{
if( !mTile || !mTile->get() )
{
QPixmap nullPixmap;
setBackgroundPixmap(nullPixmap);
if( d->mButton.box )
{
d->mButton.box->setBackgroundPixmap(nullPixmap);
d->mButton.box->setBackgroundMode(PaletteBackground);
}
setBackgroundMode(PaletteBackground);
}
else
{
const QPixmap *pix = mTile->get();
setBackgroundPixmap(*pix);
if( d->mButton.box )
{
d->mButton.box->setBackgroundPixmap(*pix);
}
showTile( mShowTile );
}
}
void KDialogBase::showTile( bool state )
{
mShowTile = state;
if( !mShowTile || !mTile || !mTile->get() )
{
setBackgroundMode(PaletteBackground);
if( d->mButton.box )
{
d->mButton.box->setBackgroundMode(PaletteBackground);
}
if( mUrlHelp )
{
mUrlHelp->setBackgroundMode(PaletteBackground);
}
}
else
{
const QPixmap *pix = mTile->get();
setBackgroundPixmap(*pix);
if( d->mButton.box )
{
d->mButton.box->setBackgroundPixmap(*pix);
}
if( mUrlHelp )
{
mUrlHelp->setBackgroundPixmap(*pix);
}
}
}
QSize KDialogBase::configDialogSize( const QString& groupName ) const
{
return configDialogSize( *KGlobal::config(), groupName );
}
QSize KDialogBase::configDialogSize( KConfig& config,
const QString& groupName ) const
{
int w, h;
int scnum = QApplication::desktop()->screenNumber(parentWidget());
QRect desk = QApplication::desktop()->screenGeometry(scnum);
w = sizeHint().width();
h = sizeHint().height();
KConfigGroupSaver cs(&config, groupName);
w = config.readNumEntry( QString::fromLatin1("Width %1").arg( desk.width()), w );
h = config.readNumEntry( QString::fromLatin1("Height %1").arg( desk.height()), h );
return QSize( w, h );
}
void KDialogBase::saveDialogSize( const QString& groupName, bool global )
{
saveDialogSize( *KGlobal::config(), groupName, global );
}
void KDialogBase::saveDialogSize( KConfig& config, const QString& groupName,
bool global ) const
{
int scnum = QApplication::desktop()->screenNumber(parentWidget());
QRect desk = QApplication::desktop()->screenGeometry(scnum);
KConfigGroupSaver cs(&config, groupName);
QSize sizeToSave = size();
config.writeEntry( QString::fromLatin1("Width %1").arg( desk.width()),
QString::number( sizeToSave.width()), true, global);
config.writeEntry( QString::fromLatin1("Height %1").arg( desk.height()),
QString::number( sizeToSave.height()), true, global);
}
KDialogBaseButton::KDialogBaseButton( const KGuiItem &item, int key,
QWidget *parent, const char *name )
: KPushButton( item, parent, name ), mKey(key)
{
}
KDialogBaseTile::KDialogBaseTile( QObject *parent, const char *name )
: QObject( parent, name ), mPixmap(0)
{
}
KDialogBaseTile::~KDialogBaseTile()
{
cleanup();
}
void KDialogBaseTile::set( const QPixmap *pix )
{
if( !pix )
{
cleanup();
}
else
{
if( !mPixmap )
{
mPixmap = new QPixmap(*pix);
}
else
{
*mPixmap = *pix;
}
}
emit pixmapChanged();
}
const QPixmap *KDialogBaseTile::get() const
{
return mPixmap;
}
void KDialogBaseTile::cleanup()
{
delete mPixmap; mPixmap = 0;
}
void KDialogBase::virtual_hook( int id, void* data )
{ KDialog::virtual_hook( id, data ); }
#include "kdialogbase.moc"
KJanusWidget::addGridPage
virtual QGrid * addGridPage(int n, Orientation dir, const QString &itemName, const QString &header=QString::null, const QPixmap &pixmap=QPixmap())
Add a new page when the class is used in either TreeList or Tabbed mode.
Definition: kjanuswidget.cpp:341
KDialogBase::Details
Show Details button.
Definition: kdialogbase.h:211
KDialog::marginHint
static int marginHint()
Return the number of pixels you shall use between a dialog edge and the outermost widget(s) according...
Definition: kdialog.cpp:97
KJanusWidget::plainPage
virtual QFrame * plainPage()
Returns the empty widget that is available in Plain mode.
Definition: kjanuswidget.cpp:214
KDialogBase::noClicked
void noClicked()
The No button was pressed.
KDialogBase::defaultClicked
void defaultClicked()
The Default button was pressed.
KDialogBase::aboutToShowPage
void aboutToShowPage(QWidget *page)
A page is about to be shown.
KJanusWidget::addPage
virtual QFrame * addPage(const QString &item, const QString &header=QString::null, const QPixmap &pixmap=QPixmap())
Add a new page when the class is used in TreeList, IconList or Tabbed mode.
Definition: kjanuswidget.cpp:261
KDialogBase::cancelClicked
void cancelClicked()
The Cancel button was pressed.
KPushButton
This is nothing but a QPushButton with drag-support and KGuiItem support.
Definition: kpushbutton.h:37
KDialogBase::slotOk
virtual void slotOk()
Activated when the Ok button has been clicked.
Definition: kdialogbase.cpp:1164
KDialogBase::Close
Show Close-button.
Definition: kdialogbase.h:205
KDialogBase::applyClicked
void applyClicked()
The Apply button was pressed.
KDialogBase::setButtonApplyText
void setButtonApplyText(const QString &text=QString::null, const QString &tooltip=QString::null, const QString &quickhelp=QString::null) KDE_DEPRECATED
Definition: kdialogbase.cpp:922
KJanusWidget::activePageIndex
virtual int activePageIndex() const
Returns the index of the page that are currently displayed.
Definition: kjanuswidget.cpp:641
KDialogBase::applyPressed
virtual void applyPressed()
Definition: kdialogbase.cpp:1235
KDialogBase::slotDetails
virtual void slotDetails()
Activated when the Details button has been clicked.
Definition: kdialogbase.cpp:1107
KDialogBase::Ok
Show Ok button.
Definition: kdialogbase.h:201
KJanusWidget::addWidgetBelowList
void addWidgetBelowList(QWidget *widget)
Add a widget at the bottom of the TreeList/IconList.
Definition: kjanuswidget.cpp:857
KDialogBase::addVBoxPage
QVBox * addVBoxPage(const QString &itemName, const QString &header=QString::null, const QPixmap &pixmap=QPixmap())
Add a page to the dialog when the class is used in TreeList, IconList or Tabbed mode.
Definition: kdialogbase.cpp:1309
KDialogBase::apply
void apply()
Do not use this signal.
KDialogBase::setFolderIcon
void setFolderIcon(const QStringList &path, const QPixmap &pixmap)
Sets the icon used in TreeList Mode for the given path.
Definition: kdialogbase.cpp:1351
KURLLabel
A drop-in replacement for QLabel that displays hyperlinks.
Definition: kurllabel.h:71
KDialogBase::makeMainWidget
QFrame * makeMainWidget()
Make a main widget.
Definition: kdialogbase.cpp:1359
KDialogBase::addHBoxPage
QHBox * addHBoxPage(const QString &itemName, const QString &header=QString::null, const QPixmap &pixmap=QPixmap())
Add a page to the dialog when the class is used in TreeList, IconList or Tabbed mode.
Definition: kdialogbase.cpp:1322
KDialogBase::setButtonGuiItem
void setButtonGuiItem(ButtonCode id, const KGuiItem &item)
Sets the KGuiItem directly for the button instead of using 3 methods to set the text, tooltip and whatsthis strings.
Definition: kdialogbase.cpp:975
KDialogBase::setButtonCancel
void setButtonCancel(const KGuiItem &item=KStdGuiItem::cancel())
Sets the appearance of the Cancel button.
Definition: kdialogbase.cpp:970
KDialogBase::tryClicked
void tryClicked()
The Try button was pressed.
KDialogBase::KDialogBase
KDialogBase(QWidget *parent=0, const char *name=0, bool modal=true, const QString &caption=QString::null, int buttonMask=Ok|Apply|Cancel, ButtonCode defaultButton=Ok, bool separator=false, const KGuiItem &user1=KGuiItem(), const KGuiItem &user2=KGuiItem(), const KGuiItem &user3=KGuiItem())
Constructor for the standard mode where you must specify the main widget with setMainWidget() ...
Definition: kdialogbase.cpp:99
KDialogBase::enableButtonOK
void enableButtonOK(bool state)
Enable or disable (gray out) the OK button.
Definition: kdialogbase.cpp:848
KDialogBase::showTile
void showTile(bool state)
Enable hiding of the background tile (if any).
Definition: kdialogbase.cpp:1711
KDialogBase::showButtonOK
void showButtonOK(bool state)
Hide or display the OK button.
Definition: kdialogbase.cpp:876
KDialogBase::setEscapeButton
void setEscapeButton(ButtonCode id)
Sets the button that will be activated when the Escape key is pressed.
Definition: kdialogbase.cpp:365
KDialogBase::slotHelp
virtual void slotHelp()
Activated when the Help button has been clicked.
Definition: kdialogbase.cpp:1094
KDialogBase::activePageIndex
int activePageIndex() const
Returns the index of the active page.
Definition: kdialogbase.cpp:1476
KDialogBase::disableResize
void disableResize()
Convenience method.
Definition: kdialogbase.cpp:531
KDialogBase::setButtonApply
void setButtonApply(const KGuiItem &item=KStdGuiItem::apply())
Sets the appearance of the Apply button.
Definition: kdialogbase.cpp:946
KDialogBase::addPage
QFrame * addPage(const QString &itemName, const QString &header=QString::null, const QPixmap &pixmap=QPixmap())
Add a page to the dialog when the class is used in TreeList , IconList or Tabbed mode.
Definition: kdialogbase.cpp:1296
KDialogBase::enableButton
void enableButton(ButtonCode id, bool state)
Enable or disable (gray out) a general action button.
Definition: kdialogbase.cpp:838
KJanusWidget::setShowIconsInTreeList
virtual void setShowIconsInTreeList(bool state)
This function has only effect in TreeList mode.
Definition: kjanuswidget.cpp:831
KDialogBase::slotNo
virtual void slotNo()
Activated when the Yes button has been clicked.
Definition: kdialogbase.cpp:1208
KDialogBase::setIconListAllVisible
void setIconListAllVisible(bool state)
This function has only effect in IconList mode.
Definition: kdialogbase.cpp:1085
KDialog
Dialog with extended non-modal support and methods for KDE standard compliance.
Definition: kdialog.h:52
KDialogBase::setButtonText
void setButtonText(ButtonCode id, const QString &text)
Sets the text of any button.
Definition: kdialogbase.cpp:986
kdDebug
kdbgstream kdDebug(int area=0)
KDialogBase::Apply
Show Apply button.
Definition: kdialogbase.h:202
KDialogBase::Stretch
Definition: kdialogbase.h:213
KDialogBaseTile
Used internally by KDialogBase.
Definition: kdialogbase_priv.h:48
KDialogBase::user3Clicked
void user3Clicked()
The User3 button was pressed.
KDialogBase::Cancel
Show Cancel-button.
Definition: kdialogbase.h:204
klocale.h
KDialogBase::getContentsRect
QRect getContentsRect() const KDE_DEPRECATED
Definition: kdialogbase.cpp:1489
KDialogBase::ButtonCode
ButtonCode
Definition: kdialogbase.h:197
KDialogBase::cancel
void cancel()
Force closing the dialog, setting its result code to the one Esc would set.
Definition: kdialogbase.cpp:1632
KJanusWidget::pageIndex
virtual int pageIndex(QWidget *widget) const
Returns the index of a page created with addPage , addVBoxPage , addHBoxPage or addGridPage ...
Definition: kjanuswidget.cpp:665
KDialog::setCaption
virtual void setCaption(const QString &caption)
Make a KDE compliant caption.
Definition: kdialog.cpp:115
KJanusWidget::addVBoxPage
virtual QVBox * addVBoxPage(const QString &item, const QString &header=QString::null, const QPixmap &pixmap=QPixmap())
Add a new page when the class is used in TreeList, IconList or Tabbed mode.
Definition: kjanuswidget.cpp:288
KDialogBase::unfoldTreeList
void unfoldTreeList(bool persist=false)
This function has only effect in TreeList mode.
Definition: kdialogbase.cpp:1061
KJanusWidget
Easy to use widget with many layouts.
Definition: kjanuswidget.h:67
KSeparator
Standard horizontal or vertical separator.
Definition: kseparator.h:33
KDialogBase::incInitialSize
void incInitialSize(const QSize &s, bool noResize=false)
Convenience method.
Definition: kdialogbase.cpp:545
KJanusWidget::setRootIsDecorated
virtual void setRootIsDecorated(bool state)
This function has only effect in TreeList mode.
Definition: kjanuswidget.cpp:836
KDialogBase::haveBackgroundTile
static bool haveBackgroundTile()
Check whether the background tile is set or not.
Definition: kdialogbase.cpp:1662
KDialogBase::slotApply
virtual void slotApply()
Activated when the Apply button has been clicked.
Definition: kdialogbase.cpp:1171
KDialogBase::hidden
void hidden()
The dialog is about to be hidden.
KDialogBase::DialogType
DialogType
Definition: kdialogbase.h:237
KDialogBase::keyPressEvent
virtual void keyPressEvent(QKeyEvent *e)
Maps some keys to the actions buttons.
Definition: kdialogbase.cpp:1553
KDialogBase::User1
Show User defined button 1.
Definition: kdialogbase.h:206
KJanusWidget::showPage
virtual bool showPage(int index)
Raises the page which was added by addPage().
Definition: kjanuswidget.cpp:575
KDialogBase::helpClicked
void helpClicked()
The Help button was pressed.
KDialogBase::user2Clicked
void user2Clicked()
The User2 button was pressed.
KDialogBase::addButtonBelowList
void addButtonBelowList(const QString &text, QObject *recv, const char *slot)
Add a button at the bottom of the TreeList/IconList.
Definition: kdialogbase.cpp:1073
KDialog::spacingHint
static int spacingHint()
Return the number of pixels you shall use between widgets inside a dialog according to the KDE standa...
Definition: kdialog.cpp:103
KDialogBase::configDialogSize
QSize configDialogSize(const QString &groupName) const
read the dialogs size from the configuration according to the screen size.
Definition: kdialogbase.cpp:1741
KDialogBase::Help
Show Help button.
Definition: kdialogbase.h:199
KGlobalSettings::buttonLayout
static int buttonLayout()
KDialogBase::setInitialSize
void setInitialSize(const QSize &s, bool noResize=false)
Convenience method.
Definition: kdialogbase.cpp:537
KGuiItem
An abstract class for GUI data such as ToolTip and Icon.
Definition: kguiitem.h:38
KDialogBase::setButtonWhatsThis
void setButtonWhatsThis(ButtonCode id, const QString &text)
Sets the "What's this?" text of any button.
Definition: kdialogbase.cpp:1016
KDialogBase::aboutToShowDetails
void aboutToShowDetails()
The detailsWidget is about to get shown.
KJanusWidget::isValid
virtual bool isValid() const
Use this to verify that no memory allocation failed.
Definition: kjanuswidget.cpp:208
KJanusWidget::unfoldTreeList
void unfoldTreeList(bool persist=false)
This function has only effect in TreeList mode.
Definition: kjanuswidget.cpp:843
KJanusWidget::minimumSizeHint
virtual QSize minimumSizeHint() const
Returns the minimum size that must be made available for the widget so that UIs can be displayed prop...
Definition: kjanuswidget.cpp:750
KDialogBase::setHelpLinkText
void setHelpLinkText(const QString &text)
Sets the text that is shown as the linked text.
Definition: kdialogbase.cpp:1286
KURLLabel::setFloat
void setFloat(bool do_float=true)
Turns on or off the "float" feature.
Definition: kurllabel.cpp:281
KDialogBase::showButtonApply
void showButtonApply(bool state)
Hide or display the Apply button.
Definition: kdialogbase.cpp:882
KDialogBase::updateBackground
void updateBackground()
This method is called automatically whenever the background has changed.
Definition: kdialogbase.cpp:1685
KDialogBase::hideEvent
virtual void hideEvent(QHideEvent *)
Emits the hidden signal.
Definition: kdialogbase.cpp:1611
KDialogBase::updateGeometry
void updateGeometry()
Updates the margins and spacings.
Definition: kdialogbase.cpp:1542
KDialogBase::User2
Show User defined button 2.
Definition: kdialogbase.h:207
KConfigGroupSaver
KDialogBase::slotDefault
virtual void slotDefault()
Activated when the Default button has been clicked.
Definition: kdialogbase.cpp:1102
KDialogBase::setButtonOKText
void setButtonOKText(const QString &text=QString::null, const QString &tooltip=QString::null, const QString &quickhelp=QString::null) KDE_DEPRECATED
Definition: kdialogbase.cpp:894
KDialogBase::setDetails
void setDetails(bool showDetails)
Sets the status of the Details button.
Definition: kdialogbase.cpp:1127
KDialogBase::makeHBoxMainWidget
QHBox * makeHBoxMainWidget()
Make a main widget.
Definition: kdialogbase.cpp:1388
KDialogBase::actionButton
QPushButton * actionButton(ButtonCode id)
Returns the action button that corresponds to the id.
Definition: kdialogbase.cpp:832
KDialogBase::slotTry
virtual void slotTry()
Activated when the Try button has been clicked.
Definition: kdialogbase.cpp:1177
KDialogBase::helpClickedSlot
void helpClickedSlot(const QString &)
Connected to help link label.
Definition: kdialogbase.cpp:1229
KDialogBase::helpLinkText
QString helpLinkText() const
Returns the help link text.
Definition: kdialogbase.cpp:1536
KDialogBase::yesClicked
void yesClicked()
The Yes button was pressed.
KDialogBaseButton
Used internally by KDialogBase.
Definition: kdialogbase_priv.h:31
KJanusWidget::addButtonBelowList
void addButtonBelowList(const QString &text, QObject *recv, const char *slot)
Add a button at the bottom of the TreeList/IconList.
Definition: kjanuswidget.cpp:865
KDialogBase::enableButtonApply
void enableButtonApply(bool state)
Enable or disable (gray out) the Apply button.
Definition: kdialogbase.cpp:854
KDialogBase::slotUser1
virtual void slotUser1()
Activated when the User1 button has been clicked.
Definition: kdialogbase.cpp:1195
KDialogBase::slotDelayedDestruct
void slotDelayedDestruct()
Deletes the dialog immediately.
Definition: kdialogbase.cpp:288
KDialogBase::user1Clicked
void user1Clicked()
The User1 button was pressed.
KDialogBase::addGridPage
QGrid * addGridPage(int n, Orientation dir, const QString &itemName, const QString &header=QString::null, const QPixmap &pixmap=QPixmap())
Add a page to the dialog when the class is used in TreeList, IconList or Tabbed mode.
Definition: kdialogbase.cpp:1337
KJanusWidget::setSwallowedWidget
virtual bool setSwallowedWidget(QWidget *widget)
Defines the widget to be swallowed.
Definition: kjanuswidget.cpp:496
KDialogBase::addWidgetBelowList
void addWidgetBelowList(QWidget *widget)
Add a widget at the bottom of the TreeList/IconList.
Definition: kdialogbase.cpp:1067
KJanusWidget::addHBoxPage
virtual QHBox * addHBoxPage(const QString &itemName, const QString &header=QString::null, const QPixmap &pixmap=QPixmap())
Add a new page when the class is used in TreeList, IconList or Tabbed mode.
Definition: kjanuswidget.cpp:313
KDialogBase::makeGridMainWidget
QGrid * makeGridMainWidget(int n, Orientation dir)
Make a main widget.
Definition: kdialogbase.cpp:1403
KConfig
KDialogBase::slotCancel
virtual void slotCancel()
Activated when the Cancel button has been clicked.
Definition: kdialogbase.cpp:1215
KDialogBase::showButton
void showButton(ButtonCode id, bool state)
Hide or display a general action button.
Definition: kdialogbase.cpp:866
KURLLabel::setUnderline
void setUnderline(bool on=true)
Turns on or off the underlining.
Definition: kurllabel.cpp:153
KDialogBase::delayedDestruct
void delayedDestruct()
Destruct the Dialog delayed.
Definition: kdialogbase.cpp:280
KDialogBase::slotClose
virtual void slotClose()
Activated when the Close button has been clicked.
Definition: kdialogbase.cpp:1222
KPushButton::setGuiItem
void setGuiItem(const KGuiItem &item)
Sets the KGuiItem for this button.
Definition: kpushbutton.cpp:120
KDialogBase::slotYes
virtual void slotYes()
Activated when the Yes button has been clicked.
Definition: kdialogbase.cpp:1201
KDialogBase::showButtonCancel
void showButtonCancel(bool state)
Hide or display the Cancel button.
Definition: kdialogbase.cpp:888
KDialogBase::slotUser3
virtual void slotUser3()
Activated when the User3 button has been clicked.
Definition: kdialogbase.cpp:1183
KDialogBase::closeEvent
virtual void closeEvent(QCloseEvent *e)
Detects when a dialog is being closed from the window manager controls.
Definition: kdialogbase.cpp:1622
KDialogBase::setShowIconsInTreeList
void setShowIconsInTreeList(bool state)
This function has only effect in TreeList mode.
Definition: kdialogbase.cpp:1045
KDialogBase::setButtonCancelText
void setButtonCancelText(const QString &text=QString::null, const QString &tooltip=QString::null, const QString &quickhelp=QString::null) KDE_DEPRECATED
Definition: kdialogbase.cpp:952
KDialogBase::okClicked
void okClicked()
The OK button was pressed.
KDialogBase::pageIndex
int pageIndex(QWidget *widget) const
Returns the index of a page created with addPage(), addVBoxPage(), addHBoxPage() or addGridPage()...
Definition: kdialogbase.cpp:1482
KJanusWidget::setFolderIcon
virtual void setFolderIcon(const QStringList &path, const QPixmap &pixmap)
Sets the icon used in TreeList Mode for the given path.
Definition: kjanuswidget.cpp:488
KDialogBase::setMainWidget
void setMainWidget(QWidget *widget)
Sets the main user definable widget.
Definition: kdialogbase.cpp:1431
KDialogBase::setButtonOK
void setButtonOK(const KGuiItem &item=KStdGuiItem::ok())
Sets the appearance of the OK button.
Definition: kdialogbase.cpp:916
KDialogBase::enableButtonSeparator
void enableButtonSeparator(bool state)
Hide or display the a separator line drawn between the action buttons an the main widget...
Definition: kdialogbase.cpp:389
KDialogBase::enableButtonCancel
void enableButtonCancel(bool state)
Enable or disable (gray out) the Cancel button.
Definition: kdialogbase.cpp:860
KDialogBase::mainWidget
QWidget * mainWidget()
Returns the main widget if any.
Definition: kdialogbase.cpp:1464
KJanusWidget::setIconListAllVisible
virtual void setIconListAllVisible(bool state)
This function has only effect in IconList mode.
Definition: kjanuswidget.cpp:823
KDialogBase::getBackgroundTile
static const QPixmap * getBackgroundTile() KDE_DEPRECATED
Definition: kdialogbase.cpp:1668
KDialogBase::setDetailsWidget
void setDetailsWidget(QWidget *detailsWidget)
Sets the widget that gets shown when "Details" is enabled.
Definition: kdialogbase.cpp:1112
KDialogBase::NoDefault
Used when specifying a default button; indicates that no button should be marked by default...
Definition: kdialogbase.h:214
KJanusWidget::setTreeListAutoResize
virtual void setTreeListAutoResize(bool state)
This function has only effect in TreeList mode.
Definition: kjanuswidget.cpp:811
KDialogBase::setBackgroundTile
static void setBackgroundTile(const QPixmap *pix)
Sets the background tile.
Definition: kdialogbase.cpp:1676
KDialogBase::slotUser2
virtual void slotUser2()
Activated when the User2 button has been clicked.
Definition: kdialogbase.cpp:1189
KDialogBase::setButtonBoxOrientation
void setButtonBoxOrientation(int orientation)
Sets the orientation of the button box.
Definition: kdialogbase.cpp:345
KDialogBase::No
Show No button.
Definition: kdialogbase.h:209
KDialogBase::enableLinkedHelp
void enableLinkedHelp(bool state)
Display or hide the help link area on the top of the dialog.
Definition: kdialogbase.cpp:1241
KDialogBase::Default
Show Default button.
Definition: kdialogbase.h:200
endl
kndbgstream & endl(kndbgstream &s)
KDialogBase::Try
Show Try button.
Definition: kdialogbase.h:203
KDialogBase::~KDialogBase
~KDialogBase()
Destructor.
Definition: kdialogbase.cpp:211
KDialogBase::Filler
Definition: kdialogbase.h:212
KDialogBase::setHelp
void setHelp(const QString &anchor, const QString &appname=QString::null)
Sets the help path and topic.
Definition: kdialogbase.cpp:1279
KDialogBase::setButtonTip
void setButtonTip(ButtonCode id, const QString &text)
Sets the tooltip text of any button.
Definition: kdialogbase.cpp:1003
KSeparator::setOrientation
void setOrientation(int orient)
Set the orientation of the separator to orient.
Definition: kseparator.cpp:48
KDialogBase::getBorderWidths
void getBorderWidths(int &ulx, int &uly, int &lrx, int &lry) const KDE_DEPRECATED
Definition: kdialogbase.cpp:1510
KDialog::layoutHintChanged
void layoutHintChanged()
Emitted when the margin size and/or spacing size have changed.
KDialogBase::makeVBoxMainWidget
QVBox * makeVBoxMainWidget()
Make a main widget.
Definition: kdialogbase.cpp:1373
KConfig::writeEntry
void writeEntry(const QString &pKey, const QString &pValue, bool bPersistent=true, bool bGlobal=false, bool bNLS=false)
KDialogBase::setTreeListAutoResize
void setTreeListAutoResize(bool state)
This function has only effect in TreeList mode.
Definition: kdialogbase.cpp:1037
KDialogBase::showPage
bool showPage(int index)
Sets the page with index to be displayed.
Definition: kdialogbase.cpp:1470
KDialogBase::Yes
Show Yes button.
Definition: kdialogbase.h:210
KGlobal::config
static KConfig * config()
KDialogBase::backgroundTile
static const QPixmap * backgroundTile()
Returns a pointer to the background tile if there is one.
Definition: kdialogbase.cpp:1670
KDialogBase::closeClicked
void closeClicked()
The Close button was pressed.
KDialogBase::User3
Show User defined button 3.
Definition: kdialogbase.h:208
KDialogBase::plainPage
QFrame * plainPage()
Retrieve the empty page when the predefined layout is used in Plain mode.
Definition: kdialogbase.cpp:420
KConfig::readNumEntry
int readNumEntry(const QString &pKey, int nDefault=0) const
KDialogBase::finished
void finished()
The dialog has finished.
KDialogBase::saveDialogSize
void saveDialogSize(const QString &groupName, bool global=false)
save the dialogs size dependant on the screen dimension either to the global or application config fi...
Definition: kdialogbase.cpp:1765
KDialogBase::adjustSize
virtual void adjustSize()
Adjust the size of the dialog to fit the contents just before QDialog::exec() or QDialog::show() is c...
Definition: kdialogbase.cpp:427
KDialogBase::setRootIsDecorated
void setRootIsDecorated(bool state)
This function has only effect in TreeList mode.
Definition: kdialogbase.cpp:1053
KDialogBase::calculateSize
QSize calculateSize(int w, int h) const
Calculate the size hint for the dialog.
Definition: kdialogbase.cpp:1528

KDE Home | KDE Accessibility Home | Description of Access Keys