kivio_imageexportdialog.cpp
1/* This file is part of the KDE project
2 Copyright (C) 2005 Peter Simonsson <psn@linux.se>
3
4 This library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Library General Public
6 License as published by the Free Software Foundation; either
7 version 2 of the License, or (at your option) any later version.
8
9 This library 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 GNU
12 Library General Public License for more details.
13
14 You should have received a copy of the GNU Library General Public License
15 along with this library; see the file COPYING.LIB. If not, write to
16 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
17 Boston, MA 02110-1301, USA.
18*/
19
20#include "kivio_imageexportdialog.h"
21
22#include <tqspinbox.h>
23#include <tqcheckbox.h>
24
25#include <kcombobox.h>
26#include <tdelocale.h>
27#include <tdeapplication.h>
28
29#include "kivio_imageexportwidget.h"
30
31namespace Kivio
32{
33
34ImageExportDialog::ImageExportDialog(TQWidget* parent, const char* name)
35 : KDialogBase(parent, name, false, i18n("Export to Image"), Ok|Cancel)
36{
37 kapp->restoreOverrideCursor();
38 m_mainWidget = new ImageExportWidget(this);
39 setMainWidget(m_mainWidget);
40}
41
42void ImageExportDialog::setPageList(const TQStringList& pages)
43{
44 m_mainWidget->m_pageCombo->clear();
45 m_mainWidget->m_pageCombo->insertStringList(pages);
46}
47
48void ImageExportDialog::setInitialDPI(const int dpi)
49{
50 if (dpi <= 72) m_mainWidget->m_DPIcomboBox->setCurrentItem(0);
51 else if (dpi <= 96) m_mainWidget->m_DPIcomboBox->setCurrentItem(1);
52 else if (dpi <= 150) m_mainWidget->m_DPIcomboBox->setCurrentItem(2);
53 else if (dpi <= 300) m_mainWidget->m_DPIcomboBox->setCurrentItem(3);
54 else if (dpi <= 600) m_mainWidget->m_DPIcomboBox->setCurrentItem(4);
55 else if (dpi <= 720) m_mainWidget->m_DPIcomboBox->setCurrentItem(5);
56 else if (dpi <= 1200) m_mainWidget->m_DPIcomboBox->setCurrentItem(6);
57}
58
59void ImageExportDialog::setInitialmargin(const int margin)
60{
61 m_mainWidget->m_marginSpinBox->setValue(margin);
62}
63
64TQString ImageExportDialog::selectedPage() const
65{
66 return m_mainWidget->m_pageCombo->currentText();
67}
68
69int ImageExportDialog::imageDPI() const
70{
71 switch (m_mainWidget->m_DPIcomboBox->currentItem())
72 {
73 case 0:
74 return 72;
75 case 1:
76 return 96;
77 case 2:
78 return 150;
79 case 3:
80 return 300;
81 case 4:
82 return 600;
83 case 5:
84 return 720;
85 case 6:
86 return 1200;
87 default:
88 return 300;
89 }
90}
91
92bool ImageExportDialog::usePageBorders() const
93{
94 return (m_mainWidget->m_exportAreaCombo->currentItem() == 1);
95}
96
97
98int ImageExportDialog::margin() const
99{
100 return m_mainWidget->m_marginSpinBox->value();
101}
102
103}
104
105#include "kivio_imageexportdialog.moc"