void FileGraphics::initial()
{
    fcontroller = (FileController*)getAction(QString("File.FileController"));
    QAction* action = createQAction(QString("Open DEM File"));
    addMenu(QString("File"), action);
    QIODevice::connect(action, &QAction::triggered, fcontroller, &FileController::openFile);
}
Beispiel #2
0
void QtMenuBar::addAction(IAction& action, const char* path)
{
	auto qAction = getQAction(action);
	if (qAction == nullptr)
	{
		qAction = createQAction(action);
	}
	assert(qAction != nullptr);

	path = relativePath(path);
	if (path == nullptr || strlen(path) == 0)
	{
		path = action.text();
	}

	auto tok = strchr(path, '.');
	auto menuPath = tok != nullptr ? QString::fromUtf8(path, tok - path) : path;
	QMenu* menu = qMenuBar_.findChild<QMenu*>(menuPath, Qt::FindDirectChildrenOnly);
	if (menu == nullptr)
	{
		menu = qMenuBar_.addMenu(menuPath);
		menu->setObjectName(menuPath);
	}
	path = tok != nullptr ? tok + 1 : nullptr;

	QtMenu::addMenuAction(*menu, *qAction, path);
	qMenuBar_.repaint();
}