Пример #1
0
void ActionValue::handleDeath(const ActionGenerator *gen)
{
	MenuActionMap::Iterator it;
	MenuActionMap::Iterator endit = globalActions()->end();
	foreach (const ActionValue::WeakPtr &valuePtr, find(gen)) {
		ActionValue *value = valuePtr.data();
		MenuController *controller = qobject_cast<MenuController*>(value->key.first);
		if (controller) {
			MenuControllerPrivate *p = MenuControllerPrivate::get(controller);
			const QMetaObject *meta = controller->metaObject();
			while (meta) {
				it = globalActions()->find(meta);
				for (; it != endit; ++it) {
					if (it.key() != meta)
						break;
					if (it.value().gen != gen)
						continue;
					p->actions.removeAction(ActionInfoV2(it.value(), controller));
				}
				meta = meta->superClass();
			}
			controller->removeAction(gen);
		}
	}
Пример #2
0
int main(int argc, char **argv)
{
    QApplication app(argc, argv);
    App::initializeDependencies();

    auto aboutData = App::getAboutData();
    QCommandLineParser parser;
    KAboutData::setApplicationData(aboutData);
    parser.addVersionOption();
    parser.addHelpOption();
    aboutData.setupCommandLine(&parser);
    parser.process(app);
    aboutData.processCommandLine(&parser);

    KSharedConfig::Ptr config = KSharedConfig::openConfig(QStringLiteral("zanshin-migratorrc"));
    KConfigGroup group = config->group("Migrations");
    if (!group.readEntry("Migrated021Projects", false)) {
        std::cerr << "Migrating data from zanshin 0.2, please wait..." << std::endl;
        QProcess proc;
        proc.start(QStringLiteral("zanshin-migrator"));
        proc.waitForFinished(-1);
        if (proc.exitStatus() == QProcess::CrashExit) {
            std::cerr << "Migrator crashed!" << std::endl;
        } else if (proc.exitCode() == 0) {
            std::cerr << "Migration done" << std::endl;
        } else {
            std::cerr << "Migration error, code" << proc.exitCode() << std::endl;
        }
    }

    auto widget = new QWidget;
    auto components = new Widgets::ApplicationComponents(widget);
    components->setModel(Presentation::ApplicationModel::Ptr::create());

    auto layout = new QVBoxLayout;
    layout->setContentsMargins(0, 0, 0, 0);
    layout->addWidget(components->pageView());
    widget->setLayout(layout);

    auto sourcesDock = new QDockWidget(QObject::tr("Sources"));
    sourcesDock->setObjectName(QStringLiteral("sourcesDock"));
    sourcesDock->setWidget(components->availableSourcesView());

    auto pagesDock = new QDockWidget(QObject::tr("Pages"));
    pagesDock->setObjectName(QStringLiteral("pagesDock"));
    pagesDock->setWidget(components->availablePagesView());

    auto editorDock = new QDockWidget(QObject::tr("Editor"));
    editorDock->setObjectName(QStringLiteral("editorDock"));
    editorDock->setWidget(components->editorView());

    auto window = new KXmlGuiWindow;
    window->setCentralWidget(widget);

    window->addDockWidget(Qt::RightDockWidgetArea, editorDock);
    window->addDockWidget(Qt::LeftDockWidgetArea, pagesDock);
    window->addDockWidget(Qt::LeftDockWidgetArea, sourcesDock);

    auto actions = components->globalActions();
    actions.insert(QStringLiteral("dock_sources"), sourcesDock->toggleViewAction());
    actions.insert(QStringLiteral("dock_pages"), pagesDock->toggleViewAction());
    actions.insert(QStringLiteral("dock_editor"), editorDock->toggleViewAction());

    auto ac = window->actionCollection();
    ac->addAction(KStandardAction::Quit, window, SLOT(close()));
    for (auto it = actions.constBegin(); it != actions.constEnd(); ++it) {
        auto shortcut = it.value()->shortcut();
        if (!shortcut.isEmpty()) {
            ac->setDefaultShortcut(it.value(), shortcut);
        }
        ac->addAction(it.key(), it.value());
    }

    window->setupGUI(QSize(1024, 600),
                     KXmlGuiWindow::ToolBar
                   | KXmlGuiWindow::Keys
                   | KXmlGuiWindow::Save
                   | KXmlGuiWindow::Create);
    window->show();

    return app.exec();
}
Пример #3
0
			const QMetaObject *meta = controller->metaObject();
			while (meta) {
				it = globalActions()->find(meta);
				for (; it != endit; ++it) {
					if (it.key() != meta)
						break;
					if (it.value().gen != gen)
						continue;
					p->actions.removeAction(ActionInfoV2(it.value(), controller));
				}
				meta = meta->superClass();
			}
			controller->removeAction(gen);
		}
	}
	it = globalActions()->begin();
	for (; it != endit;) {
		ActionInfo &info = it.value();
		if (info.gen == gen)
			globalActions()->erase(it++);
		else
			++it;
	}
}

const QByteArray &menuNameBySet(const QByteArray &name)
{
	return *menuNameSet()->insert(name);
}

ActionHandlerHelper *handler()