void ScripterCore::ReadPlugPrefs() { PrefsContext* prefs = PrefsManager::instance()->prefsFile->getPluginContext("scriptplugin"); if (!prefs) { qDebug("scriptplugin: Unable to load prefs"); return; } PrefsTable* prefRecentScripts = prefs->getTable("recentscripts"); if (!prefRecentScripts) { qDebug("scriptplugin: Unable to get recent scripts"); return; } // Load recent scripts from the prefs for (int i = 0; i < prefRecentScripts->getRowCount(); i++) { QString rs(prefRecentScripts->get(i,0)); SavedRecentScripts.append(rs); } // then get more general preferences m_enableExtPython = prefs->getBool("extensionscripts",false); m_importAllNames = prefs->getBool("importall",true); m_startupScript = prefs->get("startupscript", QString::null); // and have the console window set up its position }
void gradientManagerDialog::loadGradients() { QString fileName; QString allFormats = tr("All Supported Formats")+" ("; allFormats += "*.sgr *.SGR"; allFormats += " *.ggr *.GGR"; allFormats += ");;"; QString formats = tr("Scribus Gradient Files \"*.sgr\" (*.sgr *.SGR);;"); formats += tr("Gimp Gradient Files \"*.ggr\" (*.ggr *.GGR);;"); formats += tr("All Files (*)"); allFormats += formats; PrefsContext* dirs = PrefsManager::instance()->prefsFile->getContext("dirs"); QString wdir = dirs->get("gradients", "."); CustomFDialog dia(this, wdir, tr("Open"), allFormats, fdHidePreviewCheckBox | fdExistingFiles); if (dia.exec() == QDialog::Accepted) fileName = dia.selectedFile(); else return; if (!fileName.isEmpty()) { PrefsManager::instance()->prefsFile->getContext("dirs")->set("gradients", fileName.left(fileName.lastIndexOf("/"))); QFileInfo fi(fileName); QString ext = fi.suffix().toLower(); if (ext == "sgr") loadScribusFormat(fileName); else if (ext == "ggr") loadGimpFormat(fileName); updateGradientList(); } }
bool ScPrintEngine_GDI::print( ScribusDoc& doc, PrintOptions& options ) { bool toFile; bool success; HDC printerDC; QString diaSelection, docDir, prefsDocDir; QString printerName = options.printer; QByteArray devMode = options.devMode; QString fileName; if( options.toFile ) return false; resetData(); toFile = printerUseFilePort( options.printer ); if ( toFile ) { diaSelection = doc.DocName.right( doc.DocName.length() - doc.DocName.lastIndexOf("/") - 1 ); diaSelection = diaSelection.left( diaSelection.indexOf(".") ); diaSelection += ".prn"; PrefsContext* dirs = PrefsManager::instance()->prefsFile->getContext("dirs"); QString prefsDocDir = PrefsManager::instance()->documentDir(); if (!prefsDocDir.isEmpty()) docDir = dirs->get("winprn", prefsDocDir); else docDir = "."; CustomFDialog dia( doc.scMW()->view, docDir, QObject::tr("Save As"), "Spool Files (*.prn *.ps);;All Files (*)", fdNone); dia.setSelection( diaSelection ); if (dia.exec() == QDialog::Accepted) { QString selectedFile = dia.selectedFile(); if ( overwrite(doc.scMW()->view, selectedFile) ) { dirs->set("winprn", selectedFile.left(selectedFile.lastIndexOf("/"))); fileName = QDir::toNativeSeparators( selectedFile ); } } else return true; } // Set user options in the DEVmode structure setDeviceParams( &doc, options, (DEVMODEW*) devMode.data() ); // Create the device context printerDC = CreateDCW( NULL, (LPCWSTR) printerName.utf16(), NULL, (DEVMODEW*) devMode.data() ); if( printerDC ) { success = printPages( &doc, options, printerDC, (DEVMODEW*) devMode.data(), fileName); DeleteDC( printerDC ); } else { qWarning("doPrintPages : the device context could not be created"); success = false; } return success; }
void Prefs_KeyboardShortcuts::importKeySetFile() { PrefsContext* dirs = PrefsManager::instance()->prefsFile->getContext("dirs"); QString currentPath = dirs->get("keymapprefs_import", ScPaths::instance().shareDir() + "keysets/"); QString s = QFileDialog::getOpenFileName(this, tr("Select a Key set file to read"), currentPath, tr("Key Set XML Files (*.xml)")); if (!s.isEmpty()) importKeySet(s); }
void Prefs_KeyboardShortcuts::exportKeySetFile() { PrefsContext* dirs = PrefsManager::instance()->prefsFile->getContext("dirs"); QString currentPath= dirs->get("keymapprefs_export", "."); QString s = QFileDialog::getSaveFileName(this, tr("Select a Key set file to save to"), currentPath, tr("Key Set XML Files (*.xml)") ); if (!s.isEmpty()) exportKeySet(s); }
void MenuSAT::RunSATPlug(ScribusDoc* doc) { QDir templates(ScPaths::getApplicationDataDir()); if (!templates.exists("templates")) { templates.mkdir("templates"); } QString currentPath(QDir::currentPath()); QString currentFile(doc->DocName); bool hasName = doc->hasName; bool isModified = doc->isModified(); QString userTemplatesDir = PrefsManager::instance()->appPrefs.pathPrefs.documentTemplates; PrefsContext* dirs = PrefsManager::instance()->prefsFile->getContext("dirs"); QString oldCollect = dirs->get("collect", "."); QString templatesDir = "."; if (userTemplatesDir.isEmpty()) templatesDir = ScPaths::getApplicationDataDir() + "templates"; else { if (userTemplatesDir.right(1) == "/") userTemplatesDir.chop(1); templatesDir = userTemplatesDir; } dirs->set("collect", templatesDir); if (doc->scMW()->fileCollect().isEmpty()) return; if (oldCollect != ".") dirs->set("collect", oldCollect); QString docPath = doc->DocName; QString docDir = docPath.left(docPath.lastIndexOf('/')); QString docName = docPath.right(docPath.length() - docPath.lastIndexOf('/') - 1); docName = docName.left(docName.lastIndexOf(".s")); if (currentFile != doc->DocName) { SATDialog* satdia = new SATDialog(doc->scMW(),docName, static_cast<int>(doc->pageWidth() + 0.5), static_cast<int>(doc->pageHeight() + 0.5)); if (satdia->exec()) { sat* s = new sat(doc, satdia, docPath.right(docPath.length() - docPath.lastIndexOf('/') - 1),docDir); s->createImages(); s->createTmplXml(); delete s; } // Restore the state that was before ScMW->Collect() doc->DocName = currentFile; doc->hasName = hasName; doc->setModified(isModified); QString newCaption=currentFile; if (isModified) newCaption.append('*'); doc->scMW()->updateActiveWindowCaption(newCaption); doc->scMW()->removeRecent(docPath); QDir::setCurrent(currentPath); delete satdia; } }
bool WMFImportPlugin::import(QString filename, int flags) { if (!checkFlags(flags)) return false; if (m_Doc == nullptr) m_Doc = ScCore->primaryMainWindow()->doc; ScribusMainWindow* mw=(m_Doc==nullptr) ? ScCore->primaryMainWindow() : m_Doc->scMW(); if (filename.isEmpty()) { flags |= lfInteractive; PrefsContext* prefs = PrefsManager::instance()->prefsFile->getPluginContext("WMFPlugin"); QString wdir = prefs->get("wdir", "."); CustomFDialog diaf(mw, wdir, QObject::tr("Open"), FormatsManager::instance()->fileDialogFormatList(FormatsManager::WMF)); if (diaf.exec()) { filename = diaf.selectedFile(); prefs->set("wdir", filename.left(filename.lastIndexOf("/"))); } else return true; } bool hasCurrentPage = (m_Doc && m_Doc->currentPage()); TransactionSettings trSettings; trSettings.targetName = hasCurrentPage ? m_Doc->currentPage()->getUName() : ""; trSettings.targetPixmap = Um::IImageFrame; trSettings.actionName = Um::ImportWMF; trSettings.description = filename; trSettings.actionPixmap = Um::IWMF; UndoTransaction activeTransaction; if ((m_Doc == nullptr) || !(flags & lfInteractive) || !(flags & lfScripted)) UndoManager::instance()->setUndoEnabled(false); if (UndoManager::undoEnabled()) activeTransaction = UndoManager::instance()->beginTransaction(trSettings); WMFImport *dia = new WMFImport(m_Doc, flags); dia->import(filename, trSettings, flags); Q_CHECK_PTR(dia); if (activeTransaction) activeTransaction.commit(); if ((m_Doc == nullptr) || !(flags & lfInteractive) || !(flags & lfScripted)) UndoManager::instance()->setUndoEnabled(true); if (dia->importCanceled) { if (dia->importFailed) ScMessageBox::warning(mw, CommonStrings::trWarning, tr("The file could not be imported")); else if (dia->unsupported) ScMessageBox::warning(mw, CommonStrings::trWarning, tr("WMF file contains some unsupported features")); } bool success = !dia->importFailed; delete dia; return success; }
void PDFExportDialog::ChangeFile() { PrefsContext* dirs = PrefsManager::instance()->prefsFile->getContext("dirs"); QString wdir = dirs->get("pdf", "."); QString d = QFileDialog::getSaveFileName(this, tr("Save As"), wdir, tr("PDF Files (*.pdf);;All Files (*)"), 0, QFileDialog::DontConfirmOverwrite); if (d.length()>0) { QString fn(QDir::fromNativeSeparators(d)); dirs->set("pdf", fn.left(fn.lastIndexOf("/"))); fileNameLineEdit->setText( d ); } }
void PrintDialog::SelFile() { PrefsContext* dirs = PrefsManager::instance()->prefsFile->getContext("dirs"); QString wdir = dirs->get("printdir", "."); CustomFDialog dia(this, wdir, tr("Save As"), tr("PostScript Files (*.ps);;All Files (*)"), fdNone | fdHidePreviewCheckBox); if (!LineEdit1->text().isEmpty()) dia.setSelection(LineEdit1->text()); if (dia.exec() == QDialog::Accepted) { QString selectedFile = dia.selectedFile(); dirs->set("printdir", selectedFile.left(selectedFile.lastIndexOf("/"))); LineEdit1->setText( QDir::toNativeSeparators(selectedFile) ); } }
void NewDoc::createOpenDocPage() { PrefsContext* docContext = prefsManager->prefsFile->getContext("docdirs", false); QString docDir = "."; QString prefsDocDir=prefsManager->documentDir(); if (!prefsDocDir.isEmpty()) docDir = docContext->get("docsopen", prefsDocDir); else docDir = docContext->get("docsopen", "."); QString formats(FileLoader::getLoadFilterString()); // formats.remove("PDF (*.pdf *.PDF);;"); openDocFrame = new QFrame(this); openDocLayout = new QVBoxLayout(openDocFrame); openDocLayout->setMargin(5); openDocLayout->setSpacing(5); m_selectedFile = ""; fileDialog = new QFileDialog(openDocFrame, tr("Open"), docDir, formats); fileDialog->setFileMode(QFileDialog::ExistingFile); fileDialog->setAcceptMode(QFileDialog::AcceptOpen); fileDialog->setOption(QFileDialog::DontUseNativeDialog); fileDialog->setNameFilterDetailsVisible(false); fileDialog->setReadOnly(true); fileDialog->setSizeGripEnabled(false); fileDialog->setModal(false); QList<QPushButton *> b = fileDialog->findChildren<QPushButton *>(); QListIterator<QPushButton *> i(b); while (i.hasNext()) i.next()->setVisible(false); fileDialog->setWindowFlags(Qt::Widget); openDocLayout->addWidget(fileDialog); FileDialogEventCatcher* keyCatcher = new FileDialogEventCatcher(this); QList<QListView *> lv = fileDialog->findChildren<QListView *>(); QListIterator<QListView *> lvi(lv); while (lvi.hasNext()) lvi.next()->installEventFilter(keyCatcher); connect(keyCatcher, SIGNAL(escapePressed()), this, SLOT(reject())); connect(keyCatcher, SIGNAL(dropLocation(QString)), this, SLOT(locationDropped(QString))); connect(keyCatcher, SIGNAL(desktopPressed()), this, SLOT(gotoDesktopDirectory())); connect(keyCatcher, SIGNAL(homePressed()), this, SLOT(gotoHomeDirectory())); connect(keyCatcher, SIGNAL(parentPressed()), this, SLOT(gotoParentDirectory())); connect(keyCatcher, SIGNAL(enterSelectedPressed()), this, SLOT(gotoSelectedDirectory())); connect(fileDialog, SIGNAL(filesSelected(const QStringList &)), this, SLOT(openFile())); connect(fileDialog, SIGNAL(rejected()), this, SLOT(reject())); }
bool ImportXfigPlugin::import(QString fileName, int flags) { if (!checkFlags(flags)) return false; if( fileName.isEmpty() ) { flags |= lfInteractive; PrefsContext* prefs = PrefsManager::instance()->prefsFile->getPluginContext("importxfig"); QString wdir = prefs->get("wdir", "."); CustomFDialog diaf(ScCore->primaryMainWindow(), wdir, QObject::tr("Open"), tr("All Supported Formats")+" (*.fig *.FIG);;All Files (*)"); if (diaf.exec()) { fileName = diaf.selectedFile(); prefs->set("wdir", fileName.left(fileName.lastIndexOf("/"))); } else return true; } m_Doc=ScCore->primaryMainWindow()->doc; UndoTransaction* activeTransaction = NULL; bool emptyDoc = (m_Doc == NULL); bool hasCurrentPage = (m_Doc && m_Doc->currentPage()); TransactionSettings trSettings; trSettings.targetName = hasCurrentPage ? m_Doc->currentPage()->getUName() : ""; trSettings.targetPixmap = Um::IImageFrame; trSettings.actionName = Um::ImportXfig; trSettings.description = fileName; trSettings.actionPixmap = Um::IXFIG; if (emptyDoc || !(flags & lfInteractive) || !(flags & lfScripted)) UndoManager::instance()->setUndoEnabled(false); if (UndoManager::undoEnabled()) activeTransaction = new UndoTransaction(UndoManager::instance()->beginTransaction(trSettings)); XfigPlug *dia = new XfigPlug(m_Doc, flags); Q_CHECK_PTR(dia); dia->import(fileName, trSettings, flags); if (activeTransaction) { activeTransaction->commit(); delete activeTransaction; activeTransaction = NULL; } if (emptyDoc || !(flags & lfInteractive) || !(flags & lfScripted)) UndoManager::instance()->setUndoEnabled(true); delete dia; return true; }
void PDFExportDialog::ChangeFile() { QString fn; PrefsContext* dirs = PrefsManager::instance()->prefsFile->getContext("dirs"); QString wdir = dirs->get("pdf", "."); CustomFDialog dia(this, wdir, tr("Save As"), tr("PDF Files (*.pdf);;All Files (*)"), fdNone); if (!fileNameLineEdit->text().isEmpty()) { QString fileName = QDir::fromNativeSeparators(fileNameLineEdit->text()); dia.setSelection(fileName); } if (dia.exec() == QDialog::Accepted) { // selectedFile() may return path with native separators fn = QDir::fromNativeSeparators(dia.selectedFile()); dirs->set("pdf", fn.left(fn.lastIndexOf("/"))); fileNameLineEdit->setText( QDir::toNativeSeparators(fn) ); } }
bool ImportPSPlugin::import(QString fileName, int flags) { if (!checkFlags(flags)) return false; if( fileName.isEmpty() ) { flags |= lfInteractive; PrefsContext* prefs = PrefsManager::instance()->prefsFile->getPluginContext("importps"); QString wdir = prefs->get("wdir", "."); CustomFDialog diaf(ScCore->primaryMainWindow(), wdir, QObject::tr("Open"), FormatsManager::instance()->fileDialogFormatList(FormatsManager::EPS|FormatsManager::PS)); if (diaf.exec()) { fileName = diaf.selectedFile(); prefs->set("wdir", fileName.left(fileName.lastIndexOf("/"))); } else return true; } m_Doc=ScCore->primaryMainWindow()->doc; UndoTransaction activeTransaction; bool emptyDoc = (m_Doc == nullptr); bool hasCurrentPage = (m_Doc && m_Doc->currentPage()); TransactionSettings trSettings; trSettings.targetName = hasCurrentPage ? m_Doc->currentPage()->getUName() : ""; trSettings.targetPixmap = Um::IImageFrame; trSettings.actionName = Um::ImportEPS; trSettings.description = fileName; trSettings.actionPixmap = Um::IEPS; if (emptyDoc || !(flags & lfInteractive) || !(flags & lfScripted)) UndoManager::instance()->setUndoEnabled(false); if (UndoManager::undoEnabled()) activeTransaction = UndoManager::instance()->beginTransaction(trSettings); EPSPlug *dia = new EPSPlug(m_Doc, flags); Q_CHECK_PTR(dia); dia->import(fileName, trSettings, flags); if (activeTransaction) activeTransaction.commit(); if (emptyDoc || !(flags & lfInteractive) || !(flags & lfScripted)) UndoManager::instance()->setUndoEnabled(true); delete dia; return true; }
void Annota::GetFile() { QString fn; PrefsContext* dirs = PrefsManager::instance()->prefsFile->getContext("dirs"); QString wdir = dirs->get("annot_getfile", "."); CustomFDialog dia(this, wdir, tr("Open"), tr("%1;;All Files (*)").arg(FormatsManager::instance()->extensionsForFormat(FormatsManager::PDF))); if (!Destfile->text().isEmpty()) dia.setSelection(Destfile->text()); if (dia.exec() == QDialog::Accepted) { fn = dia.selectedFile(); if (!fn.isEmpty()) { dirs->set("annot_getfile", fn.left(fn.lastIndexOf("/"))); Destfile->setText(fn); SpinBox1->setValue(1); SpinBox1->setMaximum(1000); SetPage(1); } } }
void ScripterCore::SavePlugPrefs() { PrefsContext* prefs = PrefsManager::instance()->prefsFile->getPluginContext("scriptplugin"); if (!prefs) { qDebug("scriptplugin: Unable to load prefs"); return; } PrefsTable* prefRecentScripts = prefs->getTable("recentscripts"); if (!prefRecentScripts) { qDebug("scriptplugin: Unable to get recent scripts"); return; } for (int i = 0; i < RecentScripts.count(); i++) prefRecentScripts->set(i, 0, RecentScripts[i]); // then save more general preferences prefs->set("extensionscripts", m_enableExtPython); prefs->set("importall", m_importAllNames); prefs->set("startupscript", m_startupScript); }
bool gtDialogs::runFileDialog(const QString& filters, const QStringList& importers) { bool accepted = false; PrefsContext* dirs = PrefsManager::instance()->prefsFile->getContext("dirs"); QString dir = dirs->get("get_text", "."); fdia = new gtFileDialog(filters, importers, dir); if (fdia->exec() == QDialog::Accepted) { fileName = fdia->selectedFile(); if (!fileName.isEmpty()) accepted = true; encoding = fdia->encodingCombo->currentText(); // if (encoding == "UTF-16") // encoding = "ISO-10646-UCS-2"; importer = fdia->importerCombo->currentIndex() - 1; dirs->set("get_text", fileName.left(fileName.lastIndexOf("/"))); } QDir::setCurrent(pwd); return accepted; }
XtgIm::XtgIm(QString fileName, QString enc, PageItem *textItem, bool textOnly) { PrefsContext* prefs = PrefsManager::instance()->prefsFile->getPluginContext("XtgIm"); bool prefix = prefs->getBool("prefix", true); bool ask = prefs->getBool("askAgain", true); encoding = enc; qDebug()<<"Encoding = "<<encoding; in_Buffer = ""; TextWriter *writer = new TextWriter(textItem->doc()); writer->open(textItem); if (!textOnly) { if (ask) { XtgDialog* xtgdia = new XtgDialog(prefix); if (xtgdia->exec()) { prefix = xtgdia->usePrefix(); prefs->set("prefix", xtgdia->usePrefix()); prefs->set("askAgain", xtgdia->askAgain()); delete xtgdia; } else { delete xtgdia; return; } } } filename = fileName; /** This will load the xtg file into a QByte Array which will be used for furthur parsing */ loadFiletoArray(); in_Buffer = toUnicode(buffer); QString docname = filename.right(filename.length() - filename.lastIndexOf("/") - 1); docname = docname.left(docname.lastIndexOf(".")); XtgScanner *scanner = new XtgScanner(docname,writer,in_Buffer,textOnly,prefix); scanner->xtgParse(); writer->close(); }
int callGS(const QStringList& args_in, const QString device) { QString cmd; QStringList args; PrefsManager* prefsManager = PrefsManager::instance(); args.append( "-q" ); args.append( "-dNOPAUSE" ); args.append( "-dQUIET" ); args.append( "-dPARANOIDSAFER" ); args.append( "-dBATCH" ); // Choose rendering device if (!device.isEmpty()) args.append( QString("-sDEVICE=%1").arg(device) ); // user specified device else if (!ScCore->havePNGAlpha()) args.append( "-sDEVICE=png16m" ); else args.append( "-sDEVICE=pngalpha" ); // and antialiasing if (prefsManager->appPrefs.extToolPrefs.gs_AntiAliasText) args.append( "-dTextAlphaBits=4" ); if (prefsManager->appPrefs.extToolPrefs.gs_AntiAliasGraphics) args.append( "-dGraphicsAlphaBits=4" ); // Add any extra font paths being used by Scribus to gs's font search path PrefsContext *pc = PrefsManager::instance()->prefsFile->getContext("Fonts"); PrefsTable *extraFonts = pc->getTable("ExtraFontDirs"); const char sep = ScPaths::envPathSeparator; if (extraFonts->getRowCount() >= 1) cmd = QString("-sFONTPATH=%1").arg(QDir::convertSeparators(extraFonts->get(0,0))); for (int i = 1; i < extraFonts->getRowCount(); ++i) cmd += QString("%1%2").arg(sep).arg(QDir::convertSeparators(extraFonts->get(i,0))); if( !cmd.isEmpty() ) args.append( cmd ); args += args_in; args.append("-c"); args.append("showpage"); // qDebug(args.join(" ").toAscii()); return System( getShortPathName(prefsManager->ghostscriptExecutable()), args ); }
int callGS(const QString& args_in, const QString device) { PrefsManager* prefsManager=PrefsManager::instance(); QString cmd1 = getShortPathName(prefsManager->ghostscriptExecutable()); cmd1 += " -q -dNOPAUSE -dQUIET -dPARANOIDSAFER -dBATCH"; // Choose rendering device if (!device.isEmpty()) // user specified device cmd1 += " -sDEVICE="+device; else if (!ScCore->havePNGAlpha()) cmd1 += " -sDEVICE=png16m"; else cmd1 += " -sDEVICE=pngalpha"; // and antialiasing if (prefsManager->appPrefs.extToolPrefs.gs_AntiAliasText) cmd1 += " -dTextAlphaBits=4"; if (prefsManager->appPrefs.extToolPrefs.gs_AntiAliasGraphics) cmd1 += " -dGraphicsAlphaBits=4"; // Add any extra font paths being used by Scribus to gs's font search path PrefsContext *pc = PrefsManager::instance()->prefsFile->getContext("Fonts"); PrefsTable *extraFonts = pc->getTable("ExtraFontDirs"); #ifndef _WIN32 if (extraFonts->getRowCount() >= 1) cmd1 += QString(" -sFONTPATH='%1'").arg(extraFonts->get(0,0)); for (int i = 1; i < extraFonts->getRowCount(); ++i) cmd1 += QString(":'%1'").arg(extraFonts->get(i,0)); #else if (extraFonts->getRowCount() >= 1) cmd1 += QString(" -sFONTPATH=\"%1\"").arg(extraFonts->get(0,0)); for (int i = 1; i < extraFonts->getRowCount(); ++i) cmd1 += QString(";\"%1\"").arg(extraFonts->get(i,0)); #endif // then add any user specified args and run gs cmd1 += " " + args_in + " -c showpage"; // qDebug("Calling gs as: %s", cmd1.ascii()); return system(cmd1.toLocal8Bit().constData()); }
void NewDoc::createOpenDocPage() { PrefsContext* docContext = prefsManager->prefsFile->getContext("docdirs", false); QString docDir = "."; QString prefsDocDir=prefsManager->documentDir(); if (!prefsDocDir.isEmpty()) docDir = docContext->get("docsopen", prefsDocDir); else docDir = docContext->get("docsopen", "."); QString formats(FileLoader::getLoadFilterString()); formats.remove("PDF (*.pdf *.PDF);;"); openDocFrame = new QFrame(this); openDocLayout = new QVBoxLayout(openDocFrame); openDocLayout->setMargin(5); openDocLayout->setSpacing(5); m_selectedFile = ""; #if QT_VERSION >= 0x040300 fileDialog = new QFileDialog(openDocFrame, tr("Open"), docDir, formats); fileDialog->setFileMode(QFileDialog::ExistingFile); fileDialog->setAcceptMode(QFileDialog::AcceptOpen); fileDialog->setReadOnly(true); #else fileDialog = new CustomFDialog(openDocFrame, docDir, tr("Open"), formats, fdNone); #endif fileDialog->setSizeGripEnabled(false); fileDialog->setModal(false); QList<QPushButton *> b = fileDialog->findChildren<QPushButton *>(); QListIterator<QPushButton *> i(b); while (i.hasNext()) i.next()->setVisible(false); fileDialog->setWindowFlags(Qt::Widget); openDocLayout->addWidget(fileDialog); #if QT_VERSION >= 0x040300 connect(fileDialog, SIGNAL(filesSelected(const QStringList &)), this, SLOT(openFile())); #else connect(fileDialog, SIGNAL(fileSelected (const QString &)), this, SLOT(openFile())); #endif }
void CurveWidget::doLoad() { QString fileName; PrefsContext* dirs = PrefsManager::instance()->prefsFile->getContext("dirs"); QString wdir = dirs->get("curves", "."); CustomFDialog dia(this, wdir, tr("Open"), tr("Curve Files (*.scu *.SCU);;All Files (*)"), fdHidePreviewCheckBox | fdExistingFiles); if (dia.exec() == QDialog::Accepted) fileName = dia.selectedFile(); else return; if (!fileName.isEmpty()) { dirs->set("curves", fileName.left(fileName.lastIndexOf("/"))); QFile f(fileName); if (f.open(QIODevice::ReadOnly)) { QTextStream fp(&f); int numVals; double xval, yval; FPointArray curve; curve.resize(0); fp >> numVals; for (int nv = 0; nv < numVals; nv++) { QString s; fp >> s; xval = ScCLocale::toDoubleC(s); fp >> s; yval = ScCLocale::toDoubleC(s); curve.addPoint(xval, yval); } cDisplay->setCurve(curve); int lin; fp >> lin; cDisplay->setLinear(lin); }
void Prefs_Printer::restoreDefaults(struct ApplicationPrefs *prefsData) { int docUnitIndex = prefsData->docSetupPrefs.docUnitIndex; unitChange(docUnitIndex); double unitRatio = unitGetRatioFromIndex(docUnitIndex); QString Pcap; QString printerName; QStringList printerNames = PrinterUtil::getPrinterNames(); int numPrinters = printerNames.count(); destinationComboBox->clear(); for( int i = 0; i < numPrinters; i++) { printerName = printerNames[i]; destinationComboBox->addItem(printerName); } destinationComboBox->addItem( tr("File")); PrefsContext* prefs = PrefsManager::instance()->prefsFile->getContext("print_options"); QString selectedDest = prefs->get("CurrentPrn", ""); int prnIndex = destinationComboBox->findText(selectedDest); if ((prnIndex > -1) && (prnIndex < destinationComboBox->count())) destinationComboBox->setCurrentIndex(prnIndex); useAltPrinterCmdCheckBox->setChecked(prefs->getBool("OtherCom", false)); selOtherComm(); altPrinterCmdLineEdit->setText(prefs->get("Command", "")); outputComboBox->setCurrentIndex(prefs->getInt("Separations", 0)); postscriptPrintToColorComboBox->setCurrentIndex(prefs->getInt("PrintColor", 0)); postscriptLevelComboBox->setCurrentIndex(prefs->getInt("PSLevel", 3)-1); pageMirrorHorizontallyCheckBox->setChecked(prefs->getBool("MirrorH", false)); pageMirrorVerticallyCheckBox->setChecked(prefs->getBool("MirrorV", false)); setMediaSizeCheckBox->setChecked(prefs->getBool("doDev", false)); applyUnderColorRemovalCheckBox->setChecked(prefs->getBool("DoGCR", false)); clipToPrinterMarginsCheckBox->setChecked(prefs->getBool("Clip", false)); convertSpotsToProcessCheckBox->setChecked(!prefs->getBool("doSpot", true)); MarginStruct bleeds; bleeds.set(prefs->getDouble("BleedTop",0.0), prefs->getDouble("BleedBottom", 0.0), prefs->getDouble("BleedRight", 0.0), prefs->getDouble("BleedLeft", 0.0)); bleedsWidget->setup(bleeds, 0, docUnitIndex, NewMarginWidget::BleedWidgetFlags); bleedsWidget->setPageWidth(prefsData->docSetupPrefs.pageWidth); bleedsWidget->setPageHeight(prefsData->docSetupPrefs.pageHeight); markLengthSpinBox->setValue(prefs->getDouble("markLength", 20.0) * unitRatio); markOffsetSpinBox->setValue(prefs->getDouble("markOffset", 0.0) * unitRatio); cropMarksCheckBox->setChecked(prefs->getBool("cropMarks", false)); bleedMarksCheckBox->setChecked(prefs->getBool("bleedMarks", false)); registrationMarksCheckBox->setChecked(prefs->getBool("registrationMarks", false)); colorBarsCheckBox->setChecked(prefs->getBool("colorMarks", false)); includePDFAnnotationsCheckBox->setChecked(prefs->getBool("includePDFMarks", true)); }
void Prefs_Printer::saveGuiToPrefs(struct ApplicationPrefs *prefsData) const { PrefsContext* prefs = PrefsManager::instance()->prefsFile->getContext("print_options"); prefs->set("CurrentPrn", destinationComboBox->currentText()); prefs->set("OtherCom", useAltPrinterCmdCheckBox->isChecked()); prefs->set("Command", altPrinterCmdLineEdit->text()); prefs->set("PrintAll", true); prefs->set("CurrentPage", false); prefs->set("PrintRange", false); prefs->set("PageNr", ""); prefs->set("Copies", 1); prefs->set("Separations", static_cast<int>(outputComboBox->currentIndex()==1)); //FIXME: This comparison looks wrong. prefs->set("PrintColor", static_cast<int>(!(postscriptPrintToColorComboBox->currentIndex()==0))); prefs->set("SepArt", 0); prefs->set("MirrorH", pageMirrorHorizontallyCheckBox->isChecked()); prefs->set("MirrorV", pageMirrorVerticallyCheckBox->isChecked()); prefs->set("DoGCR", applyUnderColorRemovalCheckBox->isChecked()); prefs->set("Clip", clipToPrinterMarginsCheckBox->isChecked()); prefs->set("PSLevel", postscriptLevelComboBox->currentIndex() + 1); prefs->set("doDev", setMediaSizeCheckBox->isChecked()); prefs->set("doSpot", !convertSpotsToProcessCheckBox->isChecked()); prefs->set("ICCinUse", true); double unitRatio = unitGetRatioFromIndex(prefsData->docSetupPrefs.docUnitIndex); MarginStruct bleeds(bleedsWidget->margins()); prefs->set("BleedTop", bleeds.top()); prefs->set("BleedBottom", bleeds.bottom()); prefs->set("BleedRight", bleeds.right()); prefs->set("BleedLeft", bleeds.left()); prefs->set("markLength", markLengthSpinBox->value() / unitRatio); prefs->set("markOffset", markOffsetSpinBox->value() / unitRatio); prefs->set("cropMarks", cropMarksCheckBox->isChecked()); prefs->set("bleedMarks", bleedMarksCheckBox->isChecked()); prefs->set("registrationMarks", registrationMarksCheckBox->isChecked()); prefs->set("colorMarks", colorBarsCheckBox->isChecked()); prefs->set("includePDFMarks", includePDFAnnotationsCheckBox->isChecked()); }
QStringList ScribusQApp::getLang(QString lang) { QStringList langs; // read the locales if (!lang.isEmpty()) langs.push_back(lang); //add in user preferences lang, only overridden by lang command line option QString Pff = QDir::toNativeSeparators(ScPaths::getApplicationDataDir()); QFileInfo Pffi = QFileInfo(Pff); if (Pffi.exists()) { QString PrefsPfad; if (Pffi.isDir()) PrefsPfad = Pff; else PrefsPfad = QDir::homePath(); QString prefsXMLFile=QDir::toNativeSeparators(PrefsPfad + "/prefs140.xml"); QFileInfo infoPrefsFile(prefsXMLFile); if (infoPrefsFile.exists()) { PrefsFile* prefsFile = new PrefsFile(prefsXMLFile); if (prefsFile) { PrefsContext* userprefsContext = prefsFile->getContext("user_preferences"); if (userprefsContext) { QString prefslang = userprefsContext->get("gui_language",""); if (!prefslang.isEmpty()) langs.push_back(prefslang); } } delete prefsFile; } } if (!(lang = ::getenv("LC_ALL")).isEmpty()) langs.push_back(lang); if (!(lang = ::getenv("LC_MESSAGES")).isEmpty()) langs.push_back(lang); if (!(lang = ::getenv("LANG")).isEmpty()) langs.push_back(lang); #if defined(_WIN32) wchar_t out[256]; QString language, sublanguage; LCID lcIdo = GetUserDefaultLCID(); WORD sortId = SORTIDFROMLCID(lcIdo); LANGID langId = GetUserDefaultUILanguage(); LCID lcIdn = MAKELCID(langId, sortId); if ( GetLocaleInfoW(lcIdn, LOCALE_SISO639LANGNAME , out, 255) ) { language = QString::fromUtf16( (ushort*)out ); if ( GetLocaleInfoW(lcIdn, LOCALE_SISO3166CTRYNAME, out, 255) ) { sublanguage = QString::fromUtf16( (ushort*)out ).toLower(); lang = language; if ( sublanguage != language && !sublanguage.isEmpty() ) lang += "_" + sublanguage.toUpper(); langs.push_back(lang); } } #endif langs.push_back(QString(QLocale::system().name())); // remove duplicate entries... QStringList::Iterator it = langs.end(); while (it != langs.begin()) { --it; if (langs.count(*it) > 1) it = langs.erase(it); } return langs; }
bool ImportPdfPlugin::import(QString fileName, int flags) { if (!checkFlags(flags)) return false; if( fileName.isEmpty() ) { flags |= lfInteractive; PrefsContext* prefs = PrefsManager::instance()->prefsFile->getPluginContext("importpdf"); QString wdir = prefs->get("wdir", "."); CustomFDialog diaf(ScCore->primaryMainWindow(), wdir, QObject::tr("Open"), tr("All Supported Formats")+" (*.pdf *.PDF);;All Files (*)"); if (diaf.exec()) { fileName = diaf.selectedFile(); prefs->set("wdir", fileName.left(fileName.lastIndexOf("/"))); } else return true; } m_Doc=ScCore->primaryMainWindow()->doc; UndoTransaction* activeTransaction = NULL; bool emptyDoc = (m_Doc == NULL); bool hasCurrentPage = (m_Doc && m_Doc->currentPage()); TransactionSettings trSettings; trSettings.targetName = hasCurrentPage ? m_Doc->currentPage()->getUName() : ""; trSettings.targetPixmap = Um::IImageFrame; trSettings.actionName = Um::ImportXfig; trSettings.description = fileName; trSettings.actionPixmap = Um::IXFIG; if (emptyDoc || !(flags & lfInteractive) || !(flags & lfScripted)) UndoManager::instance()->setUndoEnabled(false); if (UndoManager::undoEnabled()) activeTransaction = new UndoTransaction(UndoManager::instance()->beginTransaction(trSettings)); bool isCleanedFile = false; QString cleanFile = ""; QFileInfo fi(fileName); QStringList exts = QStringList() << "eps" << "epsf" << "epsi" << "eps2" << "eps3" << "epi" << "ept" << "ps"; if (exts.contains(fi.suffix().toLower())) { if (ScCore->haveGS()) { // Destill the eps/ps with ghostscript to get a clean pdf file bool cancel = false; QString errFile = getShortPathName(ScPaths::getTempFileDir())+ "/ps.err"; cleanFile = getShortPathName(ScPaths::getTempFileDir())+ "/clean.pdf"; QStringList args; args.append( "-q" ); args.append( "-dNOPAUSE" ); args.append( "-sDEVICE=pdfwrite" ); args.append( "-dBATCH" ); args.append( "-dSAFER" ); if (extensionIndicatesEPS(fi.suffix().toLower())) args.append("-dEPSCrop"); args.append("-dCompatibilityLevel=1.4"); args.append( QString("-sOutputFile=%1").arg(QDir::toNativeSeparators(cleanFile)) ); args.append( QDir::toNativeSeparators(fileName) ); System(getShortPathName(PrefsManager::instance()->ghostscriptExecutable()), args, errFile, errFile, &cancel); args.clear(); isCleanedFile = true; } else { qApp->changeOverrideCursor(QCursor(Qt::ArrowCursor)); QMessageBox::warning(ScCore->primaryMainWindow(), CommonStrings::trWarning, tr("The Import plugin cannot handle Postscript files"), 1, 0, 0); qApp->changeOverrideCursor(QCursor(Qt::WaitCursor)); return false; } } PdfPlug *dia = new PdfPlug(m_Doc, flags); Q_CHECK_PTR(dia); if (isCleanedFile) dia->import(cleanFile, trSettings, flags); else dia->import(fileName, trSettings, flags); if (activeTransaction) { activeTransaction->commit(); delete activeTransaction; activeTransaction = NULL; } if (emptyDoc || !(flags & lfInteractive) || !(flags & lfScripted)) UndoManager::instance()->setUndoEnabled(true); delete dia; if (isCleanedFile) QFile::remove(cleanFile); return true; }
PDFExportDialog::PDFExportDialog( QWidget* parent, const QString & docFileName, const QMap<QString, int > & DocFonts, ScribusView *currView, PDFOptions & pdfOptions, const ProfilesL & PDFXProfiles, const SCFonts &AllFonts, const ProfilesL & printerProfiles) : QDialog( parent ), m_doc(currView->Doc), m_opts(pdfOptions), m_unitRatio(currView->Doc->unitRatio()), m_cmsDescriptor(""), m_components(3), m_printerProfiles(printerProfiles) { setModal(true); setWindowTitle( tr( "Save as PDF" ) ); setWindowIcon(loadIcon("AppIcon.png")); PDFExportLayout = new QVBoxLayout( this ); PDFExportLayout->setSpacing( 5 ); PDFExportLayout->setMargin( 10 ); Name = new QGroupBox( this ); Name->setTitle( tr( "O&utput to File:" ) ); NameLayout = new QGridLayout( Name ); NameLayout->setSpacing( 5 ); NameLayout->setMargin( 10 ); NameLayout->setAlignment( Qt::AlignTop ); fileNameLineEdit = new QLineEdit( Name ); fileNameLineEdit->setMinimumSize( QSize( 268, 22 ) ); if (!m_opts.fileName.isEmpty()) fileNameLineEdit->setText( QDir::toNativeSeparators(m_opts.fileName) ); else { QFileInfo fi(docFileName); QString completeBaseName = fi.completeBaseName(); if (completeBaseName.endsWith(".sla", Qt::CaseInsensitive)) if (completeBaseName.length() > 4) completeBaseName.chop(4); if (completeBaseName.endsWith(".gz", Qt::CaseInsensitive)) if (completeBaseName.length() > 3) completeBaseName.chop(3); if (fi.exists()) { QString fileName(fi.path() + "/" + completeBaseName + ".pdf"); fileNameLineEdit->setText( QDir::toNativeSeparators(fileName) ); } else { PrefsContext* dirs = PrefsManager::instance()->prefsFile->getContext("dirs"); QString pdfdir = dirs->get("pdf", fi.path()); if (pdfdir.right(1) != "/") pdfdir += "/"; QString fileName(pdfdir + completeBaseName + ".pdf"); fileNameLineEdit->setText( QDir::toNativeSeparators(fileName) ); } } NameLayout->addWidget( fileNameLineEdit, 0, 0 ); changeButton = new QPushButton( Name ); changeButton->setText( tr( "Cha&nge..." ) ); changeButton->setMinimumSize( QSize( 88, 24 ) ); NameLayout->addWidget( changeButton, 0, 1 ); multiFile = new QCheckBox( tr( "Output one file for eac&h page" ), Name ); multiFile->setChecked(m_opts.doMultiFile); NameLayout->addWidget( multiFile, 1, 0 ); openAfterExportCheckBox = new QCheckBox( tr( "Open PDF after Export" ), Name ); openAfterExportCheckBox->setChecked(m_opts.openAfterExport); NameLayout->addWidget( openAfterExportCheckBox, 2, 0 ); PDFExportLayout->addWidget( Name ); Options = new TabPDFOptions( this, pdfOptions, AllFonts, PDFXProfiles, DocFonts, currView->Doc->unitIndex(), currView->Doc->pageHeight(), currView->Doc->pageWidth(), currView->Doc, true ); PDFExportLayout->addWidget( Options ); Layout7 = new QHBoxLayout; Layout7->setSpacing( 5 ); Layout7->setMargin( 0 ); QSpacerItem* spacer_2 = new QSpacerItem( 2, 2, QSizePolicy::Expanding, QSizePolicy::Minimum ); Layout7->addItem( spacer_2 ); okButton = new QPushButton( tr( "&Save" ), this ); okButton->setAutoDefault( true ); okButton->setDefault( true ); Layout7->addWidget( okButton ); cancelButton = new QPushButton( CommonStrings::tr_Cancel, this ); Layout7->addWidget( cancelButton ); PDFExportLayout->addLayout( Layout7 ); if ((m_opts.Version == PDFOptions::PDFVersion_X3) && (Options->InfoString->text().isEmpty())) okButton->setEnabled(false); resize(sizeHint()); // setMaximumSize( sizeHint() ); //tooltips multiFile->setToolTip( "<qt>" + tr( "This enables exporting one individually named PDF file for each page in the document. Page numbers are added automatically. This is most useful for imposing PDF for commercial printing.") + "</qt>" ); openAfterExportCheckBox->setToolTip( "<qt>" + tr( "Open the exported PDF with the PDF viewer as set in External Tools preferences, when not exporting to a multi-file export destination.") + "</qt>" ); okButton->setToolTip( "<qt>" + tr( "The save button will be disabled if you are trying to export PDF/X and the info string is missing from the PDF/X tab.") + "</qt>" ); // signals and slots connections connect( changeButton, SIGNAL( clicked() ), this, SLOT( ChangeFile() ) ); connect( okButton, SIGNAL( clicked() ), this, SLOT( DoExport() ) ); connect( cancelButton, SIGNAL( clicked() ), this, SLOT( reject() ) ); connect( fileNameLineEdit, SIGNAL( editingFinished() ), this, SLOT( fileNameChanged() ) ); connect( Options, SIGNAL(noInfo()), this, SLOT(disableSave())); connect( Options, SIGNAL(hasInfo()), this, SLOT(enableSave())); }
void Hyphenator::slotHyphenate(PageItem* it) { if (!(it->asTextFrame()) || (it->itemText.length() == 0)) return; m_doc->DoDrawing = false; QString text = ""; int startC = 0; if (it->itemText.selectionLength() > 0) { startC = it->itemText.startOfSelection(); text = it->itemText.text(startC, it->itemText.selectionLength()); } else { text = it->itemText.text(0, it->itemText.length()); } rememberedWords.clear(); qApp->setOverrideCursor(QCursor(Qt::WaitCursor)); BreakIterator* bi = StoryText::getWordIterator(); bi->setText((const UChar*) text.utf16()); int pos = bi->first(); while (pos != BreakIterator::DONE) { int firstC = pos; pos = bi->next(); int lastC = pos; int countC = lastC - firstC; const CharStyle& style = it->itemText.charStyle(firstC); if (countC > 0 && countC > style.hyphenWordMin() - 1) { QString word = text.mid(firstC, countC); QString wordLower = QLocale(style.language()).toLower(word); if (wordLower.contains(SpecialChars::SHYPHEN)) break; bool ok = loadDict(style.language()); if (!ok) continue; QByteArray te = m_codec->fromUnicode(wordLower); char *buffer = static_cast<char*>(malloc(te.length() + 5)); if (buffer == nullptr) break; char **rep = nullptr; int *pos = nullptr; int *cut = nullptr; // TODO: support non-standard hyphenation, see hnj_hyphen_hyphenate2 docs if (!hnj_hyphen_hyphenate2(m_hdict, te.data(), te.length(), buffer, nullptr, &rep, &pos, &cut)) { int i = 0; buffer[te.length()] = '\0'; bool hasHyphen = false; for (i = 1; i < wordLower.length()-1; ++i) { if(buffer[i] & 1) { hasHyphen = true; break; } } QString outs = ""; QString input = ""; outs += word[0]; for (i = 1; i < wordLower.length()-1; ++i) { outs += word[i]; if(buffer[i] & 1) outs += "-"; } outs += word.rightRef(1); input = outs; if (!ignoredWords.contains(word)) { if (!hasHyphen) it->itemText.hyphenateWord(startC + firstC, wordLower.length(), nullptr); else if (m_automatic) { if (specialWords.contains(word)) { outs = specialWords.value(word); uint ii = 1; for (i = 1; i < outs.length()-1; ++i) { QChar cht = outs[i]; if (cht == '-') buffer[ii-1] = 1; else { buffer[ii] = 0; ++ii; } } } it->itemText.hyphenateWord(startC + firstC, wordLower.length(), buffer); } else { if (specialWords.contains(word)) { outs = specialWords.value(word); uint ii = 1; for (i = 1; i < outs.length()-1; ++i) { QChar cht = outs[i]; if (cht == '-') buffer[ii-1] = 1; else { buffer[ii] = 0; ++ii; } } } if (rememberedWords.contains(input)) { outs = rememberedWords.value(input); uint ii = 1; for (i = 1; i < outs.length()-1; ++i) { QChar cht = outs[i]; if (cht == '-') buffer[ii-1] = 1; else { buffer[ii] = 0; ++ii; } } it->itemText.hyphenateWord(firstC, wordLower.length(), buffer); } else { qApp->changeOverrideCursor(QCursor(Qt::ArrowCursor)); PrefsContext* prefs = PrefsManager::instance()->prefsFile->getContext("hyhpen_options"); int xpos = prefs->getInt("Xposition", -9999); int ypos = prefs->getInt("Yposition", -9999); HyAsk *dia = new HyAsk((QWidget*)parent(), outs); if ((xpos != -9999) && (ypos != -9999)) dia->move(xpos, ypos); qApp->processEvents(); if (dia->exec()) { outs = dia->Wort->text(); uint ii = 1; for (i = 1; i < outs.length()-1; ++i) { QChar cht = outs[i]; if (cht == '-') buffer[ii-1] = 1; else { buffer[ii] = 0; ++ii; } } if (!rememberedWords.contains(input)) rememberedWords.insert(input, outs); if (dia->addToIgnoreList->isChecked()) { if (!ignoredWords.contains(word)) ignoredWords.insert(word); } if (dia->addToExceptionList->isChecked()) { if (!specialWords.contains(word)) specialWords.insert(word, outs); } it->itemText.hyphenateWord(firstC, wordLower.length(), buffer); } else { free(buffer); buffer = nullptr; prefs->set("Xposition", dia->xpos); prefs->set("Yposition", dia->ypos); delete dia; break; } prefs->set("Xposition", dia->xpos); prefs->set("Yposition", dia->ypos); delete dia; qApp->changeOverrideCursor(QCursor(Qt::WaitCursor)); } } } } free(buffer); if (rep) { for (int i = 0; i < te.length() - 1; ++i) free(rep[i]); } free(rep); free(pos); free(cut); } } qApp->restoreOverrideCursor(); m_doc->DoDrawing = true; rememberedWords.clear(); }
bool CreateMode::doOneClick(FPoint& startPoint, FPoint& endPoint) { bool doCreate = false; double xSize, ySize; int originPoint = 0; if (QApplication::keyboardModifiers() & Qt::ControlModifier) return true; PrefsContext* sizes = PrefsManager::instance()->prefsFile->getContext("ObjectSize"); bool doRemember = sizes->getBool("Remember", true); int lmode = (createObjectMode == modeDrawLine) ? 1 : 0; if (lmode == 0) { xSize = sizes->getDouble("defWidth", 100.0); ySize = sizes->getDouble("defHeight", 100.0); originPoint = sizes->getInt("Origin", 0); } else { xSize = sizes->getDouble("defLength", 100.0); ySize = sizes->getDouble("defAngle", 0.0); originPoint = sizes->getInt("OriginL", 0); } //#12577 Remove one click dialog //#12577 OneClick *dia = new OneClick(m_view, ScribusView::tr("Enter Object Size"), m_doc->unitIndex(), xSize, ySize, doRemember, originPoint, lmode); //#12577 if (dia->exec()) { //#12577 doRemember = dia->checkRemember->isChecked(); if (lmode == 0) { //#12577 xSize = dia->spinWidth->value() / unitGetRatioFromIndex(m_doc->unitIndex()); //#12577 ySize = dia->spinHeight->value() / unitGetRatioFromIndex(m_doc->unitIndex()); //#12577 originPoint = dia->RotationGroup->checkedId(); if (doRemember) { sizes->set("defWidth", xSize); sizes->set("defHeight", ySize); sizes->set("Origin", originPoint); } endPoint.setXY(startPoint.x() + xSize, startPoint.y() + ySize); switch (originPoint) { case 0: break; case 1: startPoint.setX(startPoint.x() - xSize); endPoint.setX(endPoint.x() - xSize); break; case 2: startPoint.setXY(startPoint.x() - xSize / 2.0, startPoint.y() - ySize / 2.0); endPoint.setXY(endPoint.x() - xSize / 2.0, endPoint.y() - ySize / 2.0); break; case 3: startPoint.setY(startPoint.y() - ySize); endPoint.setY(endPoint.y() - ySize); break; case 4: startPoint.setXY(startPoint.x() - xSize, startPoint.y() - ySize); endPoint.setXY(endPoint.x() - xSize, endPoint.y() - ySize); break; } } else { FPoint oldStart = startPoint; //#12577 xSize = dia->spinWidth->value() / unitGetRatioFromIndex(m_doc->unitIndex()); //#12577 ySize = dia->spinHeight->value(); //#12577 originPoint = dia->RotationGroup->checkedId(); if (doRemember) { sizes->set("defLength", xSize); sizes->set("defAngle", ySize); sizes->set("OriginL", originPoint); } double angle = -ySize * M_PI / 180.0; switch (originPoint) { case 0: endPoint = FPoint(startPoint.x() + xSize * cos(angle), startPoint.y() + xSize * sin(angle)); break; case 1: startPoint = FPoint(oldStart.x() - xSize * cos(angle), oldStart.y() - xSize * sin(angle)); endPoint = oldStart; break; case 2: startPoint = FPoint(oldStart.x() - xSize / 2.0 * cos(angle), oldStart.y() - xSize / 2.0 * sin(angle)); endPoint = FPoint(oldStart.x() + xSize / 2.0 * cos(angle), oldStart.y() + xSize / 2.0 * sin(angle)); break; } } sizes->set("Remember", doRemember); doCreate = true; } //delete dia; return doCreate; }
void ShapePalette::Import() { PrefsContext* dirs = PrefsManager::instance()->prefsFile->getContext("dirs"); QString s = QFileDialog::getOpenFileName(this, tr("Choose a shape file to import"), dirs->get("shape_load", "."), tr("Photoshop Custom Shape (*.csh *.CSH)")); if (!s.isEmpty()) { QFileInfo fi(s); ShapeViewWidget = new ShapeView(this); int nIndex = Frame3->addItem(ShapeViewWidget, fi.baseName()); dirs->set("shape_load", s.left(s.lastIndexOf(QDir::toNativeSeparators("/")))); QFile file(s); if (!file.open(QFile::ReadOnly)) return; QApplication::setOverrideCursor(Qt::WaitCursor); QDataStream ds(&file); ds.setByteOrder(QDataStream::BigEndian); QByteArray magic; magic.resize(4); ds.readRawData(magic.data(), 4); if (magic != "cush") return; quint32 version, count, shpCounter; shpCounter = 1; ds >> version >> count; while (!ds.atEnd()) { QString string = ""; quint32 length, dummy, shpLen, paDataLen; ds >> length; for (uint i = 0; i < length; ++i) { quint16 ch; ds >> ch; if (ch > 0) string += char(ch); } if (length % 2 != 0) ds.skipRawData(2); ds >> dummy; ds >> shpLen; qint64 posi = ds.device()->pos(); ds.skipRawData(1); QByteArray uuid; uuid.resize(36); ds.readRawData(uuid.data(), 36); qint32 x, y, w, h; ds >> y >> x >> h >> w; paDataLen = shpLen - 53; QRect bounds = QRect(QPoint(x,y), QPoint(w, h)); bool first = false; bool pathOpen = false; FPoint firstPoint, firstControl; FPointArray clip2; short type; uint data; double frac1, frac2, frac3, frac4, frac5, frac6; uint offset2; offset2 = 0; clip2.resize(0); while (offset2 < paDataLen) { ds >> type; ds >> data; frac1 = decodePSDfloat(data) * bounds.height(); ds >> data; frac2 = decodePSDfloat(data) * bounds.width(); ds >> data; frac3 = decodePSDfloat(data) * bounds.height(); ds >> data; frac4 = decodePSDfloat(data) * bounds.width(); ds >> data; frac5 = decodePSDfloat(data) * bounds.height(); ds >> data; frac6 = decodePSDfloat(data) * bounds.width(); switch (type) { case 0: case 3: if (pathOpen) { clip2.addPoint(firstPoint); clip2.addPoint(firstControl); clip2.setMarker(); } pathOpen = false; first = true; break; case 1: case 2: case 4: case 5: if (first) { firstControl = FPoint(frac2, frac1); firstPoint = FPoint(frac4, frac3); clip2.addPoint(FPoint(frac4, frac3)); clip2.addPoint(FPoint(frac6, frac5)); } else { clip2.addPoint(frac4, frac3); clip2.addPoint(frac2, frac1); clip2.addPoint(frac4, frac3); clip2.addPoint(frac6, frac5); } pathOpen = true; first = false; break; case 6: first = true; break; default: break; } offset2 += 26; } clip2.addPoint(firstPoint); clip2.addPoint(firstControl); shapeData shData; shData.height = bounds.height(); shData.width = bounds.width(); shData.path = clip2.copy(); shData.name = string; ShapeViewWidget->m_Shapes.insert(QString(uuid), shData); ds.device()->seek(posi + shpLen); shpCounter++; } file.close(); Frame3->setCurrentIndex(nIndex); ShapeViewWidget->updateShapeList(); ShapeViewWidget->m_scMW = m_scMW; QApplication::restoreOverrideCursor(); }
PDFExportDialog::PDFExportDialog( QWidget* parent, const QString & docFileName, const QMap<QString, int > & DocFonts, ScribusView *currView, PDFOptions & pdfOptions, const QList<PDFPresentationData> & Eff, const ProfilesL & PDFXProfiles, const SCFonts &AllFonts, double unitRatio, const ProfilesL & printerProfiles) : QDialog( parent ), doc(currView->Doc), EffVal(Eff), Opts(pdfOptions), docUnitRatio(unitRatio), cmsDescriptorName(""), components(3), appPrinterProfiles(printerProfiles) { setModal(true); setWindowTitle( tr( "Save as PDF" ) ); setWindowIcon(loadIcon("AppIcon.png")); PDFExportLayout = new QVBoxLayout( this ); PDFExportLayout->setSpacing( 5 ); PDFExportLayout->setMargin( 10 ); Name = new QGroupBox( this ); Name->setTitle( tr( "O&utput to File:" ) ); NameLayout = new QGridLayout( Name ); NameLayout->setSpacing( 5 ); NameLayout->setMargin( 10 ); NameLayout->setAlignment( Qt::AlignTop ); fileNameLineEdit = new QLineEdit( Name ); fileNameLineEdit->setMinimumSize( QSize( 268, 22 ) ); if (!Opts.fileName.isEmpty()) fileNameLineEdit->setText( QDir::toNativeSeparators(Opts.fileName) ); else { QFileInfo fi(docFileName); if (fi.exists()) { QString fileName(fi.path()+"/"+fi.baseName()+".pdf"); fileNameLineEdit->setText( QDir::toNativeSeparators(fileName) ); } else { PrefsContext* dirs = PrefsManager::instance()->prefsFile->getContext("dirs"); QString pdfdir = dirs->get("pdf", fi.path()); if (pdfdir.right(1) != "/") pdfdir += "/"; QString fileName(pdfdir+fi.baseName()+".pdf"); fileNameLineEdit->setText( QDir::toNativeSeparators(fileName) ); } } NameLayout->addWidget( fileNameLineEdit, 0, 0 ); FileC = new QToolButton( Name ); FileC->setText( tr( "Cha&nge..." ) ); FileC->setMinimumSize( QSize( 88, 24 ) ); NameLayout->addWidget( FileC, 0, 1 ); multiFile = new QCheckBox( tr( "Output one file for eac&h page" ), Name ); multiFile->setChecked(Opts.doMultiFile); NameLayout->addWidget( multiFile, 1, 0 ); PDFExportLayout->addWidget( Name ); Options = new TabPDFOptions( this, pdfOptions, AllFonts, PDFXProfiles, DocFonts, Eff, currView->Doc->unitIndex(), currView->Doc->pageHeight, currView->Doc->pageWidth, currView->Doc, true ); PDFExportLayout->addWidget( Options ); Layout7 = new QHBoxLayout; Layout7->setSpacing( 5 ); Layout7->setMargin( 0 ); QSpacerItem* spacer_2 = new QSpacerItem( 2, 2, QSizePolicy::Expanding, QSizePolicy::Minimum ); Layout7->addItem( spacer_2 ); OK = new QPushButton( tr( "&Save" ), this ); OK->setAutoDefault( true ); OK->setDefault( true ); Layout7->addWidget( OK ); Cancel = new QPushButton( CommonStrings::tr_Cancel, this ); Layout7->addWidget( Cancel ); PDFExportLayout->addLayout( Layout7 ); if ((Opts.Version == PDFOptions::PDFVersion_X3) && (Options->InfoString->text().isEmpty())) OK->setEnabled(false); resize(sizeHint()); // setMaximumSize( sizeHint() ); //tooltips multiFile->setToolTip( "<qt>" + tr( "This enables exporting one individually named PDF file for each page in the document. Page numbers are added automatically. This is most useful for imposing PDF for commercial printing.") + "</qt>" ); OK->setToolTip( "<qt>" + tr( "The save button will be disabled if you are trying to export PDF/X-3 and the info string is missing from the PDF/X-3 tab.") + "</qt>" ); // signals and slots connections connect( FileC, SIGNAL( clicked() ), this, SLOT( ChangeFile() ) ); connect( OK, SIGNAL( clicked() ), this, SLOT( DoExport() ) ); connect( Cancel, SIGNAL( clicked() ), this, SLOT( reject() ) ); connect( fileNameLineEdit, SIGNAL( editingFinished() ), this, SLOT( fileNameChanged() ) ); connect( Options, SIGNAL(noInfo()), this, SLOT(disableSave())); connect( Options, SIGNAL(hasInfo()), this, SLOT(enableSave())); }