Krita Source Code Documentation
Loading...
Searching...
No Matches
KoDialogPrivate Class Reference

#include <KoDialog_p.h>

Protected Slots

void helpLinkClicked ()
 
void queuedLayoutUpdate ()
 

Protected Member Functions

void appendButton (KoDialog::ButtonCode code, const KGuiItem &item)
 
 KoDialogPrivate ()
 
void setupLayout ()
 
virtual ~KoDialogPrivate ()
 

Protected Attributes

KSeparator * mActionSeparator {nullptr}
 
QString mAnchor
 
QDialogButtonBox * mButtonBox {nullptr}
 
QHash< int, QPushButton * > mButtonList
 
Qt::Orientation mButtonOrientation
 
KoDialog::ButtonCode mDefaultButton {KoDialog::NoDefault}
 
bool mDeferredDelete {false}
 
QString mDetailsButtonText
 
bool mDetailsVisible {false}
 
QWidget * mDetailsWidget {nullptr}
 
KoDialog::ButtonCode mEscapeButton {KoDialog::None}
 
QString mHelpApp
 
QString mHelpLinkText
 
QSize mIncSize
 
QPointer< QWidget > mMainWidget
 
QSize mMinSize
 
bool mSettingDetails {false}
 
QBoxLayout * mTopLayout {nullptr}
 
KUrlLabel * mUrlHelp {nullptr}
 
KoDialogq_ptr {nullptr}
 

Private Member Functions

void init (KoDialog *)
 

Private Attributes

bool dirty {false}
 

Detailed Description

Definition at line 23 of file KoDialog_p.h.

Constructor & Destructor Documentation

◆ KoDialogPrivate()

KoDialogPrivate::KoDialogPrivate ( )
inlineprotected

Definition at line 27 of file KoDialog_p.h.

28 : mDetailsVisible(false), mSettingDetails(false), mDeferredDelete(false),
31 mButtonOrientation(Qt::Horizontal),
33 mButtonBox(0)
34 {
35 }
KSeparator * mActionSeparator
Definition KoDialog_p.h:55
KoDialog::ButtonCode mDefaultButton
Definition KoDialog_p.h:62
KUrlLabel * mUrlHelp
Definition KoDialog_p.h:54
QWidget * mDetailsWidget
Definition KoDialog_p.h:47
QPointer< QWidget > mMainWidget
Definition KoDialog_p.h:53
Qt::Orientation mButtonOrientation
Definition KoDialog_p.h:61
QDialogButtonBox * mButtonBox
Definition KoDialog_p.h:65
QBoxLayout * mTopLayout
Definition KoDialog_p.h:52
@ NoDefault
Used when specifying a default button; indicates that no button should be marked by default.
Definition KoDialog.h:139

◆ ~KoDialogPrivate()

virtual KoDialogPrivate::~KoDialogPrivate ( )
inlineprotectedvirtual

Definition at line 37 of file KoDialog_p.h.

37{}

Member Function Documentation

◆ appendButton()

void KoDialogPrivate::appendButton ( KoDialog::ButtonCode code,
const KGuiItem & item )
protected

Definition at line 100 of file KoDialog.cpp.

101{
102 Q_Q(KoDialog);
103
104 QDialogButtonBox::ButtonRole role = QDialogButtonBox::InvalidRole;
105 switch (key) {
106 case KoDialog::Help:
108 role = QDialogButtonBox::HelpRole;
109 break;
111 case KoDialog::Reset:
112 role = QDialogButtonBox::ResetRole;
113 break;
114 case KoDialog::Ok:
115 role = QDialogButtonBox::AcceptRole;
116 break;
117 case KoDialog::Apply:
118 role = QDialogButtonBox::ApplyRole;
119 break;
120 case KoDialog::Try:
121 case KoDialog::Yes:
122 role = QDialogButtonBox::YesRole;
123 break;
124 case KoDialog::Close:
125 case KoDialog::Cancel:
126 role = QDialogButtonBox::RejectRole;
127 break;
128 case KoDialog::No:
129 role = QDialogButtonBox::NoRole;
130 break;
131 case KoDialog::User1:
132 case KoDialog::User2:
133 case KoDialog::User3:
134 role = QDialogButtonBox::ActionRole;
135 break;
136 default:
137 role = QDialogButtonBox::InvalidRole;
138 break;
139 }
140
141 if (role == QDialogButtonBox::InvalidRole) {
142 return;
143 }
144
145 QPushButton *button = new QPushButton;
146 KGuiItem::assign(button, item);
147 mButtonBox->addButton(button, role);
148
149 mButtonList.insert(key, button);
150
151 QObject::connect(button, &QPushButton::clicked, q, [=] { q->slotButtonClicked(key); });
152
153 if (key == mDefaultButton) {
154 // Now that it exists, set it as default
155 q->setDefaultButton(mDefaultButton);
156 }
157}
QHash< int, QPushButton * > mButtonList
Definition KoDialog_p.h:66
A dialog base class with standard buttons and predefined layouts.
Definition KoDialog.h:116
@ User2
Show User defined button 2.
Definition KoDialog.h:137
@ Ok
Show Ok button. (this button accept()s the dialog; result set to QDialog::Accepted)
Definition KoDialog.h:127
@ No
Show No button. (this button closes the dialog and sets the result to KoDialog::No)
Definition KoDialog.h:132
@ Reset
Show Reset button.
Definition KoDialog.h:134
@ Apply
Show Apply button.
Definition KoDialog.h:128
@ User3
Show User defined button 3.
Definition KoDialog.h:138
@ Yes
Show Yes button. (this button closes the dialog and sets the result to KoDialog::Yes)
Definition KoDialog.h:133
@ Default
Show Default button.
Definition KoDialog.h:126
@ User1
Show User defined button 1.
Definition KoDialog.h:136
@ Details
Show Details button. (this button will show the detail widget set with setDetailsWidget)
Definition KoDialog.h:135
@ Cancel
Show Cancel-button. (this button reject()s the dialog; result set to QDialog::Rejected)
Definition KoDialog.h:130
@ Help
Show Help button. (this button will run the help set with setHelp)
Definition KoDialog.h:125
@ Try
Show Try button.
Definition KoDialog.h:129
@ Close
Show Close-button. (this button closes the dialog)
Definition KoDialog.h:131
QString button(const QWheelEvent &ev)

References KoDialog::Apply, button(), KoDialog::Cancel, KoDialog::Close, KoDialog::Default, KoDialog::Details, KoDialog::Help, mButtonBox, mButtonList, mDefaultButton, KoDialog::No, KoDialog::Ok, KoDialog::Reset, KoDialog::Try, KoDialog::User1, KoDialog::User2, KoDialog::User3, and KoDialog::Yes.

◆ helpLinkClicked

void KoDialogPrivate::helpLinkClicked ( )
protectedslot

Definition at line 171 of file KoDialog.cpp.

172{
174}
KoDialog * q_ptr
Definition KoDialog_p.h:39
virtual void slotButtonClicked(int button)
Definition KoDialog.cpp:820

References KoDialog::Help, q_ptr, and KoDialog::slotButtonClicked().

◆ init()

void KoDialogPrivate::init ( KoDialog * q)
private

Definition at line 159 of file KoDialog.cpp.

160{
161 q_ptr = q;
162
163 dirty = false;
164
167
168 q->setPlainCaption(qApp->applicationDisplayName()); // set appropriate initial window title for case it gets not set later
169}
void setButtons(ButtonCodes buttonMask)
Definition KoDialog.cpp:195
virtual void setPlainCaption(const QString &caption)
Definition KoDialog.cpp:516
void setDefaultButton(ButtonCode id)
Definition KoDialog.cpp:302

References KoDialog::Cancel, dirty, KoDialog::Ok, q_ptr, KoDialog::setButtons(), KoDialog::setDefaultButton(), and KoDialog::setPlainCaption().

◆ queuedLayoutUpdate

void KoDialogPrivate::queuedLayoutUpdate ( )
protectedslot

Definition at line 47 of file KoDialog.cpp.

48{
49 if (!dirty) {
50 return;
51 }
52
53 dirty = false;
54
55 Q_Q(KoDialog);
56
57 // Don't lose the focus widget when re-creating the layout.
58 // Testcase: KOrganizer's "Select Categories" dialog
59 QPointer<QWidget> focusWidget = mMainWidget ? mMainWidget->focusWidget() : 0;
60
61 if (q->layout() && q->layout() != mTopLayout) {
62 qWarning() << q->metaObject()->className() << "created with a layout; don't do that, KoDialog takes care of it, use mainWidget or setMainWidget instead";
63 delete q->layout();
64 }
65
66 delete mTopLayout;
67
68 if (mButtonOrientation == Qt::Horizontal) {
69 mTopLayout = new QVBoxLayout(q);
70 } else {
71 mTopLayout = new QHBoxLayout(q);
72 }
73
74 if (mUrlHelp) {
75 mTopLayout->addWidget(mUrlHelp, 0, Qt::AlignRight);
76 }
77
78 if (mMainWidget) {
79 mTopLayout->addWidget(mMainWidget, 10);
80 }
81
82 if (mDetailsWidget) {
83 mTopLayout->addWidget(mDetailsWidget);
84 }
85
86 if (mActionSeparator) {
87 mTopLayout->addWidget(mActionSeparator);
88 }
89
90 if (mButtonBox) {
91 mButtonBox->setOrientation(mButtonOrientation);
92 mTopLayout->addWidget(mButtonBox);
93 }
94
95 if (focusWidget) {
96 focusWidget->setFocus();
97 }
98}

References dirty, mActionSeparator, mButtonBox, mButtonOrientation, mDetailsWidget, mMainWidget, mTopLayout, and mUrlHelp.

◆ setupLayout()

void KoDialogPrivate::setupLayout ( )
protected

Definition at line 38 of file KoDialog.cpp.

39{
40 Q_Q(KoDialog);
41 if (!dirty) {
42 QMetaObject::invokeMethod(q, "queuedLayoutUpdate", Qt::QueuedConnection);
43 dirty = true;
44 }
45}

References dirty.

Member Data Documentation

◆ dirty

bool KoDialogPrivate::dirty {false}
private

Definition at line 74 of file KoDialog_p.h.

74{false};

◆ mActionSeparator

KSeparator* KoDialogPrivate::mActionSeparator {nullptr}
protected

Definition at line 55 of file KoDialog_p.h.

55{nullptr};

◆ mAnchor

QString KoDialogPrivate::mAnchor
protected

Definition at line 57 of file KoDialog_p.h.

◆ mButtonBox

QDialogButtonBox* KoDialogPrivate::mButtonBox {nullptr}
protected

Definition at line 65 of file KoDialog_p.h.

65{nullptr};

◆ mButtonList

QHash<int, QPushButton *> KoDialogPrivate::mButtonList
protected

Definition at line 66 of file KoDialog_p.h.

◆ mButtonOrientation

Qt::Orientation KoDialogPrivate::mButtonOrientation
protected

Definition at line 61 of file KoDialog_p.h.

◆ mDefaultButton

KoDialog::ButtonCode KoDialogPrivate::mDefaultButton {KoDialog::NoDefault}
protected

Definition at line 62 of file KoDialog_p.h.

◆ mDeferredDelete

bool KoDialogPrivate::mDeferredDelete {false}
protected

Definition at line 46 of file KoDialog_p.h.

46{false};

◆ mDetailsButtonText

QString KoDialogPrivate::mDetailsButtonText
protected

Definition at line 50 of file KoDialog_p.h.

◆ mDetailsVisible

bool KoDialogPrivate::mDetailsVisible {false}
protected

Definition at line 44 of file KoDialog_p.h.

44{false};

◆ mDetailsWidget

QWidget* KoDialogPrivate::mDetailsWidget {nullptr}
protected

Definition at line 47 of file KoDialog_p.h.

47{nullptr};

◆ mEscapeButton

KoDialog::ButtonCode KoDialogPrivate::mEscapeButton {KoDialog::None}
protected

Definition at line 63 of file KoDialog_p.h.

◆ mHelpApp

QString KoDialogPrivate::mHelpApp
protected

Definition at line 58 of file KoDialog_p.h.

◆ mHelpLinkText

QString KoDialogPrivate::mHelpLinkText
protected

Definition at line 59 of file KoDialog_p.h.

◆ mIncSize

QSize KoDialogPrivate::mIncSize
protected

Definition at line 48 of file KoDialog_p.h.

◆ mMainWidget

QPointer<QWidget> KoDialogPrivate::mMainWidget
protected

Definition at line 53 of file KoDialog_p.h.

◆ mMinSize

QSize KoDialogPrivate::mMinSize
protected

Definition at line 49 of file KoDialog_p.h.

◆ mSettingDetails

bool KoDialogPrivate::mSettingDetails {false}
protected

Definition at line 45 of file KoDialog_p.h.

45{false};

◆ mTopLayout

QBoxLayout* KoDialogPrivate::mTopLayout {nullptr}
protected

Definition at line 52 of file KoDialog_p.h.

52{nullptr};

◆ mUrlHelp

KUrlLabel* KoDialogPrivate::mUrlHelp {nullptr}
protected

Definition at line 54 of file KoDialog_p.h.

54{nullptr};

◆ q_ptr

KoDialog* KoDialogPrivate::q_ptr {nullptr}
protected

Definition at line 39 of file KoDialog_p.h.

39{nullptr};

The documentation for this class was generated from the following files: