Beispiel #1
0
void KviMainWindow::toolbarsPopupSelected(QAction * pAction)
{
	bool bOk = false;
	int idext = pAction->data().toInt(&bOk);
	if(!bOk)
		return;

	KviCustomToolBarDescriptor * dd = KviCustomToolBarManager::instance()->findDescriptorByInternalId(idext);
	if(dd)
	{
		if(dd->toolBar())
			dd->toolBar()->deleteLater();
		else
			dd->createToolBar();
	}

	if(KviMexToolBar * t = moduleExtensionToolBar(idext))
	{
		t->die();
	}
	else
	{
		g_pModuleExtensionManager->allocateExtension("toolbar", idext, firstConsole());
	}
}
bool KviCustomToolBarManager::renameDescriptor(const QString & szId, const QString & szNewId, const QString & szNewLabelCode)
{
	KviCustomToolBarDescriptor * d = m_pDescriptors->find(szId);
	if(!d)
		return false;
	d->rename(szNewLabelCode);
	if(szId == szNewId)
		return true; // already done
	m_pDescriptors->setAutoDelete(false);
	m_pDescriptors->remove(szId);
	m_pDescriptors->replace(szNewId, d);
	m_pDescriptors->setAutoDelete(true);
	return true;
}
void KviCustomToolBarManager::load(const QString & szFileName)
{
	KviConfigurationFile cfg(szFileName, KviConfigurationFile::Read);

	KviConfigurationFileIterator it(*(cfg.dict()));
	while(it.current())
	{
		cfg.setGroup(it.currentKey());
		KviCustomToolBarDescriptor * d = new KviCustomToolBarDescriptor(it.currentKey(), QString());
		d->m_bVisibleAtStartup = (cfg.readIntEntry("Visible", 0) > 0);
		if(!d->load(&cfg))
			delete d;
		else
			m_pDescriptors->replace(it.currentKey(), d);
		++it;
	}
}
void CustomizeToolBarsDialog::newToolBar()
{
	CustomToolBarPropertiesDialog * dlg = new CustomToolBarPropertiesDialog(this,
		__tr2qs_ctx("Please specify the properties for the new toolbar","editor"),
		KviCustomToolBarManager::instance()->idForNewToolBar(__tr2qs_ctx("My ToolBar","editor")),
		__tr2qs_ctx("My ToolBar","editor"));

	dlg->show();
	if(dlg->exec() != QDialog::Accepted)
	{
		delete dlg;
		return;
	}

	QString id = dlg->id();
	QString label = dlg->label();
	QString icon = dlg->iconId();
	delete dlg;

	KviCustomToolBarDescriptor * d = KviCustomToolBarManager::instance()->create(id,label);
	d->setIconId(icon);
	KviCustomToolBar * t = d->createToolBar();
	KviActionManager::instance()->setCurrentToolBar(t);
}