This repository has been archived by the owner on Sep 8, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 19
/
FontMapComboBox.cpp
145 lines (131 loc) · 3.31 KB
/
FontMapComboBox.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
/***************************************************************************//**
* @brief Thumbnail me 3.0
* Thumbnail me is a user interface for Movie thumbnailer.
* Generate thumbnails from any movie is now easier !
*
* @file FontMapComboBox.cpp
* @class FontMapComboBox
* Cette classe permet de générer un QFontComboBox avec un QMap("Famille de la police","Chemin de la police")
*
* @author Quentin Rousseau\n
* @note Copyright (C) 2011-2012 Quentin Rousseau\n
* License: GNU General Public License version 2 (GPLv2) - http://www.gnu.org/licenses/gpl-2.0.html\n
* Site web: www.thumbnailme.com\n
* Email: [email protected]
*
* @since 3.0
* @version 3.0
* @date 2011-2012
*******************************************************************************/
#include "FontMapComboBox.h"
#include "ThumbnailItem.h"
#include "QTHelper.h"
/**
*@brief Constructeur.
*@param *parent Widget parent.
*/
FontMapComboBox::FontMapComboBox(QWidget *parent) : QFontComboBox(parent)
{
this->setFontFilters(QFontComboBox::ScalableFonts);
this->setEditable(false);
this->noFontDefined = true;
}
/**
*@brief Destructeur.
*/
FontMapComboBox::~FontMapComboBox()
{
}
/**
*@brief Setter de la map.
*@param map Map de correspondance "Famille - Chemin de la police".
*/
void FontMapComboBox::setMap(QMap<QString,QString> map)
{
this->map = map;
}
/**
*@brief Retourne le chemin de la police famille.
*@param family Famille.
*@return QString - Chemin de la police.
*/
QString FontMapComboBox::path(QString family)
{
QString path;
path = this->map.value(family);
return path;
}
/**
*@brief Retourne le chemin de la police courante.
*@return QString - Chemin de la police.
*/
QString FontMapComboBox::currentFontPath()
{
return this->path(this->currentText());
}
/**
*@brief Retourne le nom du fichier de la police
*@return QString - Nom du fichier de la police
*/
QString FontMapComboBox::currentFontFileName()
{
QFileInfo fontInfo (QDir::toNativeSeparators(this->currentFontPath()));
if (fontInfo.exists())
{
return fontInfo.fileName();
}
else return QString();
}
/**
*@brief Retourne une liste des familles de police.
*@return QStringList - Familles de police.
*/
QStringList FontMapComboBox::family()
{
QStringList familyList;
if(!map.isEmpty())
{
foreach(QString family , map.keys())
{
familyList << family;
QCoreApplication::processEvents();
}
}
return familyList;
}
/**
*@brief Retourne une liste des familles de police.
*@return QStringList - Familles de police.
*/
void FontMapComboBox::addFamilyItems(QStringList items)
{
this->clear();
if(items.isEmpty() && !map.isEmpty())
{
this->addItems(this->family());
emit loadFontsFinished();
this->setnoFontDefined(false);
}
else this->addItems(items);
}
/**
*@brief Setteur de noFontDefined.
*@return QStringList - Familles de police.
*/
void FontMapComboBox::setnoFontDefined(bool value)
{
this->noFontDefined = value;
if(value)
{
this->clear();
this->addItem(tr("No fonts defined"));
}
}
/**
*@brief Si aucune police définie -> Vrai.
*@return bool - Vrai ou faux.
*/
bool FontMapComboBox::isNoFontDefined()
{
return this->noFontDefined;
}