void MainWindow::on_actionOpen_triggered()
{
    if(c->started)
    {
        switch ( saveMsg( tr( "File is not saved! \nDo you want to save it?" ) ) ) {
        case QMessageBox::Yes:
            on_actionSave_triggered();
            break;
        case QMessageBox::No:
            fileName = QFileDialog::getOpenFileName(this,
                tr("Open Image"), "", tr("Image Files (*.png *.jpg *.bmp)"));
            if(fileName.isEmpty() )
                return;
            c->openPic(fileName);
            break;
        }
    }
    else
    {
        fileName = QFileDialog::getOpenFileName(this,
            tr("Open Image"), "", tr("Image Files (*.png *.jpg *.bmp)"));
        if(fileName.isEmpty() )
            return;
        c->openPic(fileName);
    }
}
Beispiel #2
0
bool QuaMainWindow::IBFSetupMenuFile()
{
    QAction * actionNew = new QAction(tr("&New"), this);
    actionNew->setShortcut(QKeySequence::New);
    connect(actionNew, SIGNAL(triggered()), this, SLOT(on_actionNew_triggered()));
    addAction(actionNew);

    QAction * actionOpen = new QAction(tr("&Open..."), this);
    actionOpen->setShortcut(QKeySequence::Open);
    connect(actionOpen, SIGNAL(triggered()), this, SLOT(on_actionOpen_triggered()));
    addAction(actionOpen);

    QAction * actionSave = new QAction(tr("&Save"), this);
    actionSave->setShortcut(QKeySequence::Save);
    connect(actionSave, SIGNAL(triggered()), this, SLOT(on_actionSave_triggered()));
    addAction(actionSave);

    QAction * actionSaveAs = new QAction(tr("Save &As..."), this);
    actionSaveAs->setShortcut(QKeySequence::SaveAs);
    connect(actionSaveAs, SIGNAL(triggered()), this, SLOT(on_actionSaveAs_triggered()));
    addAction(actionSaveAs);

    QAction * actionQuit = new QAction(tr("&Quit"), this);
    actionQuit->setShortcut(Qt::CTRL + Qt::Key_Q);
    connect(actionQuit, SIGNAL(triggered()), this, SLOT(close()));
    addAction(actionQuit);

//    QAction * actionPreview = new QAction(tr("Preview"), this);
//    actionPreview->setShortcut(QKeySequence(tr("Ctrl+P")));
//    connect(actionPreview, SIGNAL(triggered()), this, SLOT(on_actionPreview_triggered()));
//    //tViewMenu->addAction(actionPreview);
//    addAction(actionPreview);

    return true;
}
Beispiel #3
0
void MainWindow::initWindowsThumbnail()
{
    if(QSysInfo::WindowsVersion<QSysInfo::WV_VISTA) return;

    pge_thumbbar = new QWinThumbnailToolBar(this);
    pge_thumbbar->setWindow(this->windowHandle());


    QWinThumbnailToolButton *thumbbnt_save = new QWinThumbnailToolButton(pge_thumbbar);
    thumbbnt_save->setToolTip(tr("Save"));
    thumbbnt_save->setIcon(QIcon(":/images/save.png"));
    thumbbnt_save->setDismissOnClick(true);
    connect(thumbbnt_save, SIGNAL(clicked()), this, SLOT(raise()));
    connect(thumbbnt_save, SIGNAL(clicked()), this, SLOT(on_actionSave_triggered()));

    QWinThumbnailToolButton *thumbbnt_open = new QWinThumbnailToolButton(pge_thumbbar);
    thumbbnt_open->setToolTip(tr("Open"));
    thumbbnt_open->setIcon(QIcon(":/images/open.png"));
    thumbbnt_open->setDismissOnClick(true);
    connect(thumbbnt_open, SIGNAL(clicked()), this, SLOT(on_OpenFile_triggered()));

    pge_thumbbar->addButton(thumbbnt_save);
    pge_thumbbar->addButton(thumbbnt_open);



    pge_thumbbar->setIconicPixmapNotificationsEnabled(true);
    connect(pge_thumbbar, SIGNAL(iconicThumbnailPixmapRequested()), this, SLOT(updateWindowsExtrasPixmap()));
    connect(pge_thumbbar, SIGNAL(iconicLivePreviewPixmapRequested()), this, SLOT(updateWindowsExtrasPixmap()));
    connect(ui->centralWidget, SIGNAL(subWindowActivated(QMdiSubWindow*)), this, SLOT(updateWindowsExtrasPixmap()));
}
bool EditorWindow::haveUnsavedChanges()
{
    // Detect if user has unsaved changes
    if (textWasChanged) {

        QMessageBox::StandardButton reply;
        // Ask user for actions
        reply = QMessageBox::question(this,
                                      "Unsaved changes",
                                      "You have unsaved changes.\nSave them?",
                                      QMessageBox::Yes|QMessageBox::No|QMessageBox::Cancel);

        // Discard changes
        if (reply == QMessageBox::No) {
            return false;
        }

        // Save changes
        if (reply == QMessageBox::Yes) {
            on_actionSave_triggered();
            return false;
        }

        return true;
    }

    return false;
}
Beispiel #5
0
bool MainWindow::confirmToGo()
{
    if(!isWindowModified())
        return true;

    //show dialogue
    int ret = QMessageBox::warning(this, tr("Save Changes?"),
                                   tr("The document has been modified.\n" "Do you want to save the changes?"),
                                   QMessageBox::Save, QMessageBox::Discard, QMessageBox::Cancel);

    switch (ret) {

    case QMessageBox::Save:
        if(getCurrentFileName().isEmpty())
            on_actionSaveAs_triggered();
        else
            on_actionSave_triggered();

    case QMessageBox::Discard:
        return true;

    default: // QMessageBox::Cancel
        break;
    }
    return false;

}
Beispiel #6
0
int TvrUiWidget::qt_metacall(QMetaObject::Call _c, int _id, void **_a)
{
    _id = QMainWindow::qt_metacall(_c, _id, _a);
    if (_id < 0)
        return _id;
    if (_c == QMetaObject::InvokeMetaMethod) {
        switch (_id) {
        case 0: on_actionVolume_triggered(); break;
        case 1: on_actionNew_triggered(); break;
        case 2: on_actionSave_triggered(); break;
        case 3: on_actionSaveAs_triggered(); break;
        case 4: on_actionAbout_triggered(); break;
        case 5: on_actionOpen_triggered(); break;
        case 6: on_actionExit_triggered(); break;
        case 7: on_actionRecord_triggered(); break;
        case 8: on_actionStop_triggered(); break;
        case 9: on_actionPlay_triggered(); break;
        case 10: on_actionPaused_triggered(); break;
        case 11: updateProgressBar(); break;
        default: ;
        }
        _id -= 12;
    }
    return _id;
}
SavingStatus MainWindow::doYouWantToSaveChanges()
{
    /* Ask if we want to save changes */
    int answer = QMessageBox::warning(this, "Modification not saved",
                         tr("The document has been modified.\n"
                         "Do you want to save changes?"),
                         QMessageBox::Save | QMessageBox::No
                         | QMessageBox::Cancel,
                         QMessageBox::Save);

    /* Catch answer and do the action associated to it */
    if(answer == QMessageBox::Save){
        on_actionSave_triggered();
        /* We verify if it worked */
        if(m_bAllModifSaved){
            return GO_ON;
        }
        else{
            return ABORT;
        }
    }
    else if(answer == QMessageBox::No){
        return GO_ON;
    }
    else{
       return ABORT;
    }

}
Beispiel #8
0
bool AeWindow::confirmCloseEditor(int tabindex) {
	AeEditor *e = (AeEditor*) m_tabs->widget(tabindex);

	if(e->dirty()) {
		QMessageBox confirm;
		confirm.setIcon(QMessageBox::Question);
		confirm.setText("The document `" + e->displayName() + "' has been modified");
		confirm.setInformativeText("Do you want to save your changes?");
		confirm.setStandardButtons(QMessageBox::Save | QMessageBox::Discard | QMessageBox::Cancel);
		QAbstractButton* diffButton = confirm.addButton("Show diff...", QMessageBox::ActionRole);

		int result = confirm.exec();
		while(confirm.clickedButton() == diffButton) {
			on_actionDiff_to_Saved_triggered();
			result = confirm.exec();
		}

		switch(result) {
		case QMessageBox::Save:
			if(!on_actionSave_triggered()) return false;
			break;
		case QMessageBox::Discard:
			break;
		case QMessageBox::Cancel:
			return false;
		default:
			ae_assert(false && "branch can't happen");
		}

	}

    return closeEditor(tabindex);
}
Beispiel #9
0
//File_sets
void MainWindow::on_actionQuit_2_triggered(){
    if (save_check){
    QMessageBox CloseDialog;
        CloseDialog.setText(tr("Do you want to save file before exit? "));
        CloseDialog.setStandardButtons( QMessageBox::Yes | QMessageBox::No | QMessageBox::Cancel);
        CloseDialog.setDefaultButton(QMessageBox::Cancel);
        CloseDialog.setStyleSheet("color: #fff; background-color: #303030");
        int ret = CloseDialog.exec();
        switch (ret) {
        case QMessageBox::No:
            qApp->exit();
            break;
        case QMessageBox::Yes:
            on_actionSave_triggered();
            if (save_done)
            qApp->exit();
            break;
        case QMessageBox::Cancel:
            break;
        default:
            break;
        }
    } else {
        qApp->exit();
    }
}
Beispiel #10
0
void MainWindow::on_actionRun_interpreter_triggered()
{
#ifdef Q_OS_WIN32
    QString interpreterPath = "interpreter.exe";
#elif defined(Q_OS_MAC)
    QString interpreterPath = "./interpreter.app/Contents/MacOS/interpreter";
#else
    QString interpreterPath = "./interpreter";
#endif
    switch (ui->tabWidget->currentIndex()) {
    case 0: // Command Window
        interpreterProcess->start("interpreter -i");
        if(!interpreterProcess->waitForStarted(5000))
            QMessageBox::critical(this, tr("Error"),
                                  tr("Interpreter cannot be started because of the following error:\n %1")
                                  .arg(interpreterProcess->error()));
        if(!interpreterProcess->waitForReadyRead(6000))
            QMessageBox::critical(this, tr("Error"),
                                  tr("Interpreter cannot read because of the following error:\n %1")
                                  .arg(interpreterProcess->error()));
        break;
    case 1: // File Editor
        on_actionSave_triggered();
        interpreterFileProcess->start("interpreter", {fileName});
        if(!interpreterFileProcess->waitForStarted(5000))
            QMessageBox::critical(this, tr("Error"),
                                  tr("Interpreter cannot be started because of the following error:\n %1")
                                  .arg(interpreterFileProcess->error()));
        break;
    }
}
Beispiel #11
0
void MainWindow::on_actionNew_triggered()
{
    if(c->started)
    {
        switch( saveMsg( tr( "File is not saved! \nDo you want to save it?" ))) {
        case QMessageBox::Yes:
            on_actionSave_triggered();
            break;
        case QMessageBox::No:
            delete c;
            c = new Canvas;
            vbl->addWidget(c);
            ui->frame->setLayout(vbl);
            break;
        }
    }
    else
    {
        delete c;
        c = new Canvas;
        vbl->addWidget(c);
        ui->frame->setLayout(vbl);
        windowName = windowTitle();
    }
}
void MainWindow::on_actionSaveAs_triggered()
{
    QString file = QFileDialog::getSaveFileName(this,"Save a file");
    if (!file.isEmpty())
    {
        mFilename = file;
       on_actionSave_triggered();
    }
}
Beispiel #13
0
void MainWindow::on_actionSave_as_triggered()
{
    QString file = QFileDialog::getSaveFileName(this, "Enter File", "", "Fake (*.fk)");
    if(!file.isEmpty())
    {
        m_file_name = file;
        on_actionSave_triggered();
    }
}
Beispiel #14
0
/**
 * Saves a document in a specific location and draws an attention to existing documents
 */
void MainWindow::on_actionSave_As_triggered()
{
    QString file = QFileDialog::getSaveFileName(this, tr("Save Document"), QDir::home().absolutePath(), "text files (*.sb)");

    if ( !file.isEmpty() )
    {
        fileName = file;
        on_actionSave_triggered();
    }
}
Beispiel #15
0
// save text file as
void MainWindow::on_actionSave_As_triggered()
{
    QString file = QFileDialog::getSaveFileName(this, "Save As", "*.txt");

    // call save function now that file name is provided
    if (!file.isEmpty())
    {
        fileName = file;
        on_actionSave_triggered();
    }
}
Beispiel #16
0
bool AeWindow::confirmCloseEditors(int except) {
	int result = -1;
	for(int i=m_tabs->count() - 1; i>=0; --i) {
		AeEditor *e = (AeEditor*) m_tabs->widget(i);
		if(i == except)
			continue;
		if(e->dirty()) {
			switch(result) {
			case QMessageBox::YesToAll:
				if(!on_actionSave_triggered()) return false;
				break;
			case QMessageBox::NoToAll:
				break;
			default: {
				QMessageBox confirm;
				confirm.setIcon(QMessageBox::Question);
				confirm.setText("The document `" + e->displayName() + "' has been modified");
				confirm.setInformativeText("Do you want to save your changes?");
				confirm.setStandardButtons(QMessageBox::Save | QMessageBox::Discard | QMessageBox::YesToAll | QMessageBox::NoToAll | QMessageBox::Cancel);
				QAbstractButton* diffButton = confirm.addButton("Show diff...", QMessageBox::ActionRole);
				QAbstractButton* skipButton = confirm.addButton("Skip", QMessageBox::RejectRole);

				result = confirm.exec();
				while(confirm.clickedButton() == diffButton) {
					on_actionDiff_to_Saved_triggered();
					result = confirm.exec();
				}
				if(confirm.clickedButton() == skipButton) {
					continue;
				} else if(result == QMessageBox::Save || result == QMessageBox::YesToAll) {
					if(!on_actionSave_triggered()) return false;
				} else if(result == QMessageBox::Cancel)
					return false;
			}
			break;
			}
		}
        closeEditor(i);
	}
	return m_tabs->count()==0;
}
Beispiel #17
0
/*
 * Helper method which will send prompt when a new project would
 * occur before save operation
 */
void Pixelepsy::newProject()
{
    QMessageBox::StandardButton reply;
    reply = QMessageBox::question(this, "Exit", "Save changes to the document before closing?", QMessageBox::Yes|QMessageBox::No|QMessageBox::Cancel);
    if (reply == QMessageBox::Yes)
        on_actionSave_triggered();
    else if (reply == QMessageBox::No)
    {
        //TODO: Reset the sprite class and window
    } else
        cancelFlag = true;
}
Beispiel #18
0
void MainWindow::on_actionNew_triggered()
{
    QTextCursor cursor(ui->textEdit->document());
    if (save_check)
    {

        QMessageBox NewDialog;
            NewDialog.setWindowTitle("WARNING!");
            NewDialog.setText(tr("File have been modified! Do you want to save changes? \nAll unsaved changes will be lost!"));
            NewDialog.setStandardButtons( QMessageBox::Yes | QMessageBox::No | QMessageBox::Cancel);
            NewDialog.setDefaultButton(QMessageBox::Cancel);
            NewDialog.setStyleSheet("color: #fff; background-color: #303030");
            int res = NewDialog.exec();
            switch (res)
            {
            case QMessageBox::Yes:
                on_actionSave_triggered();
                if (save_done)
                {
                    ui->textEdit->clear();
                    save_check = 0;
                }
                break;
            case QMessageBox::No:
                ui->textEdit->clear();

                ui->textEdit->selectAll();
                ui->textEdit->setFontItalic(0);
                ui->textEdit->setFontWeight(10);
                ui->textEdit->setFontUnderline(0);
                ui->textEdit->setAlignment(Qt::AlignLeft);
                ui->textEdit->setCurrentFont(QFont ("Arial",8));
                ui->textEdit->setTextCursor(cursor);
                save_check = 0;
                break;
            case QMessageBox::Cancel:
                break;
            default:
                break;
        }
    } else {
        ui->textEdit->clear();
        ui->textEdit->selectAll();
        ui->textEdit->setFontItalic(0);
        ui->textEdit->setFontWeight(10);
        ui->textEdit->setFontUnderline(0);
        ui->textEdit->setAlignment(Qt::AlignLeft);
        ui->textEdit->setCurrentFont(QFont ("Arial",8));
        ui->textEdit->setTextCursor(cursor);
        save_check = 0;
    }
}
Beispiel #19
0
//Open File
void MainWindow::on_actionOpen_triggered(){
    make_open = 1;
    if (save_check){
        QMessageBox NewDialog;
            NewDialog.setWindowTitle("WARNING!");
            NewDialog.setText(tr("File have been modified! Do you want to save changes? \nAll unsaved changes will be lost!"));
            NewDialog.setStandardButtons( QMessageBox::Yes | QMessageBox::No | QMessageBox::Cancel);
            NewDialog.setDefaultButton(QMessageBox::Cancel);
            NewDialog.setStyleSheet("color: #fff; background-color: #303030");
            int res = NewDialog.exec();
            switch (res)
            {
            case QMessageBox::Yes:
                on_actionSave_triggered();
                break;
            case QMessageBox::No:
                break;
            case QMessageBox::Cancel:
                make_open = 0;
                break;
            default:
                break;
        }
    }
    if (make_open){
    QString FilePath = QFileDialog::getOpenFileName(this, tr("Open File"), "",
            tr("Text Files (*.txt);;C++ Files (*.cpp);; HTML (*.html);;All files (*.*)"));
        if (!FilePath.isEmpty())
        {
            QFile file(FilePath);
            if (!file.open(QIODevice::ReadOnly))
            {
                QMessageBox::critical(this, tr("Error"), tr("Could not open file"));
                return;
            }
            QTextStream text(&file);
            QTextCursor cursor(ui->textEdit->document());
            ui->textEdit->setText(text.readAll());
            this->setWindowTitle(FilePath+" - RagaEditor");
            file.close();
            ui->textEdit->selectAll();
            ui->textEdit->setFontItalic(0);
            ui->textEdit->setFontWeight(10);
            ui->textEdit->setFontUnderline(0);
            ui->textEdit->setAlignment(Qt::AlignLeft);
            ui->textEdit->setCurrentFont(QFont ("Arial",8));
            ui->textEdit->setTextCursor(cursor);
            save_check = false;
            save_done = true;
        }
    }
}
Beispiel #20
0
bool QuaMainWindow::IBFSetupConnections()
{
    connect(mQuaTextEdit, SIGNAL(signal_actionNew()), this, SLOT(on_actionNew_triggered()));
    connect(mQuaTextEdit, SIGNAL(signal_actionOpen()), this, SLOT(on_actionOpen_triggered()));
    connect(mQuaTextEdit, SIGNAL(signal_actionSave()), this, SLOT(on_actionSave_triggered()));
    connect(mQuaTextEdit, SIGNAL(signal_actionSaveAs()), this, SLOT(on_actionSaveAs_triggered()));
    connect(mQuaTextEdit, SIGNAL(signal_actionQuit()), this, SLOT(on_actionQuit_triggered()));

    connect(mQuaTextEdit, SIGNAL(textChanged()), this, SLOT(on_SignalModified()));
    connect(mIBFTreeView, SIGNAL(SignalModified()), this, SLOT(on_SignalModified()));

    return true;
}
Beispiel #21
0
void MainWindow::closeEvent(QCloseEvent *event) {
    if (_model.isRunning()) {
        event->ignore();
        return;
    }

    if (! _model.isClean() && _model.isChanged()) {
        QMessageBox msgBox;
            msgBox.setIcon(QMessageBox::Question);
            msgBox.setText(tr("The document has been modified."));
            msgBox.setInformativeText(tr("Do you want to save your changes?"));
            msgBox.setStandardButtons(QMessageBox::Save | QMessageBox::Discard | QMessageBox::Cancel);
            msgBox.setDefaultButton(QMessageBox::Save);

            switch (msgBox.exec()) {
            case QMessageBox::Save:
                on_actionSave_triggered();
                if (_model.isChanged()) {
                    event->ignore();
                    return;
                }

                break;

            case QMessageBox::Discard:
                // Do nothing
                break;

            case QMessageBox::Cancel:
                event->ignore();
                return;

            default:
                throw std::runtime_error("Invalid ansver");
            }
    }

    // Save geometry
    _settings.setValue(SETTINGS_WINDOW_GEOMETRY, saveGeometry());
    _settings.setValue(SETTINGS_WINDOW_STATE, saveState());

    _settings.setValue(SETTINGS_SPLITTER_STATE, _ui->splitter->saveState());

    _settings.setValue(SETTINGS_TREEHEADER_STATE, _ui->testsTree->header()->saveState());

    // Notify application
    emit Closed(this);

    QMainWindow::closeEvent(event);
}
Beispiel #22
0
void CMainWindow::AskToSaveChanges()
{
    if(m_model)
    {
        if(m_model->IsModified() || m_openedModel == "")
        {
            auto result = QMessageBox::question(this, "Save changes", "Do you want to save changes to current model?",
                                                QMessageBox::Yes | QMessageBox::No);
            if(result == QMessageBox::Yes)
            {
                on_actionSave_triggered();
            }
        }
    }
}
Beispiel #23
0
bool MainWindow::maybeSave()
{
    if (isWindowModified())
    {
        QMessageBox::StandardButton ret;
        ret = QMessageBox::warning(this, tr("Application"),
                                   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 on_actionSave_triggered();
        else if (ret == QMessageBox::Cancel)
            return false;
    }
    return true;
}
Beispiel #24
0
bool AmuWindow::saveToClose()
{
    if (isWindowModified()) {
        int r = QMessageBox::warning(this, tr("Save changes"),
                                     tr("You have some changes.\n"
                                        "Do you want to save it?"),
                                     QMessageBox::Save | QMessageBox::Discard
                                     | QMessageBox::Cancel);
        if (r == QMessageBox::Save)
            return on_actionSave_triggered();

        else if (r == QMessageBox::Cancel)
            return false;
    }
    return true;
}
Beispiel #25
0
void MainWindow::on_actionExit_triggered()
{
    if (c->started)
    {
        switch( saveMsg(tr("File is not saved. \nSave it?")) )
        {
        case QMessageBox::No:
            qApp->quit();
            break;
        case QMessageBox::Yes:
            on_actionSave_triggered();
            break;
        }
    }else
        qApp->quit();
}
Beispiel #26
0
void MainWindow::closeEvent(QCloseEvent *event)
{
    if(changedSinceSave) {
        switch(saveAlert->exec()) {
        case QMessageBox::Save:
            on_actionSave_triggered();
        case QMessageBox::Discard:
            event->accept();
            break;
        default:
            event->ignore();
            break;
        }
    } else {
        event->accept();
    }
}
Beispiel #27
0
    MainWindow::MainWindow(QWidget *parent) :
    QMainWindow(parent),
    ui(new Ui::MainWindow)
{
    ui->setupUi(this);
    setUpEditor();

    //adds new tab button
    QToolButton *newTabButton = new QToolButton(this);
    ui->tabWidget->setCornerWidget(newTabButton);
    newTabButton->setAutoRaise(true);
    newTabButton->setText("+");

    //connect signals
    QObject::connect(newTabButton, SIGNAL(clicked()), this, SLOT(makeNewTab()));
    QObject::connect(ui->tabWidget, SIGNAL(tabCloseRequested(int)), this, SLOT(deleteTab(int)));

    //create keyboard shortcuts
    QShortcut *shortcut = new QShortcut(QKeySequence("ctrl+w"), ui->tabWidget);
    QObject::connect(shortcut, SIGNAL(activated()), this, SLOT(deleteCurrentTab()));

    shortcut = new QShortcut(QKeySequence("ctrl+t"), ui->tabWidget);
    QObject::connect(shortcut, SIGNAL(activated()), this, SLOT(makeNewTab()));

    shortcut = new QShortcut(QKeySequence("ctrl+s"), ui->tabWidget);
    QObject::connect(shortcut, SIGNAL(activated()), this, SLOT(on_actionSave_triggered()));

    shortcut = new QShortcut(QKeySequence("ctrl+shift+s"), ui->tabWidget);
    QObject::connect(shortcut, SIGNAL(activated()), this, SLOT(on_actionSave_As_triggered()));

    shortcut = new QShortcut(QKeySequence("ctrl+o"), ui->tabWidget);
    QObject::connect(shortcut, SIGNAL(activated()), this, SLOT(on_actionOpen_triggered()));

    shortcut = new QShortcut(QKeySequence("ctrl+q"), ui->tabWidget);
    QObject::connect(shortcut, SIGNAL(activated()), this, SLOT(on_actionQuit_triggered()));

    shortcut = new QShortcut(QKeySequence("ctrl+tab"), ui->tabWidget);
    QObject::connect(shortcut, SIGNAL(activated()), this, SLOT(switchToNextTab()));

    shortcut = new QShortcut(QKeySequence("ctrl+shift+tab"), ui->tabWidget);
    QObject::connect(shortcut, SIGNAL(activated()), this, SLOT(switchToPrevTab()));

    shortcut = new QShortcut(QKeySequence("ctrl+d"), ui->tabWidget);
    QObject::connect(shortcut, SIGNAL(activated()), this, SLOT(deleteLine()));
}
Beispiel #28
0
void MainWindow::on_actionSave_As_triggered()
{
    if (_model.isRunning())
        return;

    QString newFile = QFileDialog::getSaveFileName(this, tr("Save GTester file"), QDir::homePath(), tr("GTester Files (*.gtester);;All Files (*)"));

    if (! newFile.isEmpty()) {
        // Append extension if necessary
        if (! newFile.endsWith(".gtester")) {
            newFile.append(".gtester");
        }

        _actualFile = newFile;
        on_actionSave_triggered();
        updateTitle();
    }
}
Beispiel #29
0
// function that checks if it is ok to continue when the current program
// has been modified; return false if the user cancels the request to save
// the modified program
bool MainWindow::isOkToContinue(void)
{
	if (isWindowModified())
	{
		int answer = QMessageBox::warning(this, tr("IBCP"), tr("The program "
			"has been modified.\nDo you want to save the changes?"),
			QMessageBox::Yes | QMessageBox::No | QMessageBox::Cancel);
		if (answer == QMessageBox::Yes)
		{
			return on_actionSave_triggered();
		}
		else if (answer == QMessageBox::Cancel)
		{
			return false;
		}
	}
	return true;
}
Beispiel #30
0
bool MainWindow::promptUnsavedWork()
{
    if (isDirty()) {
        auto answer =
            QMessageBox::question(this,
                                  "Save your current work?",
                                  "Looks like you left a masterpiece behind. Do you want to save it?",
                                  QMessageBox::StandardButtons(QMessageBox::Yes | QMessageBox::No | QMessageBox::Cancel));
        if (answer == QMessageBox::Yes) {
            on_actionSave_triggered();
            if (isDirty()) return false;
        } else if (answer == QMessageBox::Cancel) {
            return false;
        }
    }

    return true;
}