Example #1
0
//-----------------------------------------------------------------------------
// Function: saveAs()
//-----------------------------------------------------------------------------
bool ApiDefinitionEditor::saveAs()
{
    // Ask the user for a new VLNV and directory.
    VLNV vlnv;
    QString directory;

    if (!NewObjectDialog::saveAsDialog(parentWidget(), libHandler_, *apiDef_->getVlnv(), vlnv, directory))
    {
        return false;
    }

    // Create a copy of the object and update its VLNV.
    apiDef_ = QSharedPointer<ApiDefinition>(new ApiDefinition(*apiDef_));

    vlnv.setType(VLNV::APIDEFINITION);
    apiDef_->setVlnv(vlnv);

    // Apply changes to the copy.
    applyChanges();

    if (libHandler_->writeModelToFile(directory, apiDef_))
    {
        setDocumentName(vlnv.getName() + " (" + vlnv.getVersion() + ")");
        return TabDocument::saveAs();
    }
    else
    {
        return false;
    }
}
Example #2
0
	void MainWindow::openFile(const QString &path)
	{
		QString ftmpath = QFileInfo(path).absoluteDir().absolutePath();
		settings()->setValue(SETTINGS_FTMPATH, ftmpath);

		core::FileIO *io = new core::FileIO(path.toLocal8Bit(), core::IO_READ);

		gui::stopSongConcurrent(open_cb, io);
		gui::addRecentFile(path);
		reloadRecentFiles();

		setDocumentName(QFileInfo(path).fileName());
	}
Example #3
0
//-----------------------------------------------------------------------------
// Function: ApiDefinitionEditor()
//-----------------------------------------------------------------------------
ApiDefinitionEditor::ApiDefinitionEditor(QWidget *parent, LibraryInterface* libHandler,
                                         QSharedPointer<ApiDefinition> apiDef)
    : TabDocument(parent, DOC_PROTECTION_SUPPORT),
      libHandler_(libHandler),
      apiDef_(apiDef),
      comDefVLNVEdit_(VLNV::COMDEFINITION, libHandler, parent, this),
      dataTypeList_(tr("Data types"), this),
      functionEditor_(this)
{
    // Initialize the editors.
    dataTypeList_.initialize(apiDef->getDataTypes());

    functionEditor_.updateDataTypes(apiDef->getDataTypes());
    functionEditor_.restore(*apiDef);

    comDefVLNVEdit_.setTitle(tr("COM definition reference (optional)"));
    comDefVLNVEdit_.setVLNV(apiDef->getComDefinitionRef());
    updateComDefinition();

    connect(&dataTypeList_, SIGNAL(contentChanged()), this, SIGNAL(contentChanged()), Qt::UniqueConnection);
    connect(&dataTypeList_, SIGNAL(contentChanged()), this, SLOT(updateDataTypeLists()), Qt::UniqueConnection);
    connect(&comDefVLNVEdit_, SIGNAL(contentChanged()), this, SIGNAL(contentChanged()), Qt::UniqueConnection);
    connect(&comDefVLNVEdit_, SIGNAL(contentChanged()), this, SLOT(updateComDefinition()), Qt::UniqueConnection);
    connect(&functionEditor_, SIGNAL(contentChanged()), this, SIGNAL(contentChanged()), Qt::UniqueConnection);

    // Setup the layout.
    QVBoxLayout* layout = new QVBoxLayout(this);
    layout->addWidget(&dataTypeList_);
    layout->addWidget(&comDefVLNVEdit_);
    layout->addWidget(&functionEditor_, 1);

    setModified(false);

    // Set the document name and type.
    VLNV const* vlnv = apiDef_->getVlnv();
    setDocumentName(vlnv->getName() + " (" + vlnv->getVersion() + ")");
    setDocumentType(tr("API Definition"));

    // Open in unlocked mode by default only if the version is draft.
    setProtection(vlnv->getVersion() != "draft");
}
Example #4
0
	MainWindow::MainWindow(App *a)
		: m_close_shutdown(false), m_app(a)
	{
		setupUi(this);
		setDocumentName("");
		instruments->setIconSize(QSize(16,16));

		speed->setRange(MIN_SPEED, MAX_SPEED);
		tempo->setRange(MIN_TEMPO, MAX_TEMPO);
		rows->setRange(1, MAX_PATTERN_LENGTH);
		frames->setRange(1, MAX_FRAMES);

		title->setMaxLength(MAX_SONGINFO_LENGTH);
		author->setMaxLength(MAX_SONGINFO_LENGTH);
		copyright->setMaxLength(MAX_SONGINFO_LENGTH);
		instrumentName->setMaxLength(MAX_INSTRUMENT_NAME_LENGTH);

		QObject::connect(actionNew, SIGNAL(triggered()), this, SLOT(newDoc()));
		actionNew->setIcon(QIcon::fromTheme("document-new"));
		QObject::connect(action_Open, SIGNAL(triggered()), this, SLOT(open()));
		action_Open->setIcon(QIcon::fromTheme("document-open"));
		QObject::connect(action_Save, SIGNAL(triggered()), this, SLOT(save()));
		action_Save->setIcon(QIcon::fromTheme("document-save"));
		QObject::connect(actionSave_As, SIGNAL(triggered()), this, SLOT(saveAs()));
		QObject::connect(action_Create_NSF, SIGNAL(triggered()), this, SLOT(unimplemented()));
		QObject::connect(actionCreate_WAV, SIGNAL(triggered()), this, SLOT(createWAV()));
		QObject::connect(actionImport_MIDI, SIGNAL(triggered()), this, SLOT(unimplemented()));
		QObject::connect(action_Configuration, SIGNAL(triggered()), this, SLOT(unimplemented()));
		QObject::connect(actionE_xit, SIGNAL(triggered()), this, SLOT(quit()));

		QObject::connect(actionModule_Properties, SIGNAL(triggered()), this, SLOT(moduleProperties()));

		QObject::connect(action_ViewToolbar, SIGNAL(toggled(bool)), this, SLOT(viewToolbar(bool)));
		QObject::connect(action_ViewStatusBar, SIGNAL(toggled(bool)), this, SLOT(viewStatusBar(bool)));
		QObject::connect(action_ViewControlpanel, SIGNAL(toggled(bool)), this, SLOT(viewControlpanel(bool)));
		QObject::connect(toolBar, SIGNAL(visibilityChanged(bool)), action_ViewToolbar, SLOT(setChecked(bool)));
		QObject::connect(controlPanel, SIGNAL(visibilityChanged(bool)), this, SLOT(controlPanelVisibilityChanged()));

		QObject::connect(action_About, SIGNAL(triggered()), this, SLOT(about()));
		QObject::connect(actionAbout_Qt, SIGNAL(triggered()), qApp, SLOT(aboutQt()));

		QObject::connect(songs, SIGNAL(activated(int)), this, SLOT(setSong(int)));

		QObject::connect(incPattern, SIGNAL(clicked()), this, SLOT(incrementPattern()));
		QObject::connect(decPattern, SIGNAL(clicked()), this, SLOT(decrementPattern()));
		QObject::connect(instruments, SIGNAL(itemSelectionChanged()), this, SLOT(instrumentSelect()));
		QObject::connect(instrumentName, SIGNAL(textEdited(QString)), this, SLOT(instrumentNameChange(QString)));
		QObject::connect(instruments, SIGNAL(doubleClicked(QModelIndex)), this, SLOT(instrumentDoubleClicked(QModelIndex)));

		QObject::connect(speed, SIGNAL(valueChanged(int)), this, SLOT(speedTempoChange(int)));
		QObject::connect(tempo, SIGNAL(valueChanged(int)), this, SLOT(speedTempoChange(int)));
		QObject::connect(rows, SIGNAL(valueChanged(int)), this, SLOT(rowsChange(int)));
		QObject::connect(frames, SIGNAL(valueChanged(int)), this, SLOT(framesChange(int)));

		QObject::connect(title, SIGNAL(editingFinished()), this, SLOT(changeSongTitle()));
		QObject::connect(author, SIGNAL(editingFinished()), this, SLOT(changeSongAuthor()));
		QObject::connect(copyright, SIGNAL(editingFinished()), this, SLOT(changeSongCopyright()));

		QObject::connect(action_Play, SIGNAL(triggered()), this, SLOT(play()));
		action_Play->setIcon(QIcon::fromTheme("media-playback-start"));
		QObject::connect(action_Stop, SIGNAL(triggered()), this, SLOT(stop()));
		action_Stop->setIcon(QIcon::fromTheme("media-playback-stop"));
		QObject::connect(actionToggle_edit_mode, SIGNAL(triggered()), this, SLOT(toggleEditMode()));
		actionToggle_edit_mode->setIcon(QIcon::fromTheme("media-record"));

		QObject::connect(addInstrument_button, SIGNAL(clicked()), this, SLOT(addInstrument_2A03()));
		addInstrument_button->setIcon(QIcon::fromTheme("list-add"));
		addInstrument_button->setText(tr("Add Instrument"));
		QObject::connect(removeInstrument_button, SIGNAL(clicked()), this, SLOT(removeInstrument()));
		removeInstrument_button->setIcon(QIcon::fromTheme("list-remove"));
		removeInstrument_button->setText(tr("Remove Instrument"));
		QObject::connect(editInstrument_button, SIGNAL(clicked()), this, SLOT(editInstrument()));
		editInstrument_button->setText(tr("Edit Instrument"));

		{
			QMenu *m = new QMenu(this);
			QAction *add2a03 = m->addAction(tr("New 2A03 Instrument"));
			QAction *addmmc5 = m->addAction(tr("New MMC5 Instrument"));
			QAction *addvrc6 = m->addAction(tr("New VRC6 Instrument"));
			QAction *addvrc7 = m->addAction(tr("New VRC7 Instrument"));
			QAction *addfds  = m->addAction(tr("New FDS Instrument"));

			QObject::connect(add2a03, SIGNAL(triggered()), this, SLOT(addInstrument_2A03()));
			QObject::connect(addvrc6, SIGNAL(triggered()), this, SLOT(addInstrument_VRC6()));
			QObject::connect(addvrc7, SIGNAL(triggered()), this, SLOT(addInstrument_VRC7()));
			QObject::connect(addmmc5, SIGNAL(triggered()), this, SLOT(addInstrument_MMC5()));
			QObject::connect(addfds , SIGNAL(triggered()), this, SLOT(addInstrument_FDS()));

			m->setDefaultAction(add2a03);
			addInstrument_button->setMenu(m);
		}

		QObject::connect(step, SIGNAL(valueChanged(int)), this, SLOT(changeEditSettings()));
		QObject::connect(keyRepetition, SIGNAL(stateChanged(int)), this, SLOT(changeEditSettings()));

		{
			// recent files
			int capacity = gui::recentFileCapacity();
			m_recentFiles = new QAction*[capacity];
			for (int i = 0; i < capacity; i++)
			{
				QAction *a = new QAction(this);
				a->setVisible(false);
				connect(a, SIGNAL(triggered()),
						this, SLOT(openRecentFile()));
				m_recentFiles[i] = a;
				menuRecent->addAction(a);
			}

			// end recent files
		}

		reloadRecentFiles();

		// the designer doesn't allow adding widgets

		{
			octave = new QComboBox;
			for (int i = 0; i < 8; i++)
			{
				octave->addItem(QString("%1").arg(i));
			}
			connect(octave, SIGNAL(currentIndexChanged(int)), this, SLOT(octaveChange()));
			toolBar->addWidget(new QLabel(tr("Octave")));
			toolBar->addWidget(octave);
		}

		// temporary style changing (for demonstration)
		{
			menu_View->addSeparator();
			QMenu *styles = new QMenu(tr("Styles"));
			QAction *style_default = styles->addAction(tr("Default"));
			QAction *style_monochrome = styles->addAction(tr("Monochrome"));
			menu_View->addMenu(styles);

			connect(style_default, SIGNAL(triggered()), this, SLOT(selectDefaultStyle()));
			connect(style_monochrome, SIGNAL(triggered()), this, SLOT(selectMonochromeStyle()));
		}

		QMenu *m = new QMenu;
		m->addAction(tr("New 2A03 instrument"));

		actionAdd_instrument->setMenu(m);

		setDocInfo(m_app->activeDocInfo());

		m_instrumenteditor = new InstrumentEditor(this);

		blockSignals(true);
		blockSignals(false);
	}