kdeplasma-addons: drop potd feature of frame applet

Signed-off-by: Ivailo Monev <xakepa10@gmail.com>
This commit is contained in:
Ivailo Monev 2024-04-09 08:08:44 +03:00
parent ae1492b768
commit cd96e2b642
5 changed files with 5 additions and 132 deletions

View file

@ -44,7 +44,6 @@
#include <kglobalsettings.h>
#include <Plasma/PaintUtils>
#include <Plasma/DataEngine>
#include <Plasma/ToolButton>
#include <Plasma/Frame>
#include <Plasma/ToolTipContent>
@ -196,8 +195,6 @@ void Frame::configChanged()
m_slideshowTime = cg.readEntry("slideshow time", 60); // default to 1 minute
m_currentUrl = cg.readEntry("url", m_currentUrl);
setAssociatedApplicationUrls(m_currentUrl);
m_potdProvider = cg.readEntry("potdProvider", QString());
m_potd = cg.readEntry("potd", false);
m_autoUpdateIntervall = cg.readEntry("autoupdate time", 0);
initSlideShow();
@ -537,23 +534,6 @@ void Frame::createConfigurationInterface(KConfigDialog *parent)
{
m_configDialog = new ConfigDialog(parent);
KService::List services = KServiceTypeTrader::self()->query("PlasmaPoTD/Plugin");
foreach(const KService::Ptr &service, services) {
const QString service_name(service->name());
const QVariant service_identifier(service->property("X-KDE-PlasmaPoTDProvider-Identifier", QVariant::String).toString());
m_configDialog->imageUi.potdComboBox->insertItem(m_configDialog->imageUi.potdComboBox->count(), service_name, service_identifier);
}
QStandardItemModel* model = static_cast<QStandardItemModel*>(m_configDialog->imageUi.pictureComboBox->model());
QStandardItem* item = model->item(2);
if (item) {
if (services.isEmpty())
item->setFlags(item->flags() & ~Qt::ItemIsEnabled);
else
item->setFlags(item->flags() | Qt::ItemIsEnabled);
}
parent->addPage(m_configDialog->imageSettings, i18n("Image"), icon());
parent->addPage(m_configDialog->appearanceSettings, i18n("Appearance"), "preferences-desktop-theme");
parent->setDefaultButton(KDialog::Ok);
@ -572,8 +552,6 @@ void Frame::createConfigurationInterface(KConfigDialog *parent)
if (m_slideShow) {
m_configDialog->imageUi.pictureComboBox->setCurrentIndex(1);
} else if (m_potd) {
m_configDialog->imageUi.pictureComboBox->setCurrentIndex(2);
} else {
m_configDialog->imageUi.pictureComboBox->setCurrentIndex(0);
}
@ -581,11 +559,6 @@ void Frame::createConfigurationInterface(KConfigDialog *parent)
m_configDialog->imageUi.randomCheckBox->setCheckState(m_random ? Qt::Checked : Qt::Unchecked);
m_configDialog->imageUi.recursiveCheckBox->setCheckState(m_recursiveSlideShow ? Qt::Checked : Qt::Unchecked);
if (!m_potdProvider.isEmpty())
m_configDialog->imageUi.potdComboBox->setCurrentIndex(m_configDialog->imageUi.potdComboBox->findData(m_potdProvider));
else
m_configDialog->imageUi.potdComboBox->setCurrentIndex(0);
m_configDialog->setCurrentUrl(m_currentUrl);
m_configDialog->imageUi.slideShowDirList->clear();
m_configDialog->imageUi.slideShowDirList->addItems(m_slideShowPaths);
@ -611,8 +584,6 @@ void Frame::createConfigurationInterface(KConfigDialog *parent)
parent, SLOT(settingsModified()));
connect(m_configDialog->imageUi.recursiveCheckBox, SIGNAL(toggled(bool)),
parent, SLOT(settingsModified()));
connect(m_configDialog->imageUi.potdComboBox, SIGNAL(currentIndexChanged(int)),
parent, SLOT(settingsModified()));
connect(m_configDialog->appearanceUi.roundCheckBox, SIGNAL(toggled(bool)),
parent, SLOT(settingsModified()));
connect(m_configDialog->appearanceUi.shadowCheckBox, SIGNAL(toggled(bool)),
@ -636,17 +607,10 @@ void Frame::configAccepted()
m_frameColor = m_configDialog->frameColor();
cg.writeEntry("frameColor", m_frameColor);
bool wasPotd = m_potd;
if (m_configDialog->imageUi.pictureComboBox->currentIndex() == 1) {
m_slideShow = true;
m_potd = false;
} else if (m_configDialog->imageUi.pictureComboBox->currentIndex() == 2) {
m_slideShow = false;
m_potd = true;
} else {
m_slideShow = false;
m_potd = false;
}
m_random = m_configDialog->random();
@ -674,30 +638,11 @@ void Frame::configAccepted()
m_autoUpdateIntervall = AutoUpdateTimer.second() + AutoUpdateTimer.minute() * 60 + AutoUpdateTimer.hour() * 3600;
cg.writeEntry("autoupdate time", m_autoUpdateIntervall);
QString potdProvider = m_configDialog->imageUi.potdComboBox->itemData(m_configDialog->imageUi.potdComboBox->currentIndex()).toString();
if ((wasPotd && !m_potd) || (m_potd && potdProvider != m_potdProvider)) {
// if we go from potd to no potd, or if the provider changes, then we first want to
// stop the potd engine
stopPotd();
}
m_potdProvider = potdProvider;
cg.writeEntry("potdProvider", m_potdProvider);
cg.writeEntry("potd", m_potd);
initSlideShow();
emit configNeedsSaving();
}
void Frame::stopPotd()
{
Plasma::DataEngine *engine = dataEngine("potd");
engine->disconnectSource(m_potdProvider, m_mySlideShow);
m_autoUpdateTimer->stop();
}
void Frame::initSlideShow()
{
m_mySlideShow->setUpdateInterval(0);
@ -707,9 +652,6 @@ void Frame::initSlideShow()
m_mySlideShow->setRandom(m_random);
m_mySlideShow->setDirs(m_slideShowPaths, m_recursiveSlideShow);
m_mySlideShow->setUpdateInterval(m_slideshowTime * 1000);
} else if (m_potd) {
Plasma::DataEngine *engine = dataEngine("potd");
engine->connectSource(m_potdProvider, m_mySlideShow);
} else { //no slideshow so no random stuff
m_mySlideShow->setRandom(false);
m_mySlideShow->setImage(m_currentUrl.url());
@ -751,8 +693,7 @@ void Frame::dropEvent(QGraphicsSceneDragDropEvent *event)
m_slideShow = false;
}
stopPotd();
m_potd = false;
m_autoUpdateTimer->stop();
initSlideShow();
KConfigGroup cg = config();

View file

@ -85,7 +85,6 @@ protected:
QSizeF sizeHint(Qt::SizeHint which, const QSizeF &constraint) const;
private:
void stopPotd();
void initSlideShow();
void checkSlideFrame();
@ -101,9 +100,6 @@ private:
bool m_roundCorners;
/// If true, the picture will have a drop shadow.
bool m_shadow;
/// PoTD
QString m_potdProvider;
bool m_potd;
/// Stores the current picture URL when slideShow is false. Wikipedia Picture of the Day is default.
KUrl m_currentUrl;
/// The current slideshow folder

View file

@ -23,11 +23,6 @@
<string>Slideshow</string>
</property>
</item>
<item>
<property name="text">
<string>Picture of the day</string>
</property>
</item>
</widget>
</item>
<item>
@ -320,36 +315,6 @@ Useful if you want a live cam or weather data to be up to date.</string>
</item>
</layout>
</widget>
<widget class="QWidget" name="page_2">
<layout class="QVBoxLayout" name="verticalLayout_2">
<item>
<widget class="QLabel" name="selectPoTDlabel">
<property name="text">
<string>Select Picture of the day source:</string>
</property>
<property name="buddy">
<cstring>potdComboBox</cstring>
</property>
</widget>
</item>
<item>
<widget class="KComboBox" name="potdComboBox"/>
</item>
<item>
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>68</height>
</size>
</property>
</spacer>
</item>
</layout>
</widget>
</widget>
</item>
</layout>

View file

@ -226,28 +226,4 @@ void SlideShow::clearPicture()
m_image = QImage();
}
void SlideShow::dataUpdated(const QString &name, const Plasma::DataEngine::Data &data)
{
Q_UNUSED(name);
if (data.isEmpty()) {
m_image = QImage();
m_picture->setMessage(i18n("No Picture from this Provider."));
return;
}
m_image = data["Image"].value<QImage>();
m_currentUrl = data["Url"].toString();
//kDebug() << name << "got data with keys of" << data.keys() << m_image.isNull() << data["Url"];
//Compatibility with old dataengines
if (m_image.isNull()) {
QPixmap tmpPixmap = data["Image"].value<QPixmap>();
if (!tmpPixmap.isNull()) {
m_image = tmpPixmap.toImage();
}
}
m_picture->setMessage(QString());
emit pictureUpdated();
}
#include "moc_slideshow.cpp"

View file

@ -20,17 +20,13 @@
#ifndef SLIDESHOW_H
#define SLIDESHOW_H
#include <QString>
#include <QStringList>
#include <QObject>
#include <KUrl>
#include <Plasma/DataEngine>
#include "picture.h"
#include <QTimer>
#include <QString>
#include <QStringList>
#include <QObject>
#include <KUrl>
class SlideShow : public QObject
{
@ -50,7 +46,6 @@ public:
void setUpdateInterval(int msec);
public Q_SLOTS:
void dataUpdated(const QString &name, const Plasma::DataEngine::Data &data);
void firstPicture();
void nextPicture();
void previousPicture();