kdeplasma-addons: drop all clock applets

the luna applet may be reimplemented and moved to kde-workspace

Signed-off-by: Ivailo Monev <xakepa10@gmail.com>
This commit is contained in:
Ivailo Monev 2024-04-03 18:51:12 +03:00
parent 48ed9841fe
commit ae38e9014e
28 changed files with 0 additions and 3556 deletions

View file

@ -10,17 +10,6 @@ if(${CMAKE_SOURCE_DIR} STREQUAL ${CMAKE_CURRENT_SOURCE_DIR})
add_definitions(${QT_DEFINITIONS} ${KDE4_DEFINITIONS})
endif()
kde4_optional_find_package(KDE4Workspace)
set_package_properties(KDE4Workspace PROPERTIES
DESCRIPTION "KDE base workspace libraries"
URL "https://osdn.net/projects/kde/"
PURPOSE "Needed for building several Plasma plugins"
)
include_directories(
${CMAKE_CURRENT_SOURCE_DIR}/libs
)
add_subdirectory(applets)
add_subdirectory(dataengines)
add_subdirectory(runners)

View file

@ -1,5 +1,3 @@
include_directories(${PLASMACLOCK_INCLUDE_DIR})
add_subdirectory(bball)
add_subdirectory(blackboard)
add_subdirectory(bookmarks)
@ -9,7 +7,6 @@ add_subdirectory(frame)
add_subdirectory(kolourpicker)
add_subdirectory(konsoleprofiles)
add_subdirectory(life)
add_subdirectory(luna)
add_subdirectory(magnifique)
add_subdirectory(notes)
add_subdirectory(spellcheck)
@ -19,8 +16,3 @@ add_subdirectory(unitconverter)
add_subdirectory(dict)
add_subdirectory(incomingmsg)
add_subdirectory(paste)
if(KDE4WORKSPACE_FOUND)
add_subdirectory(binary-clock)
add_subdirectory(fuzzy-clock)
endif()

View file

@ -1,21 +0,0 @@
project(binaryclock)
set(binaryclock_SRCS binaryclock.cpp clockConfig.ui)
kde4_add_plugin(plasma_applet_binaryclock ${binaryclock_SRCS})
target_link_libraries(plasma_applet_binaryclock
KDE4::kdeui
KDE4::plasma
KDE4Workspace::plasmaclock
)
install(
TARGETS plasma_applet_binaryclock
DESTINATION ${KDE4_PLUGIN_INSTALL_DIR}
)
install(
FILES plasma-applet-binaryclock.desktop
DESTINATION ${KDE4_SERVICES_INSTALL_DIR}
)

View file

@ -1,3 +0,0 @@
#! /usr/bin/env bash
$EXTRACTRC *.ui >> rc.cpp
$XGETTEXT *.cpp -o $podir/plasma_applet_binaryclock.pot

View file

@ -1,315 +0,0 @@
/***************************************************************************
* Copyright 2007 by Riccardo Iaconelli <riccardo@kde.org> *
* Copyright 2007 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 "binaryclock.h"
#include <QPainter>
#include <KConfigDialog>
#include <Plasma/DataEngine>
#include <Plasma/Theme>
BinaryClock::BinaryClock(QObject *parent, const QVariantList &args)
: ClockApplet(parent, args),
m_showSeconds(true),
m_showOffLeds(true),
m_showGrid(true),
m_time(0, 0)
{
KGlobal::locale()->insertCatalog(QLatin1String("libplasmaclock"));
KGlobal::locale()->insertCatalog(QLatin1String("timezones4"));
setHasConfigurationInterface(true);
resize(getWidthFromHeight(128), 128);
}
void BinaryClock::init()
{
ClockApplet::init();
clockConfigChanged();
connect(Plasma::Theme::defaultTheme(), SIGNAL(themeChanged()), SLOT(updateColors()));
connectToEngine();
updateColors();
}
BinaryClock::~BinaryClock()
{
}
int BinaryClock::getHeightFromWidth(int w) const
{
int dots = m_showSeconds ? 6 : 4;
int rectSize = (w - 5) * 4;
return (rectSize / dots) + 3;
}
int BinaryClock::getWidthFromHeight(int h) const
{
int dots = m_showSeconds ? 6 : 4;
int rectSize = (h - 3) / 4;
return (rectSize * dots) + (dots - 1);
}
void BinaryClock::constraintsEvent(Plasma::Constraints constraints)
{
if (constraints & Plasma::SizeConstraint) {
qreal top, bottom, left, right;
getContentsMargins(&left, &top, &right, &bottom);
qreal borderHeight = top + bottom;
qreal borderWidth = left + right;
if (formFactor() == Plasma::Vertical) {
setMinimumHeight(getHeightFromWidth((int) contentsRect().width()) + borderHeight);
setMinimumWidth(0);
} else if (formFactor() == Plasma::Horizontal) {
setMinimumWidth(getWidthFromHeight((int) contentsRect().height()) + borderWidth);
setMinimumHeight(0);
} else {
setMinimumWidth(getWidthFromHeight(40));
setMinimumHeight(40);
}
}
}
void BinaryClock::connectToEngine()
{
Plasma::DataEngine* timeEngine = dataEngine(QLatin1String("time"));
if (m_showSeconds) {
timeEngine->connectSource(currentTimezone(), this, 500);
} else {
timeEngine->connectSource(currentTimezone(), this, 6000, Plasma::AlignToMinute);
}
}
void BinaryClock::dataUpdated(const QString& source, const Plasma::DataEngine::Data &data)
{
Q_UNUSED(source);
m_time = data[QLatin1String("Time")].toTime();
if (m_time.minute() == m_lastTimeSeen.minute() &&
m_time.second() == m_lastTimeSeen.second()) {
// avoid unnecessary repaints
return;
}
if (Plasma::ToolTipManager::self()->isVisible(this)) {
updateTipContent();
}
updateClockApplet(data);
m_lastTimeSeen = m_time;
update();
}
void BinaryClock::createClockConfigurationInterface(KConfigDialog *parent)
{
QWidget *widget = new QWidget();
ui.setupUi(widget);
parent->addPage(widget, i18n("Appearance"), QLatin1String("view-media-visualization"));
ui.showSecondHandCheckBox->setChecked(m_showSeconds);
ui.showGridCheckBox->setChecked(m_showGrid);
ui.showOffLedsCheckBox->setChecked(m_showOffLeds);
QButtonGroup *onLedsGroup = new QButtonGroup(widget);
onLedsGroup->addButton(ui.onLedsDefaultColorRadioButton);
onLedsGroup->addButton(ui.onLedsCustomColorRadioButton);
QButtonGroup *offLedsGroup = new QButtonGroup(widget);
offLedsGroup->addButton(ui.offLedsDefaultColorRadioButton);
offLedsGroup->addButton(ui.offLedsCustomColorRadioButton);
ui.onLedsDefaultColorRadioButton->setChecked(!m_customOnLedsColor);
ui.offLedsDefaultColorRadioButton->setChecked(!m_customOffLedsColor);
ui.gridDefaultColorRadioButton->setChecked(!m_customGridColor);
ui.onLedsCustomColorRadioButton->setChecked(m_customOnLedsColor);
ui.offLedsCustomColorRadioButton->setChecked(m_customOffLedsColor);
ui.gridCustomColorRadioButton->setChecked(m_customGridColor);
KConfigGroup cg = config();
ui.onLedsCustomColorButton->setColor(cg.readEntry("onLedsColor", m_onLedsColor));
ui.offLedsCustomColorButton->setColor(cg.readEntry("offLedsColor", m_offLedsColor));
ui.gridCustomColorButton->setColor(cg.readEntry("gridColor", m_gridColor));
connect(ui.showSecondHandCheckBox, SIGNAL(stateChanged(int)), parent, SLOT(settingsModified()));
connect(ui.showGridCheckBox, SIGNAL(stateChanged(int)), parent, SLOT(settingsModified()));
connect(ui.showOffLedsCheckBox, SIGNAL(stateChanged(int)), parent, SLOT(settingsModified()));
connect(onLedsGroup, SIGNAL(buttonReleased(int)), parent, SLOT(settingsModified()));
connect(offLedsGroup, SIGNAL(buttonReleased(int)), parent, SLOT(settingsModified()));
connect(ui.showOffLedsCheckBox, SIGNAL(stateChanged(int)), parent, SLOT(settingsModified()));
connect(ui.showGridCheckBox, SIGNAL(stateChanged(int)), parent, SLOT(settingsModified()));
}
void BinaryClock::clockConfigAccepted()
{
KConfigGroup cg = config();
m_showSeconds = ui.showSecondHandCheckBox->isChecked();
m_showGrid = ui.showGridCheckBox->isChecked();
m_showOffLeds = ui.showOffLedsCheckBox->isChecked();
m_customOnLedsColor = ui.onLedsCustomColorRadioButton->isChecked();
m_customOffLedsColor = ui.offLedsCustomColorRadioButton->isChecked();
m_customGridColor = ui.gridCustomColorRadioButton->isChecked();
if (m_customOnLedsColor){
m_onLedsColor = ui.onLedsCustomColorButton->color();
}
if (m_customOffLedsColor){
m_offLedsColor = ui.offLedsCustomColorButton->color();
}
if (m_customGridColor){
m_gridColor = ui.gridCustomColorButton->color();
}
cg.writeEntry("showSeconds", m_showSeconds);
cg.writeEntry("showGrid", m_showGrid);
cg.writeEntry("showOffLeds", m_showOffLeds);
cg.writeEntry("customOnLedsColor", m_customOnLedsColor);
cg.writeEntry("customOffLedsColor", m_customOffLedsColor);
cg.writeEntry("customGridColor", m_customGridColor);
cg.writeEntry("onLedsColor", ui.onLedsCustomColorButton->color());
cg.writeEntry("offLedsColor", ui.offLedsCustomColorButton->color());
cg.writeEntry("gridColor", ui.gridCustomColorButton->color());
dataEngine(QLatin1String("time"))->disconnectSource(currentTimezone(), this);
connectToEngine();
update();
emit configNeedsSaving();
}
void BinaryClock::clockConfigChanged()
{
KConfigGroup cg = config();
m_showSeconds = cg.readEntry("showSeconds", m_showSeconds);
m_showGrid = cg.readEntry("showGrid", m_showGrid);
m_showOffLeds = cg.readEntry("showOffLeds", m_showOffLeds);
m_customOnLedsColor = cg.readEntry("customOnLedsColor", false);
m_customOffLedsColor = cg.readEntry("customOffLedsColor", false);
m_customGridColor = cg.readEntry("customGridColor", false);
updateColors();
}
void BinaryClock::changeEngineTimezone(const QString &oldTimezone, const QString &newTimezone)
{
dataEngine(QLatin1String("time"))->disconnectSource(oldTimezone, this);
Plasma::DataEngine* timeEngine = dataEngine(QLatin1String("time"));
if (m_showSeconds) {
timeEngine->connectSource(newTimezone, this, 500);
} else {
timeEngine->connectSource(newTimezone, this, 6000, Plasma::AlignToMinute);
}
}
void BinaryClock::updateColors()
{
KConfigGroup cg = config();
m_onLedsColor = QColor(Plasma::Theme::defaultTheme()->color(Plasma::Theme::TextColor));
if (m_customOnLedsColor){
m_onLedsColor = cg.readEntry("onLedsColor", m_onLedsColor);
}
m_offLedsColor = QColor(m_onLedsColor);
m_offLedsColor.setAlpha(40);
if (m_customOffLedsColor){
m_offLedsColor = cg.readEntry("offLedsColor", m_offLedsColor);
}
m_gridColor = QColor(m_onLedsColor);
m_gridColor.setAlpha(60);
if (m_customGridColor){
m_gridColor = cg.readEntry("gridColor", m_gridColor);
}
update();
}
void BinaryClock::paintInterface(QPainter *p, const QStyleOptionGraphicsItem *option,
const QRect &contentsRect)
{
Q_UNUSED(option);
if (! m_time.isValid()) {
return;
}
int appletHeight = (int) contentsRect.height();
int appletWidth = (int) contentsRect.width();
int dots = m_showSeconds ? 6 : 4;
int rectSize = qMax(1, qMin((appletHeight - 3) / 4, (appletWidth - 3) / dots));
int yPos = ((appletHeight - 4 * rectSize) / 2) + contentsRect.topLeft().y();
int xPos = ((appletWidth - (rectSize * dots) - 5) / 2) + contentsRect.topLeft().x();
int timeDigits[6] = {m_time.hour() / 10, m_time.hour() % 10,
m_time.minute() / 10, m_time.minute() % 10,
m_time.second() / 10, m_time.second() % 10};
for (int i = 0; i < dots; i++) {
for (int j = 0; j < 4; j++) {
if (timeDigits[i] & (1 << (3 - j))) {
p->fillRect(xPos + (i * (rectSize + 1)), yPos + (j * (rectSize + 1)), rectSize, rectSize, m_onLedsColor);
} else if (m_showOffLeds) {
p->fillRect(xPos + (i * (rectSize + 1)), yPos + (j * (rectSize + 1)), rectSize, rectSize, m_offLedsColor);
}
}
}
if (m_showGrid) {
p->setPen(m_gridColor);
p->drawRect((xPos - 1), (yPos - 1),
(dots * (rectSize + 1)), (4 * (rectSize + 1)) );
for (int i = 1; i < dots; i++) {
for (int j = 0; j < 4; j++) {
p->drawLine((xPos + (i * (rectSize + 1)) - 1), (yPos + (j * (rectSize + 1))),
(xPos + (i * (rectSize + 1)) - 1), (yPos + (j * (rectSize + 1)) + rectSize - 1) );
}
}
for (int j = 1; j < 4; j++) {
p->drawLine(xPos, (yPos + (j * (rectSize + 1)) - 1),
(xPos + (dots * (rectSize + 1)) - 2), (yPos + (j * (rectSize + 1)) - 1) );
}
}
}
#include "moc_binaryclock.cpp"

View file

@ -1,86 +0,0 @@
/***************************************************************************
* Copyright 2007 by Riccardo Iaconelli <riccardo@kde.org> *
* Copyright 2007 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 BINARYCLOCK_H
#define BINARYCLOCK_H
#include <Plasma/Applet>
#include <plasmaclock/clockapplet.h>
#include "ui_clockConfig.h"
#include <QTime>
#include <QColor>
namespace Plasma {
class DataEngine;
}
class BinaryClock : public ClockApplet
{
Q_OBJECT
public:
BinaryClock(QObject *parent, const QVariantList &args);
~BinaryClock();
void init();
void paintInterface(QPainter *painter, const QStyleOptionGraphicsItem *option, const QRect& contentsRect);
void constraintsEvent(Plasma::Constraints constraints);
public slots:
void dataUpdated(const QString &name, const Plasma::DataEngine::Data &data);
protected:
void createClockConfigurationInterface(KConfigDialog *parent);
void clockConfigAccepted();
void clockConfigChanged();
void changeEngineTimezone(const QString &oldTimezone, const QString &newTimezone);
private slots:
void updateColors();
private:
void connectToEngine();
int getWidthFromHeight(int h) const;
int getHeightFromWidth(int w) const;
bool m_showSeconds;
bool m_showOffLeds;
bool m_showGrid;
bool m_customOnLedsColor;
bool m_customOffLedsColor;
bool m_customGridColor;
QColor m_onLedsColor;
QColor m_offLedsColor;
QColor m_gridColor;
QTime m_lastTimeSeen;
QTime m_time;
Ui::clockConfig ui;
};
K_EXPORT_PLASMA_APPLET(binaryclock, BinaryClock)
#endif

View file

@ -1,422 +0,0 @@
<ui version="4.0" >
<class>clockConfig</class>
<widget class="QWidget" name="clockConfig" >
<property name="geometry" >
<rect>
<x>0</x>
<y>0</y>
<width>586</width>
<height>349</height>
</rect>
</property>
<property name="minimumSize" >
<size>
<width>400</width>
<height>300</height>
</size>
</property>
<layout class="QGridLayout" name="gridLayout" >
<item row="0" column="0" >
<widget class="QLabel" name="Appearance" >
<property name="font" >
<font>
<weight>75</weight>
<bold>true</bold>
</font>
</property>
<property name="text" >
<string>Appearance</string>
</property>
</widget>
</item>
<item row="1" column="1" >
<widget class="QLabel" name="label" >
<property name="text" >
<string>Active LEDs:</string>
</property>
<property name="alignment" >
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget>
</item>
<item row="3" column="4" >
<layout class="QHBoxLayout" name="horizontalLayout_3" >
<item>
<widget class="QRadioButton" name="onLedsCustomColorRadioButton" >
<property name="text" >
<string>Use custom color for active LEDs:</string>
</property>
</widget>
</item>
<item>
<widget class="KColorButton" name="onLedsCustomColorButton" />
</item>
<item>
<spacer name="horizontalSpacer_3" >
<property name="orientation" >
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0" >
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout>
</item>
<item row="4" column="2" >
<spacer name="verticalSpacer_3" >
<property name="orientation" >
<enum>Qt::Vertical</enum>
</property>
<property name="sizeType" >
<enum>QSizePolicy::Fixed</enum>
</property>
<property name="sizeHint" stdset="0" >
<size>
<width>20</width>
<height>7</height>
</size>
</property>
</spacer>
</item>
<item row="5" column="0" colspan="2" >
<widget class="QLabel" name="label_4" >
<property name="text" >
<string>Inactive LEDs:</string>
</property>
<property name="alignment" >
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget>
</item>
<item row="5" column="2" colspan="3" >
<widget class="QCheckBox" name="showOffLedsCheckBox" >
<property name="toolTip" >
<string>Show the inactive LEDs</string>
</property>
<property name="whatsThis" >
<string>Check this if you want to see the inactive LEDs.</string>
</property>
<property name="text" >
<string>Show</string>
</property>
<property name="checked" >
<bool>true</bool>
</property>
</widget>
</item>
<item row="6" column="4" >
<widget class="QRadioButton" name="offLedsDefaultColorRadioButton" >
<property name="text" >
<string>Use theme color</string>
</property>
</widget>
</item>
<item row="7" column="4" >
<layout class="QHBoxLayout" name="horizontalLayout_2" >
<item>
<widget class="QRadioButton" name="offLedsCustomColorRadioButton" >
<property name="sizePolicy" >
<sizepolicy vsizetype="Fixed" hsizetype="Minimum" >
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text" >
<string>Use custom color for inactive LEDs:</string>
</property>
</widget>
</item>
<item>
<widget class="KColorButton" name="offLedsCustomColorButton" />
</item>
<item>
<spacer name="horizontalSpacer_2" >
<property name="orientation" >
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0" >
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout>
</item>
<item row="8" column="2" colspan="2" >
<spacer name="verticalSpacer_2" >
<property name="orientation" >
<enum>Qt::Vertical</enum>
</property>
<property name="sizeType" >
<enum>QSizePolicy::Fixed</enum>
</property>
<property name="sizeHint" stdset="0" >
<size>
<width>20</width>
<height>7</height>
</size>
</property>
</spacer>
</item>
<item row="9" column="0" colspan="2" >
<widget class="QLabel" name="label_3" >
<property name="text" >
<string>Grid:</string>
</property>
<property name="alignment" >
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget>
</item>
<item row="9" column="2" colspan="3" >
<widget class="QCheckBox" name="showGridCheckBox" >
<property name="toolTip" >
<string>Show the grid</string>
</property>
<property name="whatsThis" >
<string>Check this if you want to see a grid around leds.</string>
</property>
<property name="text" >
<string>Show</string>
</property>
<property name="checked" >
<bool>true</bool>
</property>
</widget>
</item>
<item row="10" column="4" >
<widget class="QRadioButton" name="gridDefaultColorRadioButton" >
<property name="text" >
<string>Use theme color</string>
</property>
</widget>
</item>
<item row="11" column="4" >
<layout class="QHBoxLayout" name="horizontalLayout" >
<item>
<widget class="QRadioButton" name="gridCustomColorRadioButton" >
<property name="text" >
<string>Use custom grid color:</string>
</property>
</widget>
</item>
<item>
<widget class="KColorButton" name="gridCustomColorButton" />
</item>
<item>
<spacer name="horizontalSpacer" >
<property name="orientation" >
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0" >
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout>
</item>
<item row="12" column="0" >
<spacer name="verticalSpacer_4" >
<property name="orientation" >
<enum>Qt::Vertical</enum>
</property>
<property name="sizeType" >
<enum>QSizePolicy::Fixed</enum>
</property>
<property name="sizeHint" stdset="0" >
<size>
<width>20</width>
<height>13</height>
</size>
</property>
</spacer>
</item>
<item row="13" column="0" >
<widget class="QLabel" name="label_6" >
<property name="font" >
<font>
<weight>75</weight>
<bold>true</bold>
</font>
</property>
<property name="text" >
<string>Information</string>
</property>
</widget>
</item>
<item row="15" column="3" colspan="2" >
<spacer name="verticalSpacer" >
<property name="orientation" >
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0" >
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
<item row="2" column="4" >
<widget class="QRadioButton" name="onLedsDefaultColorRadioButton" >
<property name="text" >
<string>Use theme color</string>
</property>
</widget>
</item>
<item row="14" column="1" >
<widget class="QLabel" name="showSecondsLabel" >
<property name="text" >
<string>Seconds:</string>
</property>
<property name="alignment" >
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget>
</item>
<item row="14" column="2" colspan="3" >
<widget class="QCheckBox" name="showSecondHandCheckBox" >
<property name="toolTip" >
<string>Show the seconds LEDs</string>
</property>
<property name="whatsThis" >
<string>Check this if you want to display seconds LEDs in order to see the seconds.</string>
</property>
<property name="text" >
<string>Show</string>
</property>
</widget>
</item>
</layout>
</widget>
<customwidgets>
<customwidget>
<class>KColorButton</class>
<extends>QPushButton</extends>
<header>kcolorbutton.h</header>
</customwidget>
</customwidgets>
<connections>
<connection>
<sender>onLedsDefaultColorRadioButton</sender>
<signal>toggled(bool)</signal>
<receiver>onLedsCustomColorButton</receiver>
<slot>setDisabled(bool)</slot>
<hints>
<hint type="sourcelabel" >
<x>558</x>
<y>55</y>
</hint>
<hint type="destinationlabel" >
<x>423</x>
<y>82</y>
</hint>
</hints>
</connection>
<connection>
<sender>offLedsDefaultColorRadioButton</sender>
<signal>toggled(bool)</signal>
<receiver>offLedsCustomColorButton</receiver>
<slot>setDisabled(bool)</slot>
<hints>
<hint type="sourcelabel" >
<x>566</x>
<y>148</y>
</hint>
<hint type="destinationlabel" >
<x>424</x>
<y>172</y>
</hint>
</hints>
</connection>
<connection>
<sender>gridDefaultColorRadioButton</sender>
<signal>toggled(bool)</signal>
<receiver>gridCustomColorButton</receiver>
<slot>setDisabled(bool)</slot>
<hints>
<hint type="sourcelabel" >
<x>547</x>
<y>243</y>
</hint>
<hint type="destinationlabel" >
<x>395</x>
<y>267</y>
</hint>
</hints>
</connection>
<connection>
<sender>showOffLedsCheckBox</sender>
<signal>toggled(bool)</signal>
<receiver>offLedsDefaultColorRadioButton</receiver>
<slot>setEnabled(bool)</slot>
<hints>
<hint type="sourcelabel" >
<x>164</x>
<y>124</y>
</hint>
<hint type="destinationlabel" >
<x>184</x>
<y>147</y>
</hint>
</hints>
</connection>
<connection>
<sender>showOffLedsCheckBox</sender>
<signal>toggled(bool)</signal>
<receiver>offLedsCustomColorRadioButton</receiver>
<slot>setEnabled(bool)</slot>
<hints>
<hint type="sourcelabel" >
<x>296</x>
<y>120</y>
</hint>
<hint type="destinationlabel" >
<x>296</x>
<y>176</y>
</hint>
</hints>
</connection>
<connection>
<sender>showGridCheckBox</sender>
<signal>toggled(bool)</signal>
<receiver>gridDefaultColorRadioButton</receiver>
<slot>setEnabled(bool)</slot>
<hints>
<hint type="sourcelabel" >
<x>165</x>
<y>217</y>
</hint>
<hint type="destinationlabel" >
<x>191</x>
<y>238</y>
</hint>
</hints>
</connection>
<connection>
<sender>showGridCheckBox</sender>
<signal>toggled(bool)</signal>
<receiver>gridCustomColorRadioButton</receiver>
<slot>setEnabled(bool)</slot>
<hints>
<hint type="sourcelabel" >
<x>264</x>
<y>210</y>
</hint>
<hint type="destinationlabel" >
<x>256</x>
<y>268</y>
</hint>
</hints>
</connection>
</connections>
</ui>

View file

@ -1,126 +0,0 @@
[Desktop Entry]
Name=Binary Clock
Name[ar]=ساعة ثنائية
Name[ast]=Reló binariu
Name[bs]=binarni sat
Name[ca]=Rellotge binari
Name[ca@valencia]=Rellotge binari
Name[cs]=Binární hodiny
Name[da]=Binært ur
Name[de]=Binäre Uhr
Name[el]=Δυαδικό ρολόι
Name[en_GB]=Binary Clock
Name[es]=Reloj binario
Name[et]=Binaarkell
Name[eu]=Ordulari bitarra
Name[fi]=Binaarikello
Name[fr]=Horloge binaire
Name[ga]=Clog Dénártha
Name[gl]=Reloxo binario
Name[he]=שעון בִּינָרִי
Name[hr]=Binarni sat
Name[hu]=Bináris óra
Name[is]=Tvíundarklukka
Name[it]=Orologio binario
Name[ja]=
Name[kk]=Бинарлы сағат
Name[km]=
Name[ko]=
Name[ku]=Demjimêra Cot
Name[lt]=Dvejetainis laikrodis
Name[lv]=Binārs pulkstenis
Name[mr]=
Name[nb]=Binær klokke
Name[nds]=Bineerklock
Name[nl]=Binaire klok
Name[nn]=Binærklokke
Name[pa]=
Name[pl]=Zegar dwójkowy
Name[pt]=Relógio Binário
Name[pt_BR]=Relógio binário
Name[ro]=Ceas binar
Name[ru]=Двоичные часы
Name[sk]=Binárne hodiny
Name[sl]=Dvojiška ura
Name[sq]=Orë Bianre
Name[sr]=бинарни сат
Name[sr@ijekavian]=бинарни сат
Name[sr@ijekavianlatin]=binarni sat
Name[sr@latin]=binarni sat
Name[sv]=Binärklocka
Name[th]=
Name[tr]=İkili Saat
Name[uk]=Двійковий годинник
Name[wa]=Ôrlodje binaire
Name[x-test]=xxBinary Clockxx
Name[zh_CN]=
Name[zh_TW]=
Comment=Time displayed in binary format
Comment[ar]=الوقت يظهر بالتنسيق الثنائي
Comment[ast]=Hora amosada en formatu binariu
Comment[bs]=Vrijeme prikazano u binarnom obliku
Comment[ca]=L'hora mostrada en format binari
Comment[ca@valencia]=L'hora mostrada en format binari
Comment[cs]=Zobrazení času v binárním formátu
Comment[da]=Tiden vist i binært format
Comment[de]=Zeitanzeige im Binärformat
Comment[el]=Εμφάνιση της ώρας σε δυαδική μορφή
Comment[en_GB]=Time displayed in binary format
Comment[es]=Hora mostrada en formato binario
Comment[et]=Aja näitamine binaarkujul
Comment[eu]=Ordua formatu bitarrean bistaratuta
Comment[fi]=Binaarimuotoinen ajanesitys
Comment[fr]=Heure affichée au format numérique
Comment[ga]=An t-am i bhformáid dhénártha
Comment[gl]=Mostra a hora no formato binario
Comment[he]=השעה מוצגת בפורמט בִּינָרִי
Comment[hr]=Vrijeme je prikazano u binarnom formatu
Comment[hu]=Bináris formátumban megjelenített idő
Comment[is]=Sýnir tímann á tvíundarformi
Comment[it]=Ora mostrata in formato binario
Comment[ja]=
Comment[kk]=Бинарлы пішімдегі уақыт
Comment[km]=
Comment[ko]=
Comment[ku]=Dem di teşeya cot-bûyî de dê bê nîşandan
Comment[lt]=Laikas rodomas skaitmeniniu formatu
Comment[lv]=Rāda laiku binārā formātā
Comment[mr]= ि ि
Comment[nb]=Tiden vist i binærformat
Comment[nds]=Tiet in Bineerformaat wiest
Comment[nl]=De tijd in binair formaat
Comment[nn]=Klokka vist i binærformat
Comment[pa]= ਿ
Comment[pl]=Czas wyświetlany w formacie dwójkowym
Comment[pt]=Hora mostrada no formato binário
Comment[pt_BR]=Hora exibida em formato binário
Comment[ro]=Ora afișată în format binar
Comment[ru]=Время в двоичной записи
Comment[sk]=Čas zobrazený v binárnom formáte
Comment[sl]=Čas je prikazan v dvojiški obliki
Comment[sr]=Време приказано у бинарном облику
Comment[sr@ijekavian]=Вријеме приказано у бинарном облику
Comment[sr@ijekavianlatin]=Vrijeme prikazano u binarnom obliku
Comment[sr@latin]=Vreme prikazano u binarnom obliku
Comment[sv]=Tid visad med binärformat
Comment[th]=
Comment[tr]=Saati ikili biçimde görüntüle
Comment[uk]=Час, показаний у двійковому форматі
Comment[wa]=Eure håynêye e cogne binaire
Comment[x-test]=xxTime displayed in binary formatxx
Comment[zh_CN]=
Comment[zh_TW]=
Icon=clock
Type=Service
ServiceTypes=Plasma/Applet
X-KDE-Library=plasma_applet_binaryclock
X-KDE-PluginInfo-Author=Davide Bettio
X-KDE-PluginInfo-Email=davide.bettio@kdemail.net
X-KDE-PluginInfo-Name=binaryclock
X-KDE-PluginInfo-Version=1.0
X-KDE-PluginInfo-Website=
X-KDE-PluginInfo-Category=Date and Time
X-KDE-PluginInfo-Depends=
X-KDE-PluginInfo-License=GPL
X-KDE-PluginInfo-EnabledByDefault=true

View file

@ -1,20 +0,0 @@
project(fuzzy-clock)
set(fuzzyclock_SRCS fuzzyClock.cpp fuzzyClockConfig.ui)
kde4_add_plugin(plasma_applet_fuzzy_clock ${fuzzyclock_SRCS})
target_link_libraries(plasma_applet_fuzzy_clock
KDE4::kdeui
KDE4::plasma
KDE4Workspace::plasmaclock
)
install(
TARGETS plasma_applet_fuzzy_clock
DESTINATION ${KDE4_PLUGIN_INSTALL_DIR}
)
install(
FILES plasma-clock-fuzzy.desktop
DESTINATION ${KDE4_SERVICES_INSTALL_DIR}
)

View file

@ -1,3 +0,0 @@
#! /usr/bin/env bash
$EXTRACTRC *.ui >> rc.cpp
$XGETTEXT *.cpp -o $podir/plasma_applet_fuzzy_clock.pot

View file

@ -1,749 +0,0 @@
/***************************************************************************
* Copyright (c) 1996-2002 the kicker authors. (fuzzy logic) *
* Copyright (C) 2007 by Riccardo Iaconelli <ruphy@fsfe.org> *
* Copyright (C) 2007 by Sven Burmeister <sven.burmeister@gmx.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 "fuzzyClock.h"
#include <QFontMetrics>
#include <QPainter>
#include <KColorScheme>
#include <KConfigDialog>
#include <KDebug>
#include <KLocale>
#include <Plasma/Theme>
Clock::Clock(QObject *parent, const QVariantList &args)
: ClockApplet(parent, args),
m_oldContentSize(QSizeF (0,0)),
m_configUpdated(false),
m_adjustToHeight(1),
m_useCustomFontColor(false),
m_fontColor(Qt::white),
m_fontTimeBold(false),
m_fontTimeItalic(false),
m_fontTime(KGlobalSettings::smallestReadableFont()),
m_showTimezone(false),
m_showDate(false),
m_showYear(false),
m_showDay(false),
m_layout(0)
{
KGlobal::locale()->insertCatalog("libplasmaclock");
KGlobal::locale()->insertCatalog("timezones4");
setHasConfigurationInterface(true);
setBackgroundHints(Plasma::Applet::DefaultBackground);
//If we do not set this, the user has to press CTRL when shrinking the plasmoid on the desktop beyond a certain size.
setAspectRatioMode(Plasma::IgnoreAspectRatio);
}
Clock::~Clock()
{
}
void Clock::init()
{
ClockApplet::init();
initFuzzyTimeStrings();
m_contentSize = geometry().size();
kDebug() << "The first content's size [geometry().size()] we get, init() called: " << geometry().size();
m_locale = KGlobal::locale();
clockConfigChanged();
//By default we use the smallest readable font.
m_fontDate = QFont ( KGlobalSettings::smallestReadableFont() );
m_margin = 2;
m_verticalSpacing = 2;
Plasma::DataEngine* timeEngine = dataEngine("time");
timeEngine->connectSource(currentTimezone(), this, 6000, Plasma::AlignToMinute);
connect(Plasma::Theme::defaultTheme(), SIGNAL(themeChanged()), this, SLOT(updateColors()));
}
void Clock::clockConfigChanged()
{
KConfigGroup cg = config();
m_showTimezone = cg.readEntry("showTimezone", false);
m_showDate = cg.readEntry("showDate", true);
m_showYear = cg.readEntry("showYear",false);
m_showDay = cg.readEntry("showDay",true);
m_fuzzyness = cg.readEntry("fuzzyness", 1);
m_fontTime = cg.readEntry("fontTime", KGlobalSettings::smallestReadableFont());
m_useCustomFontColor = cg.readEntry("useCustomFontColor", false);
if (m_useCustomFontColor){
m_fontColor = cg.readEntry("fontColor", m_fontColor);
}else{
m_fontColor = KColorScheme(QPalette::Active, KColorScheme::View, Plasma::Theme::defaultTheme()->colorScheme()).foreground().color();
}
m_fontTimeBold = cg.readEntry("fontTimeBold", true);
m_fontTimeItalic = cg.readEntry("fontTimeItalic", false);
m_fontTime.setBold(m_fontTimeBold);
m_fontTime.setItalic(m_fontTimeItalic);
m_adjustToHeight = cg.readEntry("adjustToHeight", 1);
}
Qt::Orientations Clock::expandingDirections() const
{
//This tells the layout whether it's ok to be stretched, even if we do not need that space. Since we would become far too wide on a panel we do not want that.
return 0;
}
// QSizeF Clock::contentSizeHint() const
// {
// return contentSize();
// }
void Clock::constraintsEvent(Plasma::Constraints constraints)
{
kDebug() << "constraintsEvent() called";
if (constraints & Plasma::SizeConstraint || constraints & Plasma::FormFactorConstraint) {
if ( (m_oldContentSize.toSize() != geometry().size() && m_oldContentSize.toSize() != QSize (0,0)) || m_configUpdated == true ) { //The size changed or config was updated
kDebug() << "The content's size [geometry().size()] changed! old: " << m_oldContentSize << "new: " << geometry().size();
if ( m_configUpdated ) {
calculateDateString();
calculateTimeString();
}
kDebug() << "Constraints changed: " << constraints;
if (formFactor() == Plasma::Planar || formFactor() == Plasma::MediaCenter) {
kDebug() << "######## Other FormFactor";
calculateSize();
} else {
kDebug() << "######## Small FormFactor";
calculateSize();
}
kDebug() << "The new size has been calculated and set.\nneeded m_contenSize (if not in panel): " << m_contentSize << "\nactual content's size [geometry().size()] is: " << geometry().size() << "\nminimumSize() needed (in panel): " << minimumSize();
m_oldContentSize = geometry().size();
m_configUpdated = false;
update();
}
}
}
void Clock::dataUpdated(const QString& source, const Plasma::DataEngine::Data &data)
{
Q_UNUSED(source);
m_time = data["Time"].toTime();
m_date = data["Date"].toDate();
kDebug() << "dataUpdated() was called.";
if (m_time.minute() == m_lastTimeSeen.minute()) {
// avoid unnecessary repaints
// kDebug() << "avoided unnecessary update!";
return;
}
if (Plasma::ToolTipManager::self()->isVisible(this)) {
updateTipContent();
}
updateClockApplet(data);
m_lastTimeSeen = m_time;
calculateDateString();
calculateTimeString();
//The timestring changed.
if (m_timeString != m_lastTimeStringSeen || m_dateString != m_lastDateStringSeen) {
//The size might have changed
calculateSize();
m_lastTimeStringSeen = m_timeString;
m_lastDateStringSeen = m_dateString;
updateGeometry();
//request to get painted.
update();
}
}
void Clock::createClockConfigurationInterface(KConfigDialog *parent)
{
QWidget *widget = new QWidget();
ui.setupUi(widget);
parent->addPage(widget, i18n("General"), icon());
ui.fuzzynessSlider->setSliderPosition( m_fuzzyness );
ui.showTimezone->setChecked( m_showTimezone );
ui.showDate->setChecked( m_showDate );
ui.showYear->setChecked( m_showYear );
ui.showDay->setChecked( m_showDay );
ui.adjustToHeight->setSliderPosition( m_adjustToHeight );
ui.fontTimeBold->setChecked(m_fontTimeBold);
ui.fontTimeItalic->setChecked(m_fontTimeItalic);
ui.fontTime->setCurrentFont(m_fontTime);
ui.fontColor->setColor(m_fontColor);
ui.useCustomFontColor->setChecked(m_useCustomFontColor);
connect(ui.fontTime, SIGNAL(currentFontChanged(QFont)), parent, SLOT(settingsModified()));
connect(ui.fontTimeBold, SIGNAL(stateChanged(int)), parent, SLOT(settingsModified()));
connect(ui.fontTimeItalic, SIGNAL(stateChanged(int)), parent, SLOT(settingsModified()));
connect(ui.useThemeColor, SIGNAL(toggled(bool)), parent, SLOT(settingsModified()));
connect(ui.adjustToHeight, SIGNAL(valueChanged(int)), parent, SLOT(settingsModified()));
connect(ui.showDate, SIGNAL(stateChanged(int)), parent, SLOT(settingsModified()));
connect(ui.showDay, SIGNAL(stateChanged(int)), parent, SLOT(settingsModified()));
connect(ui.showYear, SIGNAL(stateChanged(int)), parent, SLOT(settingsModified()));
connect(ui.showTimezone, SIGNAL(stateChanged(int)), parent, SLOT(settingsModified()));
connect(ui.fuzzynessSlider, SIGNAL(valueChanged(int)), parent, SLOT(settingsModified()));
}
void Clock::clockConfigAccepted()
{
KConfigGroup cg = config();
QGraphicsItem::update();
m_fontTime = ui.fontTime->currentFont();
cg.writeEntry("fontTime", m_fontTime);
//In case adjustToHeight was disabled we have to reset the point-size of fontTime
m_fontTime.setPointSize ( m_fontDate.pointSize() );
m_useCustomFontColor = ui.useCustomFontColor->isChecked();
cg.writeEntry("useCustomFontColor", m_useCustomFontColor);
if (m_useCustomFontColor) {
m_fontColor = ui.fontColor->color();
} else {
m_fontColor = KColorScheme(QPalette::Active, KColorScheme::View, Plasma::Theme::defaultTheme()->colorScheme()).foreground().color();
}
cg.writeEntry("fontColor", ui.fontColor->color());
m_fontTimeBold = ui.fontTimeBold->isChecked();
cg.writeEntry("fontTimeBold", m_fontTimeBold);
m_fontTimeItalic = ui.fontTimeItalic->isChecked();
cg.writeEntry("fontTimeItalic", m_fontTimeItalic);
m_fontTime.setBold(m_fontTimeBold);
m_fontTime.setItalic(m_fontTimeItalic);
m_fuzzyness = ui.fuzzynessSlider->value();
cg.writeEntry("fuzzyness", m_fuzzyness);
m_showDate = ui.showDate->isChecked();
cg.writeEntry("showDate", m_showDate);
m_showYear = ui.showYear->isChecked();
cg.writeEntry("showYear", m_showYear);
m_showDay = ui.showDay->isChecked();
cg.writeEntry("showDay", m_showDay);
m_adjustToHeight = ui.adjustToHeight->value();
kDebug() << "adjustToHeight" << m_adjustToHeight;
cg.writeEntry("adjustToHeight", m_adjustToHeight);
m_showTimezone = ui.showTimezone->isChecked();
cg.writeEntry("showTimezone", m_showTimezone);
dataEngine("time")->connectSource(currentTimezone(), this, 6000, Plasma::AlignToMinute);
m_configUpdated = true;
updateConstraints();
emit configNeedsSaving();
}
void Clock::changeEngineTimezone(const QString &oldTimezone, const QString &newTimezone)
{
dataEngine("time")->disconnectSource(oldTimezone, this);
dataEngine("time")->connectSource(newTimezone, this, 6000, Plasma::AlignToMinute);
}
void Clock::calculateDateString()
{
if (!m_date.isValid() || ( m_showTimezone == false && m_showDate == false) ) {
return;
}
const QLocale locale = KGlobal::locale()->toLocale();
QString day = QString::number(m_date.day());
QString month = locale.monthName(m_date.month(), QLocale::ShortFormat);
QString year = QString::number(m_date.year());
//Copied from the digital-clock
if (m_showDate) {
if (m_showYear) {
m_dateString = i18nc("@label Short date: "
"%1 day in the month, %2 short month name, %3 year",
"%1 %2 %3", day, month, year);
}
else {
m_dateString = i18nc("@label Short date: "
"%1 day in the month, %2 short month name",
"%1 %2", day, month);
}
if (m_showDay) {
QString weekday = locale.dayName(m_date.dayOfWeek(), QLocale::ShortFormat);
m_dateString = i18nc("@label Day of the week with date: "
"%1 short day name, %2 short date",
"%1, %2", weekday, m_dateString);
}
}
// QString newDateString = m_locale->formatDate ( m_date , m_locale->ShortDate );
// if( m_showDate == true ) {
// m_dateString = newDateString;
// }
if( m_showTimezone == true ) {
QString timezonetranslated = i18n( currentTimezone().toUtf8().data());
timezonetranslated = timezonetranslated.replace('_', ' ');
m_timezoneString = '(' + timezonetranslated + ')';
}
}
void Clock::initFuzzyTimeStrings()
{
m_hourNames << i18nc("hour in the messages below","one")
<< i18nc("hour in the messages below","two")
<< i18nc("hour in the messages below","three")
<< i18nc("hour in the messages below","four")
<< i18nc("hour in the messages below","five")
<< i18nc("hour in the messages below","six")
<< i18nc("hour in the messages below","seven")
<< i18nc("hour in the messages below","eight")
<< i18nc("hour in the messages below","nine")
<< i18nc("hour in the messages below","ten")
<< i18nc("hour in the messages below","eleven")
<< i18nc("hour in the messages below","twelve");
m_normalFuzzy << ki18nc("%1 the hour translated above","%1 o'clock")
<< ki18nc("%1 the hour translated above","five past %1")
<< ki18nc("%1 the hour translated above","ten past %1")
<< ki18nc("%1 the hour translated above","quarter past %1")
<< ki18nc("%1 the hour translated above","twenty past %1")
<< ki18nc("%1 the hour translated above","twenty five past %1")
<< ki18nc("%1 the hour translated above","half past %1")
<< ki18nc("%1 the hour translated above","twenty five to %1")
<< ki18nc("%1 the hour translated above","twenty to %1")
<< ki18nc("%1 the hour translated above","quarter to %1")
<< ki18nc("%1 the hour translated above","ten to %1")
<< ki18nc("%1 the hour translated above","five to %1")
<< ki18nc("%1 the hour translated above","%1 o'clock");
m_dayTime << i18n("Night")
<< i18n("Early morning") << i18n("Morning") << i18n("Almost noon")
<< i18n("Noon") << i18n("Afternoon") << i18n("Evening")
<< i18n("Late evening");
m_weekTime << i18n("Start of week")
<< i18n("Middle of week")
<< i18n("End of week")
<< i18n("Weekend!");
}
void Clock::calculateTimeString()
{
if (!m_time.isValid()) {
return;
}
const int hours = m_time.hour();
// int hours = 1;
const int minutes = m_time.minute();
// int minutes = 0;
bool upcaseFirst = i18nc("Whether to uppercase the first letter of "
"completed fuzzy time strings above: "
"translate as 1 if yes, 0 if no.",
"1") != QString('0');
//Create time-string
QString newTimeString;
if (m_fuzzyness == 1 || m_fuzzyness == 2) {
// NOTE: Time strings are deliberately assembled here with English
// only in mind: translators are able to script the translation to
// their liking, and this code provides the least surprise for that.
// Those inquiring should be directed to kde-i18n-doc mailing list
// for instructions on how to make it right for their language.
int sector = 0;
int realHour = 0;
if (m_fuzzyness == 1) {
if (minutes > 2) {
sector = (minutes - 3) / 5 + 1;
}
} else {
if (minutes > 6) {
sector = ((minutes - 7) / 15 + 1) * 3;
}
}
int deltaHour = (sector <= 6 ? 0 : 1);
if ((hours + deltaHour) % 12 > 0) { //there is a modulo
realHour = (hours + deltaHour) % 12 - 1;
} else {
realHour = 12 - ((hours + deltaHour) % 12 + 1);
}
newTimeString = m_normalFuzzy[sector].subs(m_hourNames[realHour]).toString();
if (upcaseFirst) {
newTimeString.replace(0, 1, QString(newTimeString.at(0).toUpper()));
}
} else if (m_fuzzyness == 3) {
newTimeString = m_dayTime[hours / 3];
} else {
//Timezones not yet implemented: int dow = QDateTime::currentDateTime().addSecs(TZoffset).date().dayOfWeek();
int dow = QDateTime::currentDateTime().date().dayOfWeek();
int weekStrIdx;
if (dow == 1) {
weekStrIdx = 0;
}
else if (dow >= 2 && dow <= 4) {
weekStrIdx = 1;
}
else if (dow == 5) {
weekStrIdx = 2;
}
else {
weekStrIdx = 3;
}
newTimeString = m_weekTime[weekStrIdx];
}
m_timeString = newTimeString;
}
void Clock::calculateSize()
{
//Minimal sizes.
// QFont minimalFontTime = m_fontTime;
// minimalFontTime.setPointsize ( m_fontDate.pointsize() );
// QFontMetrics fmMinimalTime ( minimalFontTime );
//
// minimalTimeStringSize = QSizeF( minimalFontTime.width( m_timeString ) + m_margin*2,minimalFontTime.height() );
//In case adjustToHeight was disabled we have to reset the point-size of fontTime
m_fontTime.setPointSize ( m_fontDate.pointSize() );
//Actual size, set in config or init
QFontMetrics m_fmTime ( m_fontTime );
m_timeStringSize = QSizeF( m_fmTime.width( m_timeString ) + m_margin*2,m_fmTime.height() );
QFontMetrics m_fmDate ( m_fontDate );
//The date+timezone are currently hardcoded to the smallestReadableFont
m_dateStringSize = QSizeF ( m_fmDate.width( m_dateString ), m_fmDate.height() );
m_timezoneStringSize = QSizeF( m_fmDate.width( m_timezoneString ), m_fmDate.height() );
int minimumWantedSize = KGlobalSettings::smallestReadableFont().pointSize();
if (formFactor() == Plasma::Horizontal) {
QFont font(m_fontTime);
font.setPixelSize(size().height()/2);
minimumWantedSize = m_fontDatabase.font(font.family(), font.styleName(), font.pointSize()).pointSize();
}
if ( contentsRect().size().width() > m_timeStringSize.width() && (formFactor() == Plasma::Planar || formFactor() == Plasma::MediaCenter)) { //plasmoid wider than timestring
kDebug() << "Plasmoid wider than the timestring";
if( m_showDate == true && m_showTimezone == true ) { //date + timezone enabled
kDebug() << "Date + Timezone enabled";
if ( contentsRect().size().width() > m_dateStringSize.width() + m_timezoneStringSize.width() ) { //date + timezone fit -> 2 rows within the plasmoid
kDebug() << "plasmoid wider than date + timezone in 1 row";
m_subtitleString = m_dateString + ' ' + m_timezoneString; //Set subtitleString
//set subtitleSize
m_subtitleStringSize = QSizeF ( m_fmDate.width ( m_dateString + ' ' + m_timezoneString ) , m_dateStringSize.height()*1 );
} else { //date + timezone are split into two lines to fit the plasmoid -> 3 rows within the plasmoid
kDebug() << "Plasmoid not wide enough for date + timezone in 1 row -> 2 rows";
m_subtitleString = m_dateString + '\n' + m_timezoneString; //Set subtitleString
//set subtitleSize
m_subtitleStringSize = QSizeF ( qMax( m_dateStringSize.width(),m_timezoneStringSize.width() ) , m_dateStringSize.height()*2 );
}
} else if ( m_showDate == true ) {
kDebug() << "Only Date enabled";
m_subtitleString = m_dateString; //Set subtitleString
//set subtitleSize
m_subtitleStringSize = QSizeF ( m_dateStringSize.width() , m_dateStringSize.height() );
} else if ( m_showTimezone == true ) {
kDebug() << "Only timezone enabled";
m_subtitleString = m_timezoneString; //Set subtitleString
//set subtitleSize
m_subtitleStringSize = QSizeF ( m_timezoneStringSize.width() , m_timezoneStringSize.height() );
} else { //no subtitle
kDebug() << "Neither date nor timezone enabled";
m_subtitleStringSize = QSizeF ( 0,0 );
}
// //If the date/timezone was re-enabled we might have a wide enough, but not high enough plasmoid whose minimumContentSize only fits the timestring. -> increase minimumContentSize
if ( m_timeStringSize.height() + m_verticalSpacing + m_subtitleStringSize.height() > minimumSize().height() ) {
kDebug() << "Although the plasmoid is wider than necessary the height is too small -> set new minimum height: " << m_timeStringSize.height() + m_verticalSpacing + m_subtitleStringSize.height();
setMinimumSize ( QSizeF ( minimumSize().width(),m_timeStringSize.height() + m_verticalSpacing + m_subtitleStringSize.height() ) );
kDebug() << "New minimumContentSize(): " << minimumSize();
}
//Make the timestring fit the plasmoid since it is bigger than minimumWantedSize
m_fontTime.setPointSize(qMax((int)( geometry().size().height()/1.5), minimumWantedSize) );
m_fmTime = QFontMetrics( m_fontTime );
while ( ( m_fmTime.width( m_timeString ) > contentsRect().size().width() - 2*m_margin ||
m_fmTime.height() > contentsRect().size().height() - m_subtitleStringSize.height() - m_verticalSpacing ) &&
m_fontTime.pointSize() > minimumWantedSize) {
//decrease pointSize
m_fontTime.setPointSize(m_fontTime.pointSize() - 1);
m_fmTime = QFontMetrics( m_fontTime );
m_timeStringSize = QSizeF ( m_fmTime.width( m_timeString ), m_fmTime.height() );
}
//Adjust the height to the new horizontal size
m_contentSize = QSizeF ( contentsRect().width(),m_timeStringSize.height() + m_verticalSpacing + m_subtitleStringSize.height() );
if ( formFactor() == Plasma::Horizontal ) { //if we are on the panel we are forced to accept the given height.
kDebug() << "needed height: " << m_contentSize.height() << "fixed height forced on us: " << geometry().size().height();
//FIXME: it was resizing to size() itself
//resize ( QSizeF ( m_contentSize.width(),geometry().size().height() ) );
} else {
//add margins
resize(m_contentSize + QSizeF(size()-contentsRect().size()));
setPreferredSize(m_contentSize + QSizeF(size()-contentsRect().size()));
resize(preferredSize());
emit sizeHintChanged(Qt::PreferredSize);
emit appletTransformedItself();
}
} else { //in a panel or timestring wider than plasmoid -> change size to the minimal needed space, i.e. the timestring will not increase in point-size OR plasmoid in Panel.
kDebug() << "Plasmoid is in a panel or too small for the timestring, we are using minimumWantedSize as pointSize";
if ( m_showDate == true && m_showTimezone == true ) { //Date + timezone enabled
kDebug() << "Date + timezone enabled";
//If the user has set adjustToHeight to true the timezone and date are put into one line. This is a design decision and not based on anything else but the opinion that a slightly increased point-size is not what adjustToHeight is meant for. The latter is meant to replace the need to be able to set a font-size in the settings. Bigger fonts than this and only slightly bigger ones don't make sense on the panel. The desktop-plasmoid is not imfluenced by this.
if( m_timeStringSize.width() > m_dateStringSize.width() + m_timezoneStringSize.width() || m_adjustToHeight != 0 ) { //Time wider than date + timezone -> 2 rows in plasmoid
kDebug() << "timestring is wider than date + timezone in one row -> 1 row.";
m_subtitleString = m_dateString + ' ' + m_timezoneString; //Set subtitleString
//set subtitleSize
m_subtitleStringSize = QSizeF ( m_fmDate.width ( m_dateString + ' ' + m_timezoneString ) , m_dateStringSize.height()*1 );
//set new minimal width to fit the strings
m_minimumContentSize = QSizeF ( m_timeStringSize.width(),m_subtitleStringSize.height() + m_verticalSpacing + m_subtitleStringSize.height() );
} else { //date and timezone have to be split.
kDebug() << "Date + timezone do not fit into one row -> 2 rows.";
m_subtitleString = m_dateString + '\n' + m_timezoneString; //Set subtitleString
//set subtitleSize
m_subtitleStringSize = QSizeF ( qMax ( m_dateStringSize.width(),m_timezoneStringSize.width() ), m_dateStringSize.height()*2 );
kDebug() << "max: " << qMax ( m_timeStringSize.width(),qMax ( m_dateStringSize.width(),m_timezoneStringSize.width() ) ) << " timestring: " << m_timeStringSize.width() << "date: " << m_dateStringSize.width() << "timezone: " << m_timezoneStringSize.width();
//set new minimal width to fit widest string and adjust the height
m_minimumContentSize = QSizeF ( qMax ( m_timeStringSize.width(),qMax ( m_dateStringSize.width(),m_timezoneStringSize.width() ) ),m_timeStringSize.height() + m_verticalSpacing + m_subtitleStringSize.height() );
}
} else if ( m_showDate == true ) {
kDebug() << "Only date is enabled";
m_subtitleString = m_dateString; //Set subtitleString
//set subtitleSize
m_subtitleStringSize = QSizeF ( m_dateStringSize.width(), m_dateStringSize.height() );
//set new minimal width to fit the widest string
m_minimumContentSize = QSizeF ( qMax ( m_dateStringSize.width(),m_timeStringSize.width() ),m_timeStringSize.height() + m_verticalSpacing + m_subtitleStringSize.height() );
} else if ( m_showTimezone == true ) {
kDebug() << "Only timezone is enabled";
m_subtitleString = m_timezoneString; //Set subtitleString
//set subtitleSize
m_subtitleStringSize = QSizeF ( m_timezoneStringSize.width(), m_timezoneStringSize.height() );
//set new size to fit the strings
m_minimumContentSize = QSizeF ( qMax ( m_timezoneStringSize.width(),m_timeStringSize.width() ),m_timeStringSize.height() + m_verticalSpacing + m_subtitleStringSize.height() );
} else { //no subtitle
kDebug() << "Neither timezone nor date are enabled";
//set subtitleSize
m_subtitleStringSize = QSizeF ( 0,0 );
m_minimumContentSize = QSizeF ( m_timeStringSize.width(),m_timeStringSize.height() );//set new minimal width
}
float heightToUse = 0;
//Use x of the available height for the timstring
if ( m_adjustToHeight == 1 ) {
heightToUse = (float)2/3;
kDebug() << "We will use 2/3 of the panel's height for the time: " << heightToUse;
} else if ( m_adjustToHeight == 2 ) {
kDebug() << "We will use all of the panel's height for the time.";
heightToUse = 1;
}
//If the user enabled adjustToHeight we increase the point-size until the height is fully used. 40 as limit to avoid an endless loop.
if ( m_adjustToHeight != 0 ) {
kDebug() << "We try to find a larger font that fits the size:";
//FIXME: if the clock is the only applet on a vertical panel and returns 0 via expandingDirections(), it still gets the full height of the panel as recommended height, i.e. on a vertical panel width a height of 800, geometry().size().height() does not return 48 but some huge value. Unless this is fixed in plasma, the while-loop will take a while.
//Make the timestring fit the plasmoid since it is bigger than minimumWantedSize
m_fontTime.setPointSize(qMax((int)( geometry().size().height()/1.5), minimumWantedSize) );
m_fmTime = QFontMetrics( m_fontTime );
kDebug() << "Starting with a point size of: " << m_fontTime.pointSize();
kDebug() << "We want to have: \nwidth: < " << geometry().size().width() - 2*m_margin << "\nheight < " << (geometry().size().height() - m_subtitleStringSize.height() - m_verticalSpacing)*heightToUse;
while ( ( ( m_fmTime.width( m_timeString ) > geometry().size().width() - 2*m_margin && formFactor() != Plasma::Horizontal ) ||
m_fmTime.height() > (geometry().size().height() - m_subtitleStringSize.height() - m_verticalSpacing)*heightToUse ) &&
m_fontTime.pointSize() > minimumWantedSize) {
//decrease pointSize
m_fontTime.setPointSize(m_fontTime.pointSize() - 1);
kDebug() << "new point size: " << m_fontTime.pointSize();
m_fmTime = QFontMetrics( m_fontTime );
m_timeStringSize = QSizeF ( m_fmTime.width( m_timeString ), m_fmTime.height() );
}
}
//Adjust the width to the new size, including margins, will be reverted, if the panel is vertical
m_minimumContentSize = QSizeF ( m_timeStringSize.width() + m_margin*2,m_minimumContentSize.height() );
kDebug() << "Set new minimumSize: geometry().size() " << geometry().size() << "\nm_minimumContentSize: " << m_minimumContentSize;
//if the width given by the panel is too wide, e.g. when switching from panel at the right to panel at the bottom we get some 600 as width
//However: If we are in a vertical panel, we should use the width given.
if( m_timeStringSize.width() + m_margin*2 < geometry().size().width() && formFactor() != Plasma::Vertical ) {
kDebug() << "The width we got was too big, we need less, so lets resize.";
setMinimumSize ( m_minimumContentSize + (size() - contentsRect().size()) );
}
if ( formFactor() == Plasma::Horizontal ) { //if we are on the panel we are forced to accept the given height.
kDebug() << "needed height: " << m_minimumContentSize.height() << "[horizontal panel] fixed height forced on us: " << geometry().size().height() << " adding margin-left/-right of: " << m_margin << "width is going to be set resize( " << m_minimumContentSize.width() << "," << geometry().size().height() << ")";
setMinimumSize(QSizeF(m_minimumContentSize.width(), 0));
//Expand the panel as necessary
setPreferredSize(minimumSize());
emit sizeHintChanged(Qt::PreferredSize);
} else if ( formFactor() == Plasma::Vertical ) {
kDebug() << "needed width: " << m_minimumContentSize.width() << "[vertical panel] fixed width forced on us: " << geometry().size().width() << " adding margin left/right of: " << m_margin;
setMinimumSize ( QSizeF(0, m_minimumContentSize.height()) );
//Expand the panel as necessary
setPreferredSize(minimumSize());
emit sizeHintChanged(Qt::PreferredSize);
}else { //FIXME: In case this height does not fit the content -> disable timezone (and date)
//if the minimal width is larger than the actual size -> force minimal needed width
if( m_fontTime.pointSize() <= m_fontDate.pointSize() ) {
setMinimumSize ( m_minimumContentSize + (size() - contentsRect().size()) );
}
//we use the minimal height here, since the user has given us too much height we cannot use for anything useful. minimal width because we are in a panel.
kDebug() << "we set the minimum size needed as the size we want";
setPreferredSize ( QSizeF ( m_minimumContentSize.width() + m_margin*2,m_minimumContentSize.height() ) + (size() - contentsRect().size()) );
resize(preferredSize());
emit sizeHintChanged(Qt::PreferredSize);
emit appletTransformedItself();
}
}
}
void Clock::paintInterface(QPainter *p, const QStyleOptionGraphicsItem *option, const QRect &contentsRect)
{
Q_UNUSED( option );
kDebug() << "We get painted!";
if( m_showDate == true || m_showTimezone == true ) {
m_fontDate = QFont( KGlobalSettings::smallestReadableFont() );
QFontMetrics m_fmDate( m_fontDate );
p->setPen(QPen(m_fontColor));
p->setFont( m_fontDate );
kDebug() << "date + timezone [" << m_subtitleString << "] gets painted. y: " << -m_subtitleStringSize.height() + contentsRect.size().height() << "width: " << contentsRect.size().width() << "[needed: " << m_fmDate.width( m_subtitleString ) << "] " << "height:" << m_subtitleStringSize.height();
if( m_showDate == true || m_showTimezone == true ) {
//Draw the subtitle
p->drawText( QRectF(contentsRect.x(),
contentsRect.y() - m_subtitleStringSize.height() + contentsRect.size().height(),
contentsRect.size().width(),
m_subtitleStringSize.height()) ,
m_subtitleString,
QTextOption(Qt::AlignHCenter)
);
}
}
QFontMetrics m_fmTime ( m_fontTime );
kDebug() << "timestrings [" << m_timeString << "] gets painted. width: " << contentsRect.size().width() << "[needed: " << m_fmTime.width( m_timeString ) << "] " << "height: " << m_timeStringSize.height();
p->setFont( m_fontTime );
p->setPen(QPen(m_fontColor));
p->setRenderHint(QPainter::SmoothPixmapTransform);
p->setRenderHint(QPainter::Antialiasing);
p->drawText( QRectF(contentsRect.x(),
contentsRect.y(),
contentsRect.size().width(),
m_timeStringSize.height()) ,
m_timeString,
QTextOption(Qt::AlignHCenter)
);
}
void Clock::updateColors()
{
if (!m_useCustomFontColor) {
m_fontColor = KColorScheme(QPalette::Active, KColorScheme::View, Plasma::Theme::defaultTheme()->colorScheme()).foreground().color();
update();
}
}
#include "moc_fuzzyClock.cpp"

View file

@ -1,132 +0,0 @@
/***************************************************************************
* Copyright (C) 2007 by Sven Burmeister <sven.burmeister@gmx.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 CLOCK_H
#define CLOCK_H
#include <Plasma/DataEngine>
#include <plasmaclock/clockapplet.h>
#include "ui_fuzzyClockConfig.h"
#include <QTime>
#include <QDate>
#include <QFontDatabase>
class KLocalizedString;
class Clock : public ClockApplet
{
Q_OBJECT
public:
Clock(QObject *parent, const QVariantList &args);
~Clock();
void init();
void paintInterface(QPainter *painter, const QStyleOptionGraphicsItem *option, const QRect &contentsRect);
void setPath(const QString&);
// QSizeF contentSizeHint() const;
Qt::Orientations expandingDirections() const;
public slots:
void dataUpdated(const QString &name, const Plasma::DataEngine::Data &data);
protected slots:
// void acceptedTimeStringState(bool);
void updateColors();
protected:
void constraintsEvent(Plasma::Constraints constraints);
void createClockConfigurationInterface(KConfigDialog *parent);
void clockConfigAccepted();
void clockConfigChanged();
void changeEngineTimezone(const QString &oldTimezone, const QString &newTimezone);
private:
void initFuzzyTimeStrings();
void calculateTimeString();
void calculateDateString();
void calculateSize();
// temporary, sort out a correct way for applets to be notified
// when their content size changes and then rather than tracking
// the content size, re-implement the appropriate method to
// update the graphic sizes and so on
QSizeF m_contentSize;
QSizeF m_oldContentSize;
QSizeF m_minimumContentSize;
bool m_configUpdated;
QString m_timeString;
QString m_dateString;
QString m_timezoneString;
QString m_subtitleString;
QSizeF m_timeStringSize;
QSizeF m_dateStringSize;
QSizeF m_timezoneStringSize;
QSizeF m_subtitleStringSize;
int m_adjustToHeight;
bool m_useCustomFontColor;
QColor m_fontColor;
bool m_fontTimeBold;
bool m_fontTimeItalic;
QFont m_fontTime;
QFont m_fontDate;
// QFontMetrics m_fmTime;
// QFontMetrics m_fmDate;
QFontDatabase m_fontDatabase;
int m_fuzzyness;
bool m_showTimezone;
bool m_showDate;
bool m_showYear;
bool m_showDay;
QTime m_time;
QDate m_date;
KLocale *m_locale;
QVBoxLayout *m_layout;
QTime m_lastTimeSeen;
QString m_lastTimeStringSeen;
QString m_lastDateStringSeen;
/// Designer Config file
Ui::fuzzyClockConfig ui;
QStringList m_hourNames;
QList<KLocalizedString> m_normalFuzzy;
QStringList m_dayTime;
QStringList m_weekTime;
int m_margin;
int m_verticalSpacing;
};
K_EXPORT_PLASMA_APPLET(fuzzy_clock, Clock)
#endif

View file

@ -1,574 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>fuzzyClockConfig</class>
<widget class="QWidget" name="fuzzyClockConfig">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>437</width>
<height>417</height>
</rect>
</property>
<layout class="QGridLayout" name="gridLayout_3">
<item row="0" column="0" colspan="2">
<widget class="QLabel" name="label_6">
<property name="font">
<font>
<weight>75</weight>
<bold>true</bold>
</font>
</property>
<property name="text">
<string>Appearance</string>
</property>
</widget>
</item>
<item row="1" column="0">
<spacer name="horizontalSpacer_9">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeType">
<enum>QSizePolicy::Fixed</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>17</width>
<height>25</height>
</size>
</property>
</spacer>
</item>
<item row="1" column="1">
<widget class="QLabel" name="label_4">
<property name="text">
<string>Font style:</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
<property name="buddy">
<cstring>fontTime</cstring>
</property>
</widget>
</item>
<item row="1" column="2">
<layout class="QHBoxLayout" name="horizontalLayout_2">
<item>
<widget class="QFontComboBox" name="fontTime"/>
</item>
<item>
<spacer name="horizontalSpacer_3">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>17</height>
</size>
</property>
</spacer>
</item>
</layout>
</item>
<item row="2" column="2">
<widget class="QCheckBox" name="fontTimeBold">
<property name="toolTip">
<string>Check if you want the font in bold</string>
</property>
<property name="whatsThis">
<string>When this is checked, the clock font will be bold.</string>
</property>
<property name="text">
<string>&amp;Bold</string>
</property>
</widget>
</item>
<item row="3" column="2">
<widget class="QCheckBox" name="fontTimeItalic">
<property name="toolTip">
<string>Check if you want the font in italic</string>
</property>
<property name="whatsThis">
<string>When this is checked, the clock font will be in italic.</string>
</property>
<property name="text">
<string>&amp;Italic</string>
</property>
</widget>
</item>
<item row="5" column="1">
<widget class="QLabel" name="label_3">
<property name="text">
<string>Font color:</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
<property name="buddy">
<cstring>useThemeColor</cstring>
</property>
</widget>
</item>
<item row="5" column="2">
<widget class="QRadioButton" name="useThemeColor">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="toolTip">
<string>Use current desktop theme color</string>
</property>
<property name="whatsThis">
<string>This is default. The clock will get its font color from the current desktop theme.</string>
</property>
<property name="text">
<string>Use theme color</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
</widget>
</item>
<item row="6" column="2">
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="QRadioButton" name="useCustomFontColor">
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="toolTip">
<string>Choose your own font color</string>
</property>
<property name="whatsThis">
<string>When checked you can choose a custom color for the clock font by clicking on the color widget on the right.</string>
</property>
<property name="text">
<string>Use custom color:</string>
</property>
</widget>
</item>
<item>
<widget class="KColorButton" name="fontColor">
<property name="enabled">
<bool>false</bool>
</property>
<property name="toolTip">
<string>Color chooser</string>
</property>
<property name="whatsThis">
<string>Click on this button and the KDE standard color dialog will show. You can then choose the new color you want for your clock.</string>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer_6">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout>
</item>
<item row="8" column="0" colspan="2">
<widget class="QLabel" name="label_2">
<property name="text">
<string>Adjust text to panel-height:</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
<property name="buddy">
<cstring>adjustToHeight</cstring>
</property>
</widget>
</item>
<item row="8" column="2">
<widget class="QSlider" name="adjustToHeight">
<property name="toolTip">
<string>0: disable; 2: use full panel-height</string>
</property>
<property name="maximum">
<number>2</number>
</property>
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="tickPosition">
<enum>QSlider::TicksBothSides</enum>
</property>
</widget>
</item>
<item row="10" column="0" colspan="2">
<widget class="QLabel" name="label_7">
<property name="font">
<font>
<weight>75</weight>
<bold>true</bold>
</font>
</property>
<property name="text">
<string>Information</string>
</property>
</widget>
</item>
<item row="11" column="1">
<widget class="QLabel" name="label_9">
<property name="text">
<string>Show date:</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
<property name="buddy">
<cstring>showDate</cstring>
</property>
</widget>
</item>
<item row="11" column="2">
<layout class="QHBoxLayout" name="horizontalLayout_6">
<item>
<widget class="QCheckBox" name="showDate">
<property name="toolTip">
<string>Display the date of the day</string>
</property>
<property name="whatsThis">
<string/>
</property>
<property name="text">
<string/>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer_7">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout>
</item>
<item row="12" column="2">
<layout class="QGridLayout" name="gridLayout_2">
<item row="0" 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>20</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item row="0" column="1">
<widget class="QCheckBox" name="showDay">
<property name="enabled">
<bool>false</bool>
</property>
<property name="toolTip">
<string>Display day of the week</string>
</property>
<property name="whatsThis">
<string>Add the day of the week to the date display.</string>
</property>
<property name="text">
<string>Show day of the &amp;week</string>
</property>
</widget>
</item>
<item row="1" column="0">
<spacer name="horizontalSpacer_2">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeType">
<enum>QSizePolicy::Fixed</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item row="1" column="1">
<widget class="QCheckBox" name="showYear">
<property name="enabled">
<bool>false</bool>
</property>
<property name="toolTip">
<string>Display the current year</string>
</property>
<property name="whatsThis">
<string>Add the year to the date string.</string>
</property>
<property name="text">
<string>Show &amp;year</string>
</property>
</widget>
</item>
</layout>
</item>
<item row="14" column="1">
<widget class="QLabel" name="label_5">
<property name="text">
<string>Show time zone:</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
<property name="buddy">
<cstring>showTimezone</cstring>
</property>
</widget>
</item>
<item row="14" column="2">
<layout class="QHBoxLayout" name="horizontalLayout_4">
<item>
<widget class="QCheckBox" name="showTimezone">
<property name="toolTip">
<string>Display the time zone name</string>
</property>
<property name="whatsThis">
<string>Display the time zone name under the time.</string>
</property>
<property name="text">
<string/>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer_4">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout>
</item>
<item row="16" column="0" colspan="2">
<widget class="QLabel" name="label">
<property name="text">
<string>Degree of fuzzyness:</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
<property name="buddy">
<cstring>fuzzynessSlider</cstring>
</property>
</widget>
</item>
<item row="16" column="2">
<widget class="QSlider" name="fuzzynessSlider">
<property name="toolTip">
<string>1: least fuzzy</string>
</property>
<property name="minimum">
<number>1</number>
</property>
<property name="maximum">
<number>4</number>
</property>
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="tickPosition">
<enum>QSlider::TicksBothSides</enum>
</property>
<property name="tickInterval">
<number>1</number>
</property>
</widget>
</item>
<item row="17" column="2">
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>9</height>
</size>
</property>
</spacer>
</item>
<item row="7" column="2">
<spacer name="verticalSpacer_2">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeType">
<enum>QSizePolicy::Fixed</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>5</height>
</size>
</property>
</spacer>
</item>
<item row="9" column="2">
<spacer name="verticalSpacer_3">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeType">
<enum>QSizePolicy::Fixed</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>10</height>
</size>
</property>
</spacer>
</item>
<item row="15" column="2">
<spacer name="verticalSpacer_4">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeType">
<enum>QSizePolicy::Fixed</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>5</height>
</size>
</property>
</spacer>
</item>
<item row="4" column="2">
<spacer name="verticalSpacer_5">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeType">
<enum>QSizePolicy::Fixed</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>5</height>
</size>
</property>
</spacer>
</item>
<item row="13" column="2">
<spacer name="verticalSpacer_6">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeType">
<enum>QSizePolicy::Fixed</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>5</height>
</size>
</property>
</spacer>
</item>
</layout>
</widget>
<customwidgets>
<customwidget>
<class>KColorButton</class>
<extends>QPushButton</extends>
<header>kcolorbutton.h</header>
</customwidget>
<customwidget>
<class>KComboBox</class>
<extends>QComboBox</extends>
<header>kcombobox.h</header>
</customwidget>
</customwidgets>
<connections>
<connection>
<sender>useCustomFontColor</sender>
<signal>toggled(bool)</signal>
<receiver>fontColor</receiver>
<slot>setEnabled(bool)</slot>
<hints>
<hint type="sourcelabel">
<x>262</x>
<y>158</y>
</hint>
<hint type="destinationlabel">
<x>325</x>
<y>151</y>
</hint>
</hints>
</connection>
<connection>
<sender>showDate</sender>
<signal>toggled(bool)</signal>
<receiver>showDay</receiver>
<slot>setEnabled(bool)</slot>
<hints>
<hint type="sourcelabel">
<x>178</x>
<y>270</y>
</hint>
<hint type="destinationlabel">
<x>281</x>
<y>293</y>
</hint>
</hints>
</connection>
<connection>
<sender>showDate</sender>
<signal>toggled(bool)</signal>
<receiver>showYear</receiver>
<slot>setEnabled(bool)</slot>
<hints>
<hint type="sourcelabel">
<x>167</x>
<y>258</y>
</hint>
<hint type="destinationlabel">
<x>477</x>
<y>322</y>
</hint>
</hints>
</connection>
</connections>
</ui>

View file

@ -1,128 +0,0 @@
[Desktop Entry]
Name=Fuzzy Clock
Name[ar]=ساعة تقريبية
Name[ast]=Reló imprecisu
Name[bs]=Neprecizni sat
Name[ca]=Rellotge aproximat
Name[ca@valencia]=Rellotge aproximat
Name[cs]=Nejasné hodiny
Name[da]=Unøjagtigt ur
Name[de]=Umgangssprachliche Uhr
Name[el]=Ασαφές ρολόι
Name[en_GB]=Fuzzy Clock
Name[es]=Reloj impreciso
Name[et]=Segane kell
Name[eu]=Ordulari lausoa
Name[fi]=Epätarkka kello
Name[fr]=Horloge floue
Name[ga]=Clog Doiléir
Name[gl]=Reloxo impreciso
Name[he]=שעון מטשטש
Name[hr]=Neizrazit sat
Name[hu]=Fuzzy óra
Name[is]=Ónákvæm klukka
Name[it]=Orologio confuso
Name[ja]=
Name[kk]=Жазбаша сағат
Name[km]=
Name[ko]=
Name[ku]=Demjimêra Şêlû
Name[lt]=Netikslus laikrodis
Name[lv]=Aptuvens pulkstenis
Name[mr]=
Name[nb]=Muntlig klokke
Name[nds]=Bummelig-Klock
Name[nl]=Vage klok
Name[nn]=Uklar klokke
Name[oc]=Relòtge fosc
Name[pa]=
Name[pl]=Rozmyty zegar
Name[pt]=Relógio Difuso
Name[pt_BR]=Relógio aproximado
Name[ro]=Ceas evaziv
Name[ru]=Неточное время
Name[sk]=Približné hodiny
Name[sl]=Zgovorna ura
Name[sq]=Orë e Mjegullt
Name[sr]=одокативни сат
Name[sr@ijekavian]=одокативни сат
Name[sr@ijekavianlatin]=odokativni sat
Name[sr@latin]=odokativni sat
Name[sv]=Inexakt klocka
Name[th]=
Name[tr]=Bulanık Saat
Name[uk]=Нечіткий годинник
Name[wa]=Ôrlodje a l' avirance
Name[x-test]=xxFuzzy Clockxx
Name[zh_CN]=
Name[zh_TW]=
Comment=Time displayed in a less precise format
Comment[ar]=الوقت يظهر بتنسيق أقل دقة
Comment[ast]=Amuesa la hora nún formatu menos precisu
Comment[bs]=Vrijeme prikazano na manje precizan način
Comment[ca]=L'hora mostrada en un format aproximat
Comment[ca@valencia]=L'hora mostrada en un format aproximat
Comment[cs]=Zobrazení času v nejasném formátu
Comment[da]=Tiden vist i et mindre præcist format.
Comment[de]=Zeigt die Zeit weniger genau an
Comment[el]=Εμφάνιση ώρας σε μια λιγότερο ακριβή μορφή
Comment[en_GB]=Time displayed in a less precise format
Comment[es]=Muestra la hora en un formato menos preciso
Comment[et]=Aja näitamine mitte nii täpsel kujul
Comment[eu]=Ordua era lausoan bistaratua
Comment[fi]=Aika näytettynä epätarkassa muodossa
Comment[fr]=Heure affichée avec un format peu précis
Comment[ga]=Taispeáin an t-am i bhformáid níos lú beaichte
Comment[gl]=Mostra a hora nun formato impreciso
Comment[he]=השעה מוצגת בפורמט קצת פחות מדוייק
Comment[hr]=Vrijeme prikazano u manje preciznim oblicima
Comment[hu]=Kevésbé precíz formátumban megjelenített idő
Comment[is]=Birtir tímann á minna nákvæmu sniði
Comment[it]=Ora mostrata in modo meno preciso
Comment[ja]=
Comment[kk]=Уақытты жазу түрде көрсететін сағат
Comment[km]=
Comment[ko]=
Comment[ku]=Dem di teşeya xuyakirina kêmtir de tê nîşandan
Comment[lt]=Laikas rodomas mažesnio tikslumo formatu
Comment[lv]=Rāda laiku mazāk precīzā formātā
Comment[mr]= ि
Comment[nb]=Viser tiden i et mindre presist format
Comment[nds]=Tiet, wiest in en nich so akraat Formaat
Comment[nl]=De tijd in iets minder nauwkeurig formaat
Comment[nn]=Klokka meir eller mindre nøyaktig
Comment[pl]=Czas wyświetlany w mniej precyzyjnym formacie
Comment[pt]=Hora mostrada num formato menos exacto
Comment[pt_BR]=Hora exibida em formato menos preciso
Comment[ro]=Ora afișată într-un format mai puțin exact
Comment[ru]=Время в словесной записи
Comment[sk]=Čas zobrazený v menej presnom formáte
Comment[sl]=Čas je prikazan v ne preveč natančni obliki
Comment[sr]=Време приказано на мање прецизан начин
Comment[sr@ijekavian]=Вријеме приказано на мање прецизан начин
Comment[sr@ijekavianlatin]=Vrijeme prikazano na manje precizan način
Comment[sr@latin]=Vreme prikazano na manje precizan način
Comment[sv]=Tidvisning med ett mindre exakt format
Comment[th]=
Comment[tr]=Saati daha az belirli bir şekilde göster
Comment[uk]=Час, показаний у менш точному форматі
Comment[wa]=L' eure håynêye dins ene cogne moens precise
Comment[x-test]=xxTime displayed in a less precise formatxx
Comment[zh_CN]=
Comment[zh_TW]=
Icon=clock
Type=Service
ServiceTypes=Plasma/Applet
X-KDE-Library=plasma_applet_fuzzy_clock
X-KDE-PluginInfo-Author=Riccardo Iaconelli, Sven Burmeister
X-KDE-PluginInfo-Email=riccardo@kde.org, sven.burmeister@gmx.net
X-KDE-PluginInfo-Name=fuzzy-clock
X-KDE-PluginInfo-Version=1.0
X-KDE-PluginInfo-Website=
X-KDE-PluginInfo-Category=Date and Time
X-KDE-PluginInfo-Depends=
X-KDE-PluginInfo-License=GPL
X-KDE-PluginInfo-EnabledByDefault=true

View file

@ -1,17 +0,0 @@
project(luna)
set(luna_SRCS luna.cpp lunaConfig.ui)
kde4_add_plugin(plasma_applet_luna ${luna_SRCS})
target_link_libraries(plasma_applet_luna
KDE4::plasma KDE4::kdeui)
install(TARGETS plasma_applet_luna
DESTINATION ${KDE4_PLUGIN_INSTALL_DIR})
install(FILES plasma-applet-luna.desktop
DESTINATION ${KDE4_SERVICES_INSTALL_DIR})
install(FILES luna.svgz
DESTINATION ${KDE4_DATA_INSTALL_DIR}/desktoptheme/default/widgets/)
kde4_install_icons(${KDE4_ICON_INSTALL_DIR})

View file

@ -1,3 +0,0 @@
#! /usr/bin/env bash
$EXTRACTRC *.ui >> rc.cpp
$XGETTEXT *.cpp -o $podir/plasma_applet_luna.pot

Binary file not shown.

Before

Width:  |  Height:  |  Size: 7.3 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 393 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 638 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.5 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.3 KiB

View file

@ -1,289 +0,0 @@
/***************************************************************************
* 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();
}
#include "moc_luna.cpp"

View file

@ -1,62 +0,0 @@
/***************************************************************************
* 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

View file

@ -1,78 +0,0 @@
<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>
<connections/>
</ui>

View file

@ -1,382 +0,0 @@
/* This file is part of the kmoon application with explicit permission by the author
Copyright 1996 Christopher Osburn <chris@speakeasy.org>
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This library 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
Library General Public License for more details.
You should have received a copy of the GNU Library General Public License
along with this library; see the file COPYING.LIB. If not, write to
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
Boston, MA 02110-1301, USA.
*/
/*
** jd.c:
** 1996/02/11
**
** Copyright 1996, Christopher Osburn, Lunar Outreach Services, <chris@speakeasy.org>
** Non-commercial usage license granted to all.
**
** convert a Julian Day number to a struct tm
**
** Parameter:
** double jd: Julian day number with fraction of day
**
** Returns:
** struct tm *event_date: Date-time group holding year, month, day, hour,
** and minute of the event
*/
#include <time.h>
#include <stdlib.h>
time_t JDtoDate(double jd, struct tm *event_date)
/* convert a Julian Date to a date-time group */
{
long a, a1, z, b, c, d, e;
double f, day;
struct tm dummy;
if ( !event_date )
event_date = &dummy;
jd += 0.5;
z = (long) jd;
f = jd - z;
if (z < 2299161)
{
a = z;
}
else
{
a1 = (long) ((z - 1867216.25) / 36524.25);
a = z + 1 + a1 - (long)(a1 / 4);
}
b = a + 1524;
c = (long)((b - 122.1) / 365.25);
d = (long)(365.25 * c);
e = (long)((b - d)/30.6001);
day = b - d - (long)(30.6001 * e) + f;
if (e < 14)
{
event_date->tm_mon = (e - 1) - 1;
}
else
{
event_date->tm_mon = (e - 13) - 1;
}
if (event_date->tm_mon > (2 - 1))
{
event_date->tm_year = c - 4716 - 1900;
}
else
{
event_date->tm_year = c - 4715 - 1900;
}
event_date->tm_mday = (int)day;
day -= event_date->tm_mday;
day *= 24;
event_date->tm_hour = (int)day;
day -= event_date->tm_hour;
day *= 60;
event_date->tm_min = (int)day;
day -= event_date->tm_min;
day *= 60;
event_date->tm_sec = (int)day;
event_date->tm_isdst = -1;
return mktime(event_date);
}
double DatetoJD(struct tm *event_date)
/* convert a date-time group to a JD with fraction */
{
int y, m;
double d;
int a, b;
double jd;
y = event_date->tm_year + 1900;
m = event_date->tm_mon + 1;
d = (double)(event_date->tm_mday) + (event_date->tm_hour / 24.0)
+ (event_date->tm_min / 1440.0) + (event_date->tm_sec / 86400.0);
if (m == 1 || m == 2)
{
y--;
m += 12;
}
a = (int)(y / 100);
b = 2 - a + (int)(a / 4);
if (y < 1583)
if ((y < 1582) || (m < 10) || ((m == 10) && (d <= 15)))
b = 0;
jd = (long)(365.25 * (y + 4716)) + (long)(30.6001 * (m+1))
+ d + b - 1524.5;
return jd;
}
/*
** misc.h
** 1996/02/11
**
** Copyright 1996, Christopher Osburn, Lunar Outreach Services,
** Non-commercial usage license granted to all.
**
** Miscellaneous routines for moon phase programs
**
*/
#include <math.h>
double torad(double x)
/* convert x to radians */
{
x = fmod(x, 360.0); /* normalize the angle */
return ((x) * 0.01745329251994329576);
/* and return the result */
}
/*
** moonphase.c
** 1996/02/11
**
** Copyright 1996, Christopher Osburn, Lunar Outreach Services,
** Non-commercial usage license granted to all.
**
** calculate phase of the moon per Meeus Ch. 47
**
** Parameters:
** int lun: phase parameter. This is the number of lunations
** since the New Moon of 2000 January 6.
**
** int phi: another phase parameter, selecting the phase of the
** moon. 0 = New, 1 = First Qtr, 2 = Full, 3 = Last Qtr
**
** Return: Apparent JD of the needed phase
*/
#include <stdio.h>
double moonphase(double k, int phi)
{
int i; /* iterator to be named later. Every
program needs an i */
double T; /* time parameter, Julian Centuries since
J2000 */
double JDE; /* Julian Ephemeris Day of phase event */
double E; /* Eccentricity anomaly */
double M; /* Sun's mean anomaly */
double M1; /* Moon's mean anomaly */
double F; /* Moon's argument of latitude */
double O; /* Moon's longitude of ascenfing node */
double A[15]; /* planetary arguments */
double W; /* added correction for quarter phases */
T = k / 1236.85; /* (47.3) */
/* this is the first approximation. all else is for style points! */
JDE = 2451550.09765 + (29.530588853 * k) /* (47.1) */
+ T * T * (0.0001337 + T * (-0.000000150 + 0.00000000073 * T));
/* these are correction parameters used below */
E = 1.0 /* (45.6) */
+ T * (-0.002516 + -0.0000074 * T);
M = 2.5534 + 29.10535669 * k /* (47.4) */
+ T * T * (-0.0000218 + -0.00000011 * T);
M1 = 201.5643 + 385.81693528 * k /* (47.5) */
+ T * T * (0.0107438 + T * (0.00001239 + -0.000000058 * T));
F = 160.7108 + 390.67050274 * k /* (47.6) */
+ T * T * (-0.0016341 * T * (-0.00000227 + 0.000000011 * T));
O = 124.7746 - 1.56375580 * k /* (47.7) */
+ T * T * (0.0020691 + 0.00000215 * T);
/* planetary arguments */
A[0] = 0; /* unused! */
A[1] = 299.77 + 0.107408 * k - 0.009173 * T * T;
A[2] = 251.88 + 0.016321 * k;
A[3] = 251.83 + 26.651886 * k;
A[4] = 349.42 + 36.412478 * k;
A[5] = 84.66 + 18.206239 * k;
A[6] = 141.74 + 53.303771 * k;
A[7] = 207.14 + 2.453732 * k;
A[8] = 154.84 + 7.306860 * k;
A[9] = 34.52 + 27.261239 * k;
A[10] = 207.19 + 0.121824 * k;
A[11] = 291.34 + 1.844379 * k;
A[12] = 161.72 + 24.198154 * k;
A[13] = 239.56 + 25.513099 * k;
A[14] = 331.55 + 3.592518 * k;
/* all of the above crap must be made into radians!!! */
/* except for E... */
M = torad(M);
M1 = torad(M1);
F = torad(F);
O = torad(O);
/* all those planetary arguments, too! */
for (i=1; i<=14; ++i)
A[i] = torad(A[i]);
/* ok, we have all the parameters, let's apply them to the JDE.
(remember the JDE? this is a program about the JDE...) */
switch(phi)
{
/* a special case for each different phase. NOTE!,
I'm not treating these in a 0123 order!!! Pay
attention, there, you! */
case 0: /* New Moon */
JDE = JDE
- 0.40720 * sin (M1)
+ 0.17241 * E * sin (M)
+ 0.01608 * sin (2.0 * M1)
+ 0.01039 * sin (2.0 * F)
+ 0.00739 * E * sin (M1 - M)
- 0.00514 * E * sin (M1 + M)
+ 0.00208 * E * E * sin (2.0 * M)
- 0.00111 * sin (M1 - 2.0 * F)
- 0.00057 * sin (M1 + 2.0 * F)
+ 0.00056 * E * sin (2.0 * M1 + M)
- 0.00042 * sin (3.0 * M1)
+ 0.00042 * E * sin (M + 2.0 * F)
+ 0.00038 * E * sin (M - 2.0 * F)
- 0.00024 * E * sin (2.0 * M1 - M)
- 0.00017 * sin (O)
- 0.00007 * sin (M1 + 2.0 * M)
+ 0.00004 * sin (2.0 * M1 - 2.0 * F)
+ 0.00004 * sin (3.0 * M)
+ 0.00003 * sin (M1 + M - 2.0 * F)
+ 0.00003 * sin (2.0 * M1 + 2.0 * F)
- 0.00003 * sin (M1 + M + 2.0 * F)
+ 0.00003 * sin (M1 - M + 2.0 * F)
- 0.00002 * sin (M1 - M - 2.0 * F)
- 0.00002 * sin (3.0 * M1 + M)
+ 0.00002 * sin (4.0 * M1);
break;
case 2: /* Full Moon */
JDE = JDE
- 0.40614 * sin (M1)
+ 0.17302 * E * sin (M)
+ 0.01614 * sin (2.0 * M1)
+ 0.01043 * sin (2.0 * F)
+ 0.00734 * E * sin (M1 - M)
- 0.00515 * E * sin (M1 + M)
+ 0.00209 * E * E * sin (2.0 * M)
- 0.00111 * sin (M1 - 2.0 * F)
- 0.00057 * sin (M1 + 2.0 * F)
+ 0.00056 * E * sin (2.0 * M1 + M)
- 0.00042 * sin (3.0 * M1)
+ 0.00042 * E * sin (M + 2.0 * F)
+ 0.00038 * E * sin (M - 2.0 * F)
- 0.00024 * E * sin (2.0 * M1 - M)
- 0.00017 * sin (O)
- 0.00007 * sin (M1 + 2.0 * M)
+ 0.00004 * sin (2.0 * M1 - 2.0 * F)
+ 0.00004 * sin (3.0 * M)
+ 0.00003 * sin (M1 + M - 2.0 * F)
+ 0.00003 * sin (2.0 * M1 + 2.0 * F)
- 0.00003 * sin (M1 + M + 2.0 * F)
+ 0.00003 * sin (M1 - M + 2.0 * F)
- 0.00002 * sin (M1 - M - 2.0 * F)
- 0.00002 * sin (3.0 * M1 + M)
+ 0.00002 * sin (4.0 * M1);
break;
case 1: /* First Quarter */
case 3: /* Last Quarter */
JDE = JDE
- 0.62801 * sin (M1)
+ 0.17172 * E * sin (M)
- 0.01183 * E * sin (M1 + M)
+ 0.00862 * sin (2.0 * M1)
+ 0.00804 * sin (2.0 * F)
+ 0.00454 * E * sin (M1 - M)
+ 0.00204 * E * E * sin (2.0 * M)
- 0.00180 * sin (M1 - 2.0 * F)
- 0.00070 * sin (M1 + 2.0 * F)
- 0.00040 * sin (3.0 * M1)
- 0.00034 * E * sin (2.0 * M1 - M)
+ 0.00032 * E * sin (M + 2.0 * F)
+ 0.00032 * E * sin (M - 2.0 * F)
- 0.00028 * E * E * sin (M1 + 2.0 * M)
+ 0.00027 * E * sin (2.0 * M1 + M)
- 0.00017 * sin (O)
- 0.00005 * sin (M1 - M - 2.0 * F)
+ 0.00004 * sin (2.0 * M1 + 2.0 * F)
- 0.00004 * sin (M1 + M + 2.0 * F)
+ 0.00004 * sin (M1 - 2.0 * M)
+ 0.00003 * sin (M1 + M - 2.0 * F)
+ 0.00003 * sin (3.0 * M)
+ 0.00002 * sin (2.0 * M1 - 2.0 * F)
+ 0.00002 * sin (M1 - M + 2.0 * F)
- 0.00002 * sin (3.0 * M1 + M);
W = 0.00306
- 0.00038 * E * cos(M)
+ 0.00026 * cos(M1)
- 0.00002 * cos(M1 - M)
+ 0.00002 * cos(M1 + M)
+ 0.00002 * cos(2.0 * F);
if (phi == 3)
W = -W;
JDE += W;
break;
default: /* oops! */
fprintf(stderr, "The Moon has exploded!\n");
exit(1);
break; /* unexecuted code */
}
/* now there are some final correction to everything */
JDE = JDE
+ 0.000325 * sin(A[1])
+ 0.000165 * sin(A[2])
+ 0.000164 * sin(A[3])
+ 0.000126 * sin(A[4])
+ 0.000110 * sin(A[5])
+ 0.000062 * sin(A[6])
+ 0.000060 * sin(A[7])
+ 0.000056 * sin(A[8])
+ 0.000047 * sin(A[9])
+ 0.000042 * sin(A[10])
+ 0.000040 * sin(A[11])
+ 0.000037 * sin(A[12])
+ 0.000035 * sin(A[13])
+ 0.000023 * sin(A[14]);
return JDE;
}
#define LUNATION_OFFSET 953
double moonphasebylunation(int lun, int phi)
{
double k;
k = lun - LUNATION_OFFSET + phi / 4.0;
return moonphase(k, phi);
}

View file

@ -1,127 +0,0 @@
[Desktop Entry]
Name=Luna
Name[ar]=لونا
Name[ast]=Lluna
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]=Luna
Name[lv]=Luna
Name[mr]=
Name[nb]=Luna
Name[nds]=Luna
Name[nl]=Luna
Name[nn]=Månefaseindikator
Name[oc]=Tai
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[ast]=Amuesa les fases de la lluna pal so allugamientu
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]=Muestra las fases de la luna para 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świetlanie faz 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=
X-KDE-PluginInfo-Category=Astronomy
X-KDE-PluginInfo-Depends=
X-KDE-PluginInfo-License=GPL
X-KDE-PluginInfo-EnabledByDefault=true