bool MainWindow2::saveAsNewDocument() { QSettings settings( "Pencil", "Pencil" ); QString strDefaultFileName = settings.value( "lastFilePath", QVariant( QDir::homePath() ) ).toString(); if ( strDefaultFileName.isEmpty() ) { strDefaultFileName = QDir::homePath() + "/" + PFF_DEFAULT_FILENAME; } QString fileName = QFileDialog::getSaveFileName( this, tr( "Save As..." ), strDefaultFileName, tr( PFF_CLOSE_ALL_FILE_FILTER ) ); if ( fileName.isEmpty() ) { return false; } else { if ( !fileName.endsWith( PFF_OLD_EXTENSION ) && !fileName.endsWith( PFF_EXTENSION ) ) { fileName = fileName + PFF_EXTENSION; } QSettings settings( "Pencil", "Pencil" ); settings.setValue( "lastFilePath", QVariant( fileName ) ); return saveObject( fileName ); } }
bool MainWindow2::saveAsNewDocument() { QSettings settings("Pencil","Pencil"); QString strDefaultFileName = settings.value("lastFilePath", QVariant(QDir::homePath())).toString(); if (strDefaultFileName.isEmpty()) { strDefaultFileName = QDir::homePath() + "/untitled.pcl"; } QString fileName = QFileDialog::getSaveFileName(this, tr("Save As..."),strDefaultFileName ,tr("PCL (*.pcl)")); if (fileName.isEmpty()) { return false; } else { if (! fileName.endsWith(".pcl")) { fileName = fileName + ".pcl"; } QSettings settings("Pencil","Pencil"); settings.setValue("lastFilePath", QVariant(fileName)); return saveObject(fileName); } }
void ObjectEditor::ClikedButton(QPushButton *b){ if(b==OpenObjectButton){ openObject((*Projectpatch)+"/"+OBJECT_DIR); } if(b==PlayAnimation&&ObjectRender!=NULL&&AnimationsIndex->count()){ ObjectRender->Play(AnimationsIndex->currentIndex()); } if(b==create){ createObject((*Projectpatch)+"/"+SPRITE_DIR); } if(b==ClearAnimation&&ObjectRender!=NULL){ ObjectRender->Replay(); } if(b==Save&&ObjectRender){ saveObject(); } if(b==Bcolor&&ObjectRender!=NULL&&AnimationsIndex->count()){ QColor temp=QColorDialog::getColor(Qt::black,getMain()); camera->setBackgroundColor(temp); } if(b==Delete&&ObjectRender){ int temp = QMessageBox::question(getMain(), "Warning","delete \'"+ObjectRender->getObjectPatch()+"\' Object?", QMessageBox::No|QMessageBox::Yes); if(temp== QMessageBox::Yes){ if(ObjectRender->getEObjectNameClass()==E_GAME_RESURS){ pack->remove(((EGameResurs*)ObjectRender)->getRes()->getSource()->id()); pack->save(); } QString temp=ObjectRender->getObjectPatch(); this->removeObject(ObjectRender); QFile(temp).remove(); ObjectRender=NULL; } } }
bool MainWindow2::saveAsNewDocument() { QSettings settings( PENCIL2D, PENCIL2D ); QString strLastFolder = settings.value( LAST_FILE_PATH, QDir::homePath() ).toString(); if ( strLastFolder.isEmpty() || !QDir(strLastFolder).exists() ) { strLastFolder = QDir( QDir::homePath() ).filePath( PFF_DEFAULT_FILENAME ); } QString fileName = QFileDialog::getSaveFileName( this, tr( "Save As..." ), strLastFolder, tr( PFF_SAVE_ALL_FILE_FILTER ) ); if ( fileName.isEmpty() ) { return false; } if ( !fileName.endsWith( PFF_OLD_EXTENSION ) && !fileName.endsWith( PFF_EXTENSION ) ) { fileName = fileName + PFF_EXTENSION; } settings.setValue( LAST_FILE_PATH, QVariant( fileName ) ); return saveObject( fileName ); }
UAVObjectBrowserWidget::UAVObjectBrowserWidget(QWidget *parent) : QWidget(parent), updatePeriod(MAXIMUM_UPDATE_PERIOD) { // Create browser and configuration GUIs m_browser = new Ui_UAVObjectBrowser(); m_viewoptions = new Ui_viewoptions(); m_viewoptionsDialog = new QDialog(this); m_viewoptions->setupUi(m_viewoptionsDialog); m_browser->setupUi(this); // Create data model m_model = new UAVObjectTreeModel(this); // Create tree view and add to layout treeView = new UAVOBrowserTreeView(MAXIMUM_UPDATE_PERIOD); treeView->setObjectName(QString::fromUtf8("treeView")); m_browser->verticalLayout->addWidget(treeView); connect(m_browser->saveSDButton, SIGNAL(clicked()), this, SLOT(saveObject())); connect(m_browser->readSDButton, SIGNAL(clicked()), this, SLOT(loadObject())); connect(m_browser->eraseSDButton, SIGNAL(clicked()), this, SLOT(eraseObject())); connect(m_browser->sendButton, SIGNAL(clicked()), this, SLOT(sendUpdate())); connect(m_browser->requestButton, SIGNAL(clicked()), this, SLOT(requestUpdate())); connect(m_browser->viewSettingsButton,SIGNAL(clicked()),this,SLOT(viewSlot())); connect((QTreeView*) treeView, SIGNAL(collapsed(QModelIndex)), this, SLOT(onTreeItemCollapsed(QModelIndex) )); connect((QTreeView*) treeView, SIGNAL(expanded(QModelIndex)), this, SLOT(onTreeItemExpanded(QModelIndex) )); connect(m_browser->le_searchField, SIGNAL(textChanged(QString)), this, SLOT(searchTextChanged(QString))); connect(m_browser->bn_clearSearchField, SIGNAL(clicked()), this, SLOT(searchTextCleared())); // Set browser buttons to disabled enableUAVOBrowserButtons(false); }
void EditObjectDialog::closeEvent ( QCloseEvent * e ) { if (!object()) { e->accept(); qDebug() << "object is not accepted"; return; } if (object()->isChanged()) { int result = QMessageBox::question(this,tr("Close"),tr("Do you want to save the changes before closing?"), QMessageBox::Yes | QMessageBox::No | QMessageBox::Cancel); if (result == QMessageBox::Cancel) { e->ignore(); } else if (result == QMessageBox::No) { e->accept(); } else { if (saveObject()) e->accept(); } } else { e->accept(); } saveSettings(); }
UAVObjectBrowserWidget::UAVObjectBrowserWidget(QWidget *parent) : QWidget(parent) { m_browser = new Ui_UAVObjectBrowser(); m_viewoptions = new Ui_viewoptions(); m_viewoptionsDialog = new QDialog(this); m_viewoptions->setupUi(m_viewoptionsDialog); m_browser->setupUi(this); m_model = new UAVObjectTreeModel(); m_browser->treeView->setModel(m_model); m_browser->treeView->setColumnWidth(0, 300); // m_browser->treeView->expandAll(); BrowserItemDelegate *m_delegate = new BrowserItemDelegate(); m_browser->treeView->setItemDelegate(m_delegate); m_browser->treeView->setEditTriggers(QAbstractItemView::AllEditTriggers); m_browser->treeView->setSelectionBehavior(QAbstractItemView::SelectItems); showMetaData(m_viewoptions->cbMetaData->isChecked()); connect(m_browser->treeView->selectionModel(), SIGNAL(currentChanged(QModelIndex, QModelIndex)), this, SLOT(currentChanged(QModelIndex, QModelIndex)), Qt::UniqueConnection); connect(m_viewoptions->cbMetaData, SIGNAL(toggled(bool)), this, SLOT(showMetaData(bool))); connect(m_viewoptions->cbCategorized, SIGNAL(toggled(bool)), this, SLOT(categorize(bool))); connect(m_browser->saveSDButton, SIGNAL(clicked()), this, SLOT(saveObject())); connect(m_browser->readSDButton, SIGNAL(clicked()), this, SLOT(loadObject())); connect(m_browser->eraseSDButton, SIGNAL(clicked()), this, SLOT(eraseObject())); connect(m_browser->sendButton, SIGNAL(clicked()), this, SLOT(sendUpdate())); connect(m_browser->requestButton, SIGNAL(clicked()), this, SLOT(requestUpdate())); connect(m_browser->tbView, SIGNAL(clicked()), this, SLOT(viewSlot())); connect(m_viewoptions->cbScientific, SIGNAL(toggled(bool)), this, SLOT(useScientificNotation(bool))); connect(m_viewoptions->cbScientific, SIGNAL(toggled(bool)), this, SLOT(viewOptionsChangedSlot())); connect(m_viewoptions->cbMetaData, SIGNAL(toggled(bool)), this, SLOT(viewOptionsChangedSlot())); connect(m_viewoptions->cbCategorized, SIGNAL(toggled(bool)), this, SLOT(viewOptionsChangedSlot())); enableSendRequest(false); }
void MainWindow2::saveDocument() { if ( !m_object->filePath().isEmpty() ) { saveObject( m_object->filePath() ); } else { saveAsNewDocument(); } }
void MainWindow2::saveDocument() { if ( !m_object->strCurrentFilePath.isEmpty() ) { saveObject(m_object->strCurrentFilePath); } else { saveAsNewDocument(); } }
bool saveObject(SimObject *obj, const char *filename) { FileStream *stream; if((stream = FileStream::createAndOpen( filename, Torque::FS::File::Write )) == NULL) return false; bool ret = saveObject(obj, stream); delete stream; return ret; }
UAVObjectBrowserWidget::UAVObjectBrowserWidget(QWidget *parent) : QWidget(parent), updatePeriod(MAXIMUM_UPDATE_PERIOD) { // Create browser and configuration GUIs m_browser = new Ui_UAVObjectBrowser(); m_viewoptions = new Ui_viewoptions(); m_viewoptionsDialog = new QDialog(this); m_viewoptions->setupUi(m_viewoptionsDialog); m_browser->setupUi(this); // Create data model m_model = new UAVObjectTreeModel(); // Create tree view and add to layout treeView = new UAVOBrowserTreeView(m_model, MAXIMUM_UPDATE_PERIOD); treeView->setObjectName(QString::fromUtf8("treeView")); m_browser->verticalLayout->addWidget(treeView); treeView->setModel(m_model); treeView->setColumnWidth(0, 300); treeView->setEditTriggers(QAbstractItemView::AllEditTriggers); treeView->setSelectionBehavior(QAbstractItemView::SelectItems); treeView->setUniformRowHeights(true); BrowserItemDelegate *m_delegate = new BrowserItemDelegate(); treeView->setItemDelegate(m_delegate); showMetaData(m_viewoptions->cbMetaData->isChecked()); // Connect signals connect(treeView->selectionModel(), SIGNAL(currentChanged(QModelIndex,QModelIndex)), this, SLOT(toggleUAVOButtons(QModelIndex,QModelIndex))); connect(m_viewoptions->cbMetaData, SIGNAL(toggled(bool)), this, SLOT(showMetaData(bool))); connect(m_viewoptions->cbCategorized, SIGNAL(toggled(bool)), this, SLOT(categorize(bool))); connect(m_browser->saveSDButton, SIGNAL(clicked()), this, SLOT(saveObject())); connect(m_browser->readSDButton, SIGNAL(clicked()), this, SLOT(loadObject())); connect(m_browser->eraseSDButton, SIGNAL(clicked()), this, SLOT(eraseObject())); connect(m_browser->sendButton, SIGNAL(clicked()), this, SLOT(sendUpdate())); connect(m_browser->requestButton, SIGNAL(clicked()), this, SLOT(requestUpdate())); connect(m_browser->viewSettingsButton,SIGNAL(clicked()),this,SLOT(viewSlot())); connect(m_viewoptions->cbScientific, SIGNAL(toggled(bool)), this, SLOT(useScientificNotation(bool))); connect(m_viewoptions->cbScientific, SIGNAL(toggled(bool)), this, SLOT(viewOptionsChangedSlot())); connect(m_viewoptions->cbMetaData, SIGNAL(toggled(bool)), this, SLOT(viewOptionsChangedSlot())); connect(m_viewoptions->cbCategorized, SIGNAL(toggled(bool)), this, SLOT(viewOptionsChangedSlot())); connect((QTreeView*) treeView, SIGNAL(collapsed(QModelIndex)), this, SLOT(on_TreeItemCollapsed(QModelIndex) )); connect((QTreeView*) treeView, SIGNAL(expanded(QModelIndex)), this, SLOT(on_TreeItemExpanded(QModelIndex) )); // Set browser buttons to disabled enableUAVOBrowserButtons(false); }
ObjectTree::ObjectTree(QWidget *parent) : QVBox(parent) { copying = false; cutting = false; referencing = false; list = new ObjectListView(this); list->addColumn("Objects"); list->addColumn("Value"); list->addColumn("Def"); list->setRootIsDecorated(true); list->setItemMargin(3); list->setTreeStepSize(15); list->setAcceptDrops(true); menu = new QMenu(list); menu->addAction(QIcon(QPixmap("icons/add.png")), "Add", this, SLOT(addAttribute())); menu->addAction(QIcon(QPixmap("icons/remove.png")), "Delete", this, SLOT(deleteObject())); menu->addAction(QIcon(QPixmap("icons/object.png")), "View", this, SLOT(viewObject())); menu->addAction(QIcon(QPixmap("icons/filesaveobj.png")), "Save...", this, SLOT(saveObject())); menu->addSeparator(); menu->addAction(QIcon(QPixmap("icons/editcut.png")), "Cut", this, SLOT(objcut())); menu->addAction(QIcon(QPixmap("icons/editcopy.png")), "Copy", this, SLOT(objcopy())); menu->addAction(QIcon(QPixmap("icons/definition.png")), "Reference", this, SLOT(objref())); menu->addSeparator(); menu->addAction(QIcon(QPixmap("icons/trace.png")), "Trace", this, SLOT(traceObject())); menu->addAction(QIcon(QPixmap("icons/monitor.png")), "Monitor"); menu->addAction(QIcon(QPixmap("icons/edit.png")), "Edit", this, SLOT(editObject())); icon_array = new QPixmap[NUM_OBJTYPES]; for (int i=0; i<NUM_OBJTYPES; i++) { icon_array[i] = QPixmap(icon_files[i]); } icon_def = new QPixmap(icon_deffile); new ObjectItem(list, Null, Null, core::root, "root", false); //new ObjectItem(list, Null, Null, doste::Current, "current", false); //aname = new AttribNameDialog(); connect(list, SIGNAL(expanded(QTreeWidgetItem*)), this, SLOT(expanded(QTreeWidgetItem*))); connect(list, SIGNAL(collapsed(QTreeWidgetItem*)), this, SLOT(collapsed(QTreeWidgetItem*))); connect(list, SIGNAL(itemRenamed(QTreeWidgetItem *, int, const QString&)), this, SLOT(itemRenamed(QTreeWidgetItem*, int, const QString&))); connect(list, SIGNAL(rightButtonClicked(QTreeWidgetItem *, const QPoint&, int)), this, SLOT(rightButtonClicked(QTreeWidgetItem*, const QPoint&, int))); connect(list, SIGNAL(onItem(QTreeWidgetItem*)), this, SLOT(onItem(QTreeWidgetItem*))); connect(list, SIGNAL(clicked(QTreeWidgetItem*)), this, SLOT(itemClicked(QTreeWidgetItem*))); }
UAVObjectBrowserWidget::UAVObjectBrowserWidget(QWidget *parent) : QWidget(parent) { m_browser = new Ui_UAVObjectBrowser(); m_browser->setupUi(this); m_model = new UAVObjectTreeModel(); m_browser->treeView->setModel(m_model); m_browser->treeView->setColumnWidth(0, 300); //m_browser->treeView->expandAll(); BrowserItemDelegate *m_delegate = new BrowserItemDelegate(); m_browser->treeView->setItemDelegate(m_delegate); m_browser->treeView->setEditTriggers(QAbstractItemView::AllEditTriggers); m_browser->treeView->setSelectionBehavior(QAbstractItemView::SelectItems); showMetaData(m_browser->metaCheckBox->isChecked()); connect(m_browser->treeView->selectionModel(), SIGNAL(currentChanged(QModelIndex,QModelIndex)), this, SLOT(currentChanged(QModelIndex,QModelIndex))); connect(m_browser->metaCheckBox, SIGNAL(toggled(bool)), this, SLOT(showMetaData(bool))); connect(m_browser->saveSDButton, SIGNAL(clicked()), this, SLOT(saveObject())); connect(m_browser->readSDButton, SIGNAL(clicked()), this, SLOT(loadObject())); connect(m_browser->eraseSDButton, SIGNAL(clicked()), this, SLOT(eraseObject())); connect(m_browser->sendButton, SIGNAL(clicked()), this, SLOT(sendUpdate())); connect(m_browser->requestButton, SIGNAL(clicked()), this, SLOT(requestUpdate())); enableSendRequest(false); }
void ofxFeatureFinder::createAndSaveObject(string filepath) { ofxFeatureFinderObject object = createObject(); saveObject(object, filepath); }
void EditObjectDialog::accept() { if (saveObject()) QDialog::accept(); }