Commit 8acd4876 authored by David Jarvie's avatar David Jarvie
Browse files

Replace obsolete QStyle::PM_DefaultChildMargin

parent b132bc7f
Pipeline #24785 passed with stage
in 10 minutes and 41 seconds
......@@ -96,8 +96,11 @@ void AlarmTimeWidget::init(Mode mode, const QString& title)
connect(mButtonGroup, &ButtonGroup::buttonSet, this, &AlarmTimeWidget::slotButtonSet);
QVBoxLayout* topLayout = new QVBoxLayout(topWidget);
topLayout->setSpacing(style()->pixelMetric(QStyle::PM_LayoutVerticalSpacing));
int dcm = title.isEmpty() ? 0 : style()->pixelMetric(QStyle::PM_DefaultChildMargin);
topLayout->setContentsMargins(dcm, dcm, dcm, dcm);
const bool noTitle = title.isEmpty();
topLayout->setContentsMargins(noTitle ? 0 : style()->pixelMetric(QStyle::PM_LayoutLeftMargin),
noTitle ? 0 : style()->pixelMetric(QStyle::PM_LayoutTopMargin),
noTitle ? 0 : style()->pixelMetric(QStyle::PM_LayoutRightMargin),
noTitle ? 0 : style()->pixelMetric(QStyle::PM_LayoutBottomMargin));
// At time radio button/label
mAtTimeRadio = new RadioButton((mDeferring ? i18nc("@option:radio", "Defer to date/time:") : i18nc("@option:radio", "At date/time:")), topWidget);
......
......@@ -75,8 +75,11 @@ BirthdayDlg::BirthdayDlg(QWidget* parent)
QGroupBox* textGroup = new QGroupBox(i18nc("@title:group", "Alarm Text"), this);
topLayout->addWidget(textGroup);
QGridLayout* grid = new QGridLayout(textGroup);
int dcm = style()->pixelMetric(QStyle::PM_DefaultChildMargin);
grid->setContentsMargins(dcm, dcm, dcm, dcm);
const int dcmLeft = style()->pixelMetric(QStyle::PM_LayoutLeftMargin);
const int dcmTop = style()->pixelMetric(QStyle::PM_LayoutTopMargin);
const int dcmRight = style()->pixelMetric(QStyle::PM_LayoutRightMargin);
const int dcmBottom = style()->pixelMetric(QStyle::PM_LayoutBottomMargin);
grid->setContentsMargins(dcmLeft, dcmTop, dcmRight, dcmBottom);
grid->setHorizontalSpacing(style()->pixelMetric(QStyle::PM_LayoutHorizontalSpacing));
grid->setVerticalSpacing(style()->pixelMetric(QStyle::PM_LayoutVerticalSpacing));
QLabel* label = new QLabel(i18nc("@label:textbox", "Prefix:"), textGroup);
......@@ -149,7 +152,7 @@ BirthdayDlg::BirthdayDlg(QWidget* parent)
group = new QGroupBox(i18nc("@title:group", "Alarm Configuration"), this);
topLayout->addWidget(group);
QVBoxLayout* groupLayout = new QVBoxLayout(group);
groupLayout->setContentsMargins(dcm, dcm, dcm, dcm);
groupLayout->setContentsMargins(dcmLeft, dcmTop, dcmRight, dcmBottom);
groupLayout->setSpacing(style()->pixelMetric(QStyle::PM_LayoutVerticalSpacing));
// Sound checkbox and file selector
......
......@@ -257,8 +257,11 @@ void EditAlarmDlg::init(const KAEvent* event)
mainScroll->setWidget(mainPage); // mainPage becomes the child of mainScroll
connect(mainPage, &PageFrame::shown, this, &EditAlarmDlg::slotShowMainPage);
QVBoxLayout* topLayout = new QVBoxLayout(mainPage);
int dcm = style()->pixelMetric(QStyle::PM_DefaultChildMargin);
topLayout->setContentsMargins(dcm, dcm, dcm, dcm);
const int dcmLeft = style()->pixelMetric(QStyle::PM_LayoutLeftMargin);
const int dcmTop = style()->pixelMetric(QStyle::PM_LayoutTopMargin);
const int dcmRight = style()->pixelMetric(QStyle::PM_LayoutRightMargin);
const int dcmBottom = style()->pixelMetric(QStyle::PM_LayoutBottomMargin);
topLayout->setContentsMargins(dcmLeft, dcmTop, dcmRight, dcmBottom);
topLayout->setSpacing(style()->pixelMetric(QStyle::PM_LayoutVerticalSpacing));
// Recurrence tab
......@@ -267,7 +270,7 @@ void EditAlarmDlg::init(const KAEvent* event)
mRecurPageIndex = 1;
QFrame* recurTab = new QFrame;
QVBoxLayout* recurTabLayout = new QVBoxLayout();
recurTabLayout->setContentsMargins(dcm, dcm, dcm, dcm);
recurTabLayout->setContentsMargins(dcmLeft, dcmTop, dcmRight, dcmBottom);
recurTab->setLayout(recurTabLayout);
recurScroll->setWidget(recurTab); // recurTab becomes the child of recurScroll
mRecurrenceEdit = new RecurrenceEdit(mReadOnly);
......@@ -282,7 +285,7 @@ void EditAlarmDlg::init(const KAEvent* event)
QGroupBox* actionBox = new QGroupBox(i18nc("@title:group", "Action"), mainPage);
topLayout->addWidget(actionBox, 1);
QVBoxLayout* layout = new QVBoxLayout(actionBox);
layout->setContentsMargins(dcm, dcm, dcm, dcm);
layout->setContentsMargins(dcmLeft, dcmTop, dcmRight, dcmBottom);
layout->setSpacing(style()->pixelMetric(QStyle::PM_LayoutVerticalSpacing));
type_init(actionBox, layout);
......@@ -293,7 +296,7 @@ void EditAlarmDlg::init(const KAEvent* event)
mDeferGroup = new QGroupBox(i18nc("@title:group", "Deferred Alarm"), mainPage);
topLayout->addWidget(mDeferGroup);
QHBoxLayout* hlayout = new QHBoxLayout(mDeferGroup);
hlayout->setContentsMargins(dcm, dcm, dcm, dcm);
hlayout->setContentsMargins(dcmLeft, dcmTop, dcmRight, dcmBottom);
hlayout->setSpacing(style()->pixelMetric(QStyle::PM_LayoutHorizontalSpacing));
QLabel* label = new QLabel(i18nc("@label", "Deferred to:"), mDeferGroup);
label->setFixedSize(label->sizeHint());
......@@ -319,7 +322,7 @@ void EditAlarmDlg::init(const KAEvent* event)
QGroupBox* templateTimeBox = new QGroupBox(i18nc("@title:group", "Time"), mainPage);
topLayout->addWidget(templateTimeBox);
QGridLayout* grid = new QGridLayout(templateTimeBox);
grid->setContentsMargins(dcm, dcm, dcm, dcm);
grid->setContentsMargins(dcmLeft, dcmTop, dcmRight, dcmBottom);
grid->setHorizontalSpacing(style()->pixelMetric(QStyle::PM_LayoutHorizontalSpacing));
grid->setVerticalSpacing(style()->pixelMetric(QStyle::PM_LayoutVerticalSpacing));
mTemplateTimeGroup = new ButtonGroup(templateTimeBox);
......
......@@ -774,8 +774,10 @@ void EditCommandAlarmDlg::type_init(QWidget* parent, QVBoxLayout* frameLayout)
mCmdOutputBox = new QGroupBox(i18nc("@title:group", "Command Output"), parent);
frameLayout->addWidget(mCmdOutputBox);
QVBoxLayout* vlayout = new QVBoxLayout(mCmdOutputBox);
int dcm = style()->pixelMetric(QStyle::PM_DefaultChildMargin);
vlayout->setContentsMargins(dcm, dcm, dcm, dcm);
vlayout->setContentsMargins(style()->pixelMetric(QStyle::PM_LayoutLeftMargin),
style()->pixelMetric(QStyle::PM_LayoutTopMargin),
style()->pixelMetric(QStyle::PM_LayoutRightMargin),
style()->pixelMetric(QStyle::PM_LayoutBottomMargin));
vlayout->setSpacing(style()->pixelMetric(QStyle::PM_LayoutVerticalSpacing));
mCmdOutputGroup = new ButtonGroup(mCmdOutputBox);
connect(mCmdOutputGroup, &ButtonGroup::buttonSet, this, &EditCommandAlarmDlg::contentsChanged);
......
......@@ -112,8 +112,10 @@ void Find::display()
QGroupBox* group = new QGroupBox(i18nc("@title:group", "Alarm Type"), kalarmWidgets);
layout->addWidget(group);
QGridLayout* grid = new QGridLayout(group);
int dcm = QApplication::style()->pixelMetric(QStyle::PM_DefaultChildMargin);
grid->setContentsMargins(dcm, dcm, dcm, dcm);
grid->setContentsMargins(QApplication::style()->pixelMetric(QStyle::PM_LayoutLeftMargin),
QApplication::style()->pixelMetric(QStyle::PM_LayoutTopMargin),
QApplication::style()->pixelMetric(QStyle::PM_LayoutRightMargin),
QApplication::style()->pixelMetric(QStyle::PM_LayoutBottomMargin));
grid->setHorizontalSpacing(QApplication::style()->pixelMetric(QStyle::PM_LayoutHorizontalSpacing));
grid->setVerticalSpacing(QApplication::style()->pixelMetric(QStyle::PM_LayoutVerticalSpacing));
grid->setColumnStretch(1, 1);
......
......@@ -47,8 +47,10 @@ FontColourChooser::FontColourChooser(QWidget* parent, const QStringList& fontLis
page = new QGroupBox(frameLabel, this);
topLayout->addWidget(page);
topLayout = new QVBoxLayout(page);
int dcm = style()->pixelMetric(QStyle::PM_DefaultChildMargin);
topLayout->setContentsMargins(dcm, dcm, dcm, dcm);
topLayout->setContentsMargins(style()->pixelMetric(QStyle::PM_LayoutLeftMargin),
style()->pixelMetric(QStyle::PM_LayoutTopMargin),
style()->pixelMetric(QStyle::PM_LayoutRightMargin),
style()->pixelMetric(QStyle::PM_LayoutBottomMargin));
topLayout->setSpacing(style()->pixelMetric(QStyle::PM_LayoutVerticalSpacing));
}
QHBoxLayout* hlayout = new QHBoxLayout();
......
......@@ -343,8 +343,11 @@ void MessageWin::initView()
QWidget* topWidget = new QWidget(this);
setCentralWidget(topWidget);
QVBoxLayout* topLayout = new QVBoxLayout(topWidget);
int dcm = style()->pixelMetric(QStyle::PM_DefaultChildMargin);
topLayout->setContentsMargins(dcm, dcm, dcm, dcm);
const int dcmLeft = style()->pixelMetric(QStyle::PM_LayoutLeftMargin);
const int dcmTop = style()->pixelMetric(QStyle::PM_LayoutTopMargin);
const int dcmRight = style()->pixelMetric(QStyle::PM_LayoutRightMargin);
const int dcmBottom = style()->pixelMetric(QStyle::PM_LayoutBottomMargin);
topLayout->setContentsMargins(dcmLeft, dcmTop, dcmRight, dcmBottom);
topLayout->setSpacing(style()->pixelMetric(QStyle::PM_LayoutVerticalSpacing));
QPalette labelPalette = palette();
......@@ -491,7 +494,7 @@ void MessageWin::initView()
text->setMaximumWidth(s.width() + text->scrollBarWidth());
text->setWhatsThis(i18nc("@info:whatsthis", "The alarm message"));
const int vspace = lineSpacing/2;
const int hspace = lineSpacing - style()->pixelMetric(QStyle::PM_DefaultChildMargin);
const int hspace = lineSpacing - (dcmLeft + dcmRight)/2;
topLayout->addSpacing(vspace);
topLayout->addStretch();
// Don't include any horizontal margins if message is 2/3 screen width
......@@ -561,7 +564,7 @@ void MessageWin::initView()
frame->setWhatsThis(i18nc("@info:whatsthis", "The email to send"));
topLayout->addWidget(frame, 0, Qt::AlignHCenter);
QGridLayout* grid = new QGridLayout(frame);
grid->setContentsMargins(dcm, dcm, dcm, dcm);
grid->setContentsMargins(dcmLeft, dcmTop, dcmRight, dcmBottom);
grid->setHorizontalSpacing(style()->pixelMetric(QStyle::PM_LayoutHorizontalSpacing));
grid->setVerticalSpacing(style()->pixelMetric(QStyle::PM_LayoutVerticalSpacing));
......@@ -600,8 +603,7 @@ void MessageWin::initView()
{
setCaption(i18nc("@title:window", "Error"));
QHBoxLayout* layout = new QHBoxLayout();
int m = 2 * dcm;
layout->setContentsMargins(m, m, m, m);
layout->setContentsMargins(2 * dcmLeft, 2 * dcmTop, 2 * dcmRight, 2 * dcmBottom);
layout->addStretch();
topLayout->addLayout(layout);
QLabel* label = new QLabel(topWidget);
......@@ -719,7 +721,7 @@ void MessageWin::initView()
mKAlarmButton->setEnabled(false);
topLayout->activate();
setMinimumSize(QSize(grid->sizeHint().width() + 2 * style()->pixelMetric(QStyle::PM_DefaultChildMargin),
setMinimumSize(QSize(grid->sizeHint().width() + dcmLeft + dcmRight,
sizeHint().height()));
const bool modal = !(windowFlags() & Qt::X11BypassWindowManagerHint);
NET::States wstate = NET::Sticky | NET::KeepAbove;
......@@ -1720,7 +1722,8 @@ QSize MessageWin::sizeHint() const
{
// For command output, expand the window to accommodate the text
const QSize texthint = mCommandText->sizeHint();
int w = texthint.width() + 2 * style()->pixelMetric(QStyle::PM_DefaultChildMargin);
int w = texthint.width() + style()->pixelMetric(QStyle::PM_LayoutLeftMargin)
+ style()->pixelMetric(QStyle::PM_LayoutRightMargin);
if (w < width())
w = width();
const int ypadding = height() - mCommandText->height();
......
......@@ -444,8 +444,11 @@ MiscPrefTab::MiscPrefTab(StackedScrollGroup* scrollGroup)
QGroupBox* group = new QGroupBox(i18nc("@title:group", "Run Mode"));
topLayout()->addWidget(group);
QVBoxLayout* vlayout = new QVBoxLayout(group);
const int dcm = style()->pixelMetric(QStyle::PM_DefaultChildMargin);
vlayout->setContentsMargins(dcm, dcm, dcm, dcm);
const int dcmLeft = style()->pixelMetric(QStyle::PM_LayoutLeftMargin);
const int dcmTop = style()->pixelMetric(QStyle::PM_LayoutTopMargin);
const int dcmRight = style()->pixelMetric(QStyle::PM_LayoutRightMargin);
const int dcmBottom = style()->pixelMetric(QStyle::PM_LayoutBottomMargin);
vlayout->setContentsMargins(dcmLeft, dcmTop, dcmRight, dcmBottom);
vlayout->setSpacing(style()->pixelMetric(QStyle::PM_LayoutVerticalSpacing));
// Start at login
......@@ -491,7 +494,7 @@ MiscPrefTab::MiscPrefTab(StackedScrollGroup* scrollGroup)
group->setWhatsThis(i18nc("@info:whatsthis", "Choose which application to use when a command alarm is executed in a terminal window"));
topLayout()->addWidget(group);
QGridLayout* grid = new QGridLayout(group);
grid->setContentsMargins(dcm, dcm, dcm, dcm);
grid->setContentsMargins(dcmLeft, dcmTop, dcmRight, dcmBottom);
grid->setHorizontalSpacing(style()->pixelMetric(QStyle::PM_LayoutHorizontalSpacing));
grid->setVerticalSpacing(style()->pixelMetric(QStyle::PM_LayoutVerticalSpacing));
int row = 0;
......@@ -728,8 +731,11 @@ TimePrefTab::TimePrefTab(StackedScrollGroup* scrollGroup)
QGroupBox* group = new QGroupBox(i18nc("@title:group", "Working Hours"));
topLayout()->addWidget(group);
QBoxLayout* layout = new QVBoxLayout(group);
const int dcm = style()->pixelMetric(QStyle::PM_DefaultChildMargin);
layout->setContentsMargins(dcm, dcm, dcm, dcm);
const int dcmLeft = style()->pixelMetric(QStyle::PM_LayoutLeftMargin);
const int dcmTop = style()->pixelMetric(QStyle::PM_LayoutTopMargin);
const int dcmRight = style()->pixelMetric(QStyle::PM_LayoutRightMargin);
const int dcmBottom = style()->pixelMetric(QStyle::PM_LayoutBottomMargin);
layout->setContentsMargins(dcmLeft, dcmTop, dcmRight, dcmBottom);
layout->setSpacing(style()->pixelMetric(QStyle::PM_LayoutVerticalSpacing));
QWidget* daybox = new QWidget(group); // this is to control the QWhatsThis text display area
......@@ -790,7 +796,7 @@ TimePrefTab::TimePrefTab(StackedScrollGroup* scrollGroup)
group = new QGroupBox(i18nc("@title:group", "KOrganizer"));
topLayout()->addWidget(group);
layout = new QVBoxLayout(group);
layout->setContentsMargins(dcm, dcm, dcm, dcm);
layout->setContentsMargins(dcmLeft, dcmTop, dcmRight, dcmBottom);
layout->setSpacing(style()->pixelMetric(QStyle::PM_LayoutVerticalSpacing));
widget = new QWidget; // this is to control the QWhatsThis text display area
......@@ -870,8 +876,11 @@ StorePrefTab::StorePrefTab(StackedScrollGroup* scrollGroup)
topLayout()->addWidget(group);
QButtonGroup* bgroup = new QButtonGroup(group);
QBoxLayout* layout = new QVBoxLayout(group);
const int dcm = style()->pixelMetric(QStyle::PM_DefaultChildMargin);
layout->setContentsMargins(dcm, dcm, dcm, dcm);
const int dcmLeft = style()->pixelMetric(QStyle::PM_LayoutLeftMargin);
const int dcmTop = style()->pixelMetric(QStyle::PM_LayoutTopMargin);
const int dcmRight = style()->pixelMetric(QStyle::PM_LayoutRightMargin);
const int dcmBottom = style()->pixelMetric(QStyle::PM_LayoutBottomMargin);
layout->setContentsMargins(dcmLeft, dcmTop, dcmRight, dcmBottom);
layout->setSpacing(style()->pixelMetric(QStyle::PM_LayoutVerticalSpacing));
mDefaultResource = new QRadioButton(i18nc("@option:radio", "Store in default calendar"), group);
......@@ -889,7 +898,7 @@ StorePrefTab::StorePrefTab(StackedScrollGroup* scrollGroup)
group = new QGroupBox(i18nc("@title:group", "Archived Alarms"));
topLayout()->addWidget(group);
QGridLayout* grid = new QGridLayout(group);
grid->setContentsMargins(dcm, dcm, dcm, dcm);
grid->setContentsMargins(dcmLeft, dcmTop, dcmRight, dcmBottom);
grid->setHorizontalSpacing(style()->pixelMetric(QStyle::PM_LayoutHorizontalSpacing));
grid->setVerticalSpacing(style()->pixelMetric(QStyle::PM_LayoutVerticalSpacing));
grid->setColumnStretch(1, 1);
......@@ -1049,8 +1058,10 @@ EmailPrefTab::EmailPrefTab(StackedScrollGroup* scrollGroup)
QGroupBox* group = new QGroupBox(i18nc("@title:group", "Your Email Address"));
topLayout()->addWidget(group);
QGridLayout* grid = new QGridLayout(group);
const int dcm = style()->pixelMetric(QStyle::PM_DefaultChildMargin);
grid->setContentsMargins(dcm, dcm, dcm, dcm);
grid->setContentsMargins(style()->pixelMetric(QStyle::PM_LayoutLeftMargin),
style()->pixelMetric(QStyle::PM_LayoutTopMargin),
style()->pixelMetric(QStyle::PM_LayoutRightMargin),
style()->pixelMetric(QStyle::PM_LayoutBottomMargin));
grid->setHorizontalSpacing(style()->pixelMetric(QStyle::PM_LayoutHorizontalSpacing));
grid->setVerticalSpacing(style()->pixelMetric(QStyle::PM_LayoutVerticalSpacing));
grid->setColumnStretch(2, 1);
......@@ -1329,8 +1340,11 @@ EditPrefTab::EditPrefTab(StackedScrollGroup* scrollGroup)
QGroupBox* group = new QGroupBox(i18nc("@title:group", "Display Alarms"));
ttLayout->addWidget(group);
QVBoxLayout* vlayout = new QVBoxLayout(group);
const int dcm = style()->pixelMetric(QStyle::PM_DefaultChildMargin);
vlayout->setContentsMargins(dcm, dcm, dcm, dcm);
const int dcmLeft = style()->pixelMetric(QStyle::PM_LayoutLeftMargin);
const int dcmTop = style()->pixelMetric(QStyle::PM_LayoutTopMargin);
const int dcmRight = style()->pixelMetric(QStyle::PM_LayoutRightMargin);
const int dcmBottom = style()->pixelMetric(QStyle::PM_LayoutBottomMargin);
vlayout->setContentsMargins(dcmLeft, dcmTop, dcmRight, dcmBottom);
vlayout->setSpacing(style()->pixelMetric(QStyle::PM_LayoutVerticalSpacing));
mConfirmAck = new QCheckBox(EditDisplayAlarmDlg::i18n_chk_ConfirmAck());
......@@ -1364,7 +1378,7 @@ EditPrefTab::EditPrefTab(StackedScrollGroup* scrollGroup)
QGroupBox* bbox = new QGroupBox(i18nc("@title:group Audio options group", "Sound"));
ttLayout->addWidget(bbox);
vlayout = new QVBoxLayout(bbox);
vlayout->setContentsMargins(dcm, dcm, dcm, dcm);
vlayout->setContentsMargins(dcmLeft, dcmTop, dcmRight, dcmBottom);
vlayout->setSpacing(style()->pixelMetric(QStyle::PM_LayoutVerticalSpacing));
QHBoxLayout* hlayout = new QHBoxLayout;
......@@ -1407,7 +1421,7 @@ EditPrefTab::EditPrefTab(StackedScrollGroup* scrollGroup)
group = new QGroupBox(i18nc("@title:group", "Command Alarms"));
ttLayout->addWidget(group);
vlayout = new QVBoxLayout(group);
vlayout->setContentsMargins(dcm, dcm, dcm, dcm);
vlayout->setContentsMargins(dcmLeft, dcmTop, dcmRight, dcmBottom);
vlayout->setSpacing(style()->pixelMetric(QStyle::PM_LayoutVerticalSpacing));
hlayout = new QHBoxLayout();
hlayout->setContentsMargins(0, 0, 0, 0);
......@@ -1428,7 +1442,7 @@ EditPrefTab::EditPrefTab(StackedScrollGroup* scrollGroup)
group = new QGroupBox(i18nc("@title:group", "Email Alarms"));
ttLayout->addWidget(group);
vlayout = new QVBoxLayout(group);
vlayout->setContentsMargins(dcm, dcm, dcm, dcm);
vlayout->setContentsMargins(dcmLeft, dcmTop, dcmRight, dcmBottom);
vlayout->setSpacing(style()->pixelMetric(QStyle::PM_LayoutVerticalSpacing));
// BCC email to sender
......@@ -1643,15 +1657,17 @@ ViewPrefTab::ViewPrefTab(StackedScrollGroup* scrollGroup)
QWidget* widget = new QWidget;
QVBoxLayout* topGeneral = new QVBoxLayout(widget);
const int dcm = style()->pixelMetric(QStyle::PM_DefaultChildMargin);
const int m = dcm / 2;
topGeneral->setContentsMargins(m, m, m, m);
const int dcmLeft = style()->pixelMetric(QStyle::PM_LayoutLeftMargin);
const int dcmTop = style()->pixelMetric(QStyle::PM_LayoutTopMargin);
const int dcmRight = style()->pixelMetric(QStyle::PM_LayoutRightMargin);
const int dcmBottom = style()->pixelMetric(QStyle::PM_LayoutBottomMargin);
topGeneral->setContentsMargins(dcmLeft/2, dcmTop/2, dcmRight/2, dcmBottom/2);
topGeneral->setSpacing(style()->pixelMetric(QStyle::PM_LayoutVerticalSpacing));
mTabGeneral = mTabs->addTab(widget, i18nc("@title:tab", "General"));
widget = new QWidget;
QVBoxLayout* topWindows = new QVBoxLayout(widget);
topWindows->setContentsMargins(m, m, m, m);
topWindows->setContentsMargins(dcmLeft/2, dcmTop/2, dcmRight/2, dcmBottom/2);
topWindows->setSpacing(style()->pixelMetric(QStyle::PM_LayoutVerticalSpacing));
mTabWindows = mTabs->addTab(widget, i18nc("@title:tab", "Alarm Windows"));
......@@ -1681,7 +1697,7 @@ ViewPrefTab::ViewPrefTab(StackedScrollGroup* scrollGroup)
mShowInSystemTrayGroup->setWhatsThis(showInSysTrayWhatsThis);
topGeneral->addWidget(mShowInSystemTrayGroup);
QGridLayout* grid = new QGridLayout(mShowInSystemTrayGroup);
grid->setContentsMargins(dcm, dcm, dcm, dcm);
grid->setContentsMargins(dcmLeft, dcmTop, dcmRight, dcmBottom);
grid->setHorizontalSpacing(style()->pixelMetric(QStyle::PM_LayoutHorizontalSpacing));
grid->setVerticalSpacing(style()->pixelMetric(QStyle::PM_LayoutVerticalSpacing));
grid->setColumnStretch(1, 1);
......@@ -1726,7 +1742,7 @@ ViewPrefTab::ViewPrefTab(StackedScrollGroup* scrollGroup)
QGroupBox* group = new QGroupBox(i18nc("@title:group", "System Tray Tooltip"));
topGeneral->addWidget(group);
QGridLayout* grid = new QGridLayout(group);
grid->setContentsMargins(dcm, dcm, dcm, dcm);
grid->setContentsMargins(dcmLeft, dcmTop, dcmRight, dcmBottom);
grid->setHorizontalSpacing(style()->pixelMetric(QStyle::PM_LayoutHorizontalSpacing));
grid->setVerticalSpacing(style()->pixelMetric(QStyle::PM_LayoutVerticalSpacing));
grid->setColumnStretch(2, 1);
......@@ -1785,7 +1801,7 @@ ViewPrefTab::ViewPrefTab(StackedScrollGroup* scrollGroup)
group = new QGroupBox(i18nc("@title:group", "Alarm List"));
topGeneral->addWidget(group);
QHBoxLayout* hlayout = new QHBoxLayout(group);
hlayout->setContentsMargins(dcm, dcm, dcm, dcm);
hlayout->setContentsMargins(dcmLeft, dcmTop, dcmRight, dcmBottom);
QVBoxLayout* colourLayout = new QVBoxLayout();
colourLayout->setContentsMargins(0, 0, 0, 0);
hlayout->addLayout(colourLayout);
......@@ -1824,7 +1840,7 @@ ViewPrefTab::ViewPrefTab(StackedScrollGroup* scrollGroup)
group = new QGroupBox(i18nc("@title:group", "Alarm Message Windows"));
topWindows->addWidget(group);
grid = new QGridLayout(group);
grid->setContentsMargins(dcm, dcm, dcm, dcm);
grid->setContentsMargins(dcmLeft, dcmTop, dcmRight, dcmBottom);
grid->setHorizontalSpacing(style()->pixelMetric(QStyle::PM_LayoutHorizontalSpacing));
grid->setVerticalSpacing(style()->pixelMetric(QStyle::PM_LayoutVerticalSpacing));
grid->setColumnStretch(1, 1);
......
......@@ -96,9 +96,12 @@ RecurrenceEdit::RecurrenceEdit(bool readOnly, QWidget* parent)
QGroupBox* recurGroup = new QGroupBox(i18nc("@title:group", "Recurrence Rule"), this);
topLayout->addWidget(recurGroup);
QHBoxLayout* hlayout = new QHBoxLayout(recurGroup);
int dcm = style()->pixelMetric(QStyle::PM_DefaultChildMargin);
hlayout->setContentsMargins(dcm, dcm, dcm, dcm);
hlayout->setSpacing(style()->pixelMetric(QStyle::PM_DefaultChildMargin)); // use margin spacing due to vertical divider line
const int dcmLeft = style()->pixelMetric(QStyle::PM_LayoutLeftMargin);
const int dcmTop = style()->pixelMetric(QStyle::PM_LayoutTopMargin);
const int dcmRight = style()->pixelMetric(QStyle::PM_LayoutRightMargin);
const int dcmBottom = style()->pixelMetric(QStyle::PM_LayoutBottomMargin);
hlayout->setContentsMargins(dcmLeft, dcmTop, dcmRight, dcmBottom);
hlayout->setSpacing((dcmLeft + dcmRight)/2); // use margin spacing due to vertical divider line
// Recurrence period radio buttons
QVBoxLayout* vlayout = new QVBoxLayout();
......@@ -209,7 +212,7 @@ RecurrenceEdit::RecurrenceEdit(bool readOnly, QWidget* parent)
mRuleStack->addWidget(mWeeklyRule);
mRuleStack->addWidget(mMonthlyRule);
mRuleStack->addWidget(mYearlyRule);
hlayout->addSpacing(style()->pixelMetric(QStyle::PM_DefaultChildMargin));
hlayout->addSpacing((dcmLeft + dcmRight)/2);
// Create the recurrence range group which contains the controls
// which specify how long the recurrence is to last.
......@@ -221,7 +224,7 @@ RecurrenceEdit::RecurrenceEdit(bool readOnly, QWidget* parent)
connect(mRangeButtonGroup, &ButtonGroup::buttonSet, this, &RecurrenceEdit::contentsChanged);
vlayout = new QVBoxLayout(mRangeButtonBox);
vlayout->setContentsMargins(dcm, dcm, dcm, dcm);
vlayout->setContentsMargins(dcmLeft, dcmTop, dcmRight, dcmBottom);
vlayout->setSpacing(style()->pixelMetric(QStyle::PM_LayoutVerticalSpacing));
mNoEndDateButton = new RadioButton(i18nc("@option:radio", "No end"), mRangeButtonBox);
mNoEndDateButton->setFixedSize(mNoEndDateButton->sizeHint());
......@@ -303,7 +306,7 @@ RecurrenceEdit::RecurrenceEdit(bool readOnly, QWidget* parent)
topLayout->addWidget(mExceptionGroup);
topLayout->setStretchFactor(mExceptionGroup, 2);
hlayout = new QHBoxLayout(mExceptionGroup);
hlayout->setContentsMargins(dcm, dcm, dcm, dcm);
hlayout->setContentsMargins(dcmLeft, dcmTop, dcmRight, dcmBottom);
hlayout->setSpacing(style()->pixelMetric(QStyle::PM_LayoutHorizontalSpacing));
vlayout = new QVBoxLayout();
vlayout->setContentsMargins(0, 0, 0, 0);
......
......@@ -237,8 +237,10 @@ SoundWidget::SoundWidget(bool showPlay, bool showRepeat, QWidget* parent)
QGroupBox* group = new QGroupBox(i18nc("@title:group Sound volume", "Volume"), this);
layout->addWidget(group);
QGridLayout* grid = new QGridLayout(group);
const int dcm = style()->pixelMetric(QStyle::PM_DefaultChildMargin);
grid->setContentsMargins(dcm, dcm, dcm, dcm);
grid->setContentsMargins(style()->pixelMetric(QStyle::PM_LayoutLeftMargin),
style()->pixelMetric(QStyle::PM_LayoutTopMargin),
style()->pixelMetric(QStyle::PM_LayoutRightMargin),
style()->pixelMetric(QStyle::PM_LayoutBottomMargin));
grid->setHorizontalSpacing(style()->pixelMetric(QStyle::PM_LayoutHorizontalSpacing));
grid->setVerticalSpacing(style()->pixelMetric(QStyle::PM_LayoutVerticalSpacing));
grid->setColumnStretch(2, 1);
......
  • While I just saw this by-passing accidentally, a quick note: all (edit: most of) these calls just set the values to the default values. You could also remove the calls, and the default values will still be used :)

    I have seen similar things, and without having looked I suspect the current code is coming from having been ported away from KDialog:spacingHint/marginHint, and people had missed that layouts by themselves now default to the value from the style, so the porting should have just dropped explicit setting.

    So you might want to inspect if you cannot make your code simpler by just dumping the explicit setting of values to what otherwise would fall back to the same default values.

    Edited by Friedrich W. H. Kossebau
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment