void TextEditTestWindow::on_actionSave_triggered() { PHDEBUG << _settings->currentDocument(); if(QFile(_settings->currentDocument()).exists()) saveDocument(_settings->currentDocument()); else on_actionSave_as_triggered(); }
/*! */ bool SceneDocument::saveDocument(const QUrl& file_url, const QVariant& node, QString& error_message) noexcept { const auto object = QJsonObject::fromVariantMap(node.toMap()); const auto file_path = toFilePath(file_url); return saveDocument(file_path, object, error_message); }
bool DocumentWindow::saveDocumentDialog() { const QString savingPath = showSavingDialog(); if (savingPath.isEmpty()) { return false; } return saveDocument(savingPath); }
bool MainWindow::saveAsDocumentAction() { if ( isEmptyDocument() ) return true; QString selectedFileName = QFileDialog::getSaveFileName ( this, tr("Select file for save"), QDir::currentPath(), tr("XML files (*.xml);;All files (*.*)") ); if ( selectedFileName.isEmpty() ) return false; return saveDocument ( selectedFileName ); }
static void menu_cb_save (TextEditor me, EDITOR_ARGS_CMD) { if (my name [0]) { try { saveDocument (me, & my file); } catch (MelderError) { Melder_flushError (); return; } } else { menu_cb_saveAs (me, cmd, nullptr, 0, nullptr, nullptr, nullptr); } }
void XMLWriter::setRevision(int revision) { if(!loadDocument()) return; if(m_document.elementsByTagName("TrollingObjects").count() == 1) { QDomElement element = m_document.elementsByTagName("TrollingObjects").at(0).toElement(); element.setAttribute("revision", revision); saveDocument(); } }
bool XMLWriter::write(TrollingObject* p_object) { if(!loadDocument()) return false; QDomElement trollingObject; int id = p_object->getId(); if(!getTrollingObjectElement(trollingObject, id)) return false; p_object->setId(id); clearNodeContents(trollingObject); trollingObject.setAttribute("type", p_object->getType()); p_object->setSaved(); QHashIterator<QString, QString> iter(p_object->getProperties()); while( iter.hasNext() ) { iter.next(); if(iter.value().isEmpty()) continue; QDomElement property = m_document.createElement(iter.key()); QDomText text = m_document.createTextNode(iter.value()); property.appendChild(text); trollingObject.appendChild(property); } QList< QHash<QString, QString> > list = p_object->getList(); QDomElement listelement = m_document.createElement("PropertyList"); for(int loop=0; loop < list.size(); loop++) { QDomElement listItem = m_document.createElement("PropertyListItem"); QHash<QString, QString> subProperty = list.at(loop); QHashIterator<QString, QString> iter(subProperty); while( iter.hasNext() ) { iter.next(); if(iter.value().isEmpty()) continue; QDomElement property = m_document.createElement(iter.key()); QDomText text = m_document.createTextNode(iter.value()); property.appendChild(text); listItem.appendChild(property); } listelement.appendChild(listItem); } trollingObject.appendChild(listelement); return saveDocument(); }
void TextEditTestWindow::on_actionSave_as_triggered() { QString fileName = _settings->currentDocument(); if(fileName.isEmpty()) fileName = _settings->lastDocumentFolder(); fileName = QFileDialog::getSaveFileName(this, "Save a text file...", fileName, "Text file (*.txt)"); PHDEBUG << fileName; if(!fileName.isEmpty()) { if(!saveDocument(fileName)) QMessageBox::critical(this, "Error", "Unable to save " + fileName); } }
bool KdevDoc::canCloseFrame(KdevView* pFrame) { if(!isLastView()) return true; bool ret=false; if(isModified()) { QString saveName; switch(QMessageBox::information(pFrame, title(), tr("The current file has been modified.\n" "Do you want to save it?"),QMessageBox::Yes, QMessageBox::No, QMessageBox::Cancel )) { case QMessageBox::Yes: if(title().contains(tr("Untitled"))) { saveName=QFileDialog::getSaveFileName(0, 0, pFrame); if(saveName.isEmpty()) return false; } else saveName=pathName(); if(!saveDocument(saveName)) { switch(QMessageBox::critical(pFrame, tr("I/O Error !"), tr("Could not save the current document !\n" "Close anyway ?"),QMessageBox::Yes ,QMessageBox::No)) { case QMessageBox::Yes: ret=true; case QMessageBox::No: ret=false; } } else ret=true; break; case QMessageBox::No: ret=true; break; case QMessageBox::Cancel: default: ret=false; break; } } else ret=true; return ret; }
static void gui_button_cb_saveAndClose (TextEditor me, GuiButtonEvent /* event */) { GuiThing_hide (my dirtyCloseDialog); if (my name [0]) { try { saveDocument (me, & my file); } catch (MelderError) { Melder_flushError (); return; } closeDocument (me); } else { menu_cb_saveAs (me, Editor_getMenuCommand (me, U"File", U"Save as..."), nullptr, 0, nullptr, nullptr, nullptr); } }
static void gui_button_cb_saveAndNew (EditorCommand cmd, GuiButtonEvent /* event */) { TextEditor me = (TextEditor) cmd -> d_editor; GuiThing_hide (my dirtyNewDialog); if (my name [0]) { try { saveDocument (me, & my file); } catch (MelderError) { Melder_flushError (); return; } newDocument (me); } else { menu_cb_saveAs (me, cmd, nullptr, 0, nullptr, nullptr, nullptr); } }
bool MainWindow::maybeSave(Document* doc) { if (doc->ocafDoc()->IsModified()) { QMessageBox::StandardButton ret; ret = QMessageBox::warning(this, qApp->applicationName(), "The document " + doc->name() + " has been modified.\n" "Do you want to save your changes ?", QMessageBox::Save | QMessageBox::Discard | QMessageBox::Cancel); if (ret == QMessageBox::Save) return saveDocument(doc); else if (ret == QMessageBox::Cancel) return false; } return true; }
bool MainWindow::maybeSave() { if (m_editor->document()->isModified()) { QMessageBox::StandardButton ret; ret = QMessageBox::warning(this, qApp->applicationName(), tr("The document has been modified.\n" "Do you want to save your changes?"), QMessageBox::Save | QMessageBox::Discard | QMessageBox::Cancel); if (ret == QMessageBox::Save) return saveDocument(m_documentPath); else if (ret == QMessageBox::Cancel) return false; } return true; }
bool XMLWriter::remove(TrollingObject* p_object) { if(!loadDocument()) return false; QDomElement trollingObject; int id = p_object->getId(); if(!getTrollingObjectElement(trollingObject, id)) return false; clearNodeContents(trollingObject); trollingObject.parentNode().removeChild(trollingObject); return saveDocument(); }
bool XADDoc::saveModified() { bool completed=true; if(modified) { XADApp *win=(XADApp *) parent(); int want_save = KMessageBox::warningYesNoCancel(win, i18n("The current file has been modified.\n" "Do you want to save it?"), i18n("Warning")); switch(want_save) { case KMessageBox::Yes: if (doc_url.fileName() == i18n("Untitled")) { win->slotFileSaveAs(); } else { saveDocument(URL()); }; deleteContents(); completed=true; break; case KMessageBox::No: setModified(false); deleteContents(); completed=true; break; case KMessageBox::Cancel: completed=false; break; default: completed=false; break; } } return completed; }
void docengine::documentChanged(QString fileName) { removeDocument(fileName); QTabWidgetqq *tabWidget = MainWindow::instance()->container->focusQTabWidgetqq(); int x = isDocumentOpen(fileName); //Don't bother continuing if we can't find the document in one of the open tabs.... though this should never happen if(x == -1) { removeDocument(fileName); return; } QFile file(fileName); bool fileExisted = file.exists(); QMessageBox msgBox; msgBox.setWindowTitle(MainWindow::instance()->windowTitle()); msgBox.setIcon(QMessageBox::Critical); if(fileExisted) { msgBox.setText(tr("The file \"%1\" has been changed outside of the editor. Would you like to reload it?").arg(fileName)); }else { msgBox.setText(tr("The file \"%1\" has been removed from the file system. Would you like to save it now?").arg(fileName)); } msgBox.setStandardButtons(QMessageBox::Yes | QMessageBox::No | QMessageBox::Close); msgBox.setDefaultButton(QMessageBox::Yes); int ret = msgBox.exec(); if(ret == QMessageBox::No) { return; }else if(ret == QMessageBox::Close) { if(x != -1) { MainWindow::instance()->kindlyTabClose(tabWidget->QSciScintillaqqAt(x)); } return; } //If the file exists, we try to reload it, otherwise save it back to disk. if(fileExisted) { loadDocuments(QStringList(fileName),MainWindow::instance()->container->focusQTabWidgetqq(),true); }else { saveDocument(tabWidget->QSciScintillaqqAt(x),fileName); } addDocument(fileName); }
bool KDPluginsListBox::saveModified() { bool completed=true; if(m_modified) { KDoorsApp *win=(KDoorsApp *) parent(); int want_save = KMessageBox::warningYesNoCancel(win, i18n("Warning"), i18n("The current file has been modified.\n" "Do you want to save it?")); switch(want_save) { case 1: if (m_url.fileName() == i18n("Untitled")) { win->slotSavePlugins(); } else { saveDocument(m_url); }; //deleteContents(); completed=true; break; case 2: setModified(false); //deleteContents(); completed=true; break; case 3: completed=false; break; default: completed=false; break; } } return completed; }
bool KVerbosDoc::saveModified() { bool completed=true; if(modified) { KVerbosApp *win=(KVerbosApp *) parent(); int want_save = KMessageBox::warningYesNoCancel(win, i18n("The current file has been modified.\nDo you want to save it?"), i18n("Warning"),KStdGuiItem::save(),KStdGuiItem::discard()); switch(want_save) { // ich habe die Nummern gegenüber den originalen Nummern in der case-Anweisung // vertauscht, weil die originalen Nummern verkehrt zugeordnet sind!. // In der Dokumentation zu KMessageBox kann man die richtige Zuordnung der Buttons finden. case 2: // CANCEL completed=false; break; case 3: // YES if (doc_url.fileName() == i18n("Untitled")) { win->slotFileSaveAs(); } else { saveDocument(URL()); }; deleteContents(); completed=true; break; case 4: // NO setModified(false); deleteContents(); completed=true; break; default: // Verhalten wie CANCEL completed=false; break; } } return completed; }
void MainWindow::closeDocument() { Document *doc = currentDocument(); if (doc == 0) return; if (!doc->undoStack()->isClean()) { int button = QMessageBox::warning(this, tr("Unsaved changes"), tr("Would you like to save this document?"), QMessageBox::Yes, QMessageBox::No); if (button == QMessageBox::Yes) saveDocument(); } removeDocument(doc); delete doc; }
bool MainWindow2::maybeSave() { if ( mEditor->object()->isModified() ) { int ret = QMessageBox::warning( this, tr( "Warning" ), tr( "This animation has been modified.\n Do you want to save your changes?" ), QMessageBox::Yes | QMessageBox::Default, QMessageBox::No, QMessageBox::Cancel | QMessageBox::Escape ); if ( ret == QMessageBox::Yes ) { saveDocument(); return true; } else if ( ret == QMessageBox::Cancel ) { return false; } } return true; }
MinervaWindow::MinervaWindow(QWidget *parent): QMainWindow(parent), ui(new Ui::MinervaWindow){ window=this; psettings=NULL; ui->setupUi(this); setCentralWidget(ui->documentTabs); connect(ui->actionNew,SIGNAL(triggered()),this,SLOT(newDocument())); connect(ui->action_Open,SIGNAL(triggered()),this,SLOT(openDocument())); connect(ui->actionExit,SIGNAL(triggered()),this,SLOT(close())); connect(ui->action_Save,SIGNAL(triggered()),this,SLOT(saveDocument())); connect(ui->actionSave_As,SIGNAL(triggered()),this,SLOT(saveDocumentAs())); connect(ui->actionAbout_Minerva,SIGNAL(triggered()),this,SLOT(about())); connect(ui->documentTabs,SIGNAL(tabCloseRequested(int)),this,SLOT(closeDocument(int))); connect(ui->actionPlugins,SIGNAL(triggered()),this,SLOT(openPluginsConfiguration())); formats = new QFormatScheme(QString("%1/share/minerva/qxs/formats.qxf").arg(ROOTDIR), this); QDocument::setDefaultFormatScheme(formats); QLineMarksInfoCenter::instance()->loadMarkTypes(QString("%1/share/minerva/qxs/marks.qxm").arg(ROOTDIR)); languages = new QLanguageFactory(formats, this); languages->addDefinitionPath(QString("%1/share/minerva/qxs").arg(ROOTDIR)); editors=new QList<MinervaDocument*>(); }
void MainWindow::saveAs() { const auto formats = ImageIO::supportedImageFormats(ImageFormatInfo::CanWrite); const auto filters = tr("All Files (*);;") + mimeTypesToFilters(formatsToMimeTypes(formats)); const auto path = QFileDialog::getSaveFileName(this, tr("Save As"), QString(), filters); if (path.isEmpty()) return; const auto mt = QMimeDatabase().mimeTypeForFile(path); const auto info = ImageIO::imageFormat(mt); if (!info) { QMessageBox::warning(this, tr("Save"), tr("No format for mimetype %1").arg(mt.name())); return; } SaveOptionsDialog dialog; dialog.setImageFormat(*info); if (dialog.exec() == QDialog::Rejected) return; saveDocument(QUrl::fromLocalFile(path), dialog.subType(), dialog.options()); }
/** * Setups the UI: textarea transparency, preferences restore, signals&slots. */ void MEdiText::init() { // ui setupUi(this); showFullScreen(); this->textEdit->viewport()->setAutoFillBackground(false); // signal listening connect( newBtn, SIGNAL( clicked() ), this, SLOT( createNewDocument() ) ); connect( openBtn, SIGNAL( clicked() ), this, SLOT( openExistingDocument() ) ); connect( saveBtn, SIGNAL( clicked() ), this, SLOT( saveDocument() ) ); connect( quitBtn, SIGNAL( clicked() ), this, SLOT( closeIfSaved() ) ); connect( prefsBtn, SIGNAL( clicked() ), this, SLOT( openPreferences() ) ); // preference restore this->settings = new QSettings("MEdiText", "MEdiText"); QString path = this->settings->value("background_path", "mckenzie.jpg").toString(); int alpha = this->settings->value("background_alpha", 128).toInt(); this->setBackground(path, alpha); QString family = this->settings->value("font_family", "DejaVu Sans").toString(); int size = this->settings->value("font_size", 11).toInt(); this->setFont(family, size); }
bool MainWindow::saveDocumentAction () { if ( model->isNewModel() ) return saveAsDocumentAction(); return saveDocument ( model->fileName() ); }
void KPlatoWork_MainWindow::slotFileSave() { saveDocument(); }
void MainWindow::onSaveAsActionTriggered() { saveDocument(""); }
void MainWindow::onSaveActionTriggered() { saveDocument(m_documentPath); if (m_refreshOnSave) onRefreshActionTriggered(); }
void MainWindow2::createMenus() { // ---------- File Menu ------------- connect(ui->actionNew, SIGNAL(triggered()), this, SLOT(newDocument())); connect(ui->actionOpen, SIGNAL(triggered()), this, SLOT(openDocument())); connect(ui->actionSave_as, SIGNAL(triggered()), this, SLOT(saveAsNewDocument())); connect(ui->actionSave, SIGNAL(triggered()), this, SLOT(saveDocument())); connect(ui->actionPrint, SIGNAL(triggered()), editor, SLOT(print())); connect(ui->actionExit, SIGNAL(triggered()), this, SLOT(close())); /// --- Export Menu --- connect(ui->actionExport_X_sheet , SIGNAL(triggered()), editor, SLOT(exportX())); connect(ui->actionExport_Image_Sequence, SIGNAL(triggered()), editor, SLOT(exportSeq())); connect(ui->actionExport_Image, SIGNAL(triggered()), editor, SLOT(exportImage())); connect(ui->actionExport_Movie, SIGNAL(triggered()), editor, SLOT(exportMov())); //exportFlashAct = new QAction(tr("&Flash/SWF..."), this); //exportFlashAct->setShortcut(tr("Ctrl+Alt+F")); //connect(exportFlashAct, SIGNAL(triggered()), editor, SLOT(exportFlash())); connect(ui->actionExport_Palette, SIGNAL(triggered()), this, SLOT(exportPalette())); /// --- Import Menu --- connect(ui->actionExport_Svg_Image, SIGNAL(triggered()), editor, SLOT(saveSvg())); connect(ui->actionImport_Image, SIGNAL(triggered()), editor, SLOT(importImage())); connect(ui->actionImport_Image_Sequence, SIGNAL(triggered()), editor, SLOT(importImageSequence())); connect(ui->actionImport_Movie, SIGNAL(triggered()), editor, SLOT(importMov())); connect(ui->actionImport_Sound, SIGNAL(triggered()), editor, SLOT(importSound())); connect(ui->actionImport_Palette, SIGNAL(triggered()), this, SLOT(importPalette())); /// --- Edit Menu --- connect(ui->actionUndo, SIGNAL(triggered()), editor, SLOT(undo())); connect(ui->actionRedo, SIGNAL(triggered()), editor, SLOT(redo())); connect(ui->actionCut, SIGNAL(triggered()), editor, SLOT(cut())); connect(ui->actionCopy, SIGNAL(triggered()), editor, SLOT(copy())); connect(ui->actionPaste, SIGNAL(triggered()), editor, SLOT(paste())); connect(ui->actionDelete, SIGNAL(triggered()), editor, SLOT(clearCurrentFrame())); connect(ui->actionCrop, SIGNAL(triggered()), editor, SLOT(crop())); connect(ui->actionCrop_To_Selection, SIGNAL(triggered()), editor, SLOT(croptoselect())); connect(ui->actionSelect_All, SIGNAL(triggered()), editor, SIGNAL(selectAll())); connect(ui->actionDeselect_All, SIGNAL(triggered()), editor, SLOT(deselectAll())); connect(ui->actionPreference, SIGNAL(triggered()), this, SLOT(showPreferences())); ui->actionRedo->setEnabled(false); /// --- Layer Menu --- connect(ui->actionNew_Bitmap_Layer, SIGNAL(triggered()), editor, SLOT(newBitmapLayer())); connect(ui->actionNew_Vector_Layer, SIGNAL(triggered()), editor, SLOT(newVectorLayer())); connect(ui->actionNew_Sound_Layer, SIGNAL(triggered()), editor, SLOT(newSoundLayer())); connect(ui->actionNew_Camera_Layer, SIGNAL(triggered()), editor, SLOT(newCameraLayer())); connect(ui->actionDelete_Current_Layer, SIGNAL(triggered()), editor, SLOT(deleteCurrentLayer())); /// --- View Menu --- connect(ui->actionZoom_In, SIGNAL(triggered()), editor, SLOT(setzoom())); connect(ui->actionZoom_Out, SIGNAL(triggered()), editor, SLOT(setzoom1())); connect(ui->actionRotate_Clockwise, SIGNAL(triggered()), editor, SLOT(rotatecw())); connect(ui->actionRotate_Anticlosewise, SIGNAL(triggered()), editor, SLOT(rotateacw())); connect(ui->actionReset_Windows, SIGNAL(triggered()), this, SLOT(dockAllPalettes())); connect(ui->actionReset_View, SIGNAL(triggered()), editor, SLOT(resetView())); connect(ui->actionHorizontal_Flip, SIGNAL(triggered()), editor, SLOT(toggleMirror())); connect(ui->actionVertical_Flip, SIGNAL(triggered()), editor, SLOT(toggleMirrorV())); ui->actionPreview->setEnabled(false); //# connect(previewAct, SIGNAL(triggered()), editor, SLOT(getCameraLayer()));//TODO: Preview view ui->actionGrid->setEnabled(false); connect(ui->actionGrid, SIGNAL(triggered()), editor, SLOT(gridview())); //TODO: Grid view connect(ui->actionOnionPrevious, SIGNAL(triggered(bool)), editor, SIGNAL(toggleOnionPrev(bool))); connect(editor, SIGNAL(onionPrevChanged(bool)), ui->actionOnionPrevious, SLOT(setChecked(bool))); connect(ui->actionOnionNext, SIGNAL(triggered(bool)), editor, SIGNAL(toggleOnionNext(bool))); connect(editor, SIGNAL(onionNextChanged(bool)), ui->actionOnionNext, SLOT(setChecked(bool))); /// --- Animation Menu --- connect(ui->actionPlay, SIGNAL(triggered()), editor, SLOT(play())); connect(ui->actionLoop, SIGNAL(triggered(bool)), editor, SLOT(setLoop(bool))); connect(ui->actionLoop, SIGNAL(toggled(bool)), editor, SIGNAL(toggleLoop(bool))); //TODO: WTF? connect(editor, SIGNAL(loopToggled(bool)), ui->actionLoop, SLOT(setChecked(bool))); connect(ui->actionAdd_Frame, SIGNAL(triggered()), editor, SLOT(addKey())); connect(ui->actionRemove_Frame, SIGNAL(triggered()), editor, SLOT(removeKey())); connect(ui->actionNext_Frame, SIGNAL(triggered()), editor, SLOT(playNextFrame())); connect(ui->actionPrevious_Frame, SIGNAL(triggered()), editor, SLOT(playPrevFrame())); connect(ui->actionNext_Keyframe, SIGNAL(triggered()), editor, SLOT(scrubNextKeyframe())); connect(ui->actionPrev_Keyframe, SIGNAL(triggered()), editor, SLOT(scrubPreviousKeyframe())); connect(ui->actionDuplicate_Frame, SIGNAL(triggered()), editor, SLOT(duplicateKey())); /// --- Tool Menu --- connect(ui->actionClear, SIGNAL(triggered()), editor, SLOT(clearCurrentFrame())); connect(ui->actionMove, SIGNAL(triggered()), m_toolSet, SLOT(moveOn())); connect(ui->actionSelect, SIGNAL(triggered()), m_toolSet, SLOT(selectOn())); connect(ui->actionBrush, SIGNAL(triggered()), m_toolSet, SLOT(brushOn())); connect(ui->actionPolyline, SIGNAL(triggered()), m_toolSet, SLOT(polylineOn())); connect(ui->actionSmudge, SIGNAL(triggered()), m_toolSet, SLOT(smudgeOn())); connect(ui->actionPen, SIGNAL(triggered()), m_toolSet, SLOT(penOn())); connect(ui->actionHand, SIGNAL(triggered()), m_toolSet, SLOT(handOn())); connect(ui->actionPencil, SIGNAL(triggered()), m_toolSet, SLOT(pencilOn())); connect(ui->actionBucket, SIGNAL(triggered()), m_toolSet, SLOT(bucketOn())); connect(ui->actionEyedropper, SIGNAL(triggered()), m_toolSet, SLOT(eyedropperOn())); connect(ui->actionEraser, SIGNAL(triggered()), m_toolSet, SLOT(eraserOn())); connect(ui->actionResetToolsDefault, SIGNAL(triggered()), this, SLOT(resetToolsSettings())); /// --- Help Menu --- connect(ui->actionHelp, SIGNAL(triggered()), this, SLOT(helpBox())); connect(ui->actionAbout, SIGNAL(triggered()), this, SLOT(aboutPencil())); // --------------- Menus ------------------ openRecentMenu = new QMenu(tr("Open recent"), this); connect(ui->menuEdit, SIGNAL(aboutToShow()), this, SLOT(undoActSetText())); connect(ui->menuEdit, SIGNAL(aboutToHide()), this, SLOT(undoActSetEnabled())); }
void MongoServer::saveDocuments(const std::vector<mongo::BSONObj> &objCont, const std::string &db, const std::string &collection) { for (std::vector<mongo::BSONObj>::const_iterator it = objCont.begin(); it != objCont.end(); it++) { saveDocument(*it,db,collection); } }
void MongoServer::saveDocuments(const std::vector<mongo::BSONObj> &objCont, const MongoNamespace &ns) { for (std::vector<mongo::BSONObj>::const_iterator it = objCont.begin(); it != objCont.end(); it++) { saveDocument(*it,ns); } }