Esempio n. 1
0
void Letterbox::open()
{
	pause(true);

	if (m_modified)
	{
		switch (askToSave())
		{
		case 0:
			writeFile();

		case 1:
			break;

		case 2:
			return;
		}
	}
	
	QString defaultFilter = defaultStudyListFileFilter();
	QString filename = QFileDialog::getOpenFileName(this, tr("Choose Letterbox file to open"), getInitialDirectory(), studyListFileFilters(), &defaultFilter);
	if (!filename.isEmpty())
	{
		setInitialDirectory(filename);
		m_filename = filename;
		loadFile();
		saveSettings();
	}
}
Esempio n. 2
0
void Window::OnOpen(wxCommandEvent& WXUNUSED(event)) {
	if (askToSave()) {
		wxFileDialog d(this, wxFileSelectorPromptStr, wxEmptyString, wxEmptyString, wxT("Native (*.zngx)|*.zngx|Legacy 16 Bit (*.ZNG)|*.ZNG|Legacy 32 Bit (*.ZNG)|*.ZNG"));

		if (d.ShowModal() == wxID_OK)
			openFile(d.GetPath(), static_cast<Data::fileFormat>(d.GetFilterIndex()));
	}
}
Esempio n. 3
0
void LuaEditor::closeEvent(QCloseEvent *event)
{
    QMessageBox::StandardButton ret = askToSave();
    if(ret == QMessageBox::Save)
    {
        save();
        event->accept();
    } else if(ret == QMessageBox::Discard || QMessageBox::NoButton) {
        this->close();
    } else if(ret == QMessageBox::Cancel) {
        event->ignore();
    }
}
Esempio n. 4
0
void MainWindow::closeEvent(QCloseEvent* event)
{
	if (m_readyToClose)
	{
		event->accept();
		return;
	}

	if (askToSave())
	{
		m_closing = true;

		for (int i = m_tabs.size() - 1; i >= 0; i--)
			onTabCloseRequested(i);

		if (m_tabs.isEmpty())
			CuteChessApplication::instance()->gameManager()->finish();
	}

	event->ignore();
}
Esempio n. 5
0
void Letterbox::openParticularFile(const QString &filename)
{
	if (!filename.isEmpty())
	{
		if (m_modified)
		{
			switch (askToSave())
			{
				case 0:
					writeFile();

				case 1:
					break;

				case 2:
					return;
			}
		}

		m_filename = filename;
		loadFile();
	}
}
Esempio n. 6
0
bool Letterbox::tryToClose()
{
	pause(true);

	if (m_modified)
	{
		switch (askToSave())
		{
		case 0:
			qApp->processEvents();
			writeFile();

			// fall through

		case 1:
			return true;

		case 2:
			return false;
		}
	}

	return true;
}
Esempio n. 7
0
void Window::OnClose(wxCloseEvent& evt) {
	if (!askToSave())
		evt.Veto();
	else
		Destroy();
}
Esempio n. 8
0
void Window::OnNew(wxCommandEvent& WXUNUSED(event)) {
	if (askToSave()) {
		canvas->clear();
		canvas->Refresh();
	}
}