The BpsPrinterSettings class allows to save and restore printer settings. More...
#include <bpsprintersettings.h>
Public Member Functions | |
| BpsPrinterSettings (QPrinter *aPrinter, BpsSettings *aSettings=0, QObject *aParent=0) | |
| QMap< QString, QString > | config () const |
| bool | restore () |
| Restore the settings from human readable keys/values. | |
| bool | restore (const QString &aKey) |
| Restore the settings from an encoded value. | |
| void | save () |
| Save the settings as human readable keys/values. | |
| void | save (const QString &aKey) |
| Save the settings encoded in one single value. | |
| bool | setConfig (const QMap< QString, QString > &aConfig) |
| Load the settings from a config map instead from the settings. | |
Static Public Member Functions | |
| static QMap < QPrinter::ColorMode, QString > | colorModes () |
| static QMap < QPrinter::DuplexMode, QString > | duplexModes () |
| static QMap < QPrinter::Orientation, QString > | orientations () |
| static QMap < QPrinter::PageOrder, QString > | pageOrders () |
| static QMap < QPrinter::PaperSize, QString > | paperNames () |
| A map with the paper names. | |
| static QMap < QPrinter::PaperSize, QSizeF > | paperSizes () |
| A map with paper size informations. | |
| static QMap < QPrinter::PaperSource, QString > | paperSources () |
The BpsPrinterSettings class allows to save and restore printer settings.
This is useful when you do not want to show a print dialog every time, but reuse the last setting. The status can be saved and restored in 2 different ways: Either binary where all settings are encoded into one single value, or human readable where every setting is in a distinct value.
QPrinter p; BpsSettings s; s.open("Settings/Printers/MyPrinter"); BpsPrinterSettings ps(&p, &s); bool ok = ps.load(); if (!ok) { // no settings yet saved, show dialog as fallback ok = QPrintDialog(&p, this).exec() == QDialog::Accepted; // save the new settings if (ok) ps.save(); } // if if (ok) { // do the printing .... } // if
| BpsPrinterSettings::BpsPrinterSettings | ( | QPrinter * | aPrinter, |
| BpsSettings * | aSettings = 0, |
||
| QObject * | aParent = 0 |
||
| ) |
| [in] | aPrinter | The printer object to save/load settings for. |
| [in] | aSettings | The settings object, opened to the desire path. If aSettings is = 0, the save and restore methods will do nothing. |
| [in] | aParent | The parent object. |
| static QMap<QPrinter::ColorMode, QString> BpsPrinterSettings::colorModes | ( | ) | [static] |
| QMap<QString,QString> BpsPrinterSettings::config | ( | ) | const |
| static QMap<QPrinter::DuplexMode, QString> BpsPrinterSettings::duplexModes | ( | ) | [static] |
| static QMap<QPrinter::Orientation, QString> BpsPrinterSettings::orientations | ( | ) | [static] |
| static QMap<QPrinter::PageOrder, QString> BpsPrinterSettings::pageOrders | ( | ) | [static] |
| static QMap<QPrinter::PaperSize, QString> BpsPrinterSettings::paperNames | ( | ) | [static] |
A map with the paper names.
| static QMap<QPrinter::PaperSize, QSizeF> BpsPrinterSettings::paperSizes | ( | ) | [static] |
A map with paper size informations.
The paper size in in millimeters, and for portrait orientation. Swap width and height for landscape orientation.
| static QMap<QPrinter::PaperSource, QString> BpsPrinterSettings::paperSources | ( | ) | [static] |
| bool BpsPrinterSettings::restore | ( | ) |
Restore the settings from human readable keys/values.
| bool BpsPrinterSettings::restore | ( | const QString & | aKey | ) |
Restore the settings from an encoded value.
| [in] | aKey | The key to restore the settings from. |
| void BpsPrinterSettings::save | ( | const QString & | aKey | ) |
Save the settings encoded in one single value.
| [in] | aKey | The key to save the settings. |
| bool BpsPrinterSettings::setConfig | ( | const QMap< QString, QString > & | aConfig | ) |
Load the settings from a config map instead from the settings.
| [in] | aConfig | The config map to use. |