• Skip to content
  • Skip to link menu
KDE 3.5 API Reference
  • KDE API Reference
  • API Reference
  • Sitemap
  • Contact Us
 

kviewshell

kprintDialogPage_pageoptions.cpp

Go to the documentation of this file.
00001 // KPrintDialogPage_PageOptions.cpp
00002 //
00003 // Part of KVIEWSHELL - A framework for multipage text/gfx viewers
00004 //
00005 // (C) 2005 Stefan Kebekus
00006 // Distributed under the GPL
00007 
00008 // Add header files alphabetically
00009 
00010 #include <config.h>
00011 
00012 #include <klocale.h>
00013 #include <qbuttongroup.h>
00014 #include <qcheckbox.h>
00015 #include <qlayout.h>
00016 #include <qtooltip.h>
00017 #include <qwhatsthis.h>
00018 #include <kdebug.h>
00019 
00020 #include "kprintDialogPage_pageoptions.h"
00021 
00022   
00023 KPrintDialogPage_PageOptions::KPrintDialogPage_PageOptions( QWidget *parent, const char *name )
00024   : KPrintDialogPage( parent, name )
00025 {
00026   setTitle( i18n("Page Size & Placement") );
00027 
00028   kprintDialogPage_pageoptions_baseLayout = 0;
00029   checkBox_center = 0;
00030   checkBox_rotate = 0;
00031   checkBox_shrink = 0;
00032   checkBox_expand = 0;
00033 
00034   kprintDialogPage_pageoptions_baseLayout = new QVBoxLayout( this, 11, 6, "kprintDialogPage_pageoptions_baseLayout"); 
00035   if (kprintDialogPage_pageoptions_baseLayout == 0) {
00036     kdError(1223) << "KPrintDialogPage_PageOptions::KPrintDialogPage_PageOptions() cannot create layout" << endl;
00037     return;
00038   }
00039     
00040   checkBox_center = new QCheckBox( this, "checkBox_center" );
00041   if (checkBox_center != 0) {
00042     checkBox_center->setText( i18n( "Center the page on paper" ) );
00043     QToolTip::add( checkBox_center, i18n( "If this option is enabled, the pages are centered on the paper." ) );
00044     QWhatsThis::add( checkBox_center, i18n( "<qt><p>If this option is enabled, the pages will be printed centered on the paper; this makes "
00045                         "more visually-appealing printouts.</p>"
00046                         "<p>If the option is not enabled, all pages will be placed in the top-left corner of the paper.</p></qt>" ) );
00047     kprintDialogPage_pageoptions_baseLayout->addWidget( checkBox_center );
00048   }
00049 
00050   checkBox_rotate = new QCheckBox( this, "checkBox_rotate" );
00051   if (checkBox_rotate != 0) {
00052     checkBox_rotate->setText( i18n( "Automatically choose landscape or portrait orientation" ) );
00053     QToolTip::add( checkBox_rotate, i18n( "If this option is enabled, some pages might be rotated to better fit the paper size." ) );
00054     QWhatsThis::add( checkBox_rotate, i18n( "<qt><p>If this option is enabled, landscape or portrait orientation are automatically chosen on a "
00055                         "page-by-page basis. This makes better use of the paper and gives more visually-"
00056                         "appealing printouts.</p>"
00057                         "<p><b>Note:</b> This option overrides the Portrait/Landscape option chosen in the printer "
00058                         "properties. If this option is enabled, and if the pages in your document have different sizes, "
00059                         "then some pages might be rotated while others are not.</p></qt>" ) );
00060     kprintDialogPage_pageoptions_baseLayout->addWidget( checkBox_rotate );
00061   }
00062   
00063   QFrame *line = new QFrame( this, "line1" );
00064   if (line != 0) {
00065     line->setFrameShape( QFrame::HLine );
00066     line->setFrameShadow( QFrame::Sunken );
00067     line->setFrameShape( QFrame::HLine );
00068     kprintDialogPage_pageoptions_baseLayout->addWidget( line );
00069   }
00070   
00071   checkBox_shrink = new QCheckBox( this, "checkBox_shrink" );
00072   if (checkBox_shrink != 0) {
00073     checkBox_shrink->setText( i18n( "Shrink oversized pages to fit paper size" ) );
00074     QToolTip::add( checkBox_shrink, i18n( "If this option is enabled, large pages that would not fit the printer's paper size will be shrunk." ) );
00075     QWhatsThis::add( checkBox_shrink, i18n( "<qt><p>If this option is enabled, large pages that would not fit the printer's paper size will be "
00076                         "shrunk so that edges won't be cut off during printing.</p>"
00077                         "<p><b>Note:</b> If this option is enabled, and if the pages in your document have different sizes, "
00078                         "then different pages might be shrunk by different scaling factors.</p></qt>" ) );
00079     kprintDialogPage_pageoptions_baseLayout->addWidget( checkBox_shrink );
00080   }
00081     
00082   checkBox_expand = new QCheckBox( this, "checkBox_expand" );
00083   if (checkBox_expand != 0) {
00084     checkBox_expand->setText( i18n( "Expand small pages to fit paper size" ) );
00085     QToolTip::add( checkBox_expand, i18n( "If this option is enabled, small pages will be enlarged so that they fit the printer's paper size." ) );
00086     QWhatsThis::add( checkBox_expand, i18n( "<qt><p>If this option is enabled, small pages will be enlarged so that they fit the printer's "
00087                         "paper size.</p>"
00088                         "<p><b>Note:</b> If this option is enabled, and if the pages in your document have different sizes, "
00089                         "then different pages might be expanded by different scaling factors.</p></qt>" ) );
00090     kprintDialogPage_pageoptions_baseLayout->addWidget( checkBox_expand );
00091   }
00092 
00093   
00094   resize( QSize(319, 166).expandedTo(minimumSizeHint()) );
00095   clearWState( WState_Polished );
00096 }
00097 
00098 
00099 
00100 void KPrintDialogPage_PageOptions::getOptions( QMap<QString,QString>& opts, bool incldef )
00101 {
00102   // Save options, taking default values into consideration: by
00103   // default "center" is checked, "expand" and "shrink" are
00104   // not. Warning: The default values are also coded into setOptions()
00105   // and kmultipage::print(..).
00106   
00107   if (checkBox_center != 0)
00108     if ( incldef || !checkBox_center->isChecked() )
00109       if (checkBox_center->isChecked())
00110     opts[ "kde-kviewshell-centerpage" ] = "true";
00111       else
00112     opts[ "kde-kviewshell-centerpage" ] = "false";
00113 
00114   if (checkBox_rotate != 0)
00115     if ( incldef || !checkBox_rotate->isChecked() )
00116       if (checkBox_rotate->isChecked())
00117     opts[ "kde-kviewshell-rotatepage" ] = "true";
00118       else
00119     opts[ "kde-kviewshell-rotatepage" ] = "false";
00120   
00121   if (checkBox_shrink != 0)
00122     if ( incldef || checkBox_shrink->isChecked() )
00123       if (checkBox_shrink->isChecked())
00124     opts[ "kde-kviewshell-shrinkpage" ] = "true";
00125       else
00126     opts[ "kde-kviewshell-shrinkpage" ] = "false";
00127   
00128   if (checkBox_expand != 0)
00129     if ( incldef || checkBox_expand->isChecked() )  
00130       if (checkBox_expand->isChecked())
00131     opts[ "kde-kviewshell-expandpage" ] = "true";
00132       else
00133     opts[ "kde-kviewshell-expandpage" ] = "false";
00134 }
00135 
00136 
00137 void KPrintDialogPage_PageOptions::setOptions( const QMap<QString,QString>& opts )
00138 {
00139   // Sets the centering option. By default, this option is
00140   // checked. Warning: All default values are also coded into
00141   // getOptions() and kmultipage::print(..).
00142   QString op = opts[ "kde-kviewshell-centerpage" ];
00143   if (checkBox_center != 0)
00144     checkBox_center->setChecked( op != "false" );
00145 
00146   // same for rotation
00147   op = opts[ "kde-kviewshell-rotatepage" ];
00148   if (checkBox_rotate != 0)
00149     checkBox_rotate->setChecked( op != "false" );
00150   
00151   // Sets the shrink option. By default, this option is not checked
00152   op = opts[ "kde-kviewshell-shrinkpage" ];
00153   if (checkBox_shrink != 0)
00154     checkBox_shrink->setChecked( op == "true" );
00155   
00156   // Sets the expand option. By default, this option is not checked
00157   op = opts[ "kde-kviewshell-expandpage" ];
00158   if (checkBox_expand != 0)
00159     checkBox_expand->setChecked( op == "true" );
00160 }
00161 
00162 
00163 bool KPrintDialogPage_PageOptions::isValid( QString& )
00164 {
00165   return true;
00166 }

kviewshell

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

API Reference

Skip menu "API Reference"
  • kviewshell
Generated for API Reference by doxygen 1.5.9
This website is maintained by Adriaan de Groot and Allen Winter.
KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal