~ubuntu-branches/debian/sid/scribus/sid

« back to all changes in this revision

Viewing changes to .pc/fixes_cups1.5.patch/scribus/cupsoptions.cpp

  • Committer: Package Import Robot
  • Author(s): Oleksandr Moskalenko
  • Date: 2012-02-09 21:50:56 UTC
  • mfrom: (1.1.6)
  • Revision ID: package-import@ubuntu.com-20120209215056-2wrx1ara0jbm7fi5
Tags: 1.4.0.dfsg+r17287-1
* New upstream stable release upload into Debian (Closes: #654703).
* Applied the Ubuntu armel patch.
* Removed non-free color swatches from resources.
* debian/control:
  - Moved icc-profiles from Recommends to Suggests (Closes: #655885).
  - Updated Standards-Version to 3.9.2.
  - Updated extended description per lintian warning.
* debian/rules:
  - Update mailcap (Closes: #630751). A request for mime.types update has
    been sent to the mime-support maintainer.
  - Added build-arch and build-indep targets per lintian warning.
* debian/patches:
  - top_cmakelists.patch - don't copy extra docs and changelogs.
  - scribus_cmakelists.patch - don't copy extra docs and changelogs.
  - scribus_cmakelists.patch - don't install the non-free "doc" dir.
  - profiles_cmakelists.patch - don't install non-free sRGB profile.
* debian/copyright: 
  - Converted to the DEP5 machine readable foramt.
  - Added licenses for free color swatches.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/*
2
 
For general Scribus (>=1.3.2) copyright and licensing information please refer
3
 
to the COPYING file provided with the program. Following this notice may exist
4
 
a copyright and/or license notice that predates the release of Scribus 1.3.2
5
 
for which a new license (GPL+exception) is in place.
6
 
*/
7
 
/***************************************************************************
8
 
                          cupsoptions.cpp  -  description
9
 
                             -------------------
10
 
    begin                : Fre Jan 3 2003
11
 
    copyright            : (C) 2003 by Franz Schmid
12
 
    email                : Franz.Schmid@altmuehlnet.de
13
 
 ***************************************************************************/
14
 
 
15
 
/***************************************************************************
16
 
 *                                                                         *
17
 
 *   This program is free software; you can redistribute it and/or modify  *
18
 
 *   it under the terms of the GNU General Public License as published by  *
19
 
 *   the Free Software Foundation; either version 2 of the License, or     *
20
 
 *   (at your option) any later version.                                   *
21
 
 *                                                                         *
22
 
 ***************************************************************************/
23
 
 
24
 
#include "cupsoptions.h"
25
 
 
26
 
#include <QHBoxLayout>
27
 
#include <QVBoxLayout>
28
 
#include <QPushButton>
29
 
#include <QComboBox>
30
 
#include <QHeaderView>
31
 
#include <QTableWidget>
32
 
#include <QTableWidgetItem>
33
 
#include <QPixmap>
34
 
#include <QStringList>
35
 
#include <QToolTip>
36
 
#include <QSpacerItem>
37
 
 
38
 
#include "prefsmanager.h"
39
 
#include "prefscontext.h"
40
 
#include "prefsfile.h"
41
 
#include "commonstrings.h"
42
 
#include "scconfig.h"
43
 
#ifdef HAVE_CUPS
44
 
#include <cups/cups.h>
45
 
#endif
46
 
#include "util_icon.h"
47
 
 
48
 
CupsOptions::CupsOptions(QWidget* parent, QString Geraet) : QDialog( parent )
49
 
{
50
 
        FlagsOpt.clear();
51
 
        setModal(true);
52
 
        setWindowTitle( tr( "Printer Options" ) );
53
 
        setWindowIcon(QIcon(loadIcon ( "AppIcon.png" )));
54
 
        prefs = PrefsManager::instance()->prefsFile->getContext("cups_options");
55
 
        setSizeGripEnabled(true);
56
 
        CupsOptionsLayout = new QVBoxLayout( this );
57
 
        CupsOptionsLayout->setSpacing( 5 );
58
 
        CupsOptionsLayout->setMargin( 10 );
59
 
        Table = new QTableWidget(0, 2, this);
60
 
        Table->setSortingEnabled(false);
61
 
        Table->setSelectionMode(QAbstractItemView::NoSelection);
62
 
        Table->verticalHeader()->hide();
63
 
        Table->setHorizontalHeaderItem(0, new QTableWidgetItem( tr("Option")));
64
 
        Table->setHorizontalHeaderItem(1, new QTableWidgetItem( tr("Value")));
65
 
        QHeaderView* headerH = Table->horizontalHeader();
66
 
        headerH->setStretchLastSection(true);
67
 
        headerH->setMovable(false);
68
 
        headerH->setClickable(false);
69
 
        headerH->setResizeMode(QHeaderView::Fixed);
70
 
        Table->setMinimumSize(300, 100);
71
 
#ifdef HAVE_CUPS
72
 
        int i;
73
 
        cups_dest_t *dests;
74
 
        cups_dest_t *dest;
75
 
        int num_dests;
76
 
        const char      *filename;      /* PPD filename */
77
 
        ppd_file_t      *ppd;                           /* PPD data */
78
 
        ppd_group_t     *group;                 /* Current group */
79
 
        num_dests = cupsGetDests(&dests);
80
 
        dest = cupsGetDest(Geraet.toLocal8Bit().constData(), NULL, num_dests, dests);
81
 
        if (!(dest == NULL || (filename = cupsGetPPD(dest->name)) == NULL || (ppd = ppdOpenFile(filename)) == NULL))
82
 
        {
83
 
                ppdMarkDefaults(ppd);
84
 
                cupsMarkOptions(ppd, dest->num_options, dest->options);
85
 
                QStringList opts;
86
 
                QString Marked = "";
87
 
                KeyToText.clear();
88
 
                KeyToDefault.clear();
89
 
                for (i = ppd->num_groups, group = ppd->groups; i > 0; i --, ++group)
90
 
                {
91
 
                        int ix;
92
 
                        ppd_option_t    *option;        /* Current option */
93
 
                        ppd_choice_t    *choice;        /* Current choice */
94
 
                        for (ix = group->num_options, option = group->options; ix > 0; ix --, ++option)
95
 
                        {
96
 
                                int j;
97
 
                                Marked = "";
98
 
                                struct OpData Daten;
99
 
                                opts.clear();
100
 
                                for (j = option->num_choices, choice = option->choices;
101
 
                                                j > 0; j --, ++choice)
102
 
                                {
103
 
                                        opts.append(QString(choice->choice));
104
 
                                        if (choice->marked)
105
 
                                                Marked = QString(choice->choice);
106
 
                                }
107
 
                                if (!Marked.isEmpty())
108
 
                                {
109
 
                                        Table->setRowCount(Table->rowCount()+1);
110
 
                                        Table->setItem(Table->rowCount()-1, 0, new QTableWidgetItem(QString(option->text)));
111
 
                                        QComboBox *item = new QComboBox( this );
112
 
                                        item->setEditable(false);
113
 
                                        FlagsOpt.append(item);
114
 
                                        Daten.Cnum = static_cast<int>(FlagsOpt.count()-1);
115
 
                                        Daten.KeyW = QString(option->keyword);
116
 
                                        KeyToText[QString(option->text)] = Daten;
117
 
                                        item->addItems(opts);
118
 
                                        int lastSelected = prefs->getInt(QString(option->text), 0);
119
 
                                        if (lastSelected >= static_cast<int>(opts.count()))
120
 
                                                lastSelected = 0;
121
 
                                        item->setCurrentIndex(lastSelected);
122
 
                                        KeyToDefault[QString(option->text)] = Marked;
123
 
                                        Table->setCellWidget(Table->rowCount()-1, 1, item);
124
 
                                }
125
 
                        }
126
 
                }
127
 
                ppdClose(ppd);
128
 
                cupsFreeDests(num_dests, dests);
129
 
        }
130
 
        struct OpData Daten;
131
 
 
132
 
        Table->setRowCount(Table->rowCount()+1);
133
 
        Table->setItem(Table->rowCount()-1, 0, new QTableWidgetItem(QString( tr("Page Set"))));
134
 
        QComboBox *item4 = new QComboBox( this );
135
 
        item4->setEditable(false);
136
 
        FlagsOpt.append(item4);
137
 
        Daten.Cnum = static_cast<int>(FlagsOpt.count()-1);
138
 
        Daten.KeyW = "page-set";
139
 
        KeyToText["Page Set"] = Daten;
140
 
        item4->addItem( tr("All Pages"));
141
 
        item4->addItem( tr("Even Pages only"));
142
 
        item4->addItem( tr("Odd Pages only"));
143
 
        int lastSelected = prefs->getInt( tr("Page Set"), 0);
144
 
        if (lastSelected >= 3)
145
 
                lastSelected = 0;
146
 
        item4->setCurrentIndex(lastSelected);
147
 
        KeyToDefault["Page Set"] = tr("All Pages");
148
 
        Table->setCellWidget(Table->rowCount()-1, 1, item4);
149
 
        Table->setRowCount(Table->rowCount()+1);
150
 
        Table->setItem(Table->rowCount()-1, 0, new QTableWidgetItem(QString( tr("Mirror"))));
151
 
        QComboBox *item2 = new QComboBox( this );
152
 
        item2->setEditable(false);
153
 
        FlagsOpt.append(item2);
154
 
        Daten.Cnum = static_cast<int>(FlagsOpt.count()-1);
155
 
        Daten.KeyW = "mirror";
156
 
        KeyToText["Mirror"] = Daten;
157
 
        item2->addItem(CommonStrings::trNo);
158
 
        item2->addItem(CommonStrings::trYes);
159
 
        item2->setCurrentIndex(0);
160
 
        lastSelected = prefs->getInt( tr("Mirror"), 0);
161
 
        if (lastSelected >= 2)
162
 
                lastSelected = 0;
163
 
        item2->setCurrentIndex(lastSelected);
164
 
        KeyToDefault["Mirror"] = CommonStrings::trNo;
165
 
        Table->setCellWidget(Table->rowCount()-1, 1, item2);
166
 
        Table->setRowCount(Table->rowCount()+1);
167
 
        Table->setItem(Table->rowCount()-1, 0, new QTableWidgetItem(QString( tr("Orientation"))));
168
 
        QComboBox *item5 = new QComboBox( this );
169
 
        item5->setEditable(false);
170
 
        FlagsOpt.append(item5);
171
 
        Daten.Cnum = static_cast<int>(FlagsOpt.count()-1);
172
 
        Daten.KeyW = "orientation";
173
 
        KeyToText["Orientation"] = Daten;
174
 
        item5->addItem( tr("Portrait"));
175
 
        item5->addItem( tr("Landscape"));
176
 
        item5->setCurrentIndex(0);
177
 
        lastSelected = prefs->getInt( tr("Orientation"), 0);
178
 
        if (lastSelected >= 2)
179
 
                lastSelected = 0;
180
 
        item5->setCurrentIndex(lastSelected);
181
 
        KeyToDefault["Orientation"] = tr("Portrait");
182
 
        Table->setCellWidget(Table->rowCount()-1, 1, item5);
183
 
        Table->setRowCount(Table->rowCount()+1);
184
 
        Table->setItem(Table->rowCount()-1, 0, new QTableWidgetItem(QString( tr("N-Up Printing"))));
185
 
        QComboBox *item3 = new QComboBox( this );
186
 
        item3->setEditable(false);
187
 
        FlagsOpt.append(item3);
188
 
        Daten.Cnum = static_cast<int>(FlagsOpt.count()-1);
189
 
        Daten.KeyW = "number-up";
190
 
        KeyToText["N-Up Printing"] = Daten;
191
 
        item3->addItem("1 "+ tr("Page per Sheet"));
192
 
        item3->addItem("2 "+ tr("Pages per Sheet"));
193
 
        item3->addItem("4 "+ tr("Pages per Sheet"));
194
 
        item3->addItem("6 "+ tr("Pages per Sheet"));
195
 
        item3->addItem("9 "+ tr("Pages per Sheet"));
196
 
        item3->addItem("16 "+ tr("Pages per Sheet"));
197
 
        lastSelected = prefs->getInt( tr("N-Up Printing"), 0);
198
 
        if (lastSelected >= 6)
199
 
                lastSelected = 0;
200
 
        item3->setCurrentIndex(lastSelected);
201
 
        KeyToDefault["N-Up Printing"] = "1 "+ tr("Page per Sheet");
202
 
        Table->setCellWidget(Table->rowCount()-1, 1, item3);
203
 
#endif
204
 
        Table->resizeColumnsToContents();
205
 
        CupsOptionsLayout->addWidget( Table );
206
 
 
207
 
        Layout2 = new QHBoxLayout;
208
 
        Layout2->setSpacing( 5 );
209
 
        Layout2->setMargin( 0 );
210
 
        QSpacerItem* spacer = new QSpacerItem( 2, 2, QSizePolicy::Expanding, QSizePolicy::Minimum );
211
 
        Layout2->addItem( spacer );
212
 
        PushButton1 = new QPushButton( CommonStrings::tr_OK, this );
213
 
        PushButton1->setDefault( true );
214
 
        Layout2->addWidget( PushButton1 );
215
 
        PushButton2 = new QPushButton( CommonStrings::tr_Cancel, this );
216
 
        PushButton2->setDefault( false );
217
 
        PushButton1->setFocus();
218
 
        Layout2->addWidget( PushButton2 );
219
 
        CupsOptionsLayout->addLayout( Layout2 );
220
 
        setMinimumSize( sizeHint() );
221
 
        resize(minimumSizeHint().expandedTo(QSize(300, 100)));
222
 
 
223
 
//tooltips
224
 
        Table->setToolTip( "<qt>" + tr( "This panel displays various CUPS options when printing. The exact parameters available will depend on your printer driver. You can confirm CUPS support by selecting Help > About. Look for the listings: C-C-T These equate to C=CUPS C=littlecms T=TIFF support. Missing library support is indicated by a *" ) + "</qt>" );
225
 
 
226
 
    // signals and slots connections
227
 
        connect( PushButton2, SIGNAL( clicked() ), this, SLOT( reject() ) );
228
 
        connect( PushButton1, SIGNAL( clicked() ), this, SLOT( accept() ) );
229
 
}
230
 
 
231
 
CupsOptions::~CupsOptions()
232
 
{
233
 
        for (int i = 0; i < Table->rowCount(); ++i)
234
 
        {
235
 
                QComboBox* combo = dynamic_cast<QComboBox*>(Table->cellWidget(i, 1));
236
 
                if (combo)
237
 
                        prefs->set(Table->item(i, 0)->text(), combo->currentIndex());
238
 
        }
239
 
}