Ejemplo n.º 1
0
void MainWindow::saveFileAs()
{
    QFileDialog fd(this, "Save voxel file as...");
    fd.setFilter(tr("Sproxel project (*.sxl)"));
    fd.setAcceptMode(QFileDialog::AcceptSave);
    fd.exec();
    QStringList qsl = fd.selectedFiles();
    if (qsl.isEmpty()) return;
    if (QFileInfo(qsl[0]).isDir()) return;  // It returns the directory if you press Cancel

    QString filename = qsl[0];
    QString activeFilter = fd.selectedNameFilter();

    // Switch on save type
    bool success = false;
    if (!filename.endsWith(".sxl", Qt::CaseInsensitive))
        filename.append(".sxl");
    success = save_project(filename, m_project);

    if (success)
    {
        m_undoManager.setClean();
        m_activeFilename = filename;
        setWindowTitle(BASE_WINDOW_TITLE + " - " + m_activeFilename);  // TODO: Functionize (resetWindowTitle)
    }
    else
      QMessageBox::critical(this, "Sproxel Error", QString("Error saving project to file ")+filename);
}
Ejemplo n.º 2
0
void MainWindow::saveFile()
{
    if (m_undoManager.isClean())
        return;

    if (m_activeFilename == "")
        return saveFileAs();

    bool success = save_project(m_activeFilename, m_project);

    if (success)
      m_undoManager.setClean();
    else
      QMessageBox::critical(this, "Sproxel Error", QString("Error saving project to file ")+m_activeFilename);
}
Ejemplo n.º 3
0
/*
 * Warn about a possible bug displaying the passed message, try to save
 * any unsaved work and abort
 */
void emergency_exit(GraceApp *gapp, int is_my_bug, char *msg)
{
/*
 *  Since we got so far, memory is probably corrupted so it's better to use
 *  a static storage
 */
    static char buf[GR_MAXPATHLEN];
    int i;
    
    if (gapp->rt->emergency_save != FALSE) {
        /* don't mind signals anymore: we're in emergency save mode already */
        gapp->rt->interrupts++;
        if (gapp->rt->interrupts > 10) {
            fprintf(stderr, "oh, no luck :-(\n");
            please_report_the_bug();
            abort();
        }
        return;
    } else {
        gapp->rt->emergency_save = TRUE;
        gapp->rt->interrupts = 0;
        fprintf(stderr, "\a\nOops! %s\n", msg);

        for (i = 0; i < gapp->gpcount; i++) {
            if (gapp->gplist[i] && quark_dirtystate_get(gproject_get_top(gapp->gplist[i]))) {
                strcpy(buf, gproject_get_docname(gapp->gplist[i]));
                strcat(buf, "$");
                fprintf(stderr, "Trying to save your work into file \"%s\"... ", buf);
                fflush(stderr);
                gapp->gui->noask = TRUE;
                if (save_project(gapp->gplist[i], buf) == RETURN_SUCCESS) {
                    fprintf(stderr, "ok!\n");
                } else {
                    fprintf(stderr, "oh, no luck :-(\n");
                }
            }
        }
        if (is_my_bug) {
            please_report_the_bug();
        }
        abort();
    }
}