Commit e19f8197 authored by Friedrich W. H. Kossebau's avatar Friedrich W. H. Kossebau
Browse files

Reenable lunarphases korganizer plugin, use icon instead of text

Also remove Lunarphases::createWeekElements(), old code would add an icon
for the whole week if on start of the week there is a lunar event, which
is not really something wanted.

sc-status-moon-phase-full.svg is a copy of Breeze's
weather-clear-night.svg of KF 5.84, with the other icons derived from it.

BUG: 30331
FIXED-IN: 21.12
parent 384b429b
Pipeline #93308 passed with stage
in 50 minutes and 47 seconds
......@@ -3,7 +3,6 @@
add_subdirectory(datenums)
#Comment it it depends against kdelibs4support
#add_subdirectory(hebrew)
#Comment it is just too ugly --Allen
#add_subdirectory(lunarphases)
add_subdirectory(lunarphases)
add_subdirectory(picoftheday)
add_subdirectory(thisdayinhistory)
......@@ -18,3 +18,14 @@ install(FILES
lunarphases.desktop
DESTINATION ${KDE_INSTALL_KSERVICES5DIR}/korganizer
)
include(ECMInstallIcons)
ecm_install_icons(
ICONS
pics/sc-status-moon-phase-first-quarter.svg
pics/sc-status-moon-phase-full.svg
pics/sc-status-moon-phase-last-quarter.svg
pics/sc-status-moon-phase-new.svg
DESTINATION ${KDE_INSTALL_ICONDIR}
THEME hicolor
)
/*
SPDX-FileCopyrightText: 2018 Allen Winter <winter@kde.org>
SPDX-FileCopyrightText: 2021 Friedrich W. H. Kossebau <kossebau@kde.org>
SPDX-License-Identifier: GPL-2.0-or-later
*/
#include "lunarphases.h"
#include <KHolidays/LunarPhase>
#include <KConfig>
#include <KConfigGroup>
#include <KLocalizedString>
......@@ -15,11 +14,45 @@
K_PLUGIN_FACTORY(LunarphasesFactory, registerPlugin<Lunarphases>();)
static QIcon phaseIcon(KHolidays::LunarPhase::Phase phase)
{
const QString iconName =
(phase == KHolidays::LunarPhase::NewMoon) ? QStringLiteral("moon-phase-new") :
(phase == KHolidays::LunarPhase::FullMoon) ? QStringLiteral("moon-phase-full") :
(phase == KHolidays::LunarPhase::FirstQuarter) ? QStringLiteral("moon-phase-first-quarter") :
(phase == KHolidays::LunarPhase::LastQuarter) ? QStringLiteral("moon-phase-last-quarter") :
/* else */ QString();
return iconName.isEmpty() ? QIcon() : QIcon::fromTheme(iconName);
}
LunarphasesElement::LunarphasesElement(KHolidays::LunarPhase::Phase phase)
: Element(QStringLiteral("main element"))
, mName(KHolidays::LunarPhase::phaseName(phase))
, mIcon(phaseIcon(phase))
{
}
QString LunarphasesElement::shortText() const
{
return mName;
}
QString LunarphasesElement::longText() const
{
return mName;
}
QPixmap LunarphasesElement::newPixmap(const QSize &size)
{
// TODO: support south hemisphere & equator by rotating by 90 and 180 degrees
return mIcon.pixmap(size);
}
Lunarphases::Lunarphases(QObject *parent, const QVariantList &args)
: Decoration(parent, args)
{
KConfig _config(QStringLiteral("korganizerrc"));
KConfigGroup config(&_config, "Lunar Phases Plugin");
KConfigGroup config(&_config, "Calendar/Lunar Phases Plugin");
}
QString Lunarphases::info() const
......@@ -34,20 +67,11 @@ Element::List Lunarphases::createDayElements(const QDate &date)
{
Element::List result;
const QString name = KHolidays::LunarPhase::phaseNameAtDate(date);
StoredElement *e = new StoredElement(QStringLiteral("main element"), name, name);
result.append(e);
return result;
}
Element::List Lunarphases::createWeekElements(const QDate &date)
{
Element::List result;
const QString name = KHolidays::LunarPhase::phaseNameAtDate(date);
StoredElement *e = new StoredElement(QStringLiteral("main element"), name, name);
result.append(e);
KHolidays::LunarPhase::Phase phase = KHolidays::LunarPhase::phaseAtDate(date);
if (phase != KHolidays::LunarPhase::None) {
auto e = new LunarphasesElement(phase);
result.append(e);
}
return result;
}
......
......@@ -6,6 +6,8 @@
#pragma once
#include <EventViews/CalendarDecoration>
#include <KHolidays/LunarPhase>
#include <QIcon>
using namespace EventViews::CalendarDecoration;
......@@ -15,7 +17,21 @@ public:
Lunarphases(QObject *parent = nullptr, const QVariantList &args = {});
Q_REQUIRED_RESULT Element::List createDayElements(const QDate &) override;
Q_REQUIRED_RESULT Element::List createWeekElements(const QDate &) override;
Q_REQUIRED_RESULT QString info() const override;
};
class LunarphasesElement : public Element
{
Q_OBJECT
public:
explicit LunarphasesElement(KHolidays::LunarPhase::Phase phase);
Q_REQUIRED_RESULT QString shortText() const override;
Q_REQUIRED_RESULT QString longText() const override;
Q_REQUIRED_RESULT QPixmap newPixmap(const QSize &size) override;
private:
QString mName;
QIcon mIcon;
};
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="48" height="48">
<defs>
<linearGradient id="0">
<stop stop-color="#9fb1b1"/>
<stop offset="1" stop-color="#637575"/>
</linearGradient>
<linearGradient id="1">
<stop stop-color="#e0e8e8"/>
<stop offset="1" stop-color="#c0cccc"/>
</linearGradient>
<linearGradient xlink:href="#1" id="2" y1="503.798" x2="0" y2="542.79797" gradientUnits="userSpaceOnUse"/>
<linearGradient xlink:href="#0" id="3" y1="4" x2="0" y2="44" gradientUnits="userSpaceOnUse"/>
</defs>
<metadata/>
<g transform="translate(-384.57143,-499.798)">
<rect width="39.999973" height="39.999996" x="388.57141" y="503.798" ry="19.999987" fill="url(#2)" rx="19.999986"/>
<g transform="translate(384.57143,499.798)">
<path d="M 4.0507812 23.5 C 4.0465376 23.670335 4 23.828607 4 24 C 4 35.079993 12.920007 44 24 44 C 35.079993 44 44 35.079993 44 24 C 44 23.828607 43.953463 23.670335 43.949219 23.5 C 43.919169 24.706109 43.828388 25.898126 43.595703 27.041016 C 43.330156 28.345312 42.938281 29.601641 42.433594 30.798828 C 41.928907 31.996015 41.311171 33.133594 40.59375 34.197266 C 39.876329 35.260937 39.058046 36.250547 38.154297 37.154297 C 37.250547 38.058046 36.260937 38.876329 35.197266 39.59375 C 34.133594 40.311171 32.996015 40.928907 31.798828 41.433594 C 30.601641 41.938281 29.345312 42.330156 28.041016 42.595703 C 26.73672 42.86125 25.384999 43 24 43 C 22.615001 43 21.26328 42.86125 19.958984 42.595703 C 18.654688 42.330156 17.398359 41.938281 16.201172 41.433594 C 15.602578 41.18125 15.018174 40.900948 14.451172 40.59375 C 13.88417 40.286552 13.33457 39.952461 12.802734 39.59375 C 11.739063 38.876329 10.749453 38.058046 9.8457031 37.154297 C 8.9419537 36.250547 8.1236714 35.260937 7.40625 34.197266 C 6.6888286 33.133594 6.0710934 31.996015 5.5664062 30.798828 C 5.0617191 29.601641 4.6698436 28.345312 4.4042969 27.041016 C 4.1716115 25.898126 4.0808305 24.706109 4.0507812 23.5 z " opacity="0.2"/>
<path d="M 19.144531,4.6132812 C 14.613164,5.7374173 10.71101,8.3901858 8,12.007812 L 8,13 l 0,8 4,1 5,9 6,-4 -1,-5 -2,-4 5,-2 5,-3 L 28,8 19,9 18,7 24,6 Z M 33,12 l -3,4 3,4 -1,5 3,8 1,-3 0,-5 2,3 0,6 5,-6 z m -17,1 1,3 -3,3 -1,-3 z m 26,6 -1,2 1,3 1,-2 z m -32,7 0,3 3,1 1,-3 z" opacity="0.614" fill="url(#3)"/>
</g>
</g>
<path style="opacity:0.7;fill:#000000;stroke:none" d="M 24,43 C 13.50659,43 5,34.49341 5,24 5,13.50659 13.50659,5 24,5 c 0,15 0,25 0,38 z"/>
</svg>
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="48" height="48">
<defs>
<linearGradient id="0">
<stop stop-color="#9fb1b1"/>
<stop offset="1" stop-color="#637575"/>
</linearGradient>
<linearGradient id="1">
<stop stop-color="#e0e8e8"/>
<stop offset="1" stop-color="#c0cccc"/>
</linearGradient>
<linearGradient xlink:href="#1" id="2" y1="503.798" x2="0" y2="542.79797" gradientUnits="userSpaceOnUse"/>
<linearGradient xlink:href="#0" id="3" y1="4" x2="0" y2="44" gradientUnits="userSpaceOnUse"/>
</defs>
<metadata/>
<g transform="translate(-384.57143,-499.798)">
<rect width="39.999973" height="39.999996" x="388.57141" y="503.798" ry="19.999987" fill="url(#2)" rx="19.999986"/>
<g transform="translate(384.57143,499.798)">
<path d="M 4.0507812 23.5 C 4.0465376 23.670335 4 23.828607 4 24 C 4 35.079993 12.920007 44 24 44 C 35.079993 44 44 35.079993 44 24 C 44 23.828607 43.953463 23.670335 43.949219 23.5 C 43.919169 24.706109 43.828388 25.898126 43.595703 27.041016 C 43.330156 28.345312 42.938281 29.601641 42.433594 30.798828 C 41.928907 31.996015 41.311171 33.133594 40.59375 34.197266 C 39.876329 35.260937 39.058046 36.250547 38.154297 37.154297 C 37.250547 38.058046 36.260937 38.876329 35.197266 39.59375 C 34.133594 40.311171 32.996015 40.928907 31.798828 41.433594 C 30.601641 41.938281 29.345312 42.330156 28.041016 42.595703 C 26.73672 42.86125 25.384999 43 24 43 C 22.615001 43 21.26328 42.86125 19.958984 42.595703 C 18.654688 42.330156 17.398359 41.938281 16.201172 41.433594 C 15.602578 41.18125 15.018174 40.900948 14.451172 40.59375 C 13.88417 40.286552 13.33457 39.952461 12.802734 39.59375 C 11.739063 38.876329 10.749453 38.058046 9.8457031 37.154297 C 8.9419537 36.250547 8.1236714 35.260937 7.40625 34.197266 C 6.6888286 33.133594 6.0710934 31.996015 5.5664062 30.798828 C 5.0617191 29.601641 4.6698436 28.345312 4.4042969 27.041016 C 4.1716115 25.898126 4.0808305 24.706109 4.0507812 23.5 z " opacity="0.2"/>
<path d="M 19.144531,4.6132812 C 14.613164,5.7374173 10.71101,8.3901858 8,12.007812 L 8,13 l 0,8 4,1 5,9 6,-4 -1,-5 -2,-4 5,-2 5,-3 L 28,8 19,9 18,7 24,6 Z M 33,12 l -3,4 3,4 -1,5 3,8 1,-3 0,-5 2,3 0,6 5,-6 z m -17,1 1,3 -3,3 -1,-3 z m 26,6 -1,2 1,3 1,-2 z m -32,7 0,3 3,1 1,-3 z" opacity="0.614" fill="url(#3)"/>
</g>
</g>
</svg>
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="48" height="48">
<defs>
<linearGradient id="0">
<stop stop-color="#9fb1b1"/>
<stop offset="1" stop-color="#637575"/>
</linearGradient>
<linearGradient id="1">
<stop stop-color="#e0e8e8"/>
<stop offset="1" stop-color="#c0cccc"/>
</linearGradient>
<linearGradient xlink:href="#1" id="2" y1="503.798" x2="0" y2="542.79797" gradientUnits="userSpaceOnUse"/>
<linearGradient xlink:href="#0" id="3" y1="4" x2="0" y2="44" gradientUnits="userSpaceOnUse"/>
</defs>
<metadata/>
<g transform="translate(-384.57143,-499.798)">
<rect width="39.999973" height="39.999996" x="388.57141" y="503.798" ry="19.999987" fill="url(#2)" rx="19.999986"/>
<g transform="translate(384.57143,499.798)">
<path d="M 4.0507812 23.5 C 4.0465376 23.670335 4 23.828607 4 24 C 4 35.079993 12.920007 44 24 44 C 35.079993 44 44 35.079993 44 24 C 44 23.828607 43.953463 23.670335 43.949219 23.5 C 43.919169 24.706109 43.828388 25.898126 43.595703 27.041016 C 43.330156 28.345312 42.938281 29.601641 42.433594 30.798828 C 41.928907 31.996015 41.311171 33.133594 40.59375 34.197266 C 39.876329 35.260937 39.058046 36.250547 38.154297 37.154297 C 37.250547 38.058046 36.260937 38.876329 35.197266 39.59375 C 34.133594 40.311171 32.996015 40.928907 31.798828 41.433594 C 30.601641 41.938281 29.345312 42.330156 28.041016 42.595703 C 26.73672 42.86125 25.384999 43 24 43 C 22.615001 43 21.26328 42.86125 19.958984 42.595703 C 18.654688 42.330156 17.398359 41.938281 16.201172 41.433594 C 15.602578 41.18125 15.018174 40.900948 14.451172 40.59375 C 13.88417 40.286552 13.33457 39.952461 12.802734 39.59375 C 11.739063 38.876329 10.749453 38.058046 9.8457031 37.154297 C 8.9419537 36.250547 8.1236714 35.260937 7.40625 34.197266 C 6.6888286 33.133594 6.0710934 31.996015 5.5664062 30.798828 C 5.0617191 29.601641 4.6698436 28.345312 4.4042969 27.041016 C 4.1716115 25.898126 4.0808305 24.706109 4.0507812 23.5 z " opacity="0.2"/>
<path d="M 19.144531,4.6132812 C 14.613164,5.7374173 10.71101,8.3901858 8,12.007812 L 8,13 l 0,8 4,1 5,9 6,-4 -1,-5 -2,-4 5,-2 5,-3 L 28,8 19,9 18,7 24,6 Z M 33,12 l -3,4 3,4 -1,5 3,8 1,-3 0,-5 2,3 0,6 5,-6 z m -17,1 1,3 -3,3 -1,-3 z m 26,6 -1,2 1,3 1,-2 z m -32,7 0,3 3,1 1,-3 z" opacity="0.614" fill="url(#3)"/>
</g>
</g>
<path style="opacity:0.7;fill:#000000;stroke:none" d="M 24,43 C 34.49341,43 43,34.49341 43,24 43,13.50659 34.49341,5 24,5 c 0,15 0,25 0,38 z"/>
</svg>
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="48" height="48">
<defs>
<linearGradient id="0">
<stop stop-color="#9fb1b1"/>
<stop offset="1" stop-color="#637575"/>
</linearGradient>
<linearGradient id="1">
<stop stop-color="#e0e8e8"/>
<stop offset="1" stop-color="#c0cccc"/>
</linearGradient>
<linearGradient xlink:href="#1" id="2" y1="503.798" x2="0" y2="542.79797" gradientUnits="userSpaceOnUse"/>
<linearGradient xlink:href="#0" id="3" y1="4" x2="0" y2="44" gradientUnits="userSpaceOnUse"/>
</defs>
<metadata/>
<g transform="translate(-384.57143,-499.798)">
<rect width="39.999973" height="39.999996" x="388.57141" y="503.798" ry="19.999987" fill="url(#2)" rx="19.999986"/>
<g transform="translate(384.57143,499.798)">
<path d="M 4.0507812 23.5 C 4.0465376 23.670335 4 23.828607 4 24 C 4 35.079993 12.920007 44 24 44 C 35.079993 44 44 35.079993 44 24 C 44 23.828607 43.953463 23.670335 43.949219 23.5 C 43.919169 24.706109 43.828388 25.898126 43.595703 27.041016 C 43.330156 28.345312 42.938281 29.601641 42.433594 30.798828 C 41.928907 31.996015 41.311171 33.133594 40.59375 34.197266 C 39.876329 35.260937 39.058046 36.250547 38.154297 37.154297 C 37.250547 38.058046 36.260937 38.876329 35.197266 39.59375 C 34.133594 40.311171 32.996015 40.928907 31.798828 41.433594 C 30.601641 41.938281 29.345312 42.330156 28.041016 42.595703 C 26.73672 42.86125 25.384999 43 24 43 C 22.615001 43 21.26328 42.86125 19.958984 42.595703 C 18.654688 42.330156 17.398359 41.938281 16.201172 41.433594 C 15.602578 41.18125 15.018174 40.900948 14.451172 40.59375 C 13.88417 40.286552 13.33457 39.952461 12.802734 39.59375 C 11.739063 38.876329 10.749453 38.058046 9.8457031 37.154297 C 8.9419537 36.250547 8.1236714 35.260937 7.40625 34.197266 C 6.6888286 33.133594 6.0710934 31.996015 5.5664062 30.798828 C 5.0617191 29.601641 4.6698436 28.345312 4.4042969 27.041016 C 4.1716115 25.898126 4.0808305 24.706109 4.0507812 23.5 z " opacity="0.2"/>
<path d="M 19.144531,4.6132812 C 14.613164,5.7374173 10.71101,8.3901858 8,12.007812 L 8,13 l 0,8 4,1 5,9 6,-4 -1,-5 -2,-4 5,-2 5,-3 L 28,8 19,9 18,7 24,6 Z M 33,12 l -3,4 3,4 -1,5 3,8 1,-3 0,-5 2,3 0,6 5,-6 z m -17,1 1,3 -3,3 -1,-3 z m 26,6 -1,2 1,3 1,-2 z m -32,7 0,3 3,1 1,-3 z" opacity="0.614" fill="url(#3)"/>
</g>
</g>
<circle style="opacity:0.7;fill:#000000;stroke:none" cx="24" cy="24" r="19"/>
</svg>
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