Commit 2824a744 authored by Daniel Vrátil's avatar Daniel Vrátil 🤖
Browse files

KAlarm: port away from KDialog

parent 81d1e826
......@@ -151,6 +151,7 @@ KF5::AkonadiMime
KF5::AkonadiContact
KF5::Holidays
KF5::Codecs
KF5::ConfigCore
kdepim
Phonon::phonon4qt5
KF5::Auth
......
......@@ -35,7 +35,6 @@
#include <kalarmcal/datetime.h>
#include <KTimeZone>
#include <kdatecombobox.h>
#include <kdialog.h>
#include <KLocalizedString>
#include <QGroupBox>
......@@ -102,8 +101,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(KDialog::spacingHint());
topLayout->setMargin(title.isEmpty() ? 0 : KDialog::marginHint());
topLayout->setSpacing(style()->pixelMetric(QStyle::PM_DefaultLayoutSpacing));
topLayout->setMargin(title.isEmpty() ? 0 : style()->pixelMetric(QStyle::PM_DefaultChildMargin));
// At time radio button/label
mAtTimeRadio = new RadioButton((mDeferring ? i18nc("@option:radio", "Defer to date/time:") : i18nc("@option:radio", "At date/time:")), topWidget);
......@@ -125,7 +124,7 @@ void AlarmTimeWidget::init(Mode mode, const QString& title)
QWidget* timeBox = new QWidget(topWidget);
QHBoxLayout* timeBoxHLayout = new QHBoxLayout(timeBox);
timeBoxHLayout->setMargin(0);
timeBoxHLayout->setSpacing(2*KDialog::spacingHint());
timeBoxHLayout->setSpacing(2 * style()->pixelMetric(QStyle::PM_DefaultLayoutSpacing));
mTimeEdit = new TimeEdit(timeBox);
timeBoxHLayout->addWidget(mTimeEdit);
mTimeEdit->setFixedSize(mTimeEdit->sizeHint());
......@@ -206,7 +205,7 @@ void AlarmTimeWidget::init(Mode mode, const QString& title)
QHBoxLayout* layout = new QHBoxLayout();
topLayout->addLayout(layout);
layout->setSpacing(2*KDialog::spacingHint());
layout->setSpacing(2 * style()->pixelMetric(QStyle::PM_DefaultLayoutSpacing));
// Time zone selector
mTimeZoneBox = new QWidget(topWidget); // this is to control the QWhatsThis text display area
......
......@@ -53,27 +53,21 @@
#include <QHeaderView>
#include <QHBoxLayout>
#include <QVBoxLayout>
#include <QDialogButtonBox>
#include "kalarm_debug.h"
using namespace KCal;
BirthdayDlg::BirthdayDlg(QWidget* parent)
: KDialog(parent),
: QDialog(parent),
mSpecialActionsButton(Q_NULLPTR)
{
setObjectName(QStringLiteral("BirthdayDlg")); // used by LikeBack
setCaption(i18nc("@title:window", "Import Birthdays From KAddressBook"));
setButtons(Ok | Cancel);
setDefaultButton(Ok);
setWindowTitle(i18nc("@title:window", "Import Birthdays From KAddressBook"));
connect(this, &BirthdayDlg::okClicked, this, &BirthdayDlg::slotOk);
QWidget* topWidget = new QWidget(this);
setMainWidget(topWidget);
QVBoxLayout* topLayout = new QVBoxLayout(topWidget);
topLayout->setMargin(0);
topLayout->setSpacing(spacingHint());
QVBoxLayout* topLayout = new QVBoxLayout(this);
topLayout->setSpacing(style()->pixelMetric(QStyle::PM_DefaultLayoutSpacing));
// Prefix and suffix to the name in the alarm text
// Get default prefix and suffix texts from config file
......@@ -81,11 +75,11 @@ BirthdayDlg::BirthdayDlg(QWidget* parent)
mPrefixText = config.readEntry("BirthdayPrefix", i18nc("@info", "Birthday: "));
mSuffixText = config.readEntry("BirthdaySuffix");
QGroupBox* textGroup = new QGroupBox(i18nc("@title:group", "Alarm Text"), topWidget);
QGroupBox* textGroup = new QGroupBox(i18nc("@title:group", "Alarm Text"), this);
topLayout->addWidget(textGroup);
QGridLayout* grid = new QGridLayout(textGroup);
grid->setMargin(marginHint());
grid->setSpacing(spacingHint());
grid->setMargin(style()->pixelMetric(QStyle::PM_DefaultChildMargin));
grid->setSpacing(style()->pixelMetric(QStyle::PM_DefaultLayoutSpacing));
QLabel* label = new QLabel(i18nc("@label:textbox", "Prefix:"), textGroup);
label->setFixedSize(label->sizeHint());
grid->addWidget(label, 0, 0);
......@@ -110,7 +104,7 @@ BirthdayDlg::BirthdayDlg(QWidget* parent)
"including any necessary leading spaces."));
grid->addWidget(mSuffix, 1, 1);
QGroupBox* group = new QGroupBox(i18nc("@title:group", "Select Birthdays"), topWidget);
QGroupBox* group = new QGroupBox(i18nc("@title:group", "Select Birthdays"), this);
topLayout->addWidget(group);
QVBoxLayout* layout = new QVBoxLayout(group);
layout->setMargin(0);
......@@ -153,11 +147,11 @@ BirthdayDlg::BirthdayDlg(QWidget* parent)
"or by clicking the mouse while pressing Ctrl or Shift.</para>"));
layout->addWidget(mListView);
group = new QGroupBox(i18nc("@title:group", "Alarm Configuration"), topWidget);
group = new QGroupBox(i18nc("@title:group", "Alarm Configuration"), this);
topLayout->addWidget(group);
QVBoxLayout* groupLayout = new QVBoxLayout(group);
groupLayout->setMargin(marginHint());
groupLayout->setSpacing(spacingHint());
groupLayout->setMargin(style()->pixelMetric(QStyle::PM_DefaultChildMargin));
groupLayout->setSpacing(style()->pixelMetric(QStyle::PM_DefaultLayoutSpacing));
// Sound checkbox and file selector
QHBoxLayout* hlayout = new QHBoxLayout();
......@@ -166,7 +160,7 @@ BirthdayDlg::BirthdayDlg(QWidget* parent)
mSoundPicker = new SoundPicker(group);
mSoundPicker->setFixedSize(mSoundPicker->sizeHint());
hlayout->addWidget(mSoundPicker);
hlayout->addSpacing(2*spacingHint());
hlayout->addSpacing(2 * style()->pixelMetric(QStyle::PM_DefaultLayoutSpacing));
hlayout->addStretch();
// Font and colour choice button and sample text
......@@ -189,12 +183,12 @@ BirthdayDlg::BirthdayDlg(QWidget* parent)
// Acknowledgement confirmation required - default = no confirmation
hlayout = new QHBoxLayout();
hlayout->setMargin(0);
hlayout->setSpacing(2*spacingHint());
hlayout->setSpacing(2 * style()->pixelMetric(QStyle::PM_DefaultLayoutSpacing));
groupLayout->addLayout(hlayout);
mConfirmAck = EditDisplayAlarmDlg::createConfirmAckCheckbox(group);
mConfirmAck->setFixedSize(mConfirmAck->sizeHint());
hlayout->addWidget(mConfirmAck);
hlayout->addSpacing(2*spacingHint());
hlayout->addSpacing(2 * style()->pixelMetric(QStyle::PM_DefaultLayoutSpacing));
hlayout->addStretch();
if (ShellProcess::authorised()) // don't display if shell commands not allowed (e.g. kiosk mode)
......@@ -208,7 +202,7 @@ BirthdayDlg::BirthdayDlg(QWidget* parent)
// Late display checkbox - default = allow late display
hlayout = new QHBoxLayout();
hlayout->setMargin(0);
hlayout->setSpacing(2*spacingHint());
hlayout->setSpacing(2 * style()->pixelMetric(QStyle::PM_DefaultLayoutSpacing));
groupLayout->addLayout(hlayout);
mLateCancel = new LateCancelSelector(false, group);
mLateCancel->setFixedSize(mLateCancel->sizeHint());
......@@ -243,6 +237,17 @@ BirthdayDlg::BirthdayDlg(QWidget* parent)
mSpecialActionsButton->setActions(Preferences::defaultPreAction(), Preferences::defaultPostAction(), opts);
}
mButtonBox = new QDialogButtonBox(this);
mButtonBox->addButton(QDialogButtonBox::Ok);
mButtonBox->addButton(QDialogButtonBox::Cancel);
connect(mButtonBox, &QDialogButtonBox::accepted,
this, &BirthdayDlg::slotOk);
connect(mButtonBox, &QDialogButtonBox::rejected,
this, &QDialog::reject);
topLayout->addWidget(mButtonBox);
KActionCollection* actions = new KActionCollection(this);
KStandardAction::selectAll(mListView, SLOT(selectAll()), actions);
KStandardAction::deselect(mListView, SLOT(clearSelection()), actions);
......@@ -250,7 +255,7 @@ BirthdayDlg::BirthdayDlg(QWidget* parent)
foreach (QAction* action, actions->actions())
action->setShortcutContext(Qt::WidgetWithChildrenShortcut);
enableButtonOk(false); // only enable OK button when something is selected
mButtonBox->button(QDialogButtonBox::Ok)->setEnabled(false); // only enable OK button when something is selected
}
/******************************************************************************
......@@ -318,7 +323,7 @@ void BirthdayDlg::slotOk()
if (mSoundPicker->repeatPause() >= 0) mFlags |= KAEvent::REPEAT_SOUND;
if (mConfirmAck->isChecked()) mFlags |= KAEvent::CONFIRM_ACK;
if (mFontColourButton->defaultFont()) mFlags |= KAEvent::DEFAULT_FONT;
KDialog::accept();
QDialog::accept();
}
/******************************************************************************
......@@ -327,7 +332,7 @@ void BirthdayDlg::slotOk()
*/
void BirthdayDlg::slotSelectionChanged()
{
enableButtonOk(mListView->selectionModel()->hasSelection());
mButtonBox->button(QDialogButtonBox::Ok)->setEnabled(mListView->selectionModel()->hasSelection());
}
/******************************************************************************
......
......@@ -22,7 +22,7 @@
#include <kalarmcal/kaevent.h>
#include <kdialog.h>
#include <QDialog>
#include <QVector>
#include <QLineEdit>
......@@ -37,10 +37,11 @@ class LateCancelSelector;
class Reminder;
class BLineEdit;
class BirthdaySortModel;
class QDialogButtonBox;
using namespace KAlarmCal;
class BirthdayDlg : public KDialog
class BirthdayDlg : public QDialog
{
Q_OBJECT
public:
......@@ -68,6 +69,7 @@ class BirthdayDlg : public KDialog
LateCancelSelector* mLateCancel;
SpecialActionsButton* mSpecialActionsButton;
RepetitionButton* mSubRepetition;
QDialogButtonBox * mButtonBox;
QString mPrefixText; // last entered value of prefix text
QString mSuffixText; // last entered value of suffix text
KAEvent::Flags mFlags; // event flag bits
......
......@@ -40,6 +40,7 @@
#include <KLocalizedString>
#include <KConfig>
#include <KConfigGroup>
#include <QTimer>
#include <QStandardPaths>
......
......@@ -33,36 +33,49 @@
#include <KLocalizedString>
#include <QVBoxLayout>
#include <QStyle>
#include <QDialogButtonBox>
#include <QPushButton>
#include "kalarm_debug.h"
DeferAlarmDlg::DeferAlarmDlg(const DateTime& initialDT, bool anyTimeOption, bool cancelButton, QWidget* parent)
: KDialog(parent)
: QDialog(parent)
{
setWindowModality(Qt::WindowModal);
setCaption(i18nc("@title:window", "Defer Alarm"));
setButtons(Ok | Cancel | User1);
setButtonGuiItem(User1, KGuiItem(i18nc("@action:button", "Cancel Deferral")));
if (!cancelButton)
showButton(User1, false);
connect(this, &DeferAlarmDlg::okClicked, this, &DeferAlarmDlg::slotOk);
connect(this, &DeferAlarmDlg::user1Clicked, this, &DeferAlarmDlg::slotCancelDeferral);
QWidget* page = new QWidget(this);
setMainWidget(page);
QVBoxLayout* layout = new QVBoxLayout(page);
setWindowTitle(i18nc("@title:window", "Defer Alarm"));
QVBoxLayout* layout = new QVBoxLayout(this);
layout->setMargin(0);
layout->setSpacing(spacingHint());
layout->setSpacing(style()->pixelMetric(QStyle::PM_DefaultLayoutSpacing));
mTimeWidget = new AlarmTimeWidget((anyTimeOption ? AlarmTimeWidget::DEFER_ANY_TIME : AlarmTimeWidget::DEFER_TIME), page);
mTimeWidget = new AlarmTimeWidget((anyTimeOption ? AlarmTimeWidget::DEFER_ANY_TIME : AlarmTimeWidget::DEFER_TIME), this);
mTimeWidget->setDateTime(initialDT);
mTimeWidget->setMinDateTimeIsCurrent();
connect(mTimeWidget, &AlarmTimeWidget::pastMax, this, &DeferAlarmDlg::slotPastLimit);
layout->addWidget(mTimeWidget);
layout->addSpacing(spacingHint());
layout->addSpacing(style()->pixelMetric(QStyle::PM_DefaultLayoutSpacing));
mButtonBox = new QDialogButtonBox(this);
layout->addWidget(mButtonBox);
QPushButton *okButton = mButtonBox->addButton(QDialogButtonBox::Ok);
okButton->setWhatsThis(i18nc("@info:whatsthis", "Defer the alarm until the specified time."));
if (cancelButton) {
mButtonBox->addButton(QDialogButtonBox::Cancel);
}
QPushButton *deferButton =mButtonBox->addButton(i18nc("@action:button", "Cancel Deferral"), QDialogButtonBox::ActionRole);
deferButton->setWhatsThis(i18nc("@info:whatsthis", "Cancel the deferred alarm. This does not affect future recurrences."));
connect(mButtonBox, &QDialogButtonBox::accepted,
this, &DeferAlarmDlg::slotOk);
connect(mButtonBox, &QDialogButtonBox::rejected,
this, &QDialog::reject);
connect(mButtonBox, &QDialogButtonBox::clicked,
[this, deferButton](QAbstractButton *btn) {
if (btn == deferButton) {
slotCancelDeferral();
}
});
setButtonWhatsThis(Ok, i18nc("@info:whatsthis", "Defer the alarm until the specified time."));
setButtonWhatsThis(User1, i18nc("@info:whatsthis", "Cancel the deferred alarm. This does not affect future recurrences."));
}
......@@ -131,7 +144,7 @@ void DeferAlarmDlg::setDeferMinutes(int minutes)
*/
void DeferAlarmDlg::slotPastLimit()
{
enableButtonOk(false);
mButtonBox->button(QDialogButtonBox::Ok)->setEnabled(false);
}
/******************************************************************************
......
......@@ -25,15 +25,16 @@
#include <kalarmcal/datetime.h>
#include <AkonadiCore/collection.h>
#include <kdialog.h>
#include <QDialog>
class AlarmTimeWidget;
class QDialogButtonBox;
namespace KAlarmCal { class KAEvent; }
using namespace KAlarmCal;
class DeferAlarmDlg : public KDialog
class DeferAlarmDlg : public QDialog
{
Q_OBJECT
public:
......@@ -53,6 +54,7 @@ class DeferAlarmDlg : public KDialog
private:
AlarmTimeWidget* mTimeWidget;
QDialogButtonBox* mButtonBox;
DateTime mAlarmDateTime;
DateTime mLimitDateTime; // latest date/time allowed for deferral
EventId mLimitEventId; // event IDs from whose recurrences to derive the limit date/time for deferral
......
......@@ -67,6 +67,7 @@
#include <QShowEvent>
#include <QScrollBar>
#include <QTimer>
#include <QDialogButtonBox>
#include "kalarm_debug.h"
using namespace KCal;
......@@ -132,7 +133,7 @@ EditAlarmDlg* EditAlarmDlg::create(bool Template, const KAEvent* event, bool new
* event != to initialise the dialog to show the specified event's data.
*/
EditAlarmDlg::EditAlarmDlg(bool Template, KAEvent::SubAction action, QWidget* parent, GetResourceType getResource)
: KDialog(parent),
: QDialog(parent),
mAlarmType(action),
mMainPageShown(false),
mRecurPageShown(false),
......@@ -148,14 +149,15 @@ EditAlarmDlg::EditAlarmDlg(bool Template, KAEvent::SubAction action, QWidget* pa
mDesiredReadOnly(false),
mReadOnly(false),
mShowingMore(true),
mSavedEvent(Q_NULLPTR)
mSavedEvent(Q_NULLPTR),
mLoadTemplateButton(Q_NULLPTR)
{
init(Q_NULLPTR, getResource);
}
EditAlarmDlg::EditAlarmDlg(bool Template, const KAEvent* event, bool newAlarm, QWidget* parent,
GetResourceType getResource, bool readOnly)
: KDialog(parent),
: QDialog(parent),
mAlarmType(event->actionSubType()),
mMainPageShown(false),
mRecurPageShown(false),
......@@ -172,7 +174,8 @@ EditAlarmDlg::EditAlarmDlg(bool Template, const KAEvent* event, bool newAlarm, Q
mDesiredReadOnly(readOnly),
mReadOnly(readOnly),
mShowingMore(true),
mSavedEvent(Q_NULLPTR)
mSavedEvent(Q_NULLPTR),
mLoadTemplateButton(Q_NULLPTR)
{
init(event, getResource);
}
......@@ -208,26 +211,43 @@ void EditAlarmDlg::init(const KAEvent* event)
: i18nc("@title:window", "Alarm [read-only]");
else
caption = type_caption();
setCaption(caption);
setButtons((mReadOnly ? Cancel|Try|Default : mTemplate ? Ok|Cancel|Try|Default : Ok|Cancel|Try|Help|Default));
setDefaultButton(mReadOnly ? Cancel : Ok);
setButtonText(Help, i18nc("@action:button", "Load Template..."));
setButtonIcon(Help, QIcon());
setButtonIcon(Default, QIcon());
connect(this, &EditAlarmDlg::tryClicked, this, &EditAlarmDlg::slotTry);
connect(this, &EditAlarmDlg::defaultClicked, this, &EditAlarmDlg::slotDefault); // More/Less Options button
connect(this, &EditAlarmDlg::helpClicked, this, &EditAlarmDlg::slotHelp); // Load Template button
QWidget *mainWidget = new QWidget(this);
QVBoxLayout* mainLayout = new QVBoxLayout(mainWidget);
mainLayout->setMargin(0);
setMainWidget(mainWidget);
setWindowTitle(caption);
// Create button box now so taht types can work with it, but don't insert
// it into layout just yet
mButtonBox = new QDialogButtonBox(this);
if (mReadOnly) {
mButtonBox->addButton(QDialogButtonBox::Cancel);
mTryButton = mButtonBox->addButton(i18nc("@action:button", "Try"), QDialogButtonBox::ActionRole);
mMoreLessButton = mButtonBox->addButton(QDialogButtonBox::RestoreDefaults);
} else if (mTemplate) {
mButtonBox->addButton(QDialogButtonBox::Ok);
mButtonBox->addButton(QDialogButtonBox::Cancel);
mTryButton = mButtonBox->addButton(i18nc("@action:button", "Try"), QDialogButtonBox::ActionRole);
mMoreLessButton = mButtonBox->addButton(QDialogButtonBox::RestoreDefaults);
} else {
mButtonBox->addButton(QDialogButtonBox::Ok);
mButtonBox->addButton(QDialogButtonBox::Cancel);
mTryButton = mButtonBox->addButton(i18nc("@action:button", "Try"), QDialogButtonBox::ActionRole);
mLoadTemplateButton = mButtonBox->addButton(i18nc("@action:button", "Load Template..."),
QDialogButtonBox::HelpRole);
mMoreLessButton = mButtonBox->addButton(QDialogButtonBox::RestoreDefaults);
}
connect(mButtonBox, &QDialogButtonBox::clicked,
this, &EditAlarmDlg::slotButtonClicked);
if (mButtonBox->button(QDialogButtonBox::Ok)) {
mButtonBox->button(QDialogButtonBox::Ok)->setWhatsThis(i18nc("@info:whatsthis", "Schedule the alarm at the specified time."));
}
QVBoxLayout* mainLayout = new QVBoxLayout(this);
if (mTemplate)
{
QFrame *frame = new QFrame;
QHBoxLayout* box = new QHBoxLayout();
frame->setLayout(box);
box->setMargin(0);
box->setSpacing(spacingHint());
box->setSpacing(style()->pixelMetric(QStyle::PM_DefaultLayoutSpacing));
QLabel* label = new QLabel(i18nc("@label:textbox", "Template name:"));
label->setFixedSize(label->sizeHint());
box->addWidget(label);
......@@ -240,7 +260,7 @@ void EditAlarmDlg::init(const KAEvent* event)
frame->setFixedHeight(box->sizeHint().height());
mainLayout->addWidget(frame);
}
mTabs = new QTabWidget(mainWidget);
mTabs = new QTabWidget(this);
mainLayout->addWidget(mTabs);
mTabScrollGroup = new StackedScrollGroup(this, mTabs);
......@@ -251,8 +271,8 @@ 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);
topLayout->setMargin(marginHint());
topLayout->setSpacing(spacingHint());
topLayout->setMargin(style()->pixelMetric(QStyle::PM_DefaultChildMargin));
topLayout->setSpacing(style()->pixelMetric(QStyle::PM_DefaultLayoutSpacing));
// Recurrence tab
StackedScrollWidget* recurScroll = new StackedScrollWidget(mTabScrollGroup);
......@@ -260,7 +280,7 @@ void EditAlarmDlg::init(const KAEvent* event)
mRecurPageIndex = 1;
QFrame *recurTab = new QFrame;
QVBoxLayout* recurTabLayout = new QVBoxLayout();
recurTabLayout->setMargin(marginHint());
recurTabLayout->setMargin(style()->pixelMetric(QStyle::PM_DefaultChildMargin));
recurTab->setLayout(recurTabLayout);
recurScroll->setWidget(recurTab); // recurTab becomes the child of recurScroll
mRecurrenceEdit = new RecurrenceEdit(mReadOnly);
......@@ -275,8 +295,8 @@ 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->setMargin(marginHint());
layout->setSpacing(spacingHint());
layout->setMargin(style()->pixelMetric(QStyle::PM_DefaultChildMargin));
layout->setSpacing(style()->pixelMetric(QStyle::PM_DefaultLayoutSpacing));
type_init(actionBox, layout);
......@@ -286,8 +306,8 @@ void EditAlarmDlg::init(const KAEvent* event)
mDeferGroup = new QGroupBox(i18nc("@title:group", "Deferred Alarm"), mainPage);
topLayout->addWidget(mDeferGroup);
QHBoxLayout* hlayout = new QHBoxLayout(mDeferGroup);
hlayout->setMargin(marginHint());
hlayout->setSpacing(spacingHint());
hlayout->setMargin(style()->pixelMetric(QStyle::PM_DefaultChildMargin));
hlayout->setSpacing(style()->pixelMetric(QStyle::PM_DefaultLayoutSpacing));
QLabel* label = new QLabel(i18nc("@label", "Deferred to:"), mDeferGroup);
label->setFixedSize(label->sizeHint());
hlayout->addWidget(label);
......@@ -310,10 +330,10 @@ void EditAlarmDlg::init(const KAEvent* event)
if (mTemplate)
{
QGroupBox* templateTimeBox = new QGroupBox(i18nc("@title:group", "Time"), mainPage);
hlayout->addWidget(templateTimeBox);
topLayout->addWidget(templateTimeBox);
QGridLayout* grid = new QGridLayout(templateTimeBox);
grid->setMargin(marginHint());
grid->setSpacing(spacingHint());
grid->setMargin(style()->pixelMetric(QStyle::PM_DefaultChildMargin));
grid->setSpacing(style()->pixelMetric(QStyle::PM_DefaultLayoutSpacing));
mTemplateTimeGroup = new ButtonGroup(templateTimeBox);
connect(mTemplateTimeGroup, &ButtonGroup::buttonSet, this, &EditAlarmDlg::slotTemplateTimeType);
connect(mTemplateTimeGroup, &ButtonGroup::buttonSet, this, &EditAlarmDlg::contentsChanged);
......@@ -326,11 +346,10 @@ void EditAlarmDlg::init(const KAEvent* event)
mTemplateTimeGroup->addButton(mTemplateDefaultTime);
grid->addWidget(mTemplateDefaultTime, 0, 0, Qt::AlignLeft);
QFrame *box = new QFrame(templateTimeBox);
QHBoxLayout* layout = new QHBoxLayout();
QWidget *box = new QWidget(templateTimeBox);
QHBoxLayout* layout = new QHBoxLayout(box);
layout->setMargin(0);
layout->setSpacing(spacingHint());
box->setLayout(layout);
layout->setSpacing(style()->pixelMetric(QStyle::PM_DefaultLayoutSpacing));
mTemplateUseTime = new RadioButton(i18nc("@option:radio", "Time:"), box);
mTemplateUseTime->setFixedSize(mTemplateUseTime->sizeHint());
mTemplateUseTime->setReadOnly(mReadOnly);
......@@ -345,8 +364,7 @@ void EditAlarmDlg::init(const KAEvent* event)
TimeSpinBox::shiftWhatsThis()));
connect(mTemplateTime, &TimeEdit::valueChanged, this, &EditAlarmDlg::contentsChanged);
layout->addWidget(mTemplateTime);
layout->setStretchFactor(new QWidget(box), 1); // left adjust the controls
box->setFixedHeight(box->sizeHint().height());
layout->addStretch(1);
grid->addWidget(box, 0, 1, Qt::AlignLeft);
mTemplateAnyTime = new RadioButton(i18nc("@option:radio", "Date only"), templateTimeBox);
......@@ -356,9 +374,10 @@ void EditAlarmDlg::init(const KAEvent* event)
mTemplateTimeGroup->addButton(mTemplateAnyTime);
grid->addWidget(mTemplateAnyTime, 1, 0, Qt::AlignLeft);
layout = new QHBoxLayout(templateTimeBox);
box = new QWidget(templateTimeBox);
layout = new QHBoxLayout(box);
layout->setMargin(0);
layout->setSpacing(spacingHint());
layout->setSpacing(style()->pixelMetric(QStyle::PM_DefaultLayoutSpacing));
mTemplateUseTimeAfter = new RadioButton(i18nc("@option:radio", "Time from now:"), box);
mTemplateUseTimeAfter->setFixedSize(mTemplateUseTimeAfter->sizeHint());
mTemplateUseTimeAfter->setReadOnly(mReadOnly);
......@@ -394,7 +413,7 @@ void EditAlarmDlg::init(const KAEvent* event)
topLayout->addWidget(mMoreOptions);
QVBoxLayout* moreLayout = new QVBoxLayout(mMoreOptions);
moreLayout->setMargin(0);
moreLayout->setSpacing(spacingHint());
moreLayout->setSpacing(style()->pixelMetric(QStyle::PM_DefaultLayoutSpacing));
// Reminder
mReminder = createReminder(mMoreOptions);
......@@ -413,7 +432,7 @@ void EditAlarmDlg::init(const KAEvent* event)
moreLayout->addWidget(mLateCancel, 0, Qt::AlignLeft);
PackedLayout* playout = new PackedLayout(Qt::AlignJustify);
playout->setSpacing(2*spacingHint());
playout->setSpacing(2 * style()->pixelMetric(QStyle::PM_DefaultLayoutSpacing));
moreLayout->addLayout(playout);
// Acknowledgement confirmation required - default = no confirmation
......@@ -435,7 +454,7 @@ void EditAlarmDlg::init(const KAEvent* event)
playout->addWidget(mShowInKorganizer);
}
setButtonWhatsThis(Ok, i18nc("@info:whatsthis", "Schedule the alarm at the specified time."));
mainLayout->addWidget(mButtonBox);
// Hide optional controls
KConfigGroup config(KSharedConfig::openConfig(), EDIT_MORE_GROUP);
......@@ -579,7 +598,9 @@ void EditAlarmDlg::initValues(const KAEvent* event)
mDeferGroup->hide();
bool empty = AlarmCalendar::resources()->events(CalEvent::TEMPLATE).isEmpty();
enableButton(Help, !empty); // Load Templates button
if (mLoadTemplateButton) {
mLoadTemplateButton->setEnabled(!empty);
}
}
/******************************************************************************
......@@ -711,8 +732,8 @@ void EditAlarmDlg::contentsChanged()
{
// Don't do anything if it's a new alarm or we're still initialising
// (i.e. mSavedEvent null).
if (mSavedEvent && button(Ok))
button(Ok)->setEnabled(stateChanged() || mDeferDateTime.kDateTime() != mSavedDeferTime);
if (mSavedEvent && mButtonBox->button(QDialogButtonBox::Ok))
mButtonBox->button(QDialogButtonBox::Ok)->setEnabled(stateChanged() || mDeferDateTime.kDateTime() != mSavedDeferTime);
}
/******************************************************************************
......@@ -829,11 +850,11 @@ KAEvent::Flags EditAlarmDlg::getAlarmFlags() const
*/
void EditAlarmDlg::showEvent(QShowEvent* se)
{
KDialog::showEvent(se);
QDialog::showEvent(se);
if (!mDeferGroupHeight)
{
if (mDeferGroup)
mDeferGroupHeight = mDeferGroup->height() + spacingHint();
mDeferGroupHeight = mDeferGroup->height() + style()->pixelMetric(QStyle::PM_DefaultLayoutSpacing);
QSize s;
if (KAlarm::readConfigWindowSize(mTemplate ? TEMPLATE_DIALOG_NAME : EDIT_DIALOG_NAME, s))
{
......@@ -854,7 +875,7 @@ void EditAlarmDlg::showEvent(QShowEvent* se)
void EditAlarmDlg::closeEvent(QCloseEvent* ce)
{
Q_EMIT rejected();
KDialog::closeEvent(ce);
QDialog::closeEvent(ce);