void CustomPlot::saveAs() { QFileInfo info(Preferences::LastFileAccessed()); info.setFile(info.dir(), info.completeBaseName()); while (1) { QString filter(tr("PNG") + " (*.png)"); QStringList extensions; extensions << filter << tr("JPG") + " (*.jpg)" << tr("PDF") + " (*.pdf)"; QString fileName(QFileDialog::getSaveFileName(this, tr("Save File"), info.filePath(), extensions.join(";;"), &filter)); if (fileName.isEmpty()) { // This will occur if the user cancels the action. return; }else { QRegExp rx("\\*(\\..+)\\)"); if (rx.indexIn(filter) > 0) { filter = rx.cap(1); if (!fileName.endsWith(filter, Qt::CaseInsensitive)) { fileName += filter; } } QSize dim(size()); int upscale(2); if (filter == ".pdf") { qDebug() << "Saving with filter " << fileName << filter; bool noCosmeticPen = true; savePdf(fileName, noCosmeticPen, dim.width(), dim.height()); }else if (filter == ".png") { qDebug() << "Saving with filter " << fileName << filter; savePng(fileName, dim.width(), dim.height(), upscale); }else if (filter == ".jpg") { qDebug() << "Saving with filter " << fileName << filter; saveJpg(fileName, dim.width(), dim.height(), upscale); } Preferences::LastFileAccessed(fileName); break; } } }
SchedulePrintDialog::SchedulePrintDialog( ScheduleWidget * widget ) : QDialog( widget ) , mScheduleWidget( widget ) { setupUi(this); for( int i=0; pageSizeNames[i]; i++ ) mPageSizeCombo->addItem( pageSizeNames[i] ); connect( mPreviewButton, SIGNAL( clicked() ), SLOT( preview() ) ); connect( mPrintButton, SIGNAL( clicked() ), SLOT( print() ) ); connect( mSavePdfButton, SIGNAL( clicked() ), SLOT( savePdf() ) ); mFontTree->setHeaderLabels( QStringList() << "Location" << "Font" ); connect( mFontTree, SIGNAL( itemDoubleClicked( QTreeWidgetItem *, int ) ), SLOT( updateFont( QTreeWidgetItem * ) ) ); mDisplayOptions = widget->mDisplayOptions; ScheduleDisplayOptions & dops = mDisplayOptions; setupFontItem( mFontTree, "Header Month/Year", &dops.headerMonthYearFont ); setupFontItem( mFontTree, "Header Day/Week", &dops.headerDayWeekFont ); setupFontItem( mFontTree, "Panel", &dops.panelFont ); setupFontItem( mFontTree, "Cell Day", &dops.cellDayFont ); setupFontItem( mFontTree, "Entry", &dops.entryFont ); setupFontItem( mFontTree, "Entry Hours", &dops.entryHoursFont ); }