source: smplayer/trunk/src/fontcache.cpp@ 167

Last change on this file since 167 was 165, checked in by Silvan Scherrer, 11 years ago

SMPlayer: update trunk to latest 0.8.7

File size: 2.8 KB
Line 
1/* smplayer, GUI front-end for mplayer.
2 Copyright (C) 2006-2014 Ricardo Villalba <rvm@users.sourceforge.net>
3
4 This program is free software; you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation; either version 2 of the License, or
7 (at your option) any later version.
8
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
13
14 You should have received a copy of the GNU General Public License
15 along with this program; if not, write to the Free Software
16 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17*/
18
19#include "fontcache.h"
20#include <QProcess>
21#include <QApplication>
22#include <QDir>
23
24FontCacheDialog::FontCacheDialog(QWidget * parent, Qt::WindowFlags f)
25 : QProgressDialog(parent, f)
26{
27 setWindowTitle(tr("SMPlayer is initializing"));
28 setLabelText(tr("Creating a font cache..."));
29
30 process = new QProcess(this);
31 process->setProcessChannelMode( QProcess::MergedChannels );
32 //connect(process, SIGNAL(readyReadStandardOutput()), this, SLOT(readOutput()));
33
34 connect(this, SIGNAL(canceled()), process, SLOT(kill()));
35}
36
37FontCacheDialog::~FontCacheDialog()
38{
39}
40
41void FontCacheDialog::run(QString mplayer_bin, QString file) {
42 qDebug("FontCacheDialog::run: mplayer_bin: '%s', file: '%s'", mplayer_bin.toUtf8().constData(), file.toUtf8().constData());
43
44 QRegExp rx_scanning_font("Scanning file");
45
46 int max = 100;
47 QDir fon_dir("c:/windows/fonts");
48 QStringList fon_files = fon_dir.entryList(QStringList() << "*.*", QDir::Files);
49 qDebug("FontCacheDialog::run: number of fonts: %d", fon_files.count());
50 if (fon_files.count() > 2) max = fon_files.count();
51 setMaximum(max);
52
53 QStringList arg;
54 arg << "-fontconfig" << "-ass" << "-vo" << "null" << "-ao" << "null";
55 arg << file;
56
57 process->start(mplayer_bin, arg);
58 if (!process->waitForStarted()) {
59 qDebug("FontCacheDialog::run: failed to start process");
60 return;
61 }
62
63 int fonts = 0;
64 int v = 0;
65 QByteArray line;
66 while (process->state() == QProcess::Running) {
67 qApp->processEvents();
68 if (process->waitForReadyRead(100)) {
69 line = process->readLine().trimmed();
70 qDebug("FontCacheDialog::run: line: %s", line.constData());
71 if (rx_scanning_font.indexIn(line) > -1) {
72 fonts++;
73 v++;
74 if (v >= (max-1)) v = 0;
75 setValue(v);
76 }
77 }
78 }
79 qDebug("FontCacheDialog::run: %d fonts found", fonts);
80}
81
82/*
83void FontCacheDialog::readOutput() {
84 int v = 0;
85 QByteArray line;
86 while (process->canReadLine()) {
87 line = process->readLine().trimmed();
88 qDebug("line: %s", line.constData());
89 v++;
90 setValue(v);
91 }
92}
93*/
94
95#include "moc_fontcache.cpp"
96
Note: See TracBrowser for help on using the repository browser.