forked from blue/squawk
debug and actual first way to display pictures in messageFeed
This commit is contained in:
parent
48e498be25
commit
0e937199b0
7 changed files with 118 additions and 8 deletions
|
@ -81,7 +81,8 @@ Shared::Global::Global():
|
|||
}),
|
||||
pluginSupport({
|
||||
{"KWallet", false}
|
||||
})
|
||||
}),
|
||||
fileCache()
|
||||
{
|
||||
if (instance != 0) {
|
||||
throw 551;
|
||||
|
@ -90,6 +91,34 @@ Shared::Global::Global():
|
|||
instance = this;
|
||||
}
|
||||
|
||||
Shared::Global::FileInfo Shared::Global::getFileInfo(const QString& path)
|
||||
{
|
||||
std::map<QString, FileInfo>::const_iterator itr = instance->fileCache.find(path);
|
||||
if (itr == instance->fileCache.end()) {
|
||||
QMimeDatabase db;
|
||||
QMimeType type = db.mimeTypeForFile(path);
|
||||
QStringList parts = type.name().split("/");
|
||||
QString big = parts.front();
|
||||
QFileInfo info(path);
|
||||
|
||||
FileInfo::Preview p = FileInfo::Preview::none;
|
||||
QSize size;
|
||||
if (big == "image") {
|
||||
if (parts.back() == "gif") {
|
||||
//TODO need to consider GIF as a movie
|
||||
}
|
||||
p = FileInfo::Preview::picture;
|
||||
QImage img(path);
|
||||
size = img.size();
|
||||
}
|
||||
|
||||
itr = instance->fileCache.insert(std::make_pair(path, FileInfo({info.fileName(), size, type, p}))).first;
|
||||
}
|
||||
|
||||
return itr->second;
|
||||
}
|
||||
|
||||
|
||||
Shared::Global * Shared::Global::getInstance()
|
||||
{
|
||||
return instance;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue