[1f4adec] | 1 | /* |
---|
| 2 | |
---|
| 3 | Copyright 2013 Adam Reichold |
---|
| 4 | |
---|
| 5 | This file is part of qpdfview. |
---|
| 6 | |
---|
| 7 | qpdfview is free software: you can redistribute it and/or modify |
---|
| 8 | it under the terms of the GNU General Public License as published by |
---|
| 9 | the Free Software Foundation, either version 2 of the License, or |
---|
| 10 | (at your option) any later version. |
---|
| 11 | |
---|
| 12 | qpdfview is distributed in the hope that it will be useful, |
---|
| 13 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
| 14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
---|
| 15 | GNU General Public License for more details. |
---|
| 16 | |
---|
| 17 | You should have received a copy of the GNU General Public License |
---|
| 18 | along with qpdfview. If not, see <http://www.gnu.org/licenses/>. |
---|
| 19 | |
---|
| 20 | */ |
---|
| 21 | |
---|
| 22 | #include "fontsdialog.h" |
---|
| 23 | |
---|
| 24 | #include <QDialogButtonBox> |
---|
| 25 | #include <QHeaderView> |
---|
| 26 | #include <QStandardItemModel> |
---|
| 27 | #include <QTableView> |
---|
| 28 | #include <QVBoxLayout> |
---|
| 29 | |
---|
| 30 | #include "settings.h" |
---|
| 31 | |
---|
| 32 | namespace qpdfview |
---|
| 33 | { |
---|
| 34 | |
---|
| 35 | FontsDialog::FontsDialog(QStandardItemModel* model, QWidget* parent) : QDialog(parent) |
---|
| 36 | { |
---|
| 37 | setWindowTitle(tr("Fonts") + QLatin1String(" - qpdfview")); |
---|
| 38 | |
---|
| 39 | m_tableView = new QTableView(this); |
---|
| 40 | m_tableView->setModel(model); |
---|
| 41 | |
---|
| 42 | m_tableView->setAlternatingRowColors(true); |
---|
| 43 | m_tableView->setSortingEnabled(true); |
---|
| 44 | m_tableView->setEditTriggers(QAbstractItemView::NoEditTriggers); |
---|
| 45 | m_tableView->setHorizontalScrollMode(QAbstractItemView::ScrollPerPixel); |
---|
| 46 | |
---|
| 47 | #if QT_VERSION >= QT_VERSION_CHECK(5,0,0) |
---|
| 48 | |
---|
| 49 | m_tableView->horizontalHeader()->setSectionResizeMode(QHeaderView::ResizeToContents); |
---|
| 50 | m_tableView->verticalHeader()->setSectionResizeMode(QHeaderView::ResizeToContents); |
---|
| 51 | |
---|
| 52 | #else |
---|
| 53 | |
---|
| 54 | m_tableView->horizontalHeader()->setResizeMode(QHeaderView::ResizeToContents); |
---|
| 55 | m_tableView->verticalHeader()->setResizeMode(QHeaderView::ResizeToContents); |
---|
| 56 | |
---|
| 57 | #endif // QT_VERSION |
---|
| 58 | |
---|
| 59 | m_tableView->verticalHeader()->setVisible(false); |
---|
| 60 | |
---|
| 61 | m_dialogButtonBox = new QDialogButtonBox(QDialogButtonBox::Ok, Qt::Horizontal, this); |
---|
| 62 | connect(m_dialogButtonBox, SIGNAL(accepted()), SLOT(accept())); |
---|
| 63 | connect(m_dialogButtonBox, SIGNAL(rejected()), SLOT(reject())); |
---|
| 64 | |
---|
| 65 | setLayout(new QVBoxLayout(this)); |
---|
| 66 | layout()->addWidget(m_tableView); |
---|
| 67 | layout()->addWidget(m_dialogButtonBox); |
---|
| 68 | |
---|
| 69 | resize(Settings::instance()->mainWindow().fontsDialogSize(sizeHint())); |
---|
| 70 | } |
---|
| 71 | |
---|
| 72 | FontsDialog::~FontsDialog() |
---|
| 73 | { |
---|
| 74 | Settings::instance()->mainWindow().setFontsDialogSize(size()); |
---|
| 75 | } |
---|
| 76 | |
---|
| 77 | } // qpdfview |
---|