File indexing completed on 2024-04-21 04:32:11
0001 /* 0002 * Copyright (C) 2010-2015 by Stephen Allewell 0003 * steve.allewell@gmail.com 0004 * 0005 * This program is free software; you can redistribute it and/or modify 0006 * it under the terms of the GNU General Public License as published by 0007 * the Free Software Foundation; either version 2 of the License, or 0008 * (at your option) any later version. 0009 */ 0010 0011 #include "PagePropertiesDlg.h" 0012 0013 #include <KConfigGroup> 0014 #include <KHelpClient> 0015 #include <KLocalizedString> 0016 #include <KSharedConfig> 0017 0018 #include "Page.h" 0019 #include "PageLayoutEditor.h" 0020 #include "PagePreviewListWidgetItem.h" 0021 0022 PagePropertiesDlg::PagePropertiesDlg(QWidget *parent, const QMargins &margins, bool showGrid, int gridSize) 0023 : QDialog(parent) 0024 { 0025 setWindowTitle(i18n("Page Properties")); 0026 ui.setupUi(this); 0027 0028 ui.MarginTop->setValue(margins.top()); 0029 ui.MarginLeft->setValue(margins.left()); 0030 ui.MarginRight->setValue(margins.right()); 0031 ui.MarginBottom->setValue(margins.bottom()); 0032 0033 ui.ShowGrid->setChecked(showGrid); 0034 ui.GridSize->setValue(gridSize); 0035 } 0036 0037 QMargins PagePropertiesDlg::margins() const 0038 { 0039 return QMargins(ui.MarginLeft->value(), ui.MarginTop->value(), ui.MarginRight->value(), ui.MarginBottom->value()); 0040 } 0041 0042 bool PagePropertiesDlg::showGrid() const 0043 { 0044 return ui.ShowGrid->isChecked(); 0045 } 0046 0047 int PagePropertiesDlg::gridSize() const 0048 { 0049 return ui.GridSize->value(); 0050 } 0051 0052 void PagePropertiesDlg::hideEvent(QHideEvent *event) 0053 { 0054 KConfigGroup(KSharedConfig::openConfig(), QStringLiteral("DialogSizes")).writeEntry(QStringLiteral("PagePropertiesDlg"), size()); 0055 0056 QDialog::hideEvent(event); 0057 } 0058 0059 void PagePropertiesDlg::showEvent(QShowEvent *event) 0060 { 0061 QDialog::showEvent(event); 0062 0063 if (KConfigGroup(KSharedConfig::openConfig(), QStringLiteral("DialogSizes")).hasKey(QStringLiteral("PagePropertiesDlg"))) { 0064 resize(KConfigGroup(KSharedConfig::openConfig(), QStringLiteral("DialogSizes")).readEntry(QStringLiteral("PagePropertiesDlg"), QSize())); 0065 } 0066 } 0067 0068 void PagePropertiesDlg::on_DialogButtonBox_accepted() 0069 { 0070 accept(); 0071 } 0072 0073 void PagePropertiesDlg::on_DialogButtonBox_rejected() 0074 { 0075 reject(); 0076 } 0077 0078 void PagePropertiesDlg::on_DialogButtonBox_helpRequested() 0079 { 0080 KHelpClient::invokeHelp(QStringLiteral("PrinterDialog"), QStringLiteral("kxstitch")); 0081 } 0082 0083 #include "moc_PagePropertiesDlg.cpp"