Skip to content

Commit

Permalink
bug #1836292
Browse files Browse the repository at this point in the history
  • Loading branch information
liuyuanpeng committed Sep 24, 2019
1 parent a96acc8 commit c3da62f
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
15 changes: 14 additions & 1 deletion src/configuration.cpp
Expand Up @@ -20,7 +20,9 @@
#include <QFile>
#include <QDir>
#include <QStandardPaths>
#include <QMimeDatabase>
#include <QGSettings>
#include <QMimeType>
#include <ctime>

#define GSETTINGS_SCHEMA_SCREENSAVER "org.ukui.screensaver"
Expand Down Expand Up @@ -153,9 +155,20 @@ QString Configuration::getXScreensaverPath(const QString &theme)
return QString("%1/%2").arg(XSCREENSAVER_DIRNAME, str);
}

bool Configuration::ispicture(QString filepath)
{
QMimeDatabase db;
QMimeType mime = db.mimeTypeForFile(filepath);
qDebug() << "mime: " << filepath << mime.name();
return mime.name().startsWith("image/");
}

QString Configuration::getBackground()
{
return background;
if(ispicture(background))
return background;
else
return "/usr/share/backgrounds/warty-final-ubuntukylin.jpg";
}

bool Configuration::xscreensaverActivatedWhenIdle()
Expand Down
2 changes: 2 additions & 0 deletions src/configuration.h
Expand Up @@ -57,6 +57,8 @@ public Q_SLOTS:
bool lockEnabled;
int imageTSEffect;
int imageSwitchInterval;
bool ispicture(QString filepath);

};

#endif // CONFIGURATION_H

0 comments on commit c3da62f

Please sign in to comment.