Exemplo n.º 1
0
wxRibbonArtProvider* wxRibbonAUIArtProvider::Clone() const
{
    wxRibbonAUIArtProvider *copy = new wxRibbonAUIArtProvider();
    CloneTo(copy);

    copy->m_tab_ctrl_background_colour = m_tab_ctrl_background_colour;
    copy->m_tab_ctrl_background_gradient_colour = m_tab_ctrl_background_gradient_colour;
    copy->m_panel_label_background_colour = m_panel_label_background_colour;
    copy->m_panel_label_background_gradient_colour = m_panel_label_background_gradient_colour;
    copy->m_panel_hover_label_background_colour = m_panel_hover_label_background_colour;
    copy->m_panel_hover_label_background_gradient_colour = m_panel_hover_label_background_gradient_colour;

    copy->m_background_brush = m_background_brush;
    copy->m_tab_active_top_background_brush = m_tab_active_top_background_brush;
    copy->m_tab_hover_background_brush = m_tab_hover_background_brush;
    copy->m_button_bar_hover_background_brush = m_button_bar_hover_background_brush;
    copy->m_button_bar_active_background_brush = m_button_bar_active_background_brush;
    copy->m_gallery_button_active_background_brush = m_gallery_button_active_background_brush;
    copy->m_gallery_button_hover_background_brush = m_gallery_button_hover_background_brush;
    copy->m_gallery_button_disabled_background_brush = m_gallery_button_disabled_background_brush;

    copy->m_tab_highlight_top_colour = m_tab_highlight_top_colour;
    copy->m_tab_highlight_top_gradient_colour = m_tab_highlight_top_gradient_colour;
    copy->m_tab_highlight_colour = m_tab_highlight_colour;
    copy->m_tab_highlight_gradient_colour = m_tab_highlight_gradient_colour;

    copy->m_toolbar_hover_borden_pen = m_toolbar_hover_borden_pen;
    copy->m_tool_hover_background_brush = m_tool_hover_background_brush;
    copy->m_tool_active_background_brush = m_tool_active_background_brush;

    return copy;
}
Exemplo n.º 2
0
IMachine *VirtualBoxBridge::cloneVM(QString qName, bool reInitIfaces, IMachine *m)
{
	nsXPIDLString name; name.AssignWithConversion(qName.toStdString().c_str());
	nsXPIDLString osTypeId;
	nsresult rc;

	m->GetOSTypeId(getter_Copies(osTypeId));

	IMachine *new_machine;
	IProgress *progress;

	NS_CHECK_AND_DEBUG_ERROR(virtualBox, FindMachine(name, &new_machine), rc);
	if(rc != VBOX_E_OBJECT_NOT_FOUND)
	{
		std::cout << "machine: " << &new_machine << std::endl;
		return NULL;
	}

	nsXPIDLString settingsFile;
	virtualBox->ComposeMachineFilename(name, NULL, NULL, NULL, getter_Copies(settingsFile));
	std::cout << "Predicted settings file name: " << returnQStringValue(settingsFile).toStdString() << std::endl;

	QFile file(returnQStringValue(settingsFile));
	QFile file_prev(returnQStringValue(settingsFile).append("-prev"));

	if(file.exists())
	{
		if(file.remove())
			std::cerr  << "Deleted old settings file: " << file.fileName().toStdString() << std::endl;
		else
			std::cerr  << "Error while deleting old settings file: " << file.fileName().toStdString() << std::endl;
	}
	if(file_prev.exists())
	{
		if(file_prev.remove())
			std::cerr  << "Deleted old backup settings file: " << file_prev.fileName().toStdString() << std::endl;
		else
			std::cerr  << "Error while deleting old backup settings file: " << file_prev.fileName().toStdString() << std::endl;
	}
	
	QString label = QString::fromUtf8("Creazione macchina \"").append(qName).append("\"...");
	ProgressDialog p(label);
	p.ui->progressBar->setValue(0);
	p.ui->label->setText(label);
	p.open();
	
	NS_CHECK_AND_DEBUG_ERROR(virtualBox, CreateMachine(NULL, name, 0, NULL, osTypeId, NULL, &new_machine), rc);
	if(NS_FAILED(rc))
		return NULL;

	std::cout << "Machine " << qName.toStdString() << " created" << std::endl;

	if(!reInitIfaces)
	{
		uint32_t clone_options[1];
		clone_options[0] = CloneOptions::KeepAllMACs;
		NS_CHECK_AND_DEBUG_ERROR(m, CloneTo(new_machine, CloneMode::MachineState, 1, clone_options, &progress), rc);
	}
	else
		NS_CHECK_AND_DEBUG_ERROR(m, CloneTo(new_machine, CloneMode::MachineState, 0, NULL, &progress), rc);

	if(NS_FAILED(rc))
		return NULL;

	int32_t resultCode;
	PRBool progress_completed;
	do
	{
		uint32_t percent;
		progress->GetCompleted(&progress_completed);
		progress->GetPercent(&percent);
		p.ui->progressBar->setValue(percent);
		p.refresh();
		usleep(750000);
	} while(!progress_completed);

	progress->GetResultCode(&resultCode);

	if (resultCode != 0) // check success
	{
		std::cout << "Error during clone process: " << resultCode << std::endl;
		return NULL;
	}

	std::cout << "Machine " << qName.toStdString() << " cloned" << std::endl;

	p.ui->label->setText(QString::fromUtf8("Registrazione macchina \"").append(qName).append("\"..."));
	NS_CHECK_AND_DEBUG_ERROR(virtualBox, RegisterMachine(new_machine), rc);
	if(NS_FAILED(rc))
		return NULL;
	
	std::cout << "Machine " << qName.toStdString() << " registered" << std::endl;
	return new_machine;
}