mirror of
https://github.com/qTox/qTox.git
synced 2024-03-22 14:00:36 +08:00
added smiley selection to the new settings dialog, new default search-
This commit is contained in:
parent
2aff9fde5c
commit
7e7cebf6b6
@ -40,12 +40,20 @@ SmileyPack& SmileyPack::getInstance()
|
|||||||
return smileyPack;
|
return smileyPack;
|
||||||
}
|
}
|
||||||
|
|
||||||
QList<QPair<QString, QString> > SmileyPack::listSmileyPacks(const QString &path)
|
QList<QPair<QString, QString> > SmileyPack::listSmileyPacks(const QStringList &paths)
|
||||||
{
|
{
|
||||||
QList<QPair<QString, QString> > smileyPacks;
|
QList<QPair<QString, QString> > smileyPacks;
|
||||||
|
|
||||||
|
for (QString path : paths)
|
||||||
|
{
|
||||||
|
if (path.leftRef(1) == "~")
|
||||||
|
path.replace(0, 1, QDir::homePath());
|
||||||
|
|
||||||
QDir dir(path);
|
QDir dir(path);
|
||||||
foreach (const QString& subdirectory, dir.entryList(QDir::Dirs | QDir::NoDotAndDotDot))
|
if (!dir.exists())
|
||||||
|
continue;
|
||||||
|
|
||||||
|
for (const QString& subdirectory : dir.entryList(QDir::Dirs | QDir::NoDotAndDotDot))
|
||||||
{
|
{
|
||||||
dir.cd(subdirectory);
|
dir.cd(subdirectory);
|
||||||
|
|
||||||
@ -53,12 +61,18 @@ QList<QPair<QString, QString> > SmileyPack::listSmileyPacks(const QString &path)
|
|||||||
if (entries.size() > 0) // does it contain a file called emoticons.xml?
|
if (entries.size() > 0) // does it contain a file called emoticons.xml?
|
||||||
{
|
{
|
||||||
QString packageName = dir.dirName();
|
QString packageName = dir.dirName();
|
||||||
QString relPath = QDir(QCoreApplication::applicationDirPath()).relativeFilePath(entries[0].absoluteFilePath());
|
QString absPath = entries[0].absoluteFilePath();
|
||||||
smileyPacks << QPair<QString, QString>(packageName, relPath);
|
QString relPath = QDir(QCoreApplication::applicationDirPath()).relativeFilePath(absPath);
|
||||||
|
|
||||||
|
if (relPath.leftRef(2) == "..")
|
||||||
|
smileyPacks << QPair<QString, QString>(packageName, absPath);
|
||||||
|
else
|
||||||
|
smileyPacks << QPair<QString, QString>(packageName, relPath); // use relative path for subdirectories
|
||||||
}
|
}
|
||||||
|
|
||||||
dir.cdUp();
|
dir.cdUp();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return smileyPacks;
|
return smileyPacks;
|
||||||
}
|
}
|
||||||
|
@ -22,7 +22,10 @@
|
|||||||
#include <QString>
|
#include <QString>
|
||||||
#include <QStringList>
|
#include <QStringList>
|
||||||
|
|
||||||
#define SMILEYPACK_DEFAULT_PATH "./smileys"
|
#define SMILEYPACK_SEARCH_PATHS \
|
||||||
|
{ \
|
||||||
|
"./smileys", "/usr/share/qtox/smileys", "/usr/share/emoticons", "~/.kde4/share/emoticons", "~/.kde/share/emoticons" \
|
||||||
|
}
|
||||||
|
|
||||||
//maps emoticons to smileys
|
//maps emoticons to smileys
|
||||||
class SmileyPack : public QObject
|
class SmileyPack : public QObject
|
||||||
@ -30,10 +33,10 @@ class SmileyPack : public QObject
|
|||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
static SmileyPack& getInstance();
|
static SmileyPack& getInstance();
|
||||||
static QList<QPair<QString, QString>> listSmileyPacks(const QString& path = SMILEYPACK_DEFAULT_PATH);
|
static QList<QPair<QString, QString> > listSmileyPacks(const QStringList& paths = SMILEYPACK_SEARCH_PATHS);
|
||||||
static bool isValid(const QString& filename);
|
static bool isValid(const QString& filename);
|
||||||
|
|
||||||
bool load(const QString &filename);
|
bool load(const QString& filename);
|
||||||
QString smileyfied(QString msg);
|
QString smileyfied(QString msg);
|
||||||
QList<QStringList> getEmoticons() const;
|
QList<QStringList> getEmoticons() const;
|
||||||
QString getAsRichText(const QString& key);
|
QString getAsRichText(const QString& key);
|
||||||
|
@ -4,6 +4,7 @@
|
|||||||
#include "camera.h"
|
#include "camera.h"
|
||||||
#include "selfcamview.h"
|
#include "selfcamview.h"
|
||||||
#include "core.h"
|
#include "core.h"
|
||||||
|
#include "smileypack.h"
|
||||||
|
|
||||||
#include <QListWidget>
|
#include <QListWidget>
|
||||||
#include <QListWidgetItem>
|
#include <QListWidgetItem>
|
||||||
@ -14,6 +15,7 @@
|
|||||||
#include <QGroupBox>
|
#include <QGroupBox>
|
||||||
#include <QCheckBox>
|
#include <QCheckBox>
|
||||||
#include <QLineEdit>
|
#include <QLineEdit>
|
||||||
|
#include <QComboBox>
|
||||||
|
|
||||||
|
|
||||||
// =======================================
|
// =======================================
|
||||||
@ -41,8 +43,23 @@ public:
|
|||||||
vLayout->addWidget(makeToxPortable);
|
vLayout->addWidget(makeToxPortable);
|
||||||
group->setLayout(vLayout);
|
group->setLayout(vLayout);
|
||||||
|
|
||||||
|
// theme
|
||||||
|
QGroupBox* themeGroup = new QGroupBox(tr("Theme"));
|
||||||
|
QLabel* smileyLabel = new QLabel(tr("Smiley Pack"));
|
||||||
|
smileyPack = new QComboBox(this);
|
||||||
|
|
||||||
|
auto smileyPacks = SmileyPack::listSmileyPacks();
|
||||||
|
for(auto pack : smileyPacks)
|
||||||
|
smileyPack->addItem(QString("%1 (%2)").arg(pack.first).arg(pack.second), pack.second);
|
||||||
|
|
||||||
|
QVBoxLayout* themeLayout = new QVBoxLayout();
|
||||||
|
themeLayout->addWidget(smileyLabel);
|
||||||
|
themeLayout->addWidget(smileyPack);
|
||||||
|
themeGroup->setLayout(themeLayout);
|
||||||
|
|
||||||
QVBoxLayout *mainLayout = new QVBoxLayout();
|
QVBoxLayout *mainLayout = new QVBoxLayout();
|
||||||
mainLayout->addWidget(group);
|
mainLayout->addWidget(group);
|
||||||
|
mainLayout->addWidget(themeGroup);
|
||||||
mainLayout->addStretch(1);
|
mainLayout->addStretch(1);
|
||||||
setLayout(mainLayout);
|
setLayout(mainLayout);
|
||||||
}
|
}
|
||||||
@ -50,6 +67,7 @@ public:
|
|||||||
QCheckBox* enableIPv6;
|
QCheckBox* enableIPv6;
|
||||||
QCheckBox* useTranslations;
|
QCheckBox* useTranslations;
|
||||||
QCheckBox* makeToxPortable;
|
QCheckBox* makeToxPortable;
|
||||||
|
QComboBox* smileyPack;
|
||||||
};
|
};
|
||||||
|
|
||||||
class IdentityPage : public QWidget
|
class IdentityPage : public QWidget
|
||||||
@ -327,6 +345,11 @@ void SettingsDialog::writeConfig()
|
|||||||
saveSettings = true;
|
saveSettings = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (settings.getSmileyPack() != generalPage->smileyPack->currentData().toString()) {
|
||||||
|
settings.setSmileyPack(generalPage->smileyPack->currentData().toString());
|
||||||
|
saveSettings = true;
|
||||||
|
}
|
||||||
|
|
||||||
if (saveSettings) {
|
if (saveSettings) {
|
||||||
settings.save();
|
settings.save();
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user