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
/*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "UBResources.h"
#include <QtGui>
#include "core/UBApplication.h"
#include "core/UBSettings.h"
#include "frameworks/UBFileSystemUtils.h"
#include "core/memcheck.h"
UBResources* UBResources::sSingleton = 0;
UBResources::UBResources(QObject* pParent)
: QObject(pParent)
{
// NOOP
}
UBResources::~UBResources()
{
// NOOP
}
UBResources* UBResources::resources()
{
if (!sSingleton)
{
sSingleton = new UBResources(UBApplication::staticMemoryCleaner);
sSingleton->init();
sSingleton->buildFontList();
}
return sSingleton;
}
void UBResources::init()
{
// Cursors
penCursor = QCursor(Qt::CrossCursor);
eraserCursor = QCursor(QPixmap(":/images/cursors/eraser.png"), 21, 21);
markerCursor = QCursor(QPixmap(":/images/cursors/marker.png"), 3, 30);
pointerCursor = QCursor(QPixmap(":/images/cursors/laser.png"), 2, 1);
handCursor = QCursor(Qt::OpenHandCursor);
zoomInCursor = QCursor(QPixmap(":/images/cursors/zoomIn.png"), 9, 9);
zoomOutCursor = QCursor(QPixmap(":/images/cursors/zoomOut.png"), 9, 9);
arrowCursor = QCursor(Qt::ArrowCursor);
textCursor = QCursor(Qt::ArrowCursor);
rotateCursor = QCursor(QPixmap(":/images/cursors/rotate.png"), 16, 16);
drawLineRulerCursor = QCursor(QPixmap(":/images/cursors/drawRulerLine.png"), 3, 12);
}
void UBResources::buildFontList()
{
QString customFontDirectory = UBSettings::settings()->applicationCustomFontDirectory();
QStringList fontFiles = UBFileSystemUtils::allFiles(customFontDirectory);
foreach(QString fontFile, fontFiles){
int fontId = QFontDatabase::addApplicationFont(fontFile);
mCustomFontList << QFontDatabase::applicationFontFamilies(fontId);
}
}