diff --git a/kdeui/dialogs/kdialog.cpp b/kdeui/dialogs/kdialog.cpp index d17f89c7..400c9230 100644 --- a/kdeui/dialogs/kdialog.cpp +++ b/kdeui/dialogs/kdialog.cpp @@ -56,52 +56,58 @@ void KDialogPrivate::setupLayout() { Q_Q(KDialog); if (!dirty) { - QMetaObject::invokeMethod( q, "queuedLayoutUpdate", Qt::QueuedConnection ); + QMetaObject::invokeMethod(q, "queuedLayoutUpdate", Qt::QueuedConnection); dirty = true; } } void KDialogPrivate::queuedLayoutUpdate() { - if (!dirty) - return; + if (!dirty) { + return; + } - dirty = false; + dirty = false; - Q_Q(KDialog); + Q_Q(KDialog); // Don't lose the focus widget when re-creating the layout. // Testcase: KOrganizer's "Select Categories" dialog QPointer focusWidget = mMainWidget ? mMainWidget->focusWidget() : 0; - if (q->layout() && q->layout() != mTopLayout) { - kWarning() << q->metaObject()->className() << "created with a layout; don't do that, KDialog takes care of it, use mainWidget or setMainWidget instead"; - delete q->layout(); - } + if (q->layout() && q->layout() != mTopLayout) { + kWarning() << q->metaObject()->className() << "created with a layout; don't do that, KDialog takes care of it, use mainWidget or setMainWidget instead"; + delete q->layout(); + } - delete mTopLayout; + delete mTopLayout; - if ( mButtonOrientation == Qt::Horizontal ) + if (mButtonOrientation == Qt::Horizontal) { mTopLayout = new QVBoxLayout(q); - else + } else { mTopLayout = new QHBoxLayout(q); + } - if ( mUrlHelp ) - mTopLayout->addWidget( mUrlHelp, 0, Qt::AlignRight ); + if (mUrlHelp) { + mTopLayout->addWidget(mUrlHelp, 0, Qt::AlignRight); + } - if ( mMainWidget ) - mTopLayout->addWidget( mMainWidget, 10 ); + if (mMainWidget) { + mTopLayout->addWidget(mMainWidget, 10); + } - if ( mDetailsWidget ) - mTopLayout->addWidget( mDetailsWidget ); + if (mDetailsWidget) { + mTopLayout->addWidget(mDetailsWidget); + } - if ( mActionSeparator ) - mTopLayout->addWidget( mActionSeparator ); + if (mActionSeparator) { + mTopLayout->addWidget(mActionSeparator); + } - if ( mButtonBox ) { - mButtonBox->setOrientation( mButtonOrientation ); - mTopLayout->addWidget( mButtonBox ); - } + if (mButtonBox) { + mButtonBox->setOrientation(mButtonOrientation); + mTopLayout->addWidget(mButtonBox); + } if (focusWidget) { focusWidget->setFocus(); @@ -112,54 +118,54 @@ void KDialogPrivate::appendButton(KDialog::ButtonCode key, const KGuiItem &item) { Q_Q(KDialog); - QDialogButtonBox::ButtonRole role = QDialogButtonBox::InvalidRole; - switch ( key ) { - case KDialog::Help: - case KDialog::Details: - role = QDialogButtonBox::HelpRole; - break; - case KDialog::Default: - case KDialog::Reset: - role = QDialogButtonBox::ResetRole; - break; - case KDialog::Ok: - role = QDialogButtonBox::AcceptRole; - break; - case KDialog::Apply: - role = QDialogButtonBox::ApplyRole; - break; - case KDialog::Try: - case KDialog::Yes: - role = QDialogButtonBox::YesRole; - break; - case KDialog::Close: - case KDialog::Cancel: - role = QDialogButtonBox::RejectRole; - break; - case KDialog::No: - role = QDialogButtonBox::NoRole; - break; - case KDialog::User1: - case KDialog::User2: - case KDialog::User3: - role = QDialogButtonBox::ActionRole; - break; - default: - role = QDialogButtonBox::InvalidRole; - break; - } + QDialogButtonBox::ButtonRole role = QDialogButtonBox::InvalidRole; + switch (key) { + case KDialog::Help: + case KDialog::Details: + role = QDialogButtonBox::HelpRole; + break; + case KDialog::Default: + case KDialog::Reset: + role = QDialogButtonBox::ResetRole; + break; + case KDialog::Ok: + role = QDialogButtonBox::AcceptRole; + break; + case KDialog::Apply: + role = QDialogButtonBox::ApplyRole; + break; + case KDialog::Try: + case KDialog::Yes: + role = QDialogButtonBox::YesRole; + break; + case KDialog::Close: + case KDialog::Cancel: + role = QDialogButtonBox::RejectRole; + break; + case KDialog::No: + role = QDialogButtonBox::NoRole; + break; + case KDialog::User1: + case KDialog::User2: + case KDialog::User3: + role = QDialogButtonBox::ActionRole; + break; + default: + role = QDialogButtonBox::InvalidRole; + break; + } - if ( role == QDialogButtonBox::InvalidRole ) - return; + if (role == QDialogButtonBox::InvalidRole) { + return; + } - KPushButton *button = new KPushButton( item ); - mButtonBox->addButton( button, role ); + KPushButton *button = new KPushButton(item); + mButtonBox->addButton(button, role); - mButtonList.insert( key, button ); - mButtonSignalMapper.setMapping( button, key ); + mButtonList.insert(key, button); + mButtonSignalMapper.setMapping(button, key); - QObject::connect(button, SIGNAL(clicked()), - &mButtonSignalMapper, SLOT(map()) ); + QObject::connect(button, SIGNAL(clicked()), &mButtonSignalMapper, SLOT(map())); if (key == mDefaultButton) { // Now that it exists, set it as default @@ -186,14 +192,16 @@ void KDialogPrivate::helpLinkClicked() q_ptr->slotButtonClicked(KDialog::Help); } -KDialog::KDialog( QWidget *parent, Qt::WindowFlags flags ) - : QDialog(parent, sAllowEmbeddingInGraphicsView ? flags : flags | Qt::BypassGraphicsProxyWidget ), d_ptr(new KDialogPrivate) +KDialog::KDialog(QWidget *parent, Qt::WindowFlags flags) + : QDialog(parent, sAllowEmbeddingInGraphicsView ? flags : flags | Qt::BypassGraphicsProxyWidget ), + d_ptr(new KDialogPrivate()) { d_ptr->init(this); } KDialog::KDialog(KDialogPrivate &dd, QWidget *parent, Qt::WindowFlags flags) - : QDialog(parent, sAllowEmbeddingInGraphicsView ? flags : flags | Qt::BypassGraphicsProxyWidget), d_ptr(&dd) + : QDialog(parent, sAllowEmbeddingInGraphicsView ? flags : flags | Qt::BypassGraphicsProxyWidget), + d_ptr(&dd) { d_ptr->init(this); } @@ -203,99 +211,115 @@ KDialog::~KDialog() delete d_ptr; } -void KDialog::setButtons( ButtonCodes buttonMask ) +void KDialog::setButtons(ButtonCodes buttonMask) { Q_D(KDialog); - if ( d->mButtonBox ) { - d->mButtonList.clear(); + if (d->mButtonBox) { + d->mButtonList.clear(); - delete d->mButtonBox; - d->mButtonBox = 0; - } + delete d->mButtonBox; + d->mButtonBox = 0; + } - if ( buttonMask & Cancel ) - buttonMask &= ~Close; + if (buttonMask & KDialog::Cancel) + buttonMask &= ~KDialog::Close; - if ( buttonMask & Apply ) - buttonMask &= ~Try; + if (buttonMask & KDialog::Apply) + buttonMask &= ~KDialog::Try; - if ( buttonMask & Details ) - buttonMask &= ~Default; + if (buttonMask & KDialog::Details) + buttonMask &= ~KDialog::Default; + + if (buttonMask == KDialog::None) { + d->setupLayout(); + return; // When we want no button box + } + + d->mEscapeButton = (buttonMask & KDialog::Cancel) ? KDialog::Cancel : KDialog::Close; + d->mButtonBox = new QDialogButtonBox(this); + + if (buttonMask & KDialog::Help) { + d->appendButton(KDialog::Help, KStandardGuiItem::help()); + } + if (buttonMask & KDialog::Default) { + d->appendButton(KDialog::Default, KStandardGuiItem::defaults()); + } + if (buttonMask & KDialog::Reset) { + d->appendButton(KDialog::Reset, KStandardGuiItem::reset()); + } + if (buttonMask & KDialog::User3) { + d->appendButton(KDialog::User3, KGuiItem()); + } + if (buttonMask & KDialog::User2) { + d->appendButton(KDialog::User2, KGuiItem()); + } + if (buttonMask & KDialog::User1) { + d->appendButton(KDialog::User1, KGuiItem()); + } + if (buttonMask & KDialog::Ok) { + d->appendButton(KDialog::Ok, KStandardGuiItem::ok()); + } + if (buttonMask & KDialog::Apply) { + d->appendButton(KDialog::Apply, KStandardGuiItem::apply()); + } + if (buttonMask & KDialog::Try) { + d->appendButton(KDialog::Try, KGuiItem(i18n("&Try"))); + } + if (buttonMask & KDialog::Cancel) { + d->appendButton(KDialog::Cancel, KStandardGuiItem::cancel()); + } + if (buttonMask & KDialog::Close) { + d->appendButton(KDialog::Close, KStandardGuiItem::close()); + } + if (buttonMask & KDialog::Yes) { + d->appendButton(KDialog::Yes, KStandardGuiItem::yes()); + } + if (buttonMask & KDialog::No) { + d->appendButton(KDialog::No, KStandardGuiItem::no()); + } + if (buttonMask & KDialog::Details) { + d->appendButton(KDialog::Details, KGuiItem(QString(), "help-about")); + setDetailsWidgetVisible(false); + } - if ( buttonMask == None ) { d->setupLayout(); - return; // When we want no button box - } - - d->mEscapeButton = (buttonMask & Cancel) ? Cancel : Close; - d->mButtonBox = new QDialogButtonBox( this ); - - if ( buttonMask & Help ) - d->appendButton( Help, KStandardGuiItem::help() ); - if ( buttonMask & Default ) - d->appendButton( Default, KStandardGuiItem::defaults() ); - if ( buttonMask & Reset ) - d->appendButton( Reset, KStandardGuiItem::reset() ); - if ( buttonMask & User3 ) - d->appendButton( User3, KGuiItem() ); - if ( buttonMask & User2 ) - d->appendButton( User2, KGuiItem() ); - if ( buttonMask & User1 ) - d->appendButton( User1, KGuiItem() ); - if ( buttonMask & Ok ) - d->appendButton( Ok, KStandardGuiItem::ok() ); - if ( buttonMask & Apply ) - d->appendButton( Apply, KStandardGuiItem::apply() ); - if ( buttonMask & Try ) - d->appendButton( Try, KGuiItem(i18n( "&Try" )) ); - if ( buttonMask & Cancel ) - d->appendButton( Cancel, KStandardGuiItem::cancel() ); - if ( buttonMask & Close ) - d->appendButton( Close, KStandardGuiItem::close() ); - if ( buttonMask & Yes ) - d->appendButton( Yes, KStandardGuiItem::yes() ); - if ( buttonMask & No ) - d->appendButton( No, KStandardGuiItem::no() ); - if ( buttonMask & Details ) { - d->appendButton( Details, KGuiItem(QString(), "help-about") ); - setDetailsWidgetVisible( false ); - } - - d->setupLayout(); } -void KDialog::setButtonsOrientation( Qt::Orientation orientation ) +void KDialog::setButtonsOrientation(Qt::Orientation orientation) { Q_D(KDialog); - if ( d->mButtonOrientation != orientation ) { - d->mButtonOrientation = orientation; + if (d->mButtonOrientation != orientation) { + d->mButtonOrientation = orientation; - if ( d->mActionSeparator ) - d->mActionSeparator->setOrientation( d->mButtonOrientation ); + if (d->mActionSeparator) { + d->mActionSeparator->setOrientation(d->mButtonOrientation); + } - if ( d->mButtonOrientation == Qt::Vertical ) - enableLinkedHelp( false ); // 2000-06-18 Espen: No support for this yet. - } + if (d->mButtonOrientation == Qt::Vertical) { + enableLinkedHelp(false); // 2000-06-18 Espen: No support for this yet. + } + } } -void KDialog::setEscapeButton( ButtonCode id ) +void KDialog::setEscapeButton(ButtonCode id) { d_func()->mEscapeButton = id; } -void KDialog::setDefaultButton( ButtonCode newDefaultButton ) +void KDialog::setDefaultButton(ButtonCode newDefaultButton) { Q_D(KDialog); - if (newDefaultButton == None) - newDefaultButton = NoDefault; // #148969 + if (newDefaultButton == KDialog::None) { + newDefaultButton = KDialog::NoDefault; // #148969 + } const KDialog::ButtonCode oldDefault = defaultButton(); bool oldDefaultHadFocus = false; - if (oldDefault != NoDefault) { + if (oldDefault != KDialog::NoDefault) { KPushButton *old = button(oldDefault); if (old) { oldDefaultHadFocus = (focusWidget() == old); @@ -303,7 +327,7 @@ void KDialog::setDefaultButton( ButtonCode newDefaultButton ) } } - if (newDefaultButton != NoDefault) { + if (newDefaultButton != KDialog::NoDefault) { KPushButton *b = button(newDefaultButton); if (b) { b->setDefault(true); @@ -324,22 +348,23 @@ void KDialog::setDefaultButton( ButtonCode newDefaultButton ) KDialog::ButtonCode KDialog::defaultButton() const { Q_D(const KDialog); - QHashIterator it( d->mButtonList ); - while ( it.hasNext() ) { - it.next(); - if (it.value()->isDefault()) { - return (ButtonCode)it.key(); + QHashIterator it(d->mButtonList); + while (it.hasNext()) { + it.next(); + if (it.value()->isDefault()) { + return static_cast(it.key()); + } } - } return d->mDefaultButton; } -void KDialog::setMainWidget( QWidget *widget ) +void KDialog::setMainWidget(QWidget *widget) { Q_D(KDialog); - if ( d->mMainWidget == widget ) + if (d->mMainWidget == widget) { return; + } d->mMainWidget = widget; if (d->mMainWidget && d->mMainWidget->layout()) { // Avoid double-margin problem @@ -351,87 +376,84 @@ void KDialog::setMainWidget( QWidget *widget ) QWidget *KDialog::mainWidget() { Q_D(KDialog); - if (!d->mMainWidget) - setMainWidget( new QWidget(this) ); + if (!d->mMainWidget) { + setMainWidget(new QWidget(this)); + } return d->mMainWidget; } QSize KDialog::sizeHint() const { Q_D(const KDialog); - - if (!d->mMinSize.isEmpty()) + if (!d->mMinSize.isEmpty()) { return d->mMinSize.expandedTo( minimumSizeHint() ) + d->mIncSize; - else { - if (d->dirty) - const_cast(d)->queuedLayoutUpdate(); - return QDialog::sizeHint() + d->mIncSize; } + if (d->dirty) { + const_cast(d)->queuedLayoutUpdate(); + } + return QDialog::sizeHint() + d->mIncSize; } QSize KDialog::minimumSizeHint() const { Q_D(const KDialog); - - if (d->dirty) + if (d->dirty) { const_cast(d)->queuedLayoutUpdate(); + } return QDialog::minimumSizeHint() + d->mIncSize; } // // Grab QDialogs keypresses if non-modal. // -void KDialog::keyPressEvent( QKeyEvent *event ) +void KDialog::keyPressEvent(QKeyEvent *event) { Q_D(KDialog); - if ( event->modifiers() == 0 ) { - if ( event->key() == Qt::Key_F1 ) { - KPushButton *button = this->button( Help ); + if (event->modifiers() == 0) { + if (event->key() == Qt::Key_F1) { + KPushButton *button = this->button(KDialog::Help); + if (button) { + button->animateClick(); + event->accept(); + return; + } + } - if ( button ) { - button->animateClick(); + if (event->key() == Qt::Key_Escape) { + KPushButton *button = this->button(d->mEscapeButton); + if (button) { + button->animateClick(); + event->accept(); + return; + } + } + } else if (event->key() == Qt::Key_F1 && event->modifiers() == Qt::ShiftModifier) { + QWhatsThis::enterWhatsThisMode(); event->accept(); return; - } + } else if (event->modifiers() == Qt::ControlModifier && + (event->key() == Qt::Key_Return || event->key() == Qt::Key_Enter)) + { + // accept the dialog when Ctrl-Return is pressed + KPushButton *button = this->button(KDialog::Ok); + if (button) { + button->animateClick(); + event->accept(); + return; + } } - if ( event->key() == Qt::Key_Escape ) { - KPushButton *button = this->button( d->mEscapeButton ); - - if ( button ) { - button->animateClick(); - event->accept(); - return; - } - - } - } else if ( event->key() == Qt::Key_F1 && event->modifiers() == Qt::ShiftModifier ) { - QWhatsThis::enterWhatsThisMode(); - event->accept(); - return; - } else if ( event->modifiers() == Qt::ControlModifier && - ( event->key() == Qt::Key_Return || event->key() == Qt::Key_Enter ) ) { - // accept the dialog when Ctrl-Return is pressed - KPushButton *button = this->button( Ok ); - - if ( button ) { - button->animateClick(); - event->accept(); - return; - } - } - - QDialog::keyPressEvent( event ); + QDialog::keyPressEvent(event); } int KDialog::marginHint() { - return QApplication::style()->pixelMetric( QStyle::PM_DefaultChildMargin ); + return QApplication::style()->pixelMetric(QStyle::PM_DefaultChildMargin); } int KDialog::spacingHint() { - return QApplication::style()->pixelMetric( QStyle::PM_DefaultLayoutSpacing ); + return QApplication::style()->pixelMetric(QStyle::PM_DefaultLayoutSpacing); } int KDialog::groupSpacingHint() @@ -439,49 +461,44 @@ int KDialog::groupSpacingHint() return QApplication::fontMetrics().lineSpacing(); } -QString KDialog::makeStandardCaption( const QString &userCaption, - QWidget* window, - CaptionFlags flags ) +QString KDialog::makeStandardCaption(const QString &userCaption, + QWidget* window, + CaptionFlags flags) { - Q_UNUSED(window); - QString caption = KGlobal::caption(); - QString captionString = userCaption.isEmpty() ? caption : userCaption; + Q_UNUSED(window); + QString caption = KGlobal::caption(); + QString captionString = userCaption.isEmpty() ? caption : userCaption; - // If the document is modified, add '[modified]'. - if (flags & ModifiedCaption) - captionString += QString::fromUtf8(" [") + i18n("modified") + QString::fromUtf8("]"); + // If the document is modified, add '[modified]'. + if (flags & KDialog::ModifiedCaption) { + captionString += QString::fromUtf8(" [") + i18n("modified") + QString::fromUtf8("]"); + } - if ( !userCaption.isEmpty() ) { - // Add the application name if: - // User asked for it, it's not a duplication and the app name (caption()) is not empty - if ( flags & AppNameCaption && - !caption.isEmpty() && - !userCaption.endsWith(caption) ) { + if (!userCaption.isEmpty()) { + // Add the application name if: + // User asked for it, it's not a duplication and the app name (caption()) is not empty + if ( flags & AppNameCaption && !caption.isEmpty() && !userCaption.endsWith(caption)) { // TODO: check to see if this is a transient/secondary window before trying to add the app name // on platforms that need this captionString += i18nc("Document/application separator in titlebar", " – ") + caption; - } - } - - return captionString; -} - -void KDialog::setCaption( const QString &_caption ) -{ - const QString caption = makeStandardCaption( _caption, this ); - setWindowTitle( caption ); -} - -void KDialog::setCaption( const QString &caption, bool modified ) -{ - CaptionFlags flags = HIGCompliantCaption; - - if ( modified ) - { - flags |= ModifiedCaption; + } } - setWindowTitle( makeStandardCaption(caption, this, flags) ); + return captionString; +} + +void KDialog::setCaption(const QString &caption) +{ + setWindowTitle(makeStandardCaption(caption, this)); +} + +void KDialog::setCaption(const QString &caption, bool modified) +{ + CaptionFlags flags = HIGCompliantCaption; + if (modified) { + flags |= ModifiedCaption; + } + setWindowTitle(makeStandardCaption(caption, this, flags)); } static QRect screenRect( QWidget *widget, int screen ) diff --git a/kdeui/dialogs/kdialog.h b/kdeui/dialogs/kdialog.h index b0387679..678602c7 100644 --- a/kdeui/dialogs/kdialog.h +++ b/kdeui/dialogs/kdialog.h @@ -97,15 +97,15 @@ class KDialogPrivate; * Example:\n * * \code - * KDialog *dialog = new KDialog( this ); - * dialog->setCaption( "My title" ); - * dialog->setButtons( KDialog::Ok | KDialog::Cancel | KDialog::Apply ); + * KDialog *dialog = new KDialog(this); + * dialog->setCaption("My title"); + * dialog->setButtons(KDialog::Ok | KDialog::Cancel | KDialog::Apply); * - * FooWidget *widget = new FooWidget( dialog ); - * dialog->setMainWidget( widget ); - * connect( dialog, SIGNAL( applyClicked() ), widget, SLOT( save() ) ); - * connect( dialog, SIGNAL( okClicked() ), widget, SLOT( save() ) ); - * connect( widget, SIGNAL( changed( bool ) ), dialog, SLOT( enableButtonApply( bool ) ) ); + * FooWidget *widget = new FooWidget(dialog); + * dialog->setMainWidget(widget); + * connect(dialog, SIGNAL(applyClicked()), widget, SLOT(save())); + * connect(dialog, SIGNAL(okClicked()), widget, SLOT(save())); + * connect(widget, SIGNAL(changed(bool)), dialog, SLOT(enableButtonApply(bool))); * * dialog->enableButtonApply( false ); * dialog->show(); @@ -127,49 +127,47 @@ class KDialogPrivate; */ class KDEUI_EXPORT KDialog : public QDialog { - Q_OBJECT - Q_ENUMS(ButtonCode) + Q_OBJECT + Q_ENUMS(ButtonCode) Q_DECLARE_PRIVATE(KDialog) - - public: - +public: enum ButtonCode { - None = 0x00000000, - Help = 0x00000001, ///< Show Help button. (this button will run the help set with setHelp) - Default = 0x00000002, ///< Show Default button. - Ok = 0x00000004, ///< Show Ok button. (this button accept()s the dialog; result set to QDialog::Accepted) - Apply = 0x00000008, ///< Show Apply button. - Try = 0x00000010, ///< Show Try button. - Cancel = 0x00000020, ///< Show Cancel-button. (this button reject()s the dialog; result set to QDialog::Rejected) - Close = 0x00000040, ///< Show Close-button. (this button closes the dialog) - No = 0x00000080, ///< Show No button. (this button closes the dialog and sets the result to KDialog::No) - Yes = 0x00000100, ///< Show Yes button. (this button closes the dialog and sets the result to KDialog::Yes) - Reset = 0x00000200, ///< Show Reset button - Details = 0x00000400, ///< Show Details button. (this button will show the detail widget set with setDetailsWidget) - User1 = 0x00001000, ///< Show User defined button 1. - User2 = 0x00002000, ///< Show User defined button 2. - User3 = 0x00004000, ///< Show User defined button 3. - NoDefault = 0x00008000 ///< Used when specifying a default button; indicates that no button should be marked by default. + None = 0x00000000, + Help = 0x00000001, ///< Show Help button. (this button will run the help set with setHelp) + Default = 0x00000002, ///< Show Default button. + Ok = 0x00000004, ///< Show Ok button. (this button accept()s the dialog; result set to QDialog::Accepted) + Apply = 0x00000008, ///< Show Apply button. + Try = 0x00000010, ///< Show Try button. + Cancel = 0x00000020, ///< Show Cancel-button. (this button reject()s the dialog; result set to QDialog::Rejected) + Close = 0x00000040, ///< Show Close-button. (this button closes the dialog) + No = 0x00000080, ///< Show No button. (this button closes the dialog and sets the result to KDialog::No) + Yes = 0x00000100, ///< Show Yes button. (this button closes the dialog and sets the result to KDialog::Yes) + Reset = 0x00000200, ///< Show Reset button + Details = 0x00000400, ///< Show Details button. (this button will show the detail widget set with setDetailsWidget) + User1 = 0x00001000, ///< Show User defined button 1. + User2 = 0x00002000, ///< Show User defined button 2. + User3 = 0x00004000, ///< Show User defined button 3. + NoDefault = 0x00008000 ///< Used when specifying a default button; indicates that no button should be marked by default. }; // TODO KDE5: remove NoDefault and use the value None instead Q_DECLARE_FLAGS(ButtonCodes, ButtonCode) enum ButtonPopupMode { - InstantPopup = 0, - DelayedPopup = 1 + InstantPopup = 0, + DelayedPopup = 1 }; Q_DECLARE_FLAGS(ButtonPopupModes, ButtonPopupMode) - public: +public: /** * Creates a dialog. * * @param parent The parent of the dialog. * @param flags The widget flags passed to the QDialog constructor */ - explicit KDialog( QWidget *parent = 0, Qt::WindowFlags flags = 0 ); + explicit KDialog(QWidget *parent = nullptr, Qt::WindowFlags flags = 0); /** * Destroys the dialog. @@ -189,7 +187,7 @@ class KDEUI_EXPORT KDialog : public QDialog * * @param buttonMask Specifies what buttons will be made. */ - void setButtons( ButtonCodes buttonMask ); + void setButtons(ButtonCodes buttonMask); /** * Sets the orientation of the button box. @@ -201,7 +199,7 @@ class KDEUI_EXPORT KDialog : public QDialog * * @param orientation The button box orientation. */ - void setButtonsOrientation( Qt::Orientation orientation ); + void setButtonsOrientation(Qt::Orientation orientation); /** * Sets the button that will be activated when the Escape key @@ -213,7 +211,7 @@ class KDEUI_EXPORT KDialog : public QDialog * * @param id The button code. */ - void setEscapeButton( ButtonCode id ); + void setEscapeButton(ButtonCode id); /** * Sets the button that will be activated when the Enter key @@ -223,7 +221,7 @@ class KDEUI_EXPORT KDialog : public QDialog * * @param id The button code. */ - void setDefaultButton( ButtonCode id ); + void setDefaultButton(ButtonCode id); /** * Returns the button code of the default button, @@ -235,7 +233,7 @@ class KDEUI_EXPORT KDialog : public QDialog * Hide or display the separator line drawn between the action * buttons an the main widget. */ - void showButtonSeparator( bool state ); + void showButtonSeparator(bool state); /** * Hide or display a general action button. @@ -247,7 +245,7 @@ class KDEUI_EXPORT KDialog : public QDialog * @param id Button identifier. * @param state true display the button(s). */ - void showButton( ButtonCode id, bool state ); + void showButton(ButtonCode id, bool state); /** * Sets the text of any button. @@ -255,12 +253,12 @@ class KDEUI_EXPORT KDialog : public QDialog * @param id The button identifier. * @param text Button text. */ - void setButtonText( ButtonCode id, const QString &text ); + void setButtonText(ButtonCode id, const QString &text); /** * Returns the text of any button. */ - QString buttonText( ButtonCode id ) const; + QString buttonText(ButtonCode id) const; /** * Sets the icon of any button. @@ -268,12 +266,12 @@ class KDEUI_EXPORT KDialog : public QDialog * @param id The button identifier. * @param icon Button icon. */ - void setButtonIcon( ButtonCode id, const KIcon &icon ); + void setButtonIcon(ButtonCode id, const KIcon &icon); /** * Returns the icon of any button. */ - KIcon buttonIcon( ButtonCode id ) const; + KIcon buttonIcon(ButtonCode id) const; /** * Sets the tooltip text of any button. @@ -281,12 +279,12 @@ class KDEUI_EXPORT KDialog : public QDialog * @param id The button identifier. * @param text Button text. */ - void setButtonToolTip( ButtonCode id, const QString &text ); + void setButtonToolTip(ButtonCode id, const QString &text); /** * Returns the tooltip of any button. */ - QString buttonToolTip( ButtonCode id ) const; + QString buttonToolTip(ButtonCode id) const; /** * Sets the "What's this?" text of any button. @@ -294,12 +292,12 @@ class KDEUI_EXPORT KDialog : public QDialog * @param id The button identifier. * @param text Button text. */ - void setButtonWhatsThis( ButtonCode id, const QString &text ); + void setButtonWhatsThis(ButtonCode id, const QString &text); /** * Returns the "What's this?" text of any button. */ - QString buttonWhatsThis( ButtonCode id ) const; + QString buttonWhatsThis(ButtonCode id) const; /** * Sets the KGuiItem directly for the button instead of using 3 methods to @@ -310,7 +308,7 @@ class KDEUI_EXPORT KDialog : public QDialog * @param id The button identifier. * @param item The KGuiItem for the button. */ - void setButtonGuiItem( ButtonCode id, const KGuiItem &item ); + void setButtonGuiItem(ButtonCode id, const KGuiItem &item); /** * Sets the menu of any button. @@ -319,12 +317,12 @@ class KDEUI_EXPORT KDialog : public QDialog * @param menu The menu. * @param popupmode Choose if KPushButton setMenu or setDelayedMenu is used */ - void setButtonMenu( ButtonCode id, QMenu *menu, ButtonPopupMode popupmode=InstantPopup); + void setButtonMenu(ButtonCode id, QMenu *menu, ButtonPopupMode popupmode = InstantPopup); /** * Sets the focus to the button of the passed @p id. */ - void setButtonFocus( ButtonCode id ); + void setButtonFocus(ButtonCode id); /** * Convenience method. Sets the initial dialog size. @@ -335,7 +333,7 @@ class KDEUI_EXPORT KDialog : public QDialog * * @param size Startup size. */ - void setInitialSize( const QSize &size ); + void setInitialSize(const QSize &size); /** * Convenience method. Add a size to the default minimum size of a @@ -345,7 +343,7 @@ class KDEUI_EXPORT KDialog : public QDialog * * @param size Size added to minimum size. */ - void incrementInitialSize( const QSize &size ); + void incrementInitialSize(const QSize &size); /** * Restores the dialog's size from the configuration according to @@ -355,7 +353,7 @@ class KDEUI_EXPORT KDialog : public QDialog * * @param config The config group to read from. */ - void restoreDialogSize( const KConfigGroup& config ) ; + void restoreDialogSize(const KConfigGroup &config); /** * Saves the dialog's size dependent on the screen dimension either to the @@ -366,7 +364,7 @@ class KDEUI_EXPORT KDialog : public QDialog * @param config The config group to read from. * @param options passed to KConfigGroup::writeEntry() */ - void saveDialogSize( KConfigGroup& config, KConfigGroup::WriteConfigFlags options = KConfigGroup::Normal ) const; + void saveDialogSize(KConfigGroup &config, KConfigGroup::WriteConfigFlags options = KConfigGroup::Normal) const; /** * Returns the help link text. @@ -385,7 +383,7 @@ class KDEUI_EXPORT KDialog : public QDialog /** * Returns whether any button is enabled. */ - bool isButtonEnabled( ButtonCode id ) const; + bool isButtonEnabled(ButtonCode id) const; /** * Returns the button that corresponds to the @p id. @@ -397,7 +395,7 @@ class KDEUI_EXPORT KDialog : public QDialog * @param id Identifier of the button. * @return The button or 0 if the button does not exist. */ - KPushButton* button( ButtonCode id ) const; + KPushButton* button(ButtonCode id) const; /** * Returns the number of pixels that should be used between a @@ -466,9 +464,9 @@ class KDEUI_EXPORT KDialog : public QDialog * @param flags * @return the created caption */ - static QString makeStandardCaption( const QString &userCaption, - QWidget* window = 0, - CaptionFlags flags = HIGCompliantCaption ); + static QString makeStandardCaption(const QString &userCaption, + QWidget* window = nullptr, + CaptionFlags flags = HIGCompliantCaption); /** * Centers @p widget on the desktop, taking multi-head setups into @@ -479,7 +477,7 @@ class KDEUI_EXPORT KDialog : public QDialog * @p screen will be ignored if a merged display (like Xinerama) is not * in use, or merged display placement is not enabled in kdeglobals. */ - static void centerOnScreen( QWidget *widget, int screen = -1 ); + static void centerOnScreen(QWidget *widget, int screen = -1); /** * Places @p widget so that it doesn't cover a certain @p area of the screen. @@ -489,12 +487,12 @@ class KDEUI_EXPORT KDialog : public QDialog * @return true on success (widget doesn't cover area anymore, or never did), * false on failure (not enough space found) */ - static bool avoidArea( QWidget *widget, const QRect& area, int screen = -1 ); + static bool avoidArea(QWidget *widget, const QRect& area, int screen = -1); /** * Sets the main widget of the dialog. */ - void setMainWidget( QWidget *widget ); + void setMainWidget(QWidget *widget); /** * @return The current main widget. Will create a QWidget as the mainWidget @@ -521,9 +519,9 @@ class KDEUI_EXPORT KDialog : public QDialog * will appear as separate windows. * @since 4.6 */ - static void setAllowEmbeddingInGraphicsView( bool allowEmbedding ); + static void setAllowEmbeddingInGraphicsView(bool allowEmbedding); - public Q_SLOTS: +public Q_SLOTS: /** * Make a KDE compliant caption. * @@ -531,7 +529,7 @@ class KDEUI_EXPORT KDialog : public QDialog * in this string. It will be added automatically according to the KDE * standard. */ - virtual void setCaption( const QString &caption ); + virtual void setCaption(const QString &caption); /** * Makes a KDE compliant caption. @@ -542,7 +540,7 @@ class KDEUI_EXPORT KDialog : public QDialog * @param modified Specify whether the document is modified. This displays * an additional sign in the title bar, usually "**". */ - virtual void setCaption( const QString &caption, bool modified ); + virtual void setCaption(const QString &caption, bool modified); /** * Enable or disable (gray out) a general action button. @@ -550,28 +548,28 @@ class KDEUI_EXPORT KDialog : public QDialog * @param id Button identifier. * @param state @p true enables the button(s). */ - void enableButton( ButtonCode id, bool state ); + void enableButton(ButtonCode id, bool state); /** * Enable or disable (gray out) the OK button. * * @param state @p true enables the button. */ - void enableButtonOk( bool state ); + void enableButtonOk(bool state); /** * Enable or disable (gray out) the Apply button. * * @param state true enables the button. */ - void enableButtonApply( bool state ); + void enableButtonApply(bool state); /** * Enable or disable (gray out) the Cancel button. * * @param state true enables the button. */ - void enableButtonCancel( bool state ); + void enableButtonCancel(bool state); /** * Display or hide the help link area on the top of the dialog. @@ -582,7 +580,7 @@ class KDEUI_EXPORT KDialog : public QDialog * @see setHelpLinkText() * @see setHelp() */ - void enableLinkedHelp( bool state ); + void enableLinkedHelp(bool state); /** * Sets the text that is shown as the linked text. @@ -596,7 +594,7 @@ class KDEUI_EXPORT KDialog : public QDialog * @see enableLinkedHelp() * @see setHelp() */ - void setHelpLinkText( const QString &text ); + void setHelpLinkText(const QString &text); /** * Sets the help path and topic. @@ -610,7 +608,7 @@ class KDEUI_EXPORT KDialog : public QDialog * function for Dialogs of that type. See * KCMultiDialog::slotHelp() for more information. */ - void setHelp( const QString &anchor, const QString &appname = QString() ); + void setHelp(const QString &anchor, const QString &appname = QString()); /** * Returns the status of the Details button. @@ -620,7 +618,7 @@ class KDEUI_EXPORT KDialog : public QDialog /** * Sets the status of the Details button. */ - void setDetailsWidgetVisible( bool visible ); + void setDetailsWidgetVisible(bool visible); /** * Sets the widget that gets shown when "Details" is enabled. @@ -628,7 +626,7 @@ class KDEUI_EXPORT KDialog : public QDialog * The dialog takes over ownership of the widget. * Any previously set widget gets deleted. */ - void setDetailsWidget( QWidget *detailsWidget ); + void setDetailsWidget(QWidget *detailsWidget); /** * Destruct the dialog delayed. @@ -638,7 +636,7 @@ class KDEUI_EXPORT KDialog : public QDialog */ void delayedDestruct(); - Q_SIGNALS: +Q_SIGNALS: /** * The Help button was pressed. This signal is only emitted if * slotButtonClicked() is not replaced @@ -722,7 +720,7 @@ class KDEUI_EXPORT KDialog : public QDialog * slotButtonClicked() is not replaced * @param button is the code of the pressed button. */ - void buttonClicked( KDialog::ButtonCode button); + void buttonClicked(KDialog::ButtonCode button); /** * The dialog is about to be hidden. @@ -755,12 +753,12 @@ class KDEUI_EXPORT KDialog : public QDialog */ void aboutToShowDetails(); - protected: +protected: /** * Emits the #hidden signal. You can connect to that signal to * detect when a dialog has been closed. */ - virtual void hideEvent( QHideEvent * ); + virtual void hideEvent(QHideEvent *event); /** * Detects when a dialog is being closed from the window manager @@ -768,14 +766,14 @@ class KDEUI_EXPORT KDialog : public QDialog * is activated. Otherwise standard QDialog behavior * will take place. */ - virtual void closeEvent( QCloseEvent *e ); + virtual void closeEvent( QCloseEvent *event); /** * @internal */ - virtual void keyPressEvent( QKeyEvent* ); + virtual void keyPressEvent(QKeyEvent *event); - protected Q_SLOTS: +protected Q_SLOTS: /** * Activated when the button @p button is clicked * @@ -797,14 +795,14 @@ class KDEUI_EXPORT KDialog : public QDialog */ virtual void slotButtonClicked(int button); - protected: - KDialog(KDialogPrivate &dd, QWidget *parent, Qt::WindowFlags flags = 0); - KDialogPrivate *const d_ptr; +protected: + KDialog(KDialogPrivate &dd, QWidget *parent, Qt::WindowFlags flags = 0); + KDialogPrivate *const d_ptr; - private: - Q_DISABLE_COPY(KDialog) - Q_PRIVATE_SLOT(d_ptr, void queuedLayoutUpdate()) - Q_PRIVATE_SLOT(d_ptr, void helpLinkClicked()) +private: + Q_DISABLE_COPY(KDialog) + Q_PRIVATE_SLOT(d_ptr, void queuedLayoutUpdate()) + Q_PRIVATE_SLOT(d_ptr, void helpLinkClicked()) }; Q_DECLARE_OPERATORS_FOR_FLAGS(KDialog::ButtonCodes)