Commit 341bf17b authored by David Jarvie's avatar David Jarvie
Browse files

Improve dialog spacing, and remove redundant layout spacing code

parent 8acd4876
Pipeline #25121 passed with stage
in 11 minutes and 16 seconds
......@@ -95,12 +95,8 @@ void AlarmTimeWidget::init(Mode mode, const QString& title)
mButtonGroup = new ButtonGroup(this);
connect(mButtonGroup, &ButtonGroup::buttonSet, this, &AlarmTimeWidget::slotButtonSet);
QVBoxLayout* topLayout = new QVBoxLayout(topWidget);
topLayout->setSpacing(style()->pixelMetric(QStyle::PM_LayoutVerticalSpacing));
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));
if (title.isEmpty())
topLayout->setContentsMargins(0, 0, 0, 0);
// At time radio button/label
mAtTimeRadio = new RadioButton((mDeferring ? i18nc("@option:radio", "Defer to date/time:") : i18nc("@option:radio", "At date/time:")), topWidget);
......
......@@ -64,7 +64,6 @@ BirthdayDlg::BirthdayDlg(QWidget* parent)
setWindowTitle(i18nc("@title:window", "Import Birthdays From KAddressBook"));
QVBoxLayout* topLayout = new QVBoxLayout(this);
topLayout->setSpacing(style()->pixelMetric(QStyle::PM_LayoutVerticalSpacing));
// Prefix and suffix to the name in the alarm text
// Get default prefix and suffix texts from config file
......@@ -75,13 +74,6 @@ BirthdayDlg::BirthdayDlg(QWidget* parent)
QGroupBox* textGroup = new QGroupBox(i18nc("@title:group", "Alarm Text"), this);
topLayout->addWidget(textGroup);
QGridLayout* grid = new QGridLayout(textGroup);
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);
label->setFixedSize(label->sizeHint());
grid->addWidget(label, 0, 0);
......@@ -152,8 +144,6 @@ BirthdayDlg::BirthdayDlg(QWidget* parent)
group = new QGroupBox(i18nc("@title:group", "Alarm Configuration"), this);
topLayout->addWidget(group);
QVBoxLayout* groupLayout = new QVBoxLayout(group);
groupLayout->setContentsMargins(dcmLeft, dcmTop, dcmRight, dcmBottom);
groupLayout->setSpacing(style()->pixelMetric(QStyle::PM_LayoutVerticalSpacing));
// Sound checkbox and file selector
QHBoxLayout* hlayout = new QHBoxLayout();
......
......@@ -51,7 +51,6 @@ DeferAlarmDlg::DeferAlarmDlg(const DateTime& initialDT, bool anyTimeOption, bool
setWindowTitle(i18nc("@title:window", "Defer Alarm"));
QVBoxLayout* layout = new QVBoxLayout(this);
layout->setSpacing(style()->pixelMetric(QStyle::PM_LayoutVerticalSpacing));
mTimeWidget = new AlarmTimeWidget((anyTimeOption ? AlarmTimeWidget::DEFER_ANY_TIME : AlarmTimeWidget::DEFER_TIME), this);
mTimeWidget->setDateTime(initialDT);
......
......@@ -233,7 +233,6 @@ void EditAlarmDlg::init(const KAEvent* event)
QHBoxLayout* box = new QHBoxLayout();
frame->setLayout(box);
box->setContentsMargins(0, 0, 0, 0);
box->setSpacing(style()->pixelMetric(QStyle::PM_LayoutHorizontalSpacing));
QLabel* label = new QLabel(i18nc("@label:textbox", "Template name:"));
label->setFixedSize(label->sizeHint());
box->addWidget(label);
......@@ -257,12 +256,6 @@ 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);
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
StackedScrollWidget* recurScroll = new StackedScrollWidget(mTabScrollGroup);
......@@ -270,7 +263,6 @@ void EditAlarmDlg::init(const KAEvent* event)
mRecurPageIndex = 1;
QFrame* recurTab = new QFrame;
QVBoxLayout* recurTabLayout = new QVBoxLayout();
recurTabLayout->setContentsMargins(dcmLeft, dcmTop, dcmRight, dcmBottom);
recurTab->setLayout(recurTabLayout);
recurScroll->setWidget(recurTab); // recurTab becomes the child of recurScroll
mRecurrenceEdit = new RecurrenceEdit(mReadOnly);
......@@ -285,8 +277,6 @@ 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(dcmLeft, dcmTop, dcmRight, dcmBottom);
layout->setSpacing(style()->pixelMetric(QStyle::PM_LayoutVerticalSpacing));
type_init(actionBox, layout);
......@@ -296,8 +286,6 @@ 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(dcmLeft, dcmTop, dcmRight, dcmBottom);
hlayout->setSpacing(style()->pixelMetric(QStyle::PM_LayoutHorizontalSpacing));
QLabel* label = new QLabel(i18nc("@label", "Deferred to:"), mDeferGroup);
label->setFixedSize(label->sizeHint());
hlayout->addWidget(label);
......@@ -322,9 +310,6 @@ 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(dcmLeft, dcmTop, dcmRight, dcmBottom);
grid->setHorizontalSpacing(style()->pixelMetric(QStyle::PM_LayoutHorizontalSpacing));
grid->setVerticalSpacing(style()->pixelMetric(QStyle::PM_LayoutVerticalSpacing));
mTemplateTimeGroup = new ButtonGroup(templateTimeBox);
connect(mTemplateTimeGroup, &ButtonGroup::buttonSet, this, &EditAlarmDlg::slotTemplateTimeType);
connect(mTemplateTimeGroup, &ButtonGroup::buttonSet, this, &EditAlarmDlg::contentsChanged);
......@@ -340,7 +325,6 @@ void EditAlarmDlg::init(const KAEvent* event)
QWidget* box = new QWidget(templateTimeBox);
QHBoxLayout* layout = new QHBoxLayout(box);
layout->setContentsMargins(0, 0, 0, 0);
layout->setSpacing(style()->pixelMetric(QStyle::PM_LayoutHorizontalSpacing));
mTemplateUseTime = new RadioButton(i18nc("@option:radio", "Time:"), box);
mTemplateUseTime->setFixedSize(mTemplateUseTime->sizeHint());
mTemplateUseTime->setReadOnly(mReadOnly);
......@@ -368,7 +352,6 @@ void EditAlarmDlg::init(const KAEvent* event)
box = new QWidget(templateTimeBox);
layout = new QHBoxLayout(box);
layout->setContentsMargins(0, 0, 0, 0);
layout->setSpacing(style()->pixelMetric(QStyle::PM_LayoutHorizontalSpacing));
mTemplateUseTimeAfter = new RadioButton(i18nc("@option:radio", "Time from now:"), box);
mTemplateUseTimeAfter->setFixedSize(mTemplateUseTimeAfter->sizeHint());
mTemplateUseTimeAfter->setReadOnly(mReadOnly);
......@@ -404,7 +387,6 @@ void EditAlarmDlg::init(const KAEvent* event)
topLayout->addWidget(mMoreOptions);
QVBoxLayout* moreLayout = new QVBoxLayout(mMoreOptions);
moreLayout->setContentsMargins(0, 0, 0, 0);
moreLayout->setSpacing(style()->pixelMetric(QStyle::PM_LayoutVerticalSpacing));
// Reminder
mReminder = createReminder(mMoreOptions);
......
......@@ -774,11 +774,6 @@ 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);
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);
......@@ -1738,7 +1733,6 @@ CommandEdit::CommandEdit(QWidget* parent)
{
QVBoxLayout* vlayout = new QVBoxLayout(this);
vlayout->setContentsMargins(0, 0, 0, 0);
vlayout->setSpacing(style()->pixelMetric(QStyle::PM_LayoutVerticalSpacing));
mTypeScript = new CheckBox(EditCommandAlarmDlg::i18n_chk_EnterScript(), this);
mTypeScript->setFixedSize(mTypeScript->sizeHint());
mTypeScript->setWhatsThis(i18nc("@info:whatsthis", "Check to enter the contents of a script instead of a shell command line"));
......
......@@ -32,7 +32,7 @@
#include <KFindDialog>
#include <KFind>
#include <KSeparator>
#include <kwindowsystem.h>
#include <KWindowSystem>
#include <KLocalizedString>
#include <QGroupBox>
......@@ -40,8 +40,6 @@
#include <QVBoxLayout>
#include <QGridLayout>
#include <QRegExp>
#include <QStyle>
#include <QApplication>
using namespace KAlarmCal;
......@@ -108,16 +106,9 @@ void Find::display()
// Alarm types
QVBoxLayout* layout = new QVBoxLayout(kalarmWidgets);
layout->setContentsMargins(0, 0, 0, 0);
layout->setSpacing(QApplication::style()->pixelMetric(QStyle::PM_LayoutVerticalSpacing));
QGroupBox* group = new QGroupBox(i18nc("@title:group", "Alarm Type"), kalarmWidgets);
layout->addWidget(group);
QGridLayout* grid = new QGridLayout(group);
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);
// Live & archived alarm selection
......
......@@ -28,11 +28,9 @@
#include <KFontChooser>
#include <QGroupBox>
#include <QPushButton>
#include <QLabel>
#include <QVBoxLayout>
#include <QHBoxLayout>
#include <QStyle>
FontColourChooser::FontColourChooser(QWidget* parent, const QStringList& fontList,
......@@ -40,19 +38,15 @@ FontColourChooser::FontColourChooser(QWidget* parent, const QStringList& fontLis
: QWidget(parent)
{
QVBoxLayout* topLayout = new QVBoxLayout(this);
topLayout->setSpacing(style()->pixelMetric(QStyle::PM_LayoutVerticalSpacing));
QWidget* page = this;
if (!frameLabel.isNull())
{
page = new QGroupBox(frameLabel, this);
topLayout->addWidget(page);
topLayout = new QVBoxLayout(page);
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));
}
else
topLayout->setContentsMargins(0, 0, 0, 0);
QHBoxLayout* hlayout = new QHBoxLayout();
hlayout->setContentsMargins(0, 0, 0, 0);
topLayout->addLayout(hlayout);
......@@ -65,7 +59,6 @@ FontColourChooser::FontColourChooser(QWidget* parent, const QStringList& fontLis
colourLayout->addWidget(box);
QHBoxLayout* boxHLayout = new QHBoxLayout(box);
boxHLayout->setContentsMargins(0, 0, 0, 0);
boxHLayout->setSpacing(style()->pixelMetric(QStyle::PM_LayoutHorizontalSpacing) / 2);
QLabel* label = new QLabel(i18nc("@label:listbox", "Foreground color:"), box);
boxHLayout->addWidget(label);
......@@ -81,7 +74,6 @@ FontColourChooser::FontColourChooser(QWidget* parent, const QStringList& fontLis
colourLayout->addWidget(box);
QHBoxLayout* boxHLayout = new QHBoxLayout(box);
boxHLayout->setContentsMargins(0, 0, 0, 0);
boxHLayout->setSpacing(style()->pixelMetric(QStyle::PM_LayoutHorizontalSpacing) / 2);
QLabel* label = new QLabel(i18nc("@label:listbox", "Background color:"), box);
boxHLayout->addWidget(label);
......
......@@ -64,7 +64,7 @@ void FontColourButton::slotButtonPressed()
{
// Use AutoQPointer to guard against crash on application exit while
// the dialogue is still open. It prevents double deletion (both on
// deletion of FontColourButton, and on return from this function).
// deletion of FontColourButton, and on return from this function).
AutoQPointer<FontColourDlg> dlg = new FontColourDlg(mBgColour, mFgColour, mFont, mDefaultFont,
i18nc("@title:window", "Choose Alarm Font & Color"), this);
dlg->setReadOnly(mReadOnly);
......@@ -91,7 +91,6 @@ FontColourDlg::FontColourDlg(const QColor& bgColour, const QColor& fgColour, con
setWindowTitle(caption);
QVBoxLayout* layout = new QVBoxLayout(this);
layout->setSpacing(style()->pixelMetric(QStyle::PM_LayoutVerticalSpacing));
mChooser = new FontColourChooser(this, QStringList(), QString(), true, true);
mChooser->setBgColour(bgColour);
mChooser->setFgColour(fgColour);
......
......@@ -30,7 +30,6 @@ using namespace KCalendarCore;
#include <QStackedWidget>
#include <QVBoxLayout>
#include <QHBoxLayout>
#include <QStyle>
// Collect these widget labels together to ensure consistent wording and
......@@ -52,7 +51,6 @@ LateCancelSelector::LateCancelSelector(bool allowHourMinute, QWidget* parent)
QVBoxLayout* topLayout = new QVBoxLayout(this);
topLayout->setContentsMargins(0, 0, 0, 0);
topLayout->setSpacing(style()->pixelMetric(QStyle::PM_LayoutVerticalSpacing));
mStack = new QStackedWidget(this);
topLayout->addWidget(mStack, 0, Qt::AlignLeft);
......@@ -78,8 +76,7 @@ LateCancelSelector::LateCancelSelector(bool allowHourMinute, QWidget* parent)
hlayout->addWidget(mTimeSelector, 0, Qt::AlignLeft);
hlayout = new QHBoxLayout();
hlayout->setContentsMargins(0, 0, 0, 0);
hlayout->addSpacing(3 * style()->pixelMetric(QStyle::PM_LayoutHorizontalSpacing));
hlayout->setContentsMargins(CheckBox::textIndent(mCheckbox), 0, 0, 0);
topLayout->addLayout(hlayout);
mAutoClose = new CheckBox(i18n_chk_AutoCloseWin(), this);
connect(mAutoClose, &CheckBox::toggled, this, &LateCancelSelector::changed);
......
/*
* checkbox.cpp - check box with read-only option
* Program: kalarm
* Copyright © 2002,2003,2005 David Jarvie <djarvie@kde.org>
* Copyright © 2002-2005,2020 David Jarvie <djarvie@kde.org>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
......@@ -22,6 +22,7 @@
#include <QMouseEvent>
#include <QKeyEvent>
#include <QStyleOptionButton>
CheckBox::CheckBox(QWidget* parent)
......@@ -62,6 +63,28 @@ void CheckBox::setFocusWidget(QWidget* w, bool enable)
disconnect(this, &CheckBox::clicked, this, &CheckBox::slotClicked);
}
/******************************************************************************
* Return the indentation from the left of a checkbox widget to the start of the
* checkbox text.
*/
int CheckBox::textIndent(QWidget* widget)
{
QStyleOptionButton opt;
QStyle* style;
if (qobject_cast<QCheckBox*>(widget))
{
opt.initFrom(widget);
style = widget->style();
}
else
{
QCheckBox cb(widget);
opt.initFrom(&cb);
style = cb.style();
}
return style->subElementRect(QStyle::SE_CheckBoxContents, &opt).left();
}
/******************************************************************************
* Called when the checkbox is clicked.
* If it is now checked, focus is transferred to any specified focus widget.
......
......@@ -43,46 +43,59 @@ class QKeyEvent;
*/
class CheckBox : public QCheckBox
{
Q_OBJECT
public:
/** Constructor.
* @param parent The parent object of this widget.
*/
explicit CheckBox(QWidget* parent);
/** Constructor.
* @param text Text to display.
* @param parent The parent object of this widget.
*/
CheckBox(const QString& text, QWidget* parent);
/** Returns true if the widget is read only. */
bool isReadOnly() const { return mReadOnly; }
/** Sets whether the check box is read-only for the user. If read-only,
* its state cannot be changed by the user.
* @param readOnly True to set the widget read-only, false to set it read-write.
*/
virtual void setReadOnly(bool readOnly);
/** Returns the widget which receives focus when the user selects the check box by clicking on it. */
QWidget* focusWidget() const { return mFocusWidget; }
/** Specifies a widget to receive focus when the user selects the check box by clicking on it.
* @param widget Widget to receive focus.
* @param enable If true, @p widget will be enabled before receiving focus. If
* false, the enabled state of @p widget will be left unchanged when
* the check box is clicked.
*/
void setFocusWidget(QWidget* widget, bool enable = true);
protected:
void mousePressEvent(QMouseEvent*) override;
void mouseReleaseEvent(QMouseEvent*) override;
void mouseMoveEvent(QMouseEvent*) override;
void keyPressEvent(QKeyEvent*) override;
void keyReleaseEvent(QKeyEvent*) override;
protected Q_SLOTS:
void slotClicked();
private:
Qt::FocusPolicy mFocusPolicy; // default focus policy for the QCheckBox
QWidget* mFocusWidget {nullptr}; // widget to receive focus when button is clicked on
bool mFocusWidgetEnable; // enable focus widget before setting focus
bool mReadOnly {false}; // value cannot be changed
Q_OBJECT
public:
/** Constructor.
* @param parent The parent object of this widget.
*/
explicit CheckBox(QWidget* parent);
/** Constructor.
* @param text Text to display.
* @param parent The parent object of this widget.
*/
CheckBox(const QString& text, QWidget* parent);
/** Returns true if the widget is read only. */
bool isReadOnly() const { return mReadOnly; }
/** Sets whether the check box is read-only for the user. If read-only,
* its state cannot be changed by the user.
* @param readOnly True to set the widget read-only, false to set it read-write.
*/
virtual void setReadOnly(bool readOnly);
/** Returns the widget which receives focus when the user selects the check box by clicking on it. */
QWidget* focusWidget() const { return mFocusWidget; }
/** Specifies a widget to receive focus when the user selects the check box by clicking on it.
* @param widget Widget to receive focus.
* @param enable If true, @p widget will be enabled before receiving focus. If
* false, the enabled state of @p widget will be left unchanged when
* the check box is clicked.
*/
void setFocusWidget(QWidget* widget, bool enable = true);
/** Return the indentation from the left of a checkbox widget to the start
* of the checkbox text.
* @param widget Checkbox to use, or parent widget.
* @return Indentation to start of text.
*/
static int textIndent(QWidget* cb);
protected:
void mousePressEvent(QMouseEvent*) override;
void mouseReleaseEvent(QMouseEvent*) override;
void mouseMoveEvent(QMouseEvent*) override;
void keyPressEvent(QKeyEvent*) override;
void keyReleaseEvent(QKeyEvent*) override;
protected Q_SLOTS:
void slotClicked();
private:
Qt::FocusPolicy mFocusPolicy; // default focus policy for the QCheckBox
QWidget* mFocusWidget {nullptr}; // widget to receive focus when button is clicked on
bool mFocusWidgetEnable; // enable focus widget before setting focus
bool mReadOnly {false}; // value cannot be changed
};
#endif // CHECKBOX_H
......
......@@ -347,8 +347,6 @@ void MessageWin::initView()
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();
labelPalette.setColor(backgroundRole(), labelPalette.color(QPalette::Window));
......@@ -564,9 +562,6 @@ 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(dcmLeft, dcmTop, dcmRight, dcmBottom);
grid->setHorizontalSpacing(style()->pixelMetric(QStyle::PM_LayoutHorizontalSpacing));
grid->setVerticalSpacing(style()->pixelMetric(QStyle::PM_LayoutVerticalSpacing));
QLabel* label = new QLabel(i18nc("@info Email addressee", "To:"), frame);
label->setFixedSize(label->sizeHint());
......@@ -592,7 +587,7 @@ void MessageWin::initView()
}
}
if (!mErrorMsgs.count())
if (mErrorMsgs.isEmpty())
{
topWidget->setAutoFillBackground(true);
QPalette palette = topWidget->palette();
......
This diff is collapsed.
/*
* prefdlg_p.h - private classes for program preferences dialog
* Program: kalarm
* Copyright © 2001-2019 David Jarvie <djarvie@kde.org>
* Copyright © 2001-2020 David Jarvie <djarvie@kde.org>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
......@@ -52,232 +52,234 @@ class TimeZoneCombo;
// Base class for each tab in the Preferences dialog
class PrefsTabBase : public StackedScrollWidget
{
Q_OBJECT
public:
explicit PrefsTabBase(StackedScrollGroup*);
void setPreferences();
virtual void restore(bool defaults, bool allTabs) = 0;
virtual void apply(bool syncToDisc) = 0;
void addAlignedLabel(QLabel*);
QVBoxLayout* topLayout() const { return mTopLayout; }
static int indentWidth() { return mIndentWidth; }
protected:
void showEvent(QShowEvent*) override;
private:
static int mIndentWidth; // indent width for checkboxes etc.
QVBoxLayout* mTopLayout;
QList<QLabel*> mLabels; // labels to right-align
bool mLabelsAligned {false}; // labels have been aligned
Q_OBJECT
public:
explicit PrefsTabBase(StackedScrollGroup*);
void setPreferences();
virtual void restore(bool defaults, bool allTabs) = 0;
virtual void apply(bool syncToDisc) = 0;
void addAlignedLabel(QLabel*);
QVBoxLayout* topLayout() const { return mTopLayout; }
static int indentWidth() { return mIndentWidth; }
static int gridIndentWidth() { return mGridIndentWidth; }
protected:
void showEvent(QShowEvent*) override;
private:
static int mIndentWidth; // indent width for checkboxes etc.
static int mGridIndentWidth; // minimum grid column indent width for checkboxes etc.
QVBoxLayout* mTopLayout;
QList<QLabel*> mLabels; // labels to right-align
bool mLabelsAligned {false}; // labels have been aligned
};
// Miscellaneous tab of the Preferences dialog
class MiscPrefTab : public PrefsTabBase
{
Q_OBJECT
public:
explicit MiscPrefTab(StackedScrollGroup*);
void restore(bool defaults, bool allTabs) override;
void apply(bool syncToDisc) override;
private Q_SLOTS:
void slotAutostartClicked();
void slotOtherTerminalToggled(bool);
private:
void setTimeZone(const QTimeZone&);
QCheckBox* mAutoStart;
QCheckBox* mQuitWarn;
QCheckBox* mConfirmAlarmDeletion;
TimeSpinBox* mDefaultDeferTime;
ButtonGroup* mXtermType;
QLineEdit* mXtermCommand;
int mXtermFirst; // id of first terminal window radio button
int mXtermCount; // number of terminal window types
Q_OBJECT
public:
explicit MiscPrefTab(StackedScrollGroup*);
void restore(bool defaults, bool allTabs) override;
void apply(bool syncToDisc) override;
private Q_SLOTS:
void slotAutostartClicked();
void slotOtherTerminalToggled(bool);
private:
void setTimeZone(const QTimeZone&);
QCheckBox* mAutoStart;
QCheckBox* mQuitWarn;
QCheckBox* mConfirmAlarmDeletion;
TimeSpinBox* mDefaultDeferTime;
ButtonGroup* mXtermType;
QLineEdit* mXtermCommand;
int mXtermFirst; // id of first terminal window radio button
int mXtermCount; // number of terminal window types
};
// Date/time tab of the Preferences dialog
class TimePrefTab : public PrefsTabBase
{
Q_OBJECT
public:
explicit TimePrefTab(StackedScrollGroup*);
void restore(bool defaults, bool allTabs) override;
void apply(bool syncToDisc) override;
private:
void setWorkDays(const QBitArray& days);
TimeZoneCombo* mTimeZone;
QComboBox* mHolidays;
QMap<QString, QString> mHolidayNames;
TimeEdit* mStartOfDay;
QCheckBox* mWorkDays[7];
TimeEdit* mWorkStart;
TimeEdit* mWorkEnd;
TimeSpinBox* mKOrgEventDuration;
Q_OBJECT
public:
explicit TimePrefTab(StackedScrollGroup*);
void restore(bool defaults, bool allTabs) override;
void apply(bool syncToDisc) override;
private:
void setWorkDays(const QBitArray& days);
TimeZoneCombo* mTimeZone;
QComboBox* mHolidays;
QMap<QString, QString> mHolidayNames;
TimeEdit* mStartOfDay;
QCheckBox* mWorkDays[7];
TimeEdit* mWorkStart;
TimeEdit* mWorkEnd;
TimeSpinBox* mKOrgEventDuration;
};
// Storage tab of the Preferences dialog
class StorePrefTab : public PrefsTabBase
{
Q_OBJECT
public: