Commit 7cbad16e authored by Jonathan Riddell's avatar Jonathan Riddell 🏄

FEATURE: Remove the moon

it doesn't get built, contains unclearly licenced files causing problem for distributors, there is a modern equivalent in KDE store https://store.kde.org/p/1165459/
parent 3dbd2412
set(luna_SRCS luna.cpp)
kde4_add_ui_files(luna_SRCS lunaConfig.ui)
kde4_add_plugin(plasma_applet_luna ${luna_SRCS})
target_link_libraries(plasma_applet_luna
${KDE4_PLASMA_LIBS} ${KDE4_KDEUI_LIBS})
install(TARGETS plasma_applet_luna
DESTINATION ${PLUGIN_INSTALL_DIR})
install(FILES plasma-applet-luna.desktop
DESTINATION ${SERVICES_INSTALL_DIR})
install(FILES luna.svgz
DESTINATION ${PLASMA_DATA_INSTALL_DIR}/desktoptheme/default/widgets/)
kde4_install_icons(${ICON_INSTALL_DIR})
#! /usr/bin/env bash
$EXTRACTRC *.ui >> rc.cpp
$XGETTEXT *.cpp -o $podir/plasma_applet_luna.pot
/***************************************************************************
* Copyright 1998,2000 Stephan Kulow <coolo@kde.org> *
* Copyright 2008 by Davide Bettio <davide.bettio@kdemail.net> *
* *
* 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 *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program; if not, write to the *
* Free Software Foundation, Inc., *
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA . *
***************************************************************************/
#include "luna.h"
#include <assert.h>
#include <QPainter>
#include <KConfigDialog>
#include <KDebug>
#include <Plasma/Svg>
#include <Plasma/Theme>
#include <Plasma/ToolTipManager>
#include "phases.cpp"
Luna::Luna(QObject *parent, const QVariantList &args)
: Plasma::Applet(parent, args),
counter(-1),
m_theme(0)
{
setHasConfigurationInterface(true);
setAspectRatioMode(Plasma::Square);
setBackgroundHints(Plasma::Applet::NoBackground);
resize(QSize(82, 82));
}
void Luna::init()
{
configChanged();
m_theme = new Plasma::Svg(this);
m_theme->setImagePath("widgets/luna");
m_theme->setContainsMultipleImages(true);
if (!m_theme->isValid()) {
setFailedToLaunch(true, i18n("The luna SVG file was not found"));
return;
}
Plasma::ToolTipManager::self()->registerWidget(this);
connectToEngine();
}
Luna::~Luna()
{
delete m_theme;
}
void Luna::configChanged()
{
northHemisphere = config().readEntry("northHemisphere", true);
}
void Luna::connectToEngine()
{
Plasma::DataEngine* timeEngine = dataEngine("time");
timeEngine->connectSource("UTC", this, 360000, Plasma::AlignToHour);
}
void Luna::dataUpdated(const QString& source, const Plasma::DataEngine::Data &data)
{
Q_UNUSED(source)
QDateTime dt(data["Date"].toDate(), data["Time"].toTime());
calcStatus(dt.toTime_t());
}
void Luna::createConfigurationInterface(KConfigDialog *parent)
{
QWidget *widget = new QWidget();
ui.setupUi(widget);
connect(parent, SIGNAL(applyClicked()), this, SLOT(configAccepted()));
connect(parent, SIGNAL(okClicked()), this, SLOT(configAccepted()));
parent->addPage(widget, i18n("General"), icon());
connect(ui.southernRadio , SIGNAL(clicked(bool)) , parent, SLOT(settingsModified()));
connect(ui.northenRadio , SIGNAL(clicked(bool)) , parent, SLOT(settingsModified()));
ui.northenRadio->setChecked(northHemisphere);
ui.southernRadio->setChecked(!northHemisphere);
}
void Luna::configAccepted()
{
northHemisphere = ui.northenRadio->isChecked();
config().writeEntry("northHemisphere", northHemisphere);
update();
emit configNeedsSaving();
}
void Luna::paintInterface(QPainter *p, const QStyleOptionGraphicsItem *option, const QRect &contentsRect)
{
Q_UNUSED(option)
if (!m_theme) {
return;
}
if (northHemisphere){
m_theme->paint(p, contentsRect, QString::number(counter));
}else{
p->save();
p->rotate(180);
p->translate(-geometry().width(), -geometry().height());
m_theme->paint(p, contentsRect, QString::number(counter));
p->restore();
}
}
void Luna::calcStatus(time_t time)
{
Plasma::ToolTipContent toolTipData;
uint lun = 0;
time_t last_new = 0;
time_t next_new = 0;
do {
double JDE = moonphasebylunation(lun, 0);
last_new = next_new;
next_new = JDtoDate(JDE, 0);
lun++;
} while (next_new < time);
lun -= 2;
QDateTime ln;
ln.setTime_t( last_new );
kDebug() << "last new " << KGlobal::locale()->formatDateTime( ln );
time_t first_quarter = JDtoDate( moonphasebylunation( lun, 1 ), 0 );
QDateTime fq;
fq.setTime_t( first_quarter );
kDebug() << "first quarter " << KGlobal::locale()->formatDateTime( fq );
time_t full_moon = JDtoDate( moonphasebylunation( lun, 2 ), 0 );
QDateTime fm;
fm.setTime_t( full_moon );
kDebug() << "full moon " << KGlobal::locale()->formatDateTime( fm );
time_t third_quarter = JDtoDate( moonphasebylunation( lun, 3 ), 0 );
QDateTime tq;
tq.setTime_t( third_quarter );
kDebug() << "third quarter " << KGlobal::locale()->formatDateTime( tq );
QDateTime nn;
nn.setTime_t( next_new );
kDebug() << "next new " << KGlobal::locale()->formatDateTime( nn );
QDateTime now;
now.setTime_t( time );
kDebug() << "now " << KGlobal::locale()->formatDateTime( now );
counter = ln.daysTo( now );
kDebug() << "counter " << counter << " " << fm.daysTo( now );
if ( fm.daysTo( now ) == 0 ) {
counter = 14;
toolTipData.setMainText( i18n( "Full Moon" ) );
Plasma::ToolTipManager::self()->setContent(this, toolTipData);
update();
return;
} else if ( counter <= 15 && counter >= 13 ) {
counter = 14 + fm.daysTo( now );
kDebug() << "around full moon " << counter;
}
int diff = fq.daysTo( now );
if ( diff == 0 )
counter = 7;
else if ( counter <= 8 && counter >= 6 ) {
counter = 7 + diff;
kDebug() << "around first quarter " << counter;
}
diff = ln.daysTo( now );
if ( diff == 0 )
counter = 0;
else if ( counter <= 1 || counter >= 28 )
{
counter = ( 29 + diff ) % 29;
diff = -nn.daysTo( now );
if ( diff == 0 )
counter = 0;
else if ( diff < 3 )
counter = 29 - diff;
kDebug() << "around new " << counter << " " << diff;
}
if ( tq.daysTo( now ) == 0 )
counter = 21;
else if ( counter <= 22 && counter >= 20 )
{
counter = 21 + tq.daysTo( now );
kDebug() << "around third quarter " << counter;
}
kDebug() << "counter " << counter;
assert (counter >= 0 && counter < 29);
switch (counter) {
case 0:
toolTipData.setMainText( i18n("New Moon") );
break;
case 1:
case 2:
case 3:
case 4:
case 5:
case 6:
toolTipData.setMainText( i18np("Waxing Crescent (New Moon was yesterday)", "Waxing Crescent (%1 days since New Moon)", counter ) );
break;
case 7:
toolTipData.setMainText( i18n("First Quarter") );
break;
case 8:
case 9:
case 10:
case 11:
case 12:
case 13:
toolTipData.setMainText( i18np( "Waxing Gibbous (Tomorrow is Full Moon)", "Waxing Gibbous (%1 days to Full Moon)", -fm.daysTo( now ) ) );
break;
case 14:
assert( false );
break;
case 15:
case 16:
case 17:
case 18:
case 19:
case 20:
toolTipData.setMainText( i18np("Waning Gibbous (Yesterday was Full Moon)", "Waning Gibbous (%1 days since Full Moon)", fm.daysTo( now ) ) );
break;
case 21:
toolTipData.setMainText( i18n("Last Quarter") );
break;
case 22:
case 23:
case 24:
case 25:
case 26:
case 27:
case 28:
kDebug() << "nn.days " << ln.daysTo( now ) << " " << nn.daysTo( now );
toolTipData.setMainText( i18np("Waning Crescent (Tomorrow is New Moon)", "Waning Crescent (%1 days to New Moon)", -nn.daysTo( now ) ) );
break;
default:
kFatal() << "coolo can't count\n";
}
Plasma::ToolTipManager::self()->setContent(this, toolTipData);
update();
}
/***************************************************************************
* Copyright 2008 by Davide Bettio <davide.bettio@kdemail.net> *
* *
* 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 *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program; if not, write to the *
* Free Software Foundation, Inc., *
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA . *
***************************************************************************/
#ifndef LUNA_H
#define LUNA_H
#include <Plasma/Applet>
#include <Plasma/DataEngine>
#include <Plasma/Svg>
#include "ui_lunaConfig.h"
class Luna : public Plasma::Applet
{
Q_OBJECT
public:
Luna(QObject *parent, const QVariantList &args);
~Luna();
void init();
void paintInterface(QPainter *painter, const QStyleOptionGraphicsItem *option, const QRect& contentsRect);
public slots:
void dataUpdated(const QString &name, const Plasma::DataEngine::Data &data);
void configChanged();
protected slots:
void configAccepted();
protected:
void createConfigurationInterface(KConfigDialog *parent);
private:
void connectToEngine();
void calcStatus(time_t time);
int counter;
bool northHemisphere;
Plasma::Svg *m_theme;
Ui::lunaConfig ui;
};
K_EXPORT_PLASMA_APPLET(luna, Luna)
#endif
<ui version="4.0" >
<class>lunaConfig</class>
<widget class="QWidget" name="lunaConfig" >
<property name="geometry" >
<rect>
<x>0</x>
<y>0</y>
<width>272</width>
<height>106</height>
</rect>
</property>
<layout class="QGridLayout" name="gridLayout" >
<item row="0" column="0" colspan="2" >
<widget class="QLabel" name="label" >
<property name="text" >
<string>Show moon as seen in:</string>
</property>
</widget>
</item>
<item row="1" column="0" >
<spacer name="horizontalSpacer" >
<property name="orientation" >
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeType" >
<enum>QSizePolicy::Fixed</enum>
</property>
<property name="sizeHint" stdset="0" >
<size>
<width>5</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item row="1" column="1" >
<widget class="QRadioButton" name="northenRadio" >
<property name="sizePolicy" >
<sizepolicy vsizetype="Fixed" hsizetype="Expanding" >
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text" >
<string>Northern hemisphere</string>
</property>
</widget>
</item>
<item row="2" column="1" >
<widget class="QRadioButton" name="southernRadio" >
<property name="sizePolicy" >
<sizepolicy vsizetype="Fixed" hsizetype="Expanding" >
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text" >
<string>Southern hemisphere</string>
</property>
</widget>
</item>
<item row="3" column="0" colspan="2" >
<spacer name="verticalSpacer" >
<property name="orientation" >
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0" >
<size>
<width>20</width>
<height>23</height>
</size>
</property>
</spacer>
</item>
</layout>
</widget>
<resources/>
<connections/>
</ui>
This diff is collapsed.
[Desktop Entry]
Name=Luna
Name[ar]=لونا
Name[bs]=Luna
Name[ca]=Lluna
Name[ca@valencia]=Lluna
Name[cs]=Luna
Name[da]=Luna
Name[de]=Luna
Name[el]=Σελήνη
Name[en_GB]=Luna
Name[eo]=Luna
Name[es]=Luna
Name[et]=Luna
Name[eu]=Ilargia
Name[fi]=Luna
Name[fr]=Lune
Name[ga]=Luna
Name[gl]=Lúa
Name[he]=ירח
Name[hr]=Luna
Name[hu]=Luna
Name[is]=Luna
Name[it]=Luna
Name[ja]=Luna
Name[kk]=Ай
Name[km]=Luna
Name[ko]=달
Name[ku]=Luna
Name[lt]=Mėnulis
Name[lv]=Luna
Name[mr]=चंद्र
Name[nb]=Luna
Name[nds]=Luna
Name[nl]=Luna
Name[nn]=Månefaseindikator
Name[pa]=ਲੂਨਾ
Name[pl]=Luna
Name[pt]=Luna
Name[pt_BR]=Lua
Name[ro]=Luna
Name[ru]=Луна
Name[sk]=Luna
Name[sl]=Luna
Name[sq]=Luna
Name[sr]=Луна
Name[sr@ijekavian]=Луна
Name[sr@ijekavianlatin]=Luna
Name[sr@latin]=Luna
Name[sv]=Luna
Name[th]=ข้างขึ้น/ข้างแรม
Name[tr]=Luna
Name[uk]=Луна
Name[wa]=Luna
Name[x-test]=xxLunaxx
Name[zh_CN]=月相
Name[zh_TW]=Luna
Comment=Display moon phases for your location
Comment[ar]=أظهر أطوار القمر في المكان الذي انت فيه
Comment[bs]=Prikazuje mjesečeve mijene sa vaše lokacije
Comment[ca]=Mostra les fases de la lluna per a la vostra ubicació
Comment[ca@valencia]=Mostra les fases de la lluna per a la vostra ubicació
Comment[cs]=Zobrazení fází měsíce
Comment[da]=Viser månefaser for dit lokalområde.
Comment[de]=Mondphasen für Ihren Standort anzeigen
Comment[el]=Εμφάνιση φάσεων της Σελήνης από την τοποθεσία σας
Comment[en_GB]=Display moon phases for your location
Comment[es]=Mostrar las fases de la Luna en su ubicación
Comment[et]=Kuufaaside näitamine vastavalt sinu asukohale
Comment[eu]=Bistaratu zure kokapenerako ilargi faseak
Comment[fi]=Näyttää kuun vaiheet sijainnillesi
Comment[fr]=Affiche les phases de la lune, visibles à votre position
Comment[ga]=Taispeáin céimeanna na gealaí i do cheantar
Comment[gl]=Mostra as fases da lúa na súa localización
Comment[he]=מציג שלבים של הירח לפי המיקום שלך
Comment[hr]=Prikaži faze mjeseca za Vašu lokaciju
Comment[hu]=Holdfázisok megjelenítése
Comment[is]=Sýnir stöðu tunglkvartila fyrir staðsetninguna þína
Comment[it]=Mostra le fasi lunari nella tua posizione
Comment[ja]=お住まいの場所の月の満ち欠けを表示します
Comment[kk]=Жеріңізден көрінетін ай толуы кезеңдерін көрсету
Comment[km]=បង្ហាញ​ដំណើរ​ព្រះ​ច័ន្ទ​សម្រាប់​ទីតាំង​របស់អ្នក
Comment[ko]=현재 위치의 달 모양 보이기
Comment[ku]=Ji bo herêma xwe rewşa heyvê nîşan bide
Comment[lt]=Rodyti mėnulio fazes jūsų vietovei
Comment[lv]=Rāda mēness fāzi
Comment[mr]=तुमच्या स्थानाकरिता चंद्राच्या कला दर्शवितो
Comment[nb]=Vis månefaser for der du er
Comment[nds]=De aktuelle Maanschiev wiesen
Comment[nl]=Toont maanfasen voor uw locatie
Comment[nn]=Vis korleis månen ser ut der du er
Comment[pa]=ਆਪਣੇ ਟਿਕਾਣੇ ਮੁਤਾਬਕ ਚੰਦ ਕਲਾਵਾਂ ਵੇਖੋ
Comment[pl]=Wyświetla fazy Księżyca w twojej okolicy
Comment[pt]=Mostrar as fases lunares para a sua localidade
Comment[pt_BR]=Mostra as fases da Lua para a sua localidade
Comment[ro]=Afișează fazele lunii pentru locația dumneavoastră
Comment[ru]=Показывает фазу Луны для указанного местоположения
Comment[sk]=Zobrazenie fáz mesiaca
Comment[sl]=Prikaže lunine mene za vaš položaj
Comment[sr]=Приказује месечеве мене са ваше локације
Comment[sr@ijekavian]=Приказује мјесечеве мијене са ваше локације
Comment[sr@ijekavianlatin]=Prikazuje mjesečeve mijene sa vaše lokacije
Comment[sr@latin]=Prikazuje mesečeve mene sa vaše lokacije
Comment[sv]=Visa månfaser där du befinner dig
Comment[th]=แสดงข้างขึ้น/ข้างแรม จากพื้นที่ที่คุณอาศัยอยู่
Comment[tr]=Konumunuz için Ay'ın hangi evrede olduğunu gösterin
Comment[uk]=Показує фазу Місяця у місце, де ви знаходитеся
Comment[wa]=Håyner les fåzes del lune po vosse plaece
Comment[x-test]=xxDisplay moon phases for your locationxx
Comment[zh_CN]=显示您位置的月相
Comment[zh_TW]=顯示您所在位置的月相
Type=Service
Icon=luna
ServiceTypes=Plasma/Applet
X-KDE-Library=plasma_applet_luna
X-KDE-PluginInfo-Author=Davide Bettio
X-KDE-PluginInfo-Email=davide.bettio@kdemail.net
X-KDE-PluginInfo-Name=luna
X-KDE-PluginInfo-Version=1.0
X-KDE-PluginInfo-Website=http://plasma.kde.org/
X-KDE-PluginInfo-Category=Astronomy
X-KDE-PluginInfo-Depends=
X-KDE-PluginInfo-License=GPL
X-KDE-PluginInfo-EnabledByDefault=true
X-Plasma-Requires-FileDialog=Unused
X-Plasma-Requires-LaunchApp=Unused
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