Back to index

texmacs  1.0.7.15
Public Slots | Public Member Functions | Protected Slots | Protected Member Functions | Protected Attributes
QTMPrintDialog Class Reference

Our own print dialog. More...

#include <QTMPrintDialog.hpp>

Inheritance diagram for QTMPrintDialog:
Inheritance graph
[legend]
Collaboration diagram for QTMPrintDialog:
Collaboration graph
[legend]

List of all members.

Public Slots

void accept ()
 Stores the values from the dialog into the QTMPrinterSettings object after the user presses the "Accept" button.
void reject ()

Public Member Functions

 QTMPrintDialog (QTMPrinterSettings *s, QDialog *parent=0)
 Constructs a QTMPrintDialog and sets up the connections that allow for asynchronous loading of printer configuration: QTMPrinterSettings will emit QTMPrinterSettings::doneReading() after a call to QTMPrinterSettings::readFromSystemConfig() terminates, that is, after the command executed is done.
void setupUi (QDialog *dia)

Protected Slots

void updatePrinterCapabilities ()
 Updates the controls which depend on the capabilities of the selected printer, that is: available paper sizes, color printing, and duplex printing.
void on_allPagesRadio_clicked (bool)
 Disable the From: and To: fields in the dialog.
void on_rangePagesRadio_clicked (bool)
 Enable the From: and To: fields in the dialog.
void on_copiesInput_textChanged (const QString &)
void on_fromPageInput_textChanged (const QString &)
void on_toPageInput_textChanged (const QString &)
void on_oddPagesCheck_stateChanged (int state)
void on_evenPagesCheck_stateChanged (int state)

Protected Member Functions

void retranslateUi (QDialog *QTMPrintDialog)

Protected Attributes

QTMPrinterSettings_settings
QVBoxLayout * verticalLayout
QGridLayout * gridLayout_3
QComboBox * printerCombo
QLabel * label_3
QLineEdit * copiesInput
QCheckBox * collatedCheck
QHBoxLayout * horizontalLayout_2
QGridLayout * gridLayout_2
QLabel * label_7
QRadioButton * allPagesRadio
QRadioButton * rangePagesRadio
QLineEdit * fromPageInput
QLabel * label_4
QLineEdit * toPageInput
QCheckBox * evenPagesCheck
QCheckBox * oddPagesCheck
QFrame * line
QHBoxLayout * horizontalLayout
QSpacerItem * horizontalSpacer_2
QGridLayout * gridLayout
QLabel * paperSizeLabel
QComboBox * paperSizeCombo
QLabel * label_2
QComboBox * orientationCombo
QLabel * resolutionLabel
QComboBox * resolutionCombo
QSpacerItem * horizontalSpacer
QHBoxLayout * horizontalLayout_3
QSpacerItem * horizontalSpacer_3
QCheckBox * duplexCheck
QSpacerItem * horizontalSpacer_5
QCheckBox * fitToPageCheck
QSpacerItem * horizontalSpacer_4
QGridLayout * gridLayout_4
QLabel * label_5
QComboBox * pagesPerSideCombo
QLabel * label_6
QComboBox * orderPagesCombo
QFrame * line_2
QCheckBox * blackWhiteCheck
QDialogButtonBox * buttonBox

Detailed Description

Our own print dialog.

This implements a subset of the options available in the native or QT dialogs, with the purpose of not having "dead" options in them (i.e. options we don't implement). This cannot be helped since the native print dialogs are not configurable and expect features we cannot implement: how to know if under MacOS the user selected "send per email"?

Definition at line 424 of file QTMPrintDialog.hpp.


Constructor & Destructor Documentation

QTMPrintDialog::QTMPrintDialog ( QTMPrinterSettings s,
QDialog *  parent = 0 
)

Constructs a QTMPrintDialog and sets up the connections that allow for asynchronous loading of printer configuration: QTMPrinterSettings will emit QTMPrinterSettings::doneReading() after a call to QTMPrinterSettings::readFromSystemConfig() terminates, that is, after the command executed is done.

See also:
QTMPrinterSettings
Todo:
Read the current printer settings from TeXmacs.

Definition at line 24 of file QTMPrintDialog.cpp.

  : QDialog(parent), _settings(s) {
    
  setupUi(this);
    
  QObject::connect(_settings, SIGNAL(doneReading()), 
                   this, SLOT(updatePrinterCapabilities()));
  QObject::connect(printerCombo, SIGNAL(currentIndexChanged(const QString)),
                   _settings, SLOT(startReadingSystemConfig(const QString&)));
    

}

Here is the call graph for this function:


Member Function Documentation

void QTMPrintDialog::accept ( ) [slot]

Stores the values from the dialog into the QTMPrinterSettings object after the user presses the "Accept" button.

Definition at line 114 of file QTMPrintDialog.cpp.

void QTMPrintDialog::on_allPagesRadio_clicked ( bool  on) [protected, slot]

Disable the From: and To: fields in the dialog.

Note:
We use this signal because toggled() would be fired by our call to setChecked inside on_*PageInput_textChanged()

Definition at line 160 of file QTMPrintDialog.cpp.

{
  if(on) {
    fromPageInput->setText("");
    toPageInput->setText("");
  }
  allPagesRadio->setChecked(on);
}
void QTMPrintDialog::on_copiesInput_textChanged ( const QString &  text) [protected, slot]

Definition at line 183 of file QTMPrintDialog.cpp.

{
  (void) text;
  collatedCheck->setEnabled(text.toInt() > 1);
}
void QTMPrintDialog::on_evenPagesCheck_stateChanged ( int  state) [protected, slot]

Definition at line 206 of file QTMPrintDialog.cpp.

                                                             {
  oddPagesCheck->setEnabled(state == Qt::Checked);
}
void QTMPrintDialog::on_fromPageInput_textChanged ( const QString &  text) [protected, slot]

Definition at line 189 of file QTMPrintDialog.cpp.

{
  (void) text;
  if (allPagesRadio->isChecked())
    rangePagesRadio->setChecked(true);
}
void QTMPrintDialog::on_oddPagesCheck_stateChanged ( int  state) [protected, slot]

Definition at line 202 of file QTMPrintDialog.cpp.

                                                            {
  evenPagesCheck->setEnabled(state == Qt::Checked);
}
void QTMPrintDialog::on_rangePagesRadio_clicked ( bool  on) [protected, slot]

Enable the From: and To: fields in the dialog.

Definition at line 172 of file QTMPrintDialog.cpp.

{
  if (on) {
    int f = (_settings->firstPage < 1) ? 1 : _settings->firstPage;
    int l = (_settings->lastPage < 1) ? 1 : _settings->lastPage;
    fromPageInput->setText(QString("%1").arg(f));
    toPageInput->setText(QString("%1").arg(l));
  }
  rangePagesRadio->setChecked(on);
}

Here is the call graph for this function:

void QTMPrintDialog::on_toPageInput_textChanged ( const QString &  text) [protected, slot]

Definition at line 196 of file QTMPrintDialog.cpp.

                                                                   {
  (void) text;
  if (allPagesRadio->isChecked())
    rangePagesRadio->setChecked(true);
}
void QTMPrintDialog::reject ( ) [slot]

Definition at line 145 of file QTMPrintDialog.cpp.

void Ui_QTMPrintDialog::retranslateUi ( QDialog *  QTMPrintDialog) [inline, inherited]

Definition at line 364 of file QTMPrintDialog.hpp.

  {
    QTMPrintDialog->setWindowTitle(QApplication::translate("QTMPrintDialog", "Print", 0, QApplication::UnicodeUTF8));
    label_3->setText(QApplication::translate("QTMPrintDialog", "Copies:", 0, QApplication::UnicodeUTF8));
    copiesInput->setText(QApplication::translate("QTMPrintDialog", "1", 0, QApplication::UnicodeUTF8));
    collatedCheck->setText(QApplication::translate("QTMPrintDialog", "Collated", 0, QApplication::UnicodeUTF8));
    label_7->setText(QApplication::translate("QTMPrintDialog", "Pages:", 0, QApplication::UnicodeUTF8));
    allPagesRadio->setText(QApplication::translate("QTMPrintDialog", "All", 0, QApplication::UnicodeUTF8));
    rangePagesRadio->setText(QApplication::translate("QTMPrintDialog", "From:", 0, QApplication::UnicodeUTF8));
    fromPageInput->setText(QApplication::translate("QTMPrintDialog", "1", 0, QApplication::UnicodeUTF8));
    label_4->setText(QApplication::translate("QTMPrintDialog", "To:", 0, QApplication::UnicodeUTF8));
    toPageInput->setText(QApplication::translate("QTMPrintDialog", "1", 0, QApplication::UnicodeUTF8));
    evenPagesCheck->setText(QApplication::translate("QTMPrintDialog", "Even", 0, QApplication::UnicodeUTF8));
    oddPagesCheck->setText(QApplication::translate("QTMPrintDialog", "Odd", 0, QApplication::UnicodeUTF8));
    paperSizeLabel->setText(QApplication::translate("QTMPrintDialog", "Paper size:", 0, QApplication::UnicodeUTF8));
    label_2->setText(QApplication::translate("QTMPrintDialog", "Orientation:", 0, QApplication::UnicodeUTF8));
    resolutionLabel->setText(QApplication::translate("QTMPrintDialog", "Resolution:", 0, QApplication::UnicodeUTF8));
    duplexCheck->setText(QApplication::translate("QTMPrintDialog", "Print on both sides", 0, QApplication::UnicodeUTF8));
    fitToPageCheck->setText(QApplication::translate("QTMPrintDialog", "Fit to page", 0, QApplication::UnicodeUTF8));
    label_5->setText(QApplication::translate("QTMPrintDialog", "Pages per side:", 0, QApplication::UnicodeUTF8));
    pagesPerSideCombo->clear();
    pagesPerSideCombo->insertItems(0, QStringList()
                                   << QApplication::translate("QTMPrintDialog", "1", 0, QApplication::UnicodeUTF8)
                                   << QApplication::translate("QTMPrintDialog", "2", 0, QApplication::UnicodeUTF8)
                                   << QApplication::translate("QTMPrintDialog", "4", 0, QApplication::UnicodeUTF8)
                                   << QApplication::translate("QTMPrintDialog", "6", 0, QApplication::UnicodeUTF8)
                                   << QApplication::translate("QTMPrintDialog", "9", 0, QApplication::UnicodeUTF8)
                                   << QApplication::translate("QTMPrintDialog", "16", 0, QApplication::UnicodeUTF8)
                                   );
    label_6->setText(QApplication::translate("QTMPrintDialog", "Order:", 0, QApplication::UnicodeUTF8));
    blackWhiteCheck->setText(QApplication::translate("QTMPrintDialog", "Print in black and white", 0, QApplication::UnicodeUTF8));
  } // retranslateUi

Here is the call graph for this function:

Here is the caller graph for this function:

void QTMPrintDialog::setupUi ( QDialog *  dia)
Todo:
Translate strings? QPrinterInfo::availablePrinters() does not return the spool names, but the printer names, which are useless to print with lpr.

Reimplemented from Ui_QTMPrintDialog.

Definition at line 78 of file QTMPrintDialog.cpp.

                                    {

  Ui::QTMPrintDialog::setupUi(dia);
  typedef QPair<QString, QString> printerPair;
  foreach (printerPair printer, _settings->availablePrinters())
    printerCombo->addItem(printer.first, printer.second);
  
  if(printerCombo->count() == 0)
    printerCombo->addItem("No printers available"); // TODO hide everything else

  // We use the QVariant field to retrieve the correct value later.
  orientationCombo->addItem("Portrait", QTMPrinterSettings::Portrait);
  orientationCombo->addItem("Landscape", QTMPrinterSettings::Landscape);
  orientationCombo->addItem("Reverse portrait", QTMPrinterSettings::ReversePortrait);
  orientationCombo->addItem("Reverse landscape", QTMPrinterSettings::ReverseLandscape);
  
  // We use the QVariant field to retrieve the correct value later.
  orderPagesCombo->addItem("Left-Right, Top-Bottom", QTMPrinterSettings::LR_TB);
  orderPagesCombo->addItem("Right-Left, Top-Bottom", QTMPrinterSettings::RL_TB);
  orderPagesCombo->addItem("Top-Bottom, Left-Right", QTMPrinterSettings::TB_LR);
  orderPagesCombo->addItem("Top-Bottom, Right-Left", QTMPrinterSettings::TB_RL);  
  orderPagesCombo->addItem("Left-Right, Bottom-Top", QTMPrinterSettings::LR_BT);
  orderPagesCombo->addItem("Right-Left, Bottom-Top", QTMPrinterSettings::RL_BT);
  orderPagesCombo->addItem("Bottom-Top, Left-Right", QTMPrinterSettings::BT_LR);
  orderPagesCombo->addItem("Bottom-Top, Right-Left", QTMPrinterSettings::BT_RL);
  
  // Force reading the printer settings for the first printer in the list. 
  _settings->startReadingSystemConfig(printerCombo->currentText());
}

Here is the call graph for this function:

Here is the caller graph for this function:

void QTMPrintDialog::updatePrinterCapabilities ( ) [protected, slot]

Updates the controls which depend on the capabilities of the selected printer, that is: available paper sizes, color printing, and duplex printing.

To this purpose we use QTMPrinterSettings::getChoices().

How can we translate the output from the system config? Must we?

Definition at line 46 of file QTMPrintDialog.cpp.

                                          {
  int idx = 0;
  
  paperSizeCombo->clear();
  paperSizeCombo->addItems(_settings->getChoices(QTMPrinterSettings::PageSize, idx));
  paperSizeCombo->setCurrentIndex(idx);
  paperSizeLabel->setEnabled(paperSizeCombo->count() > 1);
  paperSizeCombo->setEnabled(paperSizeCombo->count() > 1);

  resolutionCombo->clear();
  resolutionCombo->addItems(_settings->getChoices(QTMPrinterSettings::Resolution, idx));
  resolutionCombo->setCurrentIndex(idx);
  resolutionLabel->setEnabled(resolutionCombo->count() > 1);
  resolutionCombo->setEnabled(resolutionCombo->count() > 1);

  if (_settings->getChoices(QTMPrinterSettings::Duplex, idx).size() > 1) {
    duplexCheck->setEnabled(true);
  } else {
    duplexCheck->setEnabled(false);
    duplexCheck->setChecked(false);
  }
  
  blackWhiteCheck->setEnabled(_settings->getChoices(QTMPrinterSettings::ColorModel, 
                                                    idx).size() > 1);
}

Here is the call graph for this function:

Here is the caller graph for this function:


Member Data Documentation

Definition at line 448 of file QTMPrintDialog.hpp.

QRadioButton* Ui_QTMPrintDialog::allPagesRadio [inherited]

Definition at line 58 of file QTMPrintDialog.hpp.

QCheckBox* Ui_QTMPrintDialog::blackWhiteCheck [inherited]

Definition at line 88 of file QTMPrintDialog.hpp.

QDialogButtonBox* Ui_QTMPrintDialog::buttonBox [inherited]

Definition at line 89 of file QTMPrintDialog.hpp.

QCheckBox* Ui_QTMPrintDialog::collatedCheck [inherited]

Definition at line 54 of file QTMPrintDialog.hpp.

QLineEdit* Ui_QTMPrintDialog::copiesInput [inherited]

Definition at line 53 of file QTMPrintDialog.hpp.

QCheckBox* Ui_QTMPrintDialog::duplexCheck [inherited]

Definition at line 78 of file QTMPrintDialog.hpp.

QCheckBox* Ui_QTMPrintDialog::evenPagesCheck [inherited]

Definition at line 63 of file QTMPrintDialog.hpp.

QCheckBox* Ui_QTMPrintDialog::fitToPageCheck [inherited]

Definition at line 80 of file QTMPrintDialog.hpp.

QLineEdit* Ui_QTMPrintDialog::fromPageInput [inherited]

Definition at line 60 of file QTMPrintDialog.hpp.

QGridLayout* Ui_QTMPrintDialog::gridLayout [inherited]

Definition at line 68 of file QTMPrintDialog.hpp.

QGridLayout* Ui_QTMPrintDialog::gridLayout_2 [inherited]

Definition at line 56 of file QTMPrintDialog.hpp.

QGridLayout* Ui_QTMPrintDialog::gridLayout_3 [inherited]

Definition at line 50 of file QTMPrintDialog.hpp.

QGridLayout* Ui_QTMPrintDialog::gridLayout_4 [inherited]

Definition at line 82 of file QTMPrintDialog.hpp.

QHBoxLayout* Ui_QTMPrintDialog::horizontalLayout [inherited]

Definition at line 66 of file QTMPrintDialog.hpp.

QHBoxLayout* Ui_QTMPrintDialog::horizontalLayout_2 [inherited]

Definition at line 55 of file QTMPrintDialog.hpp.

QHBoxLayout* Ui_QTMPrintDialog::horizontalLayout_3 [inherited]

Definition at line 76 of file QTMPrintDialog.hpp.

QSpacerItem* Ui_QTMPrintDialog::horizontalSpacer [inherited]

Definition at line 75 of file QTMPrintDialog.hpp.

QSpacerItem* Ui_QTMPrintDialog::horizontalSpacer_2 [inherited]

Definition at line 67 of file QTMPrintDialog.hpp.

QSpacerItem* Ui_QTMPrintDialog::horizontalSpacer_3 [inherited]

Definition at line 77 of file QTMPrintDialog.hpp.

QSpacerItem* Ui_QTMPrintDialog::horizontalSpacer_4 [inherited]

Definition at line 81 of file QTMPrintDialog.hpp.

QSpacerItem* Ui_QTMPrintDialog::horizontalSpacer_5 [inherited]

Definition at line 79 of file QTMPrintDialog.hpp.

QLabel* Ui_QTMPrintDialog::label_2 [inherited]

Definition at line 71 of file QTMPrintDialog.hpp.

QLabel* Ui_QTMPrintDialog::label_3 [inherited]

Definition at line 52 of file QTMPrintDialog.hpp.

QLabel* Ui_QTMPrintDialog::label_4 [inherited]

Definition at line 61 of file QTMPrintDialog.hpp.

QLabel* Ui_QTMPrintDialog::label_5 [inherited]

Definition at line 83 of file QTMPrintDialog.hpp.

QLabel* Ui_QTMPrintDialog::label_6 [inherited]

Definition at line 85 of file QTMPrintDialog.hpp.

QLabel* Ui_QTMPrintDialog::label_7 [inherited]

Definition at line 57 of file QTMPrintDialog.hpp.

QFrame* Ui_QTMPrintDialog::line [inherited]

Definition at line 65 of file QTMPrintDialog.hpp.

QFrame* Ui_QTMPrintDialog::line_2 [inherited]

Definition at line 87 of file QTMPrintDialog.hpp.

QCheckBox* Ui_QTMPrintDialog::oddPagesCheck [inherited]

Definition at line 64 of file QTMPrintDialog.hpp.

QComboBox* Ui_QTMPrintDialog::orderPagesCombo [inherited]

Definition at line 86 of file QTMPrintDialog.hpp.

QComboBox* Ui_QTMPrintDialog::orientationCombo [inherited]

Definition at line 72 of file QTMPrintDialog.hpp.

QComboBox* Ui_QTMPrintDialog::pagesPerSideCombo [inherited]

Definition at line 84 of file QTMPrintDialog.hpp.

QComboBox* Ui_QTMPrintDialog::paperSizeCombo [inherited]

Definition at line 70 of file QTMPrintDialog.hpp.

QLabel* Ui_QTMPrintDialog::paperSizeLabel [inherited]

Definition at line 69 of file QTMPrintDialog.hpp.

QComboBox* Ui_QTMPrintDialog::printerCombo [inherited]

Definition at line 51 of file QTMPrintDialog.hpp.

QRadioButton* Ui_QTMPrintDialog::rangePagesRadio [inherited]

Definition at line 59 of file QTMPrintDialog.hpp.

QComboBox* Ui_QTMPrintDialog::resolutionCombo [inherited]

Definition at line 74 of file QTMPrintDialog.hpp.

Definition at line 73 of file QTMPrintDialog.hpp.

QLineEdit* Ui_QTMPrintDialog::toPageInput [inherited]

Definition at line 62 of file QTMPrintDialog.hpp.

QVBoxLayout* Ui_QTMPrintDialog::verticalLayout [inherited]

Definition at line 49 of file QTMPrintDialog.hpp.


The documentation for this class was generated from the following files: