AMBeamConfigurationWizard::AMBeamConfigurationWizard(QWidget* parent) : AMGraphicsViewWizard(parent) { /// two points for each square, three squares. setNumberOfPoints(6); setNumberOfPages(numberOfPoints()); setFreePage(Page_Free); setRotationEnabled(false); setPage(Page_Intro, new AMWizardPage); setPage(Page_Final, new AMWizardPage); setPage(Page_Option, new AMWizardOptionPage); for(int i = 0; i < numberOfPages(); i++) { setPage(pageWait(i), new AMBeamWaitPage); /* kind of a dirty hack here, but this makes the wait logic cleaner */ if(i < 3) setPage(pageSet(i), new AMBeamCheckPage); else setPage(pageSet(i), new AMBeamSelectPage); } setStartId(Page_Intro); setOption(HaveHelpButton, true); connect(this, SIGNAL(helpRequested()), this, SLOT(showHelp())); setWindowTitle(message(Wizard_Title)); /* have to disconnect/connect the buttons to get them to work with the new slots */ disconnect(button(QWizard::BackButton), SIGNAL(clicked()), this, SLOT(back())); connect(button(QWizard::BackButton), SIGNAL(clicked()), this, SLOT(back())); disconnect(button(QWizard::NextButton), SIGNAL(clicked()), this, SLOT(next())); connect(button(QWizard::NextButton), SIGNAL(clicked()), this, SLOT(next())); setMinimumSize(600,600); setting_ = false; reviewBeamShape_ = true; for(int i = 0; i < numberOfPoints(); i++) { pointListAppend(new QPointF(0,0)); } topLeft_ = true; coordinateListAppend(new QVector3D(0,0,0)); coordinateListAppend(new QVector3D(0,-1,0)); coordinateListAppend(new QVector3D(0,1,0)); coordinateListAppend(new QVector3D(0,0,0)); coordinateListAppend(new QVector3D(0,-1,0)); coordinateListAppend(new QVector3D(0,1,0)); addOptionPage(Page_Intro); }
int AMSimpleBeamConfigurationWizard::nextId() const { int pageId = currentId(); switch(pageId) { case Page_Intro: if(showOptionPage()) return Page_Option; else return pageWait(0); case Page_Final: return -1; default: int id = relativeId(); if(isWaitPage(pageId)) return pageSet(id); else if(isSetPage(pageId)) { if(id == numberOfPages() - 1) return Page_Final; else return pageWait(id + 1); } return -1; } }
bool AMBeamConfigurationWizard::allChecked() const { bool checkedSet = true; for(int i = 0; i < numberOfPages()/2; i++) { checkedSet *= checked(pageSet(i)); } return checkedSet; }
AMSimpleBeamConfigurationWizard::AMSimpleBeamConfigurationWizard(QWidget *parent) : AMGraphicsViewWizard(parent) { setNumberOfPoints(3); setNumberOfPages(numberOfPoints()); setFreePage(Page_Free); coordinateListAppend(new QVector3D(0,0,0)); coordinateListAppend(new QVector3D(0,2,0)); coordinateListAppend(new QVector3D(0,-2,0)); setPage(Page_Intro, new AMWizardPage); setPage(Page_Option, new AMWizardOptionPage); setPage(Page_Final, new AMWizardPage); for(int i = 0; i < numberOfPages(); i++) { setPage(pageWait(i), new AMSimpleBeamConfigurationWaitPage); setPage(pageSet(i), new AMSimpleBeamConfigurationSetPage); connect(page(pageSet(i)), SIGNAL(initBeamShape()), this, SLOT(initBeamShape())); connect(page(pageSet(i)), SIGNAL(signalMousePressed(QPointF)), this, SLOT(mousePressedHandler(QPointF))); connect(page(pageSet(i)), SIGNAL(moveBeamShape(QPointF)), this, SLOT(moveBeamShapeHandler(QPointF))); } setStartId(Page_Intro); setOption(HaveHelpButton, true); connect(this, SIGNAL(helpRequested()), this, SLOT(showHelp())); setWindowTitle(message(Wizard_Title)); disconnect(button(QWizard::BackButton), SIGNAL(clicked()), this, SLOT(back())); connect(button(QWizard::BackButton), SIGNAL(clicked()), this, SLOT(back())); setMinimumSize(600,600); /// Add options button to intro page addOptionPage(Page_Intro); }
int AMBeamConfigurationWizard::nextId() const { int pageId = currentId(); switch(pageId) { case Page_Intro: if(showOptionPage()) return Page_Option; else return pageWait(0); default: if(isWaitPage(pageId)) { return pageSet(relativeId()); } else if(isSetPage(pageId)) { if((lastCheckPage() && allChecked()) || (relativeId() >= (numberOfPages() - 1))) { return Page_Final; } else if(isCheckPage() && !allChecked())/* change this to check all lower number pages */ { return pageWait(numberOfPages()/2); } else { return pageWait(relativeId() + 1); } } else { return -1; } } }
MarginDialog::MarginDialog( QWidget* parent, ScribusDoc* doc ) : QDialog( parent) { setModal(true); setWindowTitle( tr( "Manage Page Properties" ) ); setWindowIcon(IconManager::instance()->loadIcon("AppIcon.png")); unitRatio = doc->unitRatio(); dialogLayout = new QVBoxLayout(this); dialogLayout->setMargin(10); dialogLayout->setSpacing(5); dsGroupBox7 = new QGroupBox(this); dsGroupBox7->setTitle( tr( "Page Size" ) ); dsGroupBox7Layout = new QGridLayout(dsGroupBox7); dsGroupBox7Layout->setAlignment( Qt::AlignTop ); dsGroupBox7Layout->setSpacing( 5 ); dsGroupBox7Layout->setMargin( 10 ); TextLabel1 = new QLabel( tr( "&Size:" ), dsGroupBox7 ); dsGroupBox7Layout->addWidget( TextLabel1, 0, 0, 1, 2 ); PageSize *ps=new PageSize(doc->currentPage()->m_pageSize); prefsPageSizeName=ps->name(); sizeQComboBox = new QComboBox(dsGroupBox7); QStringList insertList(ps->activeSizeTRList()); if (insertList.indexOf(prefsPageSizeName)==-1) insertList<<prefsPageSizeName; insertList.sort(); insertList<<CommonStrings::trCustomPageSize; sizeQComboBox->addItems(insertList); int sizeIndex = insertList.indexOf(ps->nameTR()); if (sizeIndex != -1) sizeQComboBox->setCurrentIndex(sizeIndex); else sizeQComboBox->setCurrentIndex(sizeQComboBox->count()-1); TextLabel1->setBuddy(sizeQComboBox); dsGroupBox7Layout->addWidget(sizeQComboBox, 0, 2, 1, 2); TextLabel2 = new QLabel( tr( "Orie&ntation:" ), dsGroupBox7 ); dsGroupBox7Layout->addWidget( TextLabel2, 1, 0, 1, 2 ); orientationQComboBox = new QComboBox( dsGroupBox7 ); orientationQComboBox->addItem( tr( "Portrait" ) ); orientationQComboBox->addItem( tr( "Landscape" ) ); orientationQComboBox->setEditable(false); orientationQComboBox->setCurrentIndex(doc->currentPage()->orientation() ); oldOri = doc->currentPage()->orientation(); TextLabel2->setBuddy(orientationQComboBox); dsGroupBox7Layout->addWidget( orientationQComboBox, 1, 2, 1, 2 ); widthSpinBox = new ScrSpinBox( 1, 16777215, dsGroupBox7, doc->unitIndex() ); widthQLabel = new QLabel( tr( "&Width:" ), dsGroupBox7 ); widthSpinBox->setValue(doc->currentPage()->width() * doc->unitRatio()); widthQLabel->setBuddy(widthSpinBox); dsGroupBox7Layout->addWidget( widthQLabel, 2, 0 ); dsGroupBox7Layout->addWidget( widthSpinBox, 2, 1 ); heightSpinBox = new ScrSpinBox( 1, 16777215, dsGroupBox7, doc->unitIndex() ); heightSpinBox->setValue(doc->currentPage()->height() * doc->unitRatio()); heightQLabel = new QLabel( tr( "&Height:" ), dsGroupBox7 ); heightQLabel->setBuddy(heightSpinBox); dsGroupBox7Layout->addWidget( heightQLabel, 2, 2 ); dsGroupBox7Layout->addWidget( heightSpinBox, 2, 3 ); moveObjects = new QCheckBox( dsGroupBox7 ); moveObjects->setText( tr( "Move Objects with their Page" ) ); moveObjects->setChecked( true ); dsGroupBox7Layout->addWidget( moveObjects, 3, 0, 1, 4 ); Links=0; if ((doc->pagePositioning() != singlePage) && (doc->masterPageMode())) { TextLabel3 = new QLabel( tr( "Type:" ), dsGroupBox7 ); dsGroupBox7Layout->addWidget( TextLabel3, 4, 0, 1, 2 ); Links = new QComboBox( dsGroupBox7 ); QStringList::Iterator pNames; QList<PageSet> pageSet(doc->pageSets()); for(pNames = pageSet[doc->pagePositioning()].pageNames.begin(); pNames != pageSet[doc->pagePositioning()].pageNames.end(); ++pNames ) { //Links->insertItem((*pNames)); Links->addItem(CommonStrings::translatePageSetLocString((*pNames))); } Links->setEditable(false); dsGroupBox7Layout->addWidget( Links, 4, 2, 1, 2 ); if (doc->currentPage()->LeftPg == 0) Links->setCurrentIndex(Links->count()-1); else if (doc->currentPage()->LeftPg == 1) Links->setCurrentIndex(0); else Links->setCurrentIndex(doc->currentPage()->LeftPg-1); } dialogLayout->addWidget( dsGroupBox7 ); GroupRand = new MarginWidget(this, tr( "Margin Guides" ), &doc->currentPage()->initialMargins, doc->unitIndex(), false, false); GroupRand->setPageWidthHeight(doc->currentPage()->width(), doc->currentPage()->height()); GroupRand->setFacingPages(!(doc->pagePositioning() == singlePage), doc->locationOfPage(doc->currentPage()->pageNr())); GroupRand->setMarginPreset(doc->currentPage()->marginPreset); dialogLayout->addWidget( GroupRand ); groupMaster = new QGroupBox( this ); groupMaster->setTitle( tr( "Other Settings" ) ); masterLayout = new QHBoxLayout( groupMaster ); masterLayout->setSpacing( 5 ); masterLayout->setMargin( 10 ); masterPageLabel = new QLabel( groupMaster ); masterLayout->addWidget( masterPageLabel ); if (!doc->masterPageMode()) { masterPageLabel->setText( tr( "Master Page:" ) ); masterPageComboBox = new QComboBox( groupMaster ); QString Nam = doc->currentPage()->MPageNam; QString na = Nam == CommonStrings::masterPageNormal ? CommonStrings::trMasterPageNormal : Nam, in; int cc = 0; for (QMap<QString,int>::Iterator it = doc->MasterNames.begin(); it != doc->MasterNames.end(); ++it) { in = it.key() == CommonStrings::masterPageNormal ? CommonStrings::trMasterPageNormal : it.key(); masterPageComboBox->addItem(in); if (in == na) masterPageComboBox->setCurrentIndex(cc); ++cc; } masterLayout->addWidget( masterPageComboBox ); pageFillColor = QColor(); } else { masterPageComboBox = NULL; masterPageLabel->setText( tr( "Page Marker Color:" ) ); QPixmap pm(100, 30); pm.fill(doc->currentPage()->getMarkColor()); pageFillColor = doc->currentPage()->getMarkColor(); pageFillColorButton = new QPushButton(this); pageFillColorButton->setText( QString::null ); pageFillColorButton->setIcon(pm); masterLayout->addWidget( pageFillColorButton ); connect(pageFillColorButton, SIGNAL(clicked()), this, SLOT(changeMarkerColor())); } dialogLayout->addWidget( groupMaster ); okCancelLayout = new QHBoxLayout; okCancelLayout->setSpacing( 5 ); okCancelLayout->setMargin( 0 ); QSpacerItem* spacer = new QSpacerItem( 2, 2, QSizePolicy::Expanding, QSizePolicy::Minimum ); okCancelLayout->addItem( spacer ); okButton = new QPushButton( CommonStrings::tr_OK, this ); okButton->setDefault( true ); okCancelLayout->addWidget(okButton); cancelButton = new QPushButton( CommonStrings::tr_Cancel, this ); cancelButton->setDefault( false ); okCancelLayout->addWidget(cancelButton); dialogLayout->addLayout( okCancelLayout ); setMaximumSize(sizeHint()); pageWidth = widthSpinBox->value() / unitRatio; pageHeight = heightSpinBox->value() / unitRatio; if (sizeQComboBox->currentText() == CommonStrings::trCustomPageSize) { heightSpinBox->setEnabled( true ); widthSpinBox->setEnabled( true ); } else { heightSpinBox->setEnabled( false ); widthSpinBox->setEnabled( false ); } delete ps; // signals and slots connections connect( okButton, SIGNAL( clicked() ), this, SLOT( accept() ) ); connect( cancelButton, SIGNAL( clicked() ), this, SLOT( reject() ) ); connect(orientationQComboBox, SIGNAL(activated(int)), this, SLOT(setOrien(int))); connect(sizeQComboBox, SIGNAL(activated(const QString &)), this, SLOT(setPageSize())); connect(widthSpinBox, SIGNAL(valueChanged(double)), this, SLOT(setPageWidth(double))); connect(heightSpinBox, SIGNAL(valueChanged(double)), this, SLOT(setPageHeight(double))); //tooltips sizeQComboBox->setToolTip( tr( "Size of the inserted pages, either a standard or custom size" ) ); orientationQComboBox->setToolTip( tr( "Orientation of the page(s) to be inserted" ) ); widthSpinBox->setToolTip( tr( "Width of the page(s) to be inserted" ) ); heightSpinBox->setToolTip( tr( "Height of the page(s) to be inserted" ) ); moveObjects->setToolTip( tr( "When inserting a new page between others, move objects with their current pages. This is the default action." ) ); setPageSize(); setMinimumSize(minimumSizeHint()); setMaximumSize(minimumSizeHint()); resize(minimumSizeHint()); }
QValueList<int> KPrinter::pageList() const { QValueList<int> list; int mp(minPage()), MP(maxPage()); if (mp > 0 && MP > 0 && MP >= mp) { // do something only if bounds specified if (option("kde-current") == "1") { // print only current page int pp = currentPage(); if (pp >= mp && pp <= MP) list.append(pp); } else { // process range specification if (!option("kde-range").isEmpty()) { QStringList ranges = QStringList::split(',',option("kde-range"),false); for (QStringList::ConstIterator it=ranges.begin();it!=ranges.end();++it) { int p = (*it).find('-'); bool ok; if (p == -1) { int pp = (*it).toInt(&ok); if (ok && pp >= mp && pp <= MP) list.append(pp); } else { int p1(0), p2(0); p1 = (*it).left(p).toInt(&ok); if (ok) p2 = (*it).right((*it).length()-p-1).toInt(&ok); if (ok && p1 <= p2) { // clip to min/max p1 = QMAX(mp,p1); p2 = QMIN(MP,p2); for (int i=p1;i<=p2;i++) list.append(i); } } } } else { // add all pages between min and max for (int i=mp;i<=MP;i++) list.append(i); } // revert the list if needed if (pageOrder() == LastPageFirst) { for (uint i=0;i<(list.count()/2);i++) qSwap(list[i],list[list.count()-1-i]); } // select page set if needed if (pageSet() != AllPages) { bool keepEven = (pageSet() == EvenPages); for (QValueList<int>::Iterator it=list.begin();it!=list.end();) if ((((*it) % 2) != 0 && keepEven) || (((*it) % 2) == 0 && !keepEven)) it = list.remove(it); else ++it; } } } return list; }
NewTm::NewTm( QWidget* parent, QString text, QString titel, ScribusDoc *doc, const QString& answerText) : QDialog( parent ) { setModal(true); setWindowTitle(titel); setWindowIcon(IconManager::instance()->loadIcon("AppIcon.png")); QueryLayout = new QVBoxLayout( this ); QueryLayout->setSpacing( 5 ); QueryLayout->setMargin( 5 ); Layout2 = new QHBoxLayout; Layout2->setSpacing( 5 ); Layout2->setMargin( 0 ); Answer = new QLineEdit( this ); Frage = new QLabel( text, this ); Frage->setBuddy(Answer); // Qt4 Frage->setFrameShape( QLabel::MShape ); // Qt4 Frage->setFrameShadow( QLabel::MShadow ); Frage->adjustSize(); Layout2->addWidget( Frage ); Layout2->addWidget( Answer ); QueryLayout->addLayout( Layout2 ); if (doc->pagePositioning() != singlePage) { Layout3 = new QHBoxLayout; Layout3->setSpacing( 5 ); Layout3->setMargin( 0 ); Links = new QComboBox( this ); QStringList::Iterator pNames; QList<PageSet> pageSet(doc->pageSets()); for(pNames = pageSet[doc->pagePositioning()].pageNames.begin(); pNames != pageSet[doc->pagePositioning()].pageNames.end(); ++pNames ) { //Links->insertItem((*pNames)); Links->addItem(CommonStrings::translatePageSetLocString((*pNames))); } if (doc->currentPage()->LeftPg == 1) Links->setCurrentIndex(0); else if (doc->currentPage()->LeftPg == 0) Links->setCurrentIndex(Links->count()-1); else Links->setCurrentIndex(doc->currentPage()->LeftPg-1); Links->setEditable(false); Layout3->addWidget( Links ); QueryLayout->addLayout( Layout3 ); } Layout1 = new QHBoxLayout; Layout1->setSpacing( 5 ); Layout1->setMargin( 0 ); QSpacerItem* spacer = new QSpacerItem( 2, 2, QSizePolicy::Expanding, QSizePolicy::Minimum ); Layout1->addItem( spacer ); PushButton1 = new QPushButton( CommonStrings::tr_OK, this ); PushButton1->setDefault( true ); Layout1->addWidget( PushButton1 ); PushButton2 = new QPushButton( CommonStrings::tr_Cancel, this ); Layout1->addWidget( PushButton2 ); QueryLayout->addLayout( Layout1 ); if (!answerText.isEmpty()) { Answer->setText(answerText); Answer->setMinimumWidth(sizeHint().width()); Answer->selectAll(); } setMinimumSize(sizeHint()); Answer->setFocus(); // signals and slots connections connect( PushButton1, SIGNAL( clicked() ), this, SLOT( accept() ) ); connect( PushButton2, SIGNAL( clicked() ), this, SLOT( reject() ) ); }