[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-commits
Subject: playground/base/plasma/applets/worldclock
From: Henry de Valence <hdevalence () gmail ! com>
Date: 2008-03-28 18:11:56
Message-ID: 1206727916.016750.8720.nullmailer () svn ! kde ! org
[Download RAW message or body]
SVN commit 791201 by hdevalence:
Added a configuration dialog that allows the user to
set the rotation of the map.
M +1 -0 CMakeLists.txt
M +71 -8 worldclock.cpp
M +10 -2 worldclock.h
A worldclockConfig.ui
--- trunk/playground/base/plasma/applets/worldclock/CMakeLists.txt #791200:791201
@@ -23,6 +23,7 @@
)
set(worldclock_SRCS worldclock.cpp )
+kde4_add_ui_files( worldclock_SRCS worldclockConfig.ui )
kde4_add_plugin(plasma_applet_worldclock ${worldclock_SRCS})
target_link_libraries(plasma_applet_worldclock
--- trunk/playground/base/plasma/applets/worldclock/worldclock.cpp #791200:791201
@@ -16,37 +16,50 @@
** MA 02110-1301, USA.
*/
+//Qt
#include <QPainter>
-#include <QGraphicsProxyWidget>
-#include <QGraphicsLinearLayout>
-#include <QGraphicsWidget>
+
+//KDE
+#include <KDebug>
+#include <KDialog>
+#include <KConfigGroup>
+
+
+//Plasma
#include <plasma/theme.h>
#include <plasma/dataengine.h>
+
+//Marble
#include <marble/MarbleMap.h>
#include <marble/SunLocator.h>
#include <marble/ClipPainter.h>
-#include <kdebug.h>
+//Mine
#include "worldclock.h"
WorldClock::WorldClock(QObject *parent, const QVariantList &args)
- : Plasma::Applet(parent, args)
+ : Plasma::Applet(parent, args),
+ m_configDialog(0)
{
+ setHasConfigurationInterface(true);
setDrawStandardBackground(true);
//The applet needs a 2:1 ratio
//so that the map fits properly
resize(QSize(400, 200));
+ KConfigGroup cg = config();
+
m_map = new MarbleMap( );
m_map->setProjection( Equirectangular );
m_map->setSize( 400, 200 );
//offset so that the date line isn't
//right on the edge of the map
- m_map->centerOn( -20, 0 );
+ //or user choice
+ m_map->centerOn( cg.readEntry("rotation", -20), 0 );
//Set how we want the map to look
m_map->setMapTheme( "earth/bluemarble/bluemarble.dgml" );
@@ -62,11 +75,12 @@
//Radius*4 = width
m_map->setRadius( 100 );
- //why doesn't this work?
//Set up the Sun to draw night/day shadow
m_sun = m_map->sunLocator();
m_sun->setShow(true);
m_sun->setCitylights(true);
+ if(cg.readEntry("centersun", static_cast<int>(Qt::Unchecked)) == Qt::Checked)
+ m_sun->setCentered(true);
m_sun->update();
m_map->updateSun();
@@ -77,6 +91,8 @@
WorldClock::~WorldClock()
{
+ if(m_configDialog)
+ delete m_configDialog;
}
//We want to redraw the map every 10 mins
@@ -125,5 +141,52 @@
p->drawPixmap( 0, 0, pixmap );
}
-
+void WorldClock::showConfigurationInterface()
+{
+ if(m_configDialog == 0) {
+ m_configDialog = new KDialog;
+ ui.setupUi(m_configDialog->mainWidget());
+ m_configDialog->setPlainCaption(i18n("Worldclock Applet Configuration"));
+ m_configDialog->setButtons(KDialog::Ok | KDialog::Apply |
+ KDialog::Cancel);
+
+ KConfigGroup cg = config();
+ if(cg.readEntry("centersun", static_cast<int>(Qt::Unchecked)) == Qt::Checked)
+ ui.centerSunCheckBox->setChecked(true);
+
+ connect(m_configDialog, SIGNAL(okClicked()),
+ this, SLOT(configAccepted()));
+ connect(m_configDialog, SIGNAL(applyClicked()),
+ this, SLOT(configAccepted()));
+ }
+
+ m_configDialog->show();
+}
+
+void WorldClock::configAccepted()
+{
+ KConfigGroup cg = config();
+ if( ui.centerSunCheckBox->checkState() !=
+ cg.readEntry("centersun", static_cast<int>(Qt::Unchecked)) ) {
+ switch(ui.centerSunCheckBox->checkState()) {
+ case Qt::Checked :
+ m_sun->setCentered(true);
+ break;
+ default :
+ m_sun->setCentered(false);
+ break;
+ }
+ m_sun->update();
+ m_map->updateSun();
+ update();
+ }
+ if( ui.rotationSpinBox->value() !=
+ cg.readEntry("rotation", -20) ) {
+ m_map->centerOn(ui.rotationSpinBox->value(), 0);
+ update();
+ }
+ cg.writeEntry("centersun", static_cast<int>(ui.centerSunCheckBox->checkState()));
+ cg.writeEntry("rotation", ui.rotationSpinBox->value());
+}
+
#include "worldclock.moc"
--- trunk/playground/base/plasma/applets/worldclock/worldclock.h #791200:791201
@@ -20,6 +20,7 @@
#define WORLDCLOCK_H
#include <Plasma/Applet>
+#include "ui_worldclockConfig.h"
class MarbleMap;
class SunLocator;
@@ -31,17 +32,24 @@
public:
WorldClock(QObject *parent, const QVariantList &args);
~WorldClock();
- void paintInterface(QPainter *painter, const QStyleOptionGraphicsItem *option,
+ void paintInterface(QPainter *painter,
+ const QStyleOptionGraphicsItem *option,
const QRect& contentsRect);
void init();
public slots:
- void dataUpdated(const QString &name, const Plasma::DataEngine::Data &data);
+ void dataUpdated(const QString &name,
+ const Plasma::DataEngine::Data &data);
+ void showConfigurationInterface();
+ protected slots:
+ void configAccepted();
private slots:
void resizeMap();
private:
void connectToEngine();
MarbleMap *m_map;
SunLocator *m_sun;
+ KDialog *m_configDialog;
+ Ui::worldclockConfig ui;
};
K_EXPORT_PLASMA_APPLET(worldclock, WorldClock)
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic