summaryrefslogtreecommitdiffstats
path: root/src/maingui/printergui.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/maingui/printergui.cpp')
-rw-r--r--src/maingui/printergui.cpp45
1 files changed, 36 insertions, 9 deletions
diff --git a/src/maingui/printergui.cpp b/src/maingui/printergui.cpp
index feddb52..8d2e81e 100644
--- a/src/maingui/printergui.cpp
+++ b/src/maingui/printergui.cpp
@@ -9,6 +9,7 @@
static QStringList knownColorOptions = QStringList() << "ColorModel" << "XRXColor";
static QStringList knownDuplexOptions = QStringList() << "Duplex";
+static QStringList knownPageSizeOptions = QStringList() << "PageSize";
// ____________________________________________________________________________
PrinterGui::PrinterGui(char *argv[], QWidget *parent) :
@@ -111,7 +112,7 @@ void PrinterGui::initializeUI()
this->activateWindow();
}
-void PrinterGui::enableOptionSelection(ppd_file_t *ppd, QStringList &nameList, QComboBox *combo, QLabel *label)
+static void enableOptionSelection(ppd_file_t *ppd, QStringList &nameList, QComboBox *combo, QLabel *label)
{
// Check for each option if it matches an
QString matchedProperty;
@@ -123,13 +124,21 @@ void PrinterGui::enableOptionSelection(ppd_file_t *ppd, QStringList &nameList, Q
continue;
// Matches, update combo
matchedProperty = option;
+ combo->setUpdatesEnabled(false);
combo->clear();
for (int i = 0; i < o->num_choices; ++i) {
- combo->addItem(QString::fromUtf8(o->choices[i].text), QString::fromLatin1(o->choices[i].choice));
- if (strcmp(o->choices[i].choice, o->defchoice) == 0) {
+ if (o->choices[i].choice == NULL)
+ continue;
+ if (o->choices[i].text == NULL) {
+ combo->addItem(QString::fromUtf8(o->choices[i].choice), QString::fromLatin1(o->choices[i].choice));
+ } else {
+ combo->addItem(QString::fromUtf8(o->choices[i].text), QString::fromLatin1(o->choices[i].choice));
+ }
+ if (o->defchoice != NULL && strcmp(o->choices[i].choice, o->defchoice) == 0) {
combo->setCurrentIndex(i);
}
}
+ combo->setUpdatesEnabled(true);
combo->adjustSize();
break;
}
@@ -144,7 +153,7 @@ void PrinterGui::on_printerList_currentItemChanged(QTreeWidgetItem *current, QTr
{
ui->printerList->setFocus();
- cups_dest_t *dest =cupsGetNamedDest(CUPS_HTTP_DEFAULT, current->text(0).toUtf8().constData(), NULL);
+ cups_dest_t *dest = cupsGetNamedDest(CUPS_HTTP_DEFAULT, current->text(0).toUtf8().constData(), NULL);
/* * Check printer properties (auth, color, duplex, copies) * */
@@ -162,6 +171,7 @@ void PrinterGui::on_printerList_currentItemChanged(QTreeWidgetItem *current, QTr
//if (res & CUPS_PRINTER_COLOR) // No needed? Should just get disabled either way
enableOptionSelection(ppd, knownColorOptions, ui->comboBoxColor, ui->label_color);
enableOptionSelection(ppd, knownDuplexOptions, ui->comboBoxSides, ui->label_duplex);
+ enableOptionSelection(ppd, knownPageSizeOptions, ui->cboPaperSize, ui->lblPaperSize);
ppdClose(ppd);
} else {
qDebug() << "ppd is null"<< dest->name << cupsLastErrorString();
@@ -209,18 +219,28 @@ void PrinterGui::on_buttonPrint_clicked()
// Color
QString colorKey = ui->comboBoxColor->property("key").toString();
- if (!colorKey.isEmpty())
+ if (!colorKey.isEmpty()) {
dest->num_options = cupsAddOption(colorKey.toUtf8().constData(),
- ui->comboBoxColor->itemData(ui->comboBoxColor->currentIndex()).toString().toStdString().c_str(),
+ ui->comboBoxColor->itemData(ui->comboBoxColor->currentIndex()).toString().toUtf8().constData(),
dest->num_options,
&(dest->options));
+ }
// Duplex
QString duplexKey = ui->comboBoxSides->property("key").toString();
- if (!duplexKey.isEmpty())
+ if (!duplexKey.isEmpty()) {
dest->num_options = cupsAddOption(duplexKey.toUtf8().constData(),
- ui->comboBoxSides->itemData(ui->comboBoxSides->currentIndex()).toString().toStdString().c_str(),
+ ui->comboBoxSides->itemData(ui->comboBoxSides->currentIndex()).toString().toUtf8().constData(),
+ dest->num_options,
+ &(dest->options));
+ }
+ // Paper size
+ QString paperKey = ui->cboPaperSize->property("key").toString();
+ if (!paperKey.isEmpty()) {
+ dest->num_options = cupsAddOption(paperKey.toUtf8().constData(),
+ ui->cboPaperSize->itemData(ui->cboPaperSize->currentIndex()).toString().toUtf8().constData(),
dest->num_options,
&(dest->options));
+ }
// Kopien
if (ui->lineEditCopies->isEnabled()) {
dest->num_options = cupsAddOption("copies",
@@ -242,7 +262,14 @@ void PrinterGui::on_buttonPrint_clicked()
QMessageBox::critical(this, "CUPS Fehler", cupsLastErrorString());
} else {
this->bgTimeout = 0;
- this->hide();
+ statusBar()->showMessage("Druckauftrag wird verarbeitet...");
+ ui->buttonCancel->setEnabled(false);
+ ui->buttonPrint->setEnabled(false);
+ ui->cboPaperSize->setEnabled(false);
+ ui->comboBoxColor->setEnabled(false);
+ ui->comboBoxSides->setEnabled(false);
+ ui->lineEditCopies->setEnabled(false);
+ ui->printerList->setEnabled(false);
}
}