Back to index

scribus-ng  1.3.4.dfsg+svn20071115
useprintermarginsdialog.cpp
Go to the documentation of this file.
00001 /*
00002 For general Scribus (>=1.3.2) copyright and licensing information please refer
00003 to the COPYING file provided with the program. Following this notice may exist
00004 a copyright and/or license notice that predates the release of Scribus 1.3.2
00005 for which a new license (GPL+exception) is in place.
00006 */
00007 /***************************************************************************
00008                           useprintermarginsdialog.cpp  -  description
00009                              -------------------
00010     copyright            : (C) 2006 by Craig Bradney
00011     email                : cbradney@zip.com.au
00012  ***************************************************************************/
00013 
00014 #include "useprintermarginsdialog.h"
00015 #include "useprintermarginsdialog.moc"
00016 
00017 #include <qcombobox.h>
00018 #include <qgroupbox.h>
00019 #include <qlineedit.h>
00020 #include <qpushbutton.h>
00021 
00022 #include "printerutil.h"
00023 
00024 
00025 
00026 // This class implements only the non-GUI parts of the
00027 // UsePrinterMargins dialog. Please use Qt Designer on
00028 // useprintermarginsdialog.ui if you need to modify the layout,
00029 // widget properties, etc.
00030 
00031 UsePrinterMarginsDialog::UsePrinterMarginsDialog( QWidget* parent, const QString& pageSize, double unitRatio, const QString& suffix )
00032        : UsePrinterMarginsDialogBase( parent, "UsePrinterMarginsDialog" )
00033 {
00034        m_ptsTopMargin=m_ptsBottomMargin=m_ptsLeftMargin=m_ptsRightMargin=0.0;
00035        m_pageSize=pageSize;
00036        m_unitRatio=unitRatio;
00037        m_suffix=suffix;
00038        QStringList printerNames=PrinterUtil::getPrinterNames();
00039        printerComboBox->clear();
00040        if (printerNames.count()>0 && !pageSize.isEmpty())
00041        {
00042               printerComboBox->insertStringList(printerNames);
00043               getPrinterMarginValues(printerNames.first());
00044               marginsGroupBox->setTitle( tr("Minimum Margins for Page Size %1").arg(pageSize));
00045               connect(printerComboBox, SIGNAL(activated(const QString&)), this, SLOT(getPrinterMarginValues(const QString&)));
00046        }
00047        connect(okButton, SIGNAL(clicked()), this, SLOT(accept()));
00048        connect(cancelButton, SIGNAL(clicked()), this, SLOT(reject()));
00049 }
00050 
00051 UsePrinterMarginsDialog::~UsePrinterMarginsDialog()
00052 {
00053 }
00054 
00055 void UsePrinterMarginsDialog::getNewPrinterMargins(double &topMargin,double &bottomMargin,double &leftMargin,double &rightMargin)
00056 {
00057        topMargin=m_ptsTopMargin;
00058        bottomMargin=m_ptsBottomMargin;
00059        leftMargin=m_ptsLeftMargin;
00060        rightMargin=m_ptsRightMargin;
00061 }
00062 
00063 void UsePrinterMarginsDialog::getPrinterMarginValues(const QString& printerName)
00064 {
00065        m_ptsTopMargin=m_ptsBottomMargin=m_ptsLeftMargin=m_ptsRightMargin=0.0;
00066        bool foundSize=PrinterUtil::getPrinterMarginValues(printerName, m_pageSize, m_ptsTopMargin, m_ptsBottomMargin, m_ptsLeftMargin, m_ptsRightMargin);
00067 
00068        topLineEdit->setEnabled(foundSize);
00069        bottomLineEdit->setEnabled(foundSize);
00070        leftLineEdit->setEnabled(foundSize);
00071        rightLineEdit->setEnabled(foundSize);
00072        okButton->setEnabled(foundSize);
00073        
00074        topLineEdit->setText(QString::number(m_ptsTopMargin * m_unitRatio,'g',4)+m_suffix);
00075        bottomLineEdit->setText(QString::number(m_ptsBottomMargin * m_unitRatio,'g',4)+m_suffix);
00076        leftLineEdit->setText(QString::number(m_ptsLeftMargin * m_unitRatio,'g',4)+m_suffix);
00077        rightLineEdit->setText(QString::number(m_ptsRightMargin * m_unitRatio,'g',4)+m_suffix);    
00078 }