mirror of
https://github.com/RetroShare/RetroShare.git
synced 2025-02-03 02:50:07 -05:00
Recheck for new stickers when opening the dialog
This commit is contained in:
parent
8b5a1036e0
commit
8ff71150c5
@ -41,17 +41,17 @@
|
|||||||
|
|
||||||
static QHash<QString, QPair<QVector<QString>, QHash<QString, QString> > > Smileys;
|
static QHash<QString, QPair<QVector<QString>, QHash<QString, QString> > > Smileys;
|
||||||
static QVector<QString> grpOrdered;
|
static QVector<QString> grpOrdered;
|
||||||
static QVector<QString > StickerGroups;
|
|
||||||
static QStringList filters;
|
static QStringList filters;
|
||||||
|
static QStringList stickerFolders;
|
||||||
static QHash<QString, QString> tooltipcache;
|
static QHash<QString, QString> tooltipcache;
|
||||||
|
|
||||||
void Emoticons::load()
|
void Emoticons::load()
|
||||||
{
|
{
|
||||||
loadSmiley();
|
loadSmiley();
|
||||||
filters << "*.png" << "*.jpg" << "*.gif";
|
filters << "*.png" << "*.jpg" << "*.gif";
|
||||||
loadSticker(QString::fromStdString(RsAccounts::ConfigDirectory()) + "/stickers"); //under .retroshare, shared between users
|
stickerFolders << (QString::fromStdString(RsAccounts::ConfigDirectory()) + "/stickers"); //under .retroshare, shared between users
|
||||||
loadSticker(QString::fromStdString(RsAccounts::AccountDirectory()) + "/stickers"); //under account, unique for user
|
stickerFolders << (QString::fromStdString(RsAccounts::AccountDirectory()) + "/stickers"); //under account, unique for user
|
||||||
loadSticker(QString::fromStdString(RsAccounts::systemDataDirectory()) + "/stickers"); //exe's folder, shipped with RS
|
stickerFolders << (QString::fromStdString(RsAccounts::systemDataDirectory()) + "/stickers"); //exe's folder, shipped with RS
|
||||||
}
|
}
|
||||||
|
|
||||||
void Emoticons::loadSmiley()
|
void Emoticons::loadSmiley()
|
||||||
@ -285,7 +285,13 @@ void Emoticons::showSmileyWidget(QWidget *parent, QWidget *button, const char *s
|
|||||||
smWidget->show() ;
|
smWidget->show() ;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Emoticons::loadSticker(QString foldername)
|
void Emoticons::refreshStickerTabs(QVector<QString>& stickerTabs)
|
||||||
|
{
|
||||||
|
for(int i = 0; i < stickerFolders.count(); ++i)
|
||||||
|
refreshStickerTabs(stickerTabs, stickerFolders[i]);
|
||||||
|
}
|
||||||
|
|
||||||
|
void Emoticons::refreshStickerTabs(QVector<QString>& stickerTabs, QString foldername)
|
||||||
{
|
{
|
||||||
QDir dir(foldername);
|
QDir dir(foldername);
|
||||||
if(!dir.exists()) return;
|
if(!dir.exists()) return;
|
||||||
@ -293,26 +299,28 @@ void Emoticons::loadSticker(QString foldername)
|
|||||||
//If it contains at a least one png then add it as a group
|
//If it contains at a least one png then add it as a group
|
||||||
QStringList files = dir.entryList(filters, QDir::Files);
|
QStringList files = dir.entryList(filters, QDir::Files);
|
||||||
if(files.count() > 0)
|
if(files.count() > 0)
|
||||||
StickerGroups.append(foldername);
|
stickerTabs.append(foldername);
|
||||||
|
|
||||||
//Check subfolders
|
//Check subfolders
|
||||||
QFileInfoList subfolders = dir.entryInfoList(QDir::AllDirs | QDir::NoDotAndDotDot);
|
QFileInfoList subfolders = dir.entryInfoList(QDir::AllDirs | QDir::NoDotAndDotDot);
|
||||||
for(int i = 0; i<subfolders.length(); i++)
|
for(int i = 0; i<subfolders.length(); i++)
|
||||||
loadSticker(subfolders[i].filePath());
|
refreshStickerTabs(stickerTabs, subfolders[i].filePath());
|
||||||
}
|
}
|
||||||
|
|
||||||
void Emoticons::showStickerWidget(QWidget *parent, QWidget *button, const char *slotAddMethod, bool above)
|
void Emoticons::showStickerWidget(QWidget *parent, QWidget *button, const char *slotAddMethod, bool above)
|
||||||
{
|
{
|
||||||
|
QApplication::setOverrideCursor(Qt::WaitCursor);
|
||||||
|
QVector<QString> stickerTabs;
|
||||||
|
refreshStickerTabs(stickerTabs);
|
||||||
QWidget *smWidget = new QWidget(parent, Qt::Popup) ;
|
QWidget *smWidget = new QWidget(parent, Qt::Popup) ;
|
||||||
smWidget->setAttribute(Qt::WA_DeleteOnClose) ;
|
smWidget->setAttribute(Qt::WA_DeleteOnClose) ;
|
||||||
smWidget->setWindowTitle("Stickers") ;
|
smWidget->setWindowTitle("Stickers") ;
|
||||||
QApplication::setOverrideCursor(Qt::WaitCursor);
|
|
||||||
|
|
||||||
if(StickerGroups.count() == 0) {
|
if(stickerTabs.count() == 0) {
|
||||||
QMessageBox::warning(parent, "Stickers", "No stickers installed");
|
QMessageBox::warning(parent, "Stickers", "No stickers installed");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
bool bOnlyOneGroup = (StickerGroups.count() == 1);
|
bool bOnlyOneGroup = (stickerTabs.count() == 1);
|
||||||
|
|
||||||
QTabWidget *smTab = nullptr;
|
QTabWidget *smTab = nullptr;
|
||||||
if (! bOnlyOneGroup)
|
if (! bOnlyOneGroup)
|
||||||
@ -328,7 +336,7 @@ void Emoticons::showStickerWidget(QWidget *parent, QWidget *button, const char *
|
|||||||
int maxRowCount = 0;
|
int maxRowCount = 0;
|
||||||
int maxCountPerLine = 0;
|
int maxCountPerLine = 0;
|
||||||
|
|
||||||
QVectorIterator<QString> grp(StickerGroups);
|
QVectorIterator<QString> grp(stickerTabs);
|
||||||
while(grp.hasNext())
|
while(grp.hasNext())
|
||||||
{
|
{
|
||||||
QDir groupDir = QDir(grp.next());
|
QDir groupDir = QDir(grp.next());
|
||||||
|
@ -21,6 +21,8 @@
|
|||||||
#ifndef _EMOTICONS_H
|
#ifndef _EMOTICONS_H
|
||||||
#define _EMOTICONS_H
|
#define _EMOTICONS_H
|
||||||
|
|
||||||
|
#include <QVector>
|
||||||
|
|
||||||
class QWidget;
|
class QWidget;
|
||||||
class QString;
|
class QString;
|
||||||
|
|
||||||
@ -29,7 +31,8 @@ class Emoticons
|
|||||||
public:
|
public:
|
||||||
static void load();
|
static void load();
|
||||||
static void loadSmiley();
|
static void loadSmiley();
|
||||||
static void loadSticker(QString foldername);
|
static void refreshStickerTabs(QVector<QString>& stickerTabs, QString foldername);
|
||||||
|
static void refreshStickerTabs(QVector<QString>& stickerTabs);
|
||||||
|
|
||||||
static void showSmileyWidget(QWidget *parent, QWidget *button, const char *slotAddMethod, bool above);
|
static void showSmileyWidget(QWidget *parent, QWidget *button, const char *slotAddMethod, bool above);
|
||||||
static void showStickerWidget(QWidget *parent, QWidget *button, const char *slotAddMethod, bool above);
|
static void showStickerWidget(QWidget *parent, QWidget *button, const char *slotAddMethod, bool above);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user