//------------------------------------------------------------------------- void MainWindow::exportRectDialog(const QRectF& exportRectangle ) { //Select filename & export type QString savePath = getFileDialogPath(); if ( savePath == "" ) savePath = windowFilePath(); savePath += "/" + QFileInfo(windowFilePath()).fileName(); QString filters = PNG_FILE_FILTER + QString("\n") + PDF_FILE_FILTER // + QString("\n") + PS_FILE_FILTER ; QString selectedFilter(""); QString fileName = QFileDialog::getSaveFileName(this, tr("Export the scene"), savePath, tr(filters.toAscii().data()) , &selectedFilter); if ( fileName.isEmpty() ) return; setLastManagedFile(fileName); formatFileName(fileName,selectedFilter,filters); exportRect( exportRectangle , fileName , selectedFilter ); }
void RecipeWidget::save(QString filepath) { if(!filepath.isEmpty()) { setWindowFilePath(filepath); } else if(!isWindowModified()) { return; // Don't do anything if the file would be the same } QDomDocument document("Recipe"); document.appendChild(recipe()->toXml(document)); if(windowFilePath().isEmpty()) { throw tr("File path is not valid"); } QFile file(windowFilePath()); if(!file.open(QIODevice::WriteOnly)) { throw tr("Failed to open ingredients file"); } file.write(document.toString().toLatin1()); file.flush(); file.close(); setWindowModified(false); refreshText(); emit changed(); }
bool MainWindow::save() { if (windowFilePath().isEmpty()) return saveAs(); else return canvas->saveImage(windowFilePath()); }
void MainWindow::on_action_Open_triggered() { if (maybeSave()) { setWindowFilePath(QFileDialog::getOpenFileName(this, tr("Open File"), QDir::currentPath())); if (!windowFilePath().isEmpty()) canvas->openImage(windowFilePath()); } }
bool MainWindow::saveAs() { QString filter = "All Files (*)"; for (auto format : QImageWriter::supportedImageFormats()) { filter += ";;" + QString(format).toUpper() + " Files (*." + QString(format) + ")"; } setWindowFilePath(QFileDialog::getSaveFileName(this, tr("Save As"), windowFilePath(), filter)); if (windowFilePath().isEmpty()) { return false; } else { return canvas->saveImage(windowFilePath()); } }
//------------------------------------------------------------------------- void MainWindow::exportItemToMidi() { QLanguageItem * container = dynamic_cast<QLanguageItem *>( sender() ); assert(container); QString savePath; if ( container->file().length() ) savePath = QFileInfo( container->file() ).absolutePath(); if ( savePath == "" ) savePath = windowFilePath(); if ( savePath == "" ) savePath = QDir::homePath(); savePath += "/" + container->name(); QString filters = MIDI_FILE_FILTER; QString selectedFilter(""); QString fileName = QFileDialog::getSaveFileName(this, tr("Export item"), savePath, tr(filters.toAscii().data()) , &selectedFilter); if ( fileName.isEmpty() ) return; formatFileName(fileName,selectedFilter,filters); QGuidoAR::midiExport(container->code() , fileName ); }
void MainWindow::reload() { if (saveChanges()) { loadFile(windowFilePath()); setWindowModified(false); } }
void MainWindow::writeSettings(void) { QSettings settings("ZNU","SHVSM"); settings.setValue("pos", pos()); settings.setValue("size", size()); settings.setValue("path",windowFilePath()); settings.setValue("state",(int)windowState()); settings.setValue("lang",langNo); }
void MainWindow::saveForm() { const QString fileName = windowFilePath(); if (fileName.isEmpty() || fileName == tr("Untitled")) saveFormAs(); else { form->saveFile(fileName); setWindowModified(false); updateRecentFile(fileName); } }
void MainWindow::setCurrentFile(const QString &fileName) { static int sequenceNumber = 1; isUntitled = fileName.isEmpty(); if (isUntitled) { curFile = tr("document%1.txt").arg(sequenceNumber++); } else { curFile = QFileInfo(fileName).canonicalFilePath(); } textEdit->document()->setModified(false); setWindowModified(false); if (!isUntitled && windowFilePath() != curFile) MainWindow::prependToRecentFiles(curFile); setWindowFilePath(curFile); }
void HistogramWindow::exportAsImage() { QFileDialog dialog(this, QString("Save image"), windowFilePath()); QStringList mimeTypeFilters; foreach (const QByteArray &mimeTypeName, QImageReader::supportedMimeTypes()) mimeTypeFilters.append(mimeTypeName); mimeTypeFilters.sort(); dialog.setAcceptMode(QFileDialog::AcceptSave); dialog.setMimeTypeFilters(mimeTypeFilters); dialog.selectMimeTypeFilter("image"); bool saved = false; while(dialog.exec() == QDialog::Accepted && !(saved= saveImage(dialog.selectedFiles().first()))){ if(!saved) QMessageBox::critical(this, tr("Error!"), tr("Can't save image.")); } }
void RecipeWidget::load(QString filepath) { setWindowFilePath(filepath); QDomDocument document("Ingredients"); QFile file(windowFilePath()); if(!file.open(QIODevice::ReadOnly)) throw tr("Failed to open recipe file"); if(!document.setContent(&file)) { file.close(); throw tr("Failed to read recipe file"); } file.close(); if(document.documentElement().tagName() != "Recipe") { throw tr("Not a recipe file"); } setRecipe(new Recipe(document.documentElement())); }
int QWidget::qt_metacall(QMetaObject::Call _c, int _id, void **_a) { _id = QObject::qt_metacall(_c, _id, _a); if (_id < 0) return _id; if (_c == QMetaObject::InvokeMetaMethod) { if (_id < 23) qt_static_metacall(this, _c, _id, _a); _id -= 23; } #ifndef QT_NO_PROPERTIES else if (_c == QMetaObject::ReadProperty) { void *_v = _a[0]; switch (_id) { case 0: *reinterpret_cast< bool*>(_v) = isModal(); break; case 1: *reinterpret_cast< Qt::WindowModality*>(_v) = windowModality(); break; case 2: *reinterpret_cast< bool*>(_v) = isEnabled(); break; case 3: *reinterpret_cast< QRect*>(_v) = geometry(); break; case 4: *reinterpret_cast< QRect*>(_v) = frameGeometry(); break; case 5: *reinterpret_cast< QRect*>(_v) = normalGeometry(); break; case 6: *reinterpret_cast< int*>(_v) = x(); break; case 7: *reinterpret_cast< int*>(_v) = y(); break; case 8: *reinterpret_cast< QPoint*>(_v) = pos(); break; case 9: *reinterpret_cast< QSize*>(_v) = frameSize(); break; case 10: *reinterpret_cast< QSize*>(_v) = size(); break; case 11: *reinterpret_cast< int*>(_v) = width(); break; case 12: *reinterpret_cast< int*>(_v) = height(); break; case 13: *reinterpret_cast< QRect*>(_v) = rect(); break; case 14: *reinterpret_cast< QRect*>(_v) = childrenRect(); break; case 15: *reinterpret_cast< QRegion*>(_v) = childrenRegion(); break; case 16: *reinterpret_cast< QSizePolicy*>(_v) = sizePolicy(); break; case 17: *reinterpret_cast< QSize*>(_v) = minimumSize(); break; case 18: *reinterpret_cast< QSize*>(_v) = maximumSize(); break; case 19: *reinterpret_cast< int*>(_v) = minimumWidth(); break; case 20: *reinterpret_cast< int*>(_v) = minimumHeight(); break; case 21: *reinterpret_cast< int*>(_v) = maximumWidth(); break; case 22: *reinterpret_cast< int*>(_v) = maximumHeight(); break; case 23: *reinterpret_cast< QSize*>(_v) = sizeIncrement(); break; case 24: *reinterpret_cast< QSize*>(_v) = baseSize(); break; case 25: *reinterpret_cast< QPalette*>(_v) = palette(); break; case 26: *reinterpret_cast< QFont*>(_v) = font(); break; case 27: *reinterpret_cast< QCursor*>(_v) = cursor(); break; case 28: *reinterpret_cast< bool*>(_v) = hasMouseTracking(); break; case 29: *reinterpret_cast< bool*>(_v) = isActiveWindow(); break; case 30: *reinterpret_cast< Qt::FocusPolicy*>(_v) = focusPolicy(); break; case 31: *reinterpret_cast< bool*>(_v) = hasFocus(); break; case 32: *reinterpret_cast< Qt::ContextMenuPolicy*>(_v) = contextMenuPolicy(); break; case 33: *reinterpret_cast< bool*>(_v) = updatesEnabled(); break; case 34: *reinterpret_cast< bool*>(_v) = isVisible(); break; case 35: *reinterpret_cast< bool*>(_v) = isMinimized(); break; case 36: *reinterpret_cast< bool*>(_v) = isMaximized(); break; case 37: *reinterpret_cast< bool*>(_v) = isFullScreen(); break; case 38: *reinterpret_cast< QSize*>(_v) = sizeHint(); break; case 39: *reinterpret_cast< QSize*>(_v) = minimumSizeHint(); break; case 40: *reinterpret_cast< bool*>(_v) = acceptDrops(); break; case 41: *reinterpret_cast< QString*>(_v) = windowTitle(); break; case 42: *reinterpret_cast< QIcon*>(_v) = windowIcon(); break; case 43: *reinterpret_cast< QString*>(_v) = windowIconText(); break; case 44: *reinterpret_cast< double*>(_v) = windowOpacity(); break; case 45: *reinterpret_cast< bool*>(_v) = isWindowModified(); break; case 46: *reinterpret_cast< QString*>(_v) = toolTip(); break; case 47: *reinterpret_cast< QString*>(_v) = statusTip(); break; case 48: *reinterpret_cast< QString*>(_v) = whatsThis(); break; case 49: *reinterpret_cast< QString*>(_v) = accessibleName(); break; case 50: *reinterpret_cast< QString*>(_v) = accessibleDescription(); break; case 51: *reinterpret_cast< Qt::LayoutDirection*>(_v) = layoutDirection(); break; case 52: *reinterpret_cast< bool*>(_v) = autoFillBackground(); break; case 53: *reinterpret_cast< QString*>(_v) = styleSheet(); break; case 54: *reinterpret_cast< QLocale*>(_v) = locale(); break; case 55: *reinterpret_cast< QString*>(_v) = windowFilePath(); break; case 56: *reinterpret_cast< Qt::InputMethodHints*>(_v) = inputMethodHints(); break; } _id -= 57; } else if (_c == QMetaObject::WriteProperty) { void *_v = _a[0]; switch (_id) { case 1: setWindowModality(*reinterpret_cast< Qt::WindowModality*>(_v)); break; case 2: setEnabled(*reinterpret_cast< bool*>(_v)); break; case 3: setGeometry(*reinterpret_cast< QRect*>(_v)); break; case 8: move(*reinterpret_cast< QPoint*>(_v)); break; case 10: resize(*reinterpret_cast< QSize*>(_v)); break; case 16: setSizePolicy(*reinterpret_cast< QSizePolicy*>(_v)); break; case 17: setMinimumSize(*reinterpret_cast< QSize*>(_v)); break; case 18: setMaximumSize(*reinterpret_cast< QSize*>(_v)); break; case 19: setMinimumWidth(*reinterpret_cast< int*>(_v)); break; case 20: setMinimumHeight(*reinterpret_cast< int*>(_v)); break; case 21: setMaximumWidth(*reinterpret_cast< int*>(_v)); break; case 22: setMaximumHeight(*reinterpret_cast< int*>(_v)); break; case 23: setSizeIncrement(*reinterpret_cast< QSize*>(_v)); break; case 24: setBaseSize(*reinterpret_cast< QSize*>(_v)); break; case 25: setPalette(*reinterpret_cast< QPalette*>(_v)); break; case 26: setFont(*reinterpret_cast< QFont*>(_v)); break; case 27: setCursor(*reinterpret_cast< QCursor*>(_v)); break; case 28: setMouseTracking(*reinterpret_cast< bool*>(_v)); break; case 30: setFocusPolicy(*reinterpret_cast< Qt::FocusPolicy*>(_v)); break; case 32: setContextMenuPolicy(*reinterpret_cast< Qt::ContextMenuPolicy*>(_v)); break; case 33: setUpdatesEnabled(*reinterpret_cast< bool*>(_v)); break; case 34: setVisible(*reinterpret_cast< bool*>(_v)); break; case 40: setAcceptDrops(*reinterpret_cast< bool*>(_v)); break; case 41: setWindowTitle(*reinterpret_cast< QString*>(_v)); break; case 42: setWindowIcon(*reinterpret_cast< QIcon*>(_v)); break; case 43: setWindowIconText(*reinterpret_cast< QString*>(_v)); break; case 44: setWindowOpacity(*reinterpret_cast< double*>(_v)); break; case 45: setWindowModified(*reinterpret_cast< bool*>(_v)); break; case 46: setToolTip(*reinterpret_cast< QString*>(_v)); break; case 47: setStatusTip(*reinterpret_cast< QString*>(_v)); break; case 48: setWhatsThis(*reinterpret_cast< QString*>(_v)); break; case 49: setAccessibleName(*reinterpret_cast< QString*>(_v)); break; case 50: setAccessibleDescription(*reinterpret_cast< QString*>(_v)); break; case 51: setLayoutDirection(*reinterpret_cast< Qt::LayoutDirection*>(_v)); break; case 52: setAutoFillBackground(*reinterpret_cast< bool*>(_v)); break; case 53: setStyleSheet(*reinterpret_cast< QString*>(_v)); break; case 54: setLocale(*reinterpret_cast< QLocale*>(_v)); break; case 55: setWindowFilePath(*reinterpret_cast< QString*>(_v)); break; case 56: setInputMethodHints(*reinterpret_cast< Qt::InputMethodHints*>(_v)); break; } _id -= 57; } else if (_c == QMetaObject::ResetProperty) { switch (_id) { case 27: unsetCursor(); break; case 51: unsetLayoutDirection(); break; case 54: unsetLocale(); break; } _id -= 57; } else if (_c == QMetaObject::QueryPropertyDesignable) { bool *_b = reinterpret_cast<bool*>(_a[0]); switch (_id) { case 41: *_b = isWindow(); break; case 42: *_b = isWindow(); break; case 43: *_b = isWindow(); break; case 44: *_b = isWindow(); break; case 45: *_b = isWindow(); break; case 55: *_b = isWindow(); break; } _id -= 57; } else if (_c == QMetaObject::QueryPropertyScriptable) { _id -= 57; } else if (_c == QMetaObject::QueryPropertyStored) { _id -= 57; } else if (_c == QMetaObject::QueryPropertyEditable) { _id -= 57; } else if (_c == QMetaObject::QueryPropertyUser) { _id -= 57; } #endif // QT_NO_PROPERTIES return _id; }