• Skip to content
  • Skip to link menu
KDE API Reference
  • KDE API Reference
  • kdeedu API Reference
  • KDE Home
  • Contact Us
 

kig

  • sources
  • kde-4.12
  • kdeedu
  • kig
  • filters
imageexporteroptions.cc
Go to the documentation of this file.
1 // Copyright (C) 2002 Dominique Devriese <devriese@kde.org>
2 
3 // This program is free software; you can redistribute it and/or
4 // modify it under the terms of the GNU General Public License
5 // as published by the Free Software Foundation; either version 2
6 // of the License, or (at your option) any later version.
7 
8 // This program is distributed in the hope that it will be useful,
9 // but WITHOUT ANY WARRANTY; without even the implied warranty of
10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 // GNU General Public License for more details.
12 
13 // You should have received a copy of the GNU General Public License
14 // along with this program; if not, write to the Free Software
15 // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
16 // 02110-1301, USA.
17 
18 #include "imageexporteroptions.h"
19 #include "imageexporteroptions.moc"
20 
21 #include "ui_imageexporteroptionswidget.h"
22 
23 #include <qapplication.h>
24 #include <qcheckbox.h>
25 #include <qdesktopwidget.h>
26 #include <qlayout.h>
27 #include <qsize.h>
28 #include <qspinbox.h>
29 
30 ImageExporterOptions::ImageExporterOptions( QWidget* parent )
31  : QWidget( parent ), minternallysettingstuff( false )
32 {
33  expwidget = new Ui_ImageExporterOptionsWidget();
34  expwidget->setupUi( this );
35 
36  msize = QSize( 1, 1 );
37 
38  // detecting the dpi resolutions
39  QDesktopWidget* dw = QApplication::desktop();
40  // and creating the Unit objects
41  mxunit = Unit( msize.width(), Unit::pixel, dw->logicalDpiX() );
42  myunit = Unit( msize.height(), Unit::pixel, dw->logicalDpiY() );
43 
44  maspectratio = (double)msize.height() / (double)msize.width();
45 
46  expwidget->keepAspectRatio->setChecked( true );
47  layout()->setMargin( 0 );
48 
49  expwidget->comboUnit->addItems( Unit::unitList() );
50 
51  connect( expwidget->WidthInput, SIGNAL( valueChanged( double ) ), this, SLOT( slotWidthChanged( double ) ) );
52  connect( expwidget->HeightInput, SIGNAL( valueChanged( double ) ), this, SLOT( slotHeightChanged( double ) ) );
53  connect( expwidget->comboUnit, SIGNAL( activated( int ) ), this, SLOT( slotUnitChanged( int ) ) );
54 }
55 
56 ImageExporterOptions::~ImageExporterOptions()
57 {
58  delete expwidget;
59 }
60 
61 void ImageExporterOptions::setGrid( bool grid )
62 {
63  expwidget->showGridCheckBox->setChecked( grid );
64 }
65 
66 bool ImageExporterOptions::showGrid() const
67 {
68  return expwidget->showGridCheckBox->isChecked();
69 }
70 
71 void ImageExporterOptions::setAxes( bool axes )
72 {
73  expwidget->showAxesCheckBox->setChecked( axes );
74 }
75 
76 bool ImageExporterOptions::showAxes() const
77 {
78  return expwidget->showAxesCheckBox->isChecked();
79 }
80 
81 void ImageExporterOptions::setImageSize( const QSize& size )
82 {
83  msize = size;
84  minternallysettingstuff = true;
85  expwidget->WidthInput->setValue( size.width() );
86  expwidget->HeightInput->setValue( size.height() );
87  mxunit.setValue( size.width() );
88  myunit.setValue( size.height() );
89  maspectratio = (double)msize.height() / (double)msize.width();
90  minternallysettingstuff = false;
91 }
92 
93 QSize ImageExporterOptions::imageSize() const
94 {
95  return QSize( (int)qRound( mxunit.getValue( Unit::pixel ) ),
96  (int)qRound( myunit.getValue( Unit::pixel ) ) );
97 }
98 
99 void ImageExporterOptions::slotWidthChanged( double w )
100 {
101  if ( ! minternallysettingstuff && expwidget->keepAspectRatio->isChecked() )
102  {
103  minternallysettingstuff = true;
104  expwidget->HeightInput->setValue( w * maspectratio );
105  mxunit.setValue( w );
106  myunit.setValue( w * maspectratio );
107  minternallysettingstuff = false;
108  };
109 }
110 
111 void ImageExporterOptions::slotHeightChanged( double h )
112 {
113  if ( ! minternallysettingstuff && expwidget->keepAspectRatio->isChecked() )
114  {
115  minternallysettingstuff = true;
116  expwidget->WidthInput->setValue( h / maspectratio );
117  mxunit.setValue( h / maspectratio );
118  myunit.setValue( h );
119  minternallysettingstuff = false;
120  };
121 }
122 
123 void ImageExporterOptions::slotUnitChanged( int index )
124 {
125  minternallysettingstuff = true;
126  Unit::MetricalUnit newunit = Unit::intToUnit( index );
127  mxunit.convertTo( newunit );
128  myunit.convertTo( newunit );
129  int newprecision = Unit::precision( newunit );
130  expwidget->WidthInput->setDecimals( newprecision );
131  expwidget->WidthInput->setValue( mxunit.value() );
132  expwidget->HeightInput->setDecimals( newprecision );
133  expwidget->HeightInput->setValue( myunit.value() );
134  minternallysettingstuff = false;
135 }
ImageExporterOptions::setAxes
void setAxes(bool axes)
Definition: imageexporteroptions.cc:71
Unit::MetricalUnit
MetricalUnit
The kinds of metrical units we support.
Definition: unit.h:36
Unit::unitList
static QStringList unitList()
Get a list of the supported metrical units.
Definition: unit.cc:118
QWidget
Unit::getValue
double getValue(Unit::MetricalUnit unit) const
Definition: unit.cc:63
ImageExporterOptions::showAxes
bool showAxes() const
Definition: imageexporteroptions.cc:76
ImageExporterOptions::setImageSize
void setImageSize(const QSize &size)
Definition: imageexporteroptions.cc:81
Unit::convertTo
void convertTo(Unit::MetricalUnit unit)
Set the unit of the current object to unit and convert the value to the new unit using convert()...
Definition: unit.cc:52
ImageExporterOptions::slotHeightChanged
void slotHeightChanged(double)
Definition: imageexporteroptions.cc:111
Unit::pixel
Definition: unit.h:36
ImageExporterOptions::setGrid
void setGrid(bool grid)
Definition: imageexporteroptions.cc:61
Unit::setValue
void setValue(double value)
Definition: unit.cc:37
ImageExporterOptions::slotWidthChanged
void slotWidthChanged(double)
Definition: imageexporteroptions.cc:99
ImageExporterOptions::imageSize
QSize imageSize() const
Definition: imageexporteroptions.cc:93
imageexporteroptions.h
Unit::precision
static int precision(Unit::MetricalUnit unit)
How many decimals the unit have.
Definition: unit.cc:139
ImageExporterOptions::slotUnitChanged
void slotUnitChanged(int)
Definition: imageexporteroptions.cc:123
Unit::intToUnit
static Unit::MetricalUnit intToUnit(int index)
Definition: unit.cc:127
ImageExporterOptions::ImageExporterOptions
ImageExporterOptions(QWidget *parent)
Definition: imageexporteroptions.cc:30
Unit::value
double value() const
Definition: unit.cc:42
ImageExporterOptions::~ImageExporterOptions
~ImageExporterOptions()
Definition: imageexporteroptions.cc:56
Unit
This small class server as helper to perform conversions between metrical units.
Definition: unit.h:30
ImageExporterOptions::showGrid
bool showGrid() const
Definition: imageexporteroptions.cc:66
This file is part of the KDE documentation.
Documentation copyright © 1996-2014 The KDE developers.
Generated on Tue Oct 14 2014 22:35:39 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

kig

Skip menu "kig"
  • Main Page
  • Namespace List
  • Namespace Members
  • Alphabetical List
  • Class List
  • Class Hierarchy
  • Class Members
  • File List
  • File Members

kdeedu API Reference

Skip menu "kdeedu API Reference"
  • Analitza
  •     lib
  • kalgebra
  • kalzium
  •   libscience
  • kanagram
  • kig
  •   lib
  • klettres
  • kstars
  • libkdeedu
  •   keduvocdocument
  • marble
  • parley
  • rocs
  •   App
  •   RocsCore
  •   VisualEditor
  •   stepcore

Search



Report problems with this website to our bug tracking system.
Contact the specific authors with questions and comments about the page contents.

KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal