| 1 |
/* |
| 2 |
* Copyright (C) 2008, Pino Toscano <[email protected]> |
| 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, or (at your option) |
| 7 |
* 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., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA. |
| 17 |
*/ |
| 18 |
|
| 19 |
#include "fonts.h" |
| 20 |
|
| 21 |
#include <poppler-qt6.h> |
| 22 |
|
| 23 |
#include <QtWidgets/QTableWidget> |
| 24 |
|
| 25 |
static QString yesNoStatement(bool value) |
| 26 |
{ |
| 27 |
return value ? QStringLiteral("yes") : QStringLiteral("no"); |
| 28 |
} |
| 29 |
|
| 30 |
FontsDock::FontsDock(QWidget *parent) : AbstractInfoDock(parent) |
| 31 |
{ |
| 32 |
m_table = new QTableWidget(this); |
| 33 |
setWidget(m_table); |
| 34 |
setWindowTitle(tr("Fonts")); |
| 35 |
m_table->setColumnCount(5); |
| 36 |
m_table->setHorizontalHeaderLabels(QStringList() << tr("Name") << tr("Type") << tr("Embedded") << tr("Subset") << tr("File")); |
| 37 |
m_table->setHorizontalScrollMode(QAbstractItemView::ScrollPerPixel); |
| 38 |
} |
| 39 |
|
| 40 |
FontsDock::~FontsDock() = default; |
| 41 |
|
| 42 |
void FontsDock::fillInfo() |
| 43 |
{ |
| 44 |
const QList<Poppler::FontInfo> fonts = document()->fonts(); |
| 45 |
m_table->setHorizontalHeaderLabels(QStringList() << tr("Name") << tr("Type") << tr("Embedded") << tr("Subset") << tr("File")); |
| 46 |
m_table->setRowCount(fonts.count()); |
| 47 |
int i = 0; |
| 48 |
Q_FOREACH (const Poppler::FontInfo &font, fonts) { |
| 49 |
if (font.name().isNull()) { |
| 50 |
m_table->setItem(i, 0, new QTableWidgetItem(QStringLiteral("[none]"))); |
| 51 |
} else { |
| 52 |
m_table->setItem(i, 0, new QTableWidgetItem(font.name())); |
| 53 |
} |
| 54 |
m_table->setItem(i, 1, new QTableWidgetItem(font.typeName())); |
| 55 |
m_table->setItem(i, 2, new QTableWidgetItem(yesNoStatement(font.isEmbedded()))); |
| 56 |
m_table->setItem(i, 3, new QTableWidgetItem(yesNoStatement(font.isSubset()))); |
| 57 |
m_table->setItem(i, 4, new QTableWidgetItem(font.file())); |
| 58 |
++i; |
| 59 |
} |
| 60 |
} |
| 61 |
|
| 62 |
void FontsDock::documentClosed() |
| 63 |
{ |
| 64 |
m_table->clear(); |
| 65 |
m_table->setRowCount(0); |
| 66 |
AbstractInfoDock::documentClosed(); |
| 67 |
} |