Members of the KDE Community are recommended to subscribe to the kde-community mailing list at https://mail.kde.org/mailman/listinfo/kde-community to allow them to participate in important discussions and receive other important announcements

Commit b6a185b2 authored by Henrik Fehlauer's avatar Henrik Fehlauer

Prevent occasional empty Save button when upgrading from earlier version

Summary:
63bc26c6 introduced a regression, where when upgrading from
Spectacle 17.12 with {nav Save As} used last to 18.04 the {nav Save}
button would show no text at all and clicking would be a no-op (the down
arrow menu still worked, though).

The reason is the removal of a `default` case, however the root problem
has been there before: `lastUsedSaveMode()` could pass invalid values.
This can be fixed by properly refactoring the latter method too and
trading meticulosity for compactness when converting from `int` to
`enum`, i.e. adding the `default` to the correct place. If Spectacle
used KConfigXT this would not have been a problem in the first place…

Test Plan:
- `rm ~/.config/spectaclerc`
- Start Spectacle 17.12, {nav Save As}, {nav Quit}
- Start Spectacle from master
{nav Save} button now correctly shows the default text instead of
nothing at all. Button state still remembered after restart.

Reviewers: #spectacle, ngraham

Reviewed By: #spectacle, ngraham

Subscribers: ngraham

Differential Revision: https://phabricator.kde.org/D10682
parent db2231ae
......@@ -199,7 +199,13 @@ void SpectacleConfig::setUseLightRegionMaskColour(bool enabled)
SaveMode SpectacleConfig::lastUsedSaveMode() const
{
return static_cast<SaveMode>(mGuiConfig.readEntry(QStringLiteral("lastUsedSaveMode"), 0));
switch (mGuiConfig.readEntry(QStringLiteral("lastUsedSaveMode"), 0)) {
default:
case 0:
return SaveMode::SaveAs;
case 1:
return SaveMode::Save;
}
}
void SpectacleConfig::setLastUsedSaveMode(SaveMode mode)
......
......@@ -27,7 +27,7 @@
#include <KSharedConfig>
#include <KConfigGroup>
enum SaveMode {
enum class SaveMode {
SaveAs,
Save
};
......
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