SVN commit 799260 by sebas: Port trainclock to new API. It has some resizing problems, still. M +14 -26 clock.cpp M +2 -3 clock.h --- trunk/playground/base/plasma/applets/train-clock/clock.cpp #799259:799260 @@ -36,7 +36,7 @@ #include #include #include -#include +#include #include #include #include @@ -57,7 +57,6 @@ m_timezone(0), m_time(), m_date(), - m_dialog(0), m_calendar(0), m_layout(0), m_lastTimeSeen(), @@ -67,15 +66,13 @@ m_horizontalSpacing(0), m_verticalSpacing(0) { - kDebug(); setHasConfigurationInterface(true); - + Applet::resize(150, 50); m_fgColor = Plasma::Theme::self()->textColor(); } void Clock::init() { - kDebug(); KConfigGroup cg = config(); m_timezone = cg.readEntry("timezone", "Local"); m_showTimezone = cg.readEntry("showTimezone", (m_timezone != "Local")); @@ -173,27 +170,20 @@ m_calendar->hide(); } else { kDebug(); - m_calendar->position(event, boundingRect(), mapToScene(boundingRect().topLeft())); + m_calendar->position(event, geometry(), mapToScene(geometry().topLeft())); m_calendar->show(); } } -void Clock::showConfigurationInterface() +void Clock::createConfigurationInterface(KConfigDialog *parent) { - kDebug(); - if (m_dialog == 0) - { - m_dialog = new KDialog; - - m_dialog->setCaption(i18n("Configure Clock")); - - ui.setupUi(m_dialog->mainWidget()); - m_dialog->mainWidget()->layout()->setMargin(0); - m_dialog->setButtons(KDialog::Ok | KDialog::Cancel | KDialog::Apply); - - connect(m_dialog, SIGNAL(applyClicked()), this, SLOT(configAccepted())); - connect(m_dialog, SIGNAL(okClicked()), this, SLOT(configAccepted())); - } + QWidget *widget = new QWidget(); + ui.setupUi(widget); + parent->setButtons( KDialog::Ok | KDialog::Cancel | KDialog::Apply ); + parent->addPage(widget, parent->windowTitle(), "chronometer"); + connect(parent, SIGNAL(applyClicked()), this, SLOT(configAccepted())); + connect(parent, SIGNAL(okClicked()), this, SLOT(configAccepted())); + ui.showDate->setChecked(m_showDate); ui.showYear->setChecked(m_showYear); ui.showDay->setChecked(m_showDay); @@ -204,7 +194,6 @@ ui.localTimeZone->setChecked(m_timezone == "Local"); ui.timeZones->setSelected(m_timezone, true); - m_dialog->show(); } void Clock::configAccepted() @@ -262,7 +251,6 @@ { kDebug(); delete m_calendar; - delete m_dialog; delete m_theme; } @@ -363,9 +351,9 @@ // Plasma::Applet::shouldConserveResources() is true Q_UNUSED(option); if (m_time.isValid() && m_date.isValid()) { - if (m_contentSize != geometry().size()) { - updateSizes(); - } + //if (m_contentSize != geometry().size()) { + // updateSizes(); + //} // *** First, set some properties! p->setFont (KGlobalSettings::smallestReadableFont()); --- trunk/playground/base/plasma/applets/train-clock/clock.h #799259:799260 @@ -57,9 +57,9 @@ public slots: void dataUpdated(const QString &name, const Plasma::DataEngine::Data &data); - void showConfigurationInterface(); protected slots: + void createConfigurationInterface(KConfigDialog *parent); void configAccepted(); void showCalendar(QGraphicsSceneMouseEvent *event); void animationSlot(int step); @@ -94,8 +94,7 @@ Plasma::Svg* m_theme; QTime m_time; QDate m_date; - KDialog *m_dialog; //should we move this into another class? - Plasma::Dialog *m_calendar; + Plasma::Dialog *m_calendar; QVBoxLayout *m_layout; QTime m_lastTimeSeen; QString m_prettyTimezone;