Commit 1e44f031 authored by David Jarvie's avatar David Jarvie
Browse files

Bug 453193: Fix crash in font chooser after deselecting default font

If the font chooser is displayed with 'use default font' selected,
and 'use default font' is deselected and a style is then chosen,
it crashed due to having no current font.

BUG:453193
parent 7a6348bd
Pipeline #170111 passed with stage
in 1 minute and 39 seconds
KAlarm Change Log
=== Version 3.4.1 (KDE Gear 22.04.1) --- 25 April 2022 ===
=== Version 3.4.1 (KDE Gear 22.04.1) --- 30 April 2022 ===
* Fix checkboxes being disabled in Preferences dialogue.
* Fix time spin boxes being displayed in the wrong position.
* Fix crash when Try clicked to stop audio alarm with fade [KDE Bug 452962]
* Fix Stop Play button not working for display alarm with audio file.
* Fix crash in font chooser when style is selected after deselecting default font [KDE Bug 453193]
=== Version 3.4.0 (KDE Gear 22.04) --- 6 April 2022 ===
* Allow calendars and date picker to be shown together in side panel [KDE Bug 440250]
......
......@@ -204,7 +204,7 @@ BirthdayDlg::BirthdayDlg(QWidget* parent)
// Set the values to their defaults
setColours(Preferences::defaultFgColour(), Preferences::defaultBgColour());
mFontColourButton->setDefaultFont();
mFontColourButton->setFont(Preferences::messageFont(), true);
mFontColourButton->setBgColour(Preferences::defaultBgColour());
mFontColourButton->setFgColour(Preferences::defaultFgColour());
mLateCancel->setMinutes(Preferences::defaultLateCancel(), true, TimePeriod::Days);
......
......@@ -294,10 +294,7 @@ void EditDisplayAlarmDlg::type_initValues(const KAEvent& event)
&& AlarmText::checkIfEmail(event.cleanText()))
mEmailId = event.emailId();
lateCancel()->setAutoClose(event.autoClose());
if (event.useDefaultFont())
mFontColourButton->setDefaultFont();
else
mFontColourButton->setFont(event.font());
mFontColourButton->setFont(event.font(), event.useDefaultFont());
mFontColourButton->setBgColour(event.bgColour());
mFontColourButton->setFgColour(event.fgColour());
setColours(event.fgColour(), event.bgColour());
......@@ -343,7 +340,7 @@ void EditDisplayAlarmDlg::type_initValues(const KAEvent& event)
}
lateCancel()->setAutoClose(Preferences::defaultAutoClose());
mTypeCombo->setCurrentIndex(0);
mFontColourButton->setDefaultFont();
mFontColourButton->setFont(Preferences::messageFont(), true);
mFontColourButton->setBgColour(Preferences::defaultBgColour());
mFontColourButton->setFgColour(Preferences::defaultFgColour());
setColours(Preferences::defaultFgColour(), Preferences::defaultBgColour());
......
/*
* fontcolour.cpp - font and colour chooser widget
* Program: kalarm
* SPDX-FileCopyrightText: 2001-2020 David Jarvie <djarvie@kde.org>
* SPDX-FileCopyrightText: 2001-2022 David Jarvie <djarvie@kde.org>
*
* SPDX-License-Identifier: GPL-2.0-or-later
*/
......@@ -99,16 +99,10 @@ FontColourChooser::FontColourChooser(QWidget* parent, const QStringList& fontLis
slotDefaultFontToggled(false);
}
void FontColourChooser::setDefaultFont()
void FontColourChooser::setFont(const QFont& font, bool defaultFont, bool onlyFixed)
{
if (mDefaultFont)
mDefaultFont->setChecked(true);
}
void FontColourChooser::setFont(const QFont& font, bool onlyFixed)
{
if (mDefaultFont)
mDefaultFont->setChecked(false);
mDefaultFont->setChecked(defaultFont);
mFontChooser->setFont(font, onlyFixed);
}
......
/*
* fontcolour.h - font and colour chooser widget
* Program: kalarm
* SPDX-FileCopyrightText: 2001, 2003, 2008, 2009 David Jarvie <djarvie@kde.org>
* SPDX-FileCopyrightText: 2001-2022 David Jarvie <djarvie@kde.org>
*
* SPDX-License-Identifier: GPL-2.0-or-later
*/
......@@ -26,8 +26,7 @@ public:
const QString& frameLabel = i18n("Requested font"),
bool fg = true, bool defaultFont = false, int visibleListSize = 8);
void setDefaultFont();
void setFont(const QFont&, bool onlyFixed = false);
void setFont(const QFont&, bool defaultFont = false, bool onlyFixed = false);
bool defaultFont() const;
QFont font() const;
QColor fgColour() const;
......
/*
* fontcolourbutton.cpp - pushbutton widget to select a font and colour
* Program: kalarm
* SPDX-FileCopyrightText: 2003-2021 David Jarvie <djarvie@kde.org>
* SPDX-FileCopyrightText: 2003-2022 David Jarvie <djarvie@kde.org>
*
* SPDX-License-Identifier: GPL-2.0-or-later
*/
......@@ -9,7 +9,6 @@
#include "fontcolourbutton.h"
#include "fontcolour.h"
#include "preferences.h"
#include "lib/autoqpointer.h"
#include "kalarm_debug.h"
......@@ -33,14 +32,9 @@ FontColourButton::FontColourButton(QWidget* parent)
setWhatsThis(i18nc("@info:whatsthis", "Choose the font, and foreground and background color, for the alarm message."));
}
void FontColourButton::setDefaultFont()
void FontColourButton::setFont(const QFont& font, bool defaultFont)
{
mDefaultFont = true;
}
void FontColourButton::setFont(const QFont& font)
{
mDefaultFont = false;
mDefaultFont = defaultFont;
mFont = font;
}
......@@ -82,10 +76,7 @@ FontColourDlg::FontColourDlg(const QColor& bgColour, const QColor& fgColour, con
mChooser = new FontColourChooser(this, QStringList(), QString(), true, true);
mChooser->setBgColour(bgColour);
mChooser->setFgColour(fgColour);
if (defaultFont)
mChooser->setDefaultFont();
else
mChooser->setFont(font);
mChooser->setFont(font, defaultFont);
layout->addWidget(mChooser);
layout->addSpacing(style()->pixelMetric(QStyle::PM_LayoutVerticalSpacing));
......
/*
* fontcolourbutton.h - pushbutton widget to select a font and colour
* Program: kalarm
* SPDX-FileCopyrightText: 2003-2020 David Jarvie <djarvie@kde.org>
* SPDX-FileCopyrightText: 2003-2022 David Jarvie <djarvie@kde.org>
*
* SPDX-License-Identifier: GPL-2.0-or-later
*/
......@@ -21,8 +21,14 @@ class FontColourButton : public PushButton
Q_OBJECT
public:
explicit FontColourButton(QWidget* parent = nullptr);
void setDefaultFont();
void setFont(const QFont&);
/** Set the font to use. If using the default font,
* @param font Font to use.
* If @p defaultFont is true, this is the font which is currently the default.
* @param defaultFont true to use the default font.
*/
void setFont(const QFont& font, bool defaultFont);
void setBgColour(const QColor& c) { mBgColour = c; }
void setFgColour(const QColor& c) { mFgColour = c; }
bool defaultFont() const { return mDefaultFont; }
......
Supports Markdown
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