Exemplo n.º 1
0
    MainWindow::MainWindow()
    {
        resize(640, 640);

        scroll = new QScrollArea();
        scroll->setWidgetResizable(true);
        setCentralWidget(scroll);

        editor = new EditorWidget();
        scroll->setWidget(editor);

        statusBar()->showMessage(tr("%1 - by Overkill.").arg(AppName), 2000);
        statusBar()->setStyleSheet(
            "QStatusBar {"
            "   border-top: 1px solid #CCCCCC;"
            "   background-color: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1, stop: 0 #DADBDE, stop: 1 #F6F7FA);"
            "   padding: 4px;"
            "   color: #777777;"
            "}"
        );

#ifdef Q_WS_WIN
        QKeySequence quitSequence(Qt::ALT + Qt::Key_F4);
#else
        QKeySequence quitSequence(QKeySequence::Quit);
#endif

        fileMenu = menuBar()->addMenu(tr("&File"));
        newAction = createAction(fileMenu, tr("&New"), tr("Create a new CHR."), QKeySequence::New);
        openAction = createAction(fileMenu, tr("&Open..."), tr("Open an existing CHR."), QKeySequence::Open);
        createSeparator(fileMenu);
        saveAction = createAction(fileMenu, tr("&Save..."), tr("Save the current CHR."), QKeySequence::Save);
        saveAsAction = createAction(fileMenu, tr("Save &As..."), tr("Save a copy of the current CHR."), QKeySequence::SaveAs);
        createSeparator(fileMenu);
        for(int i = 0; i < MaxRecentCount; ++i)
        {
            auto action = createAction(fileMenu, QKeySequence(Qt::ALT + Qt::Key_1 + i));
            action->setDisabled(true);
            recentFileActions[i] = action;
            connect(action, SIGNAL(triggered()), this, SLOT(openRecentFile()));
        }
        clearRecentAction = createAction(fileMenu, tr("Clear &Recent Files"), tr("Clear all recently opened files."), QKeySequence(Qt::CTRL + Qt::SHIFT + Qt::Key_Delete));
        updateRecentFiles();
        createSeparator(fileMenu);
        exitAction = createAction(fileMenu, tr("E&xit"), tr("Exit the program."), quitSequence);

        helpMenu = menuBar()->addMenu(tr("&Help"));
        aboutAction = createAction(helpMenu, tr("&About..."), tr("About %1.").arg(AppName), QKeySequence::HelpContents);

        connect(newAction, SIGNAL(triggered()), this, SLOT(newFile()));
        connect(openAction, SIGNAL(triggered()), this, SLOT(openFile()));
        connect(saveAction, SIGNAL(triggered()), this, SLOT(saveFile()));
        connect(saveAsAction, SIGNAL(triggered()), this, SLOT(saveFileAs()));
        connect(clearRecentAction, SIGNAL(triggered()), this, SLOT(clearRecentFiles()));
        connect(exitAction, SIGNAL(triggered()), this, SLOT(close()));
        connect(aboutAction, SIGNAL(triggered()), this, SLOT(about()));

        QTimer::singleShot(0, this, SLOT(newFile()));
    }
Exemplo n.º 2
0
ContainerWidgetTaskMenu::ContainerWidgetTaskMenu(QWidget *widget, ContainerType type, QObject *parent) :
    QDesignerTaskMenu(widget, parent),
    m_type(type),
    m_containerWidget(widget),
    m_core(formWindow()->core()),
    m_pagePromotionTaskMenu(new PromotionTaskMenu(0, PromotionTaskMenu::ModeSingleWidget, this)),
    m_pageMenuAction(new QAction(this)),
    m_pageMenu(new QMenu),
    m_actionInsertPageAfter(new QAction(this)),
    m_actionInsertPage(0),
    m_actionDeletePage(new QAction(tr("Delete"), this))
{
    Q_ASSERT(m_core);
    m_taskActions.append(createSeparator());

    connect(m_actionDeletePage, SIGNAL(triggered()), this, SLOT(removeCurrentPage()));

    connect(m_actionInsertPageAfter, SIGNAL(triggered()), this, SLOT(addPageAfter()));
    // Empty Per-Page submenu, deletion and promotion. Updated on demand due to promotion state
    switch (m_type) {
    case WizardContainer:
    case PageContainer:
        m_taskActions.append(createSeparator()); // for the browse actions
        break;
    case MdiContainer:
        break;
    }
    // submenu
    m_pageMenuAction->setMenu(m_pageMenu);
    m_taskActions.append(m_pageMenuAction);
    // Insertion
    switch (m_type) {
    case WizardContainer:
    case PageContainer: { // Before and after in a submenu
        QAction *insertMenuAction = new QAction(tr("Insert"), this);
        QMenu *insertMenu = new QMenu;
        // before
        m_actionInsertPage = new QAction(tr("Insert Page Before Current Page"), this);
        connect(m_actionInsertPage, SIGNAL(triggered()), this, SLOT(addPage()));
        insertMenu->addAction(m_actionInsertPage);
        // after
        m_actionInsertPageAfter->setText(tr("Insert Page After Current Page"));
        insertMenu->addAction(m_actionInsertPageAfter);

        insertMenuAction->setMenu(insertMenu);
        m_taskActions.append(insertMenuAction);
    }
        break;
    case MdiContainer: // No concept of order
        m_actionInsertPageAfter->setText(tr("Add Subwindow"));
        m_taskActions.append(m_actionInsertPageAfter);
        break;
    }
}
Exemplo n.º 3
0
// -------------- WizardContainerWidgetTaskMenu
WizardContainerWidgetTaskMenu::WizardContainerWidgetTaskMenu(QWizard *w, QObject *parent) :
    ContainerWidgetTaskMenu(w, WizardContainer, parent),
    m_nextAction(new QAction(tr("Next"), this)),
    m_previousAction(new QAction(tr("Back"), this))
{
    connect(m_nextAction, SIGNAL(triggered()), w, SLOT(next()));
    connect(m_previousAction, SIGNAL(triggered()), w, SLOT(back()));
    QList<QAction*> &l = containerActions();
    l.push_front(createSeparator());
    l.push_front(m_nextAction);
    l.push_front(m_previousAction);
    l.push_front(createSeparator());
}
Exemplo n.º 4
0
void MdiContainerWidgetTaskMenu::initializeActions()
{
    m_nextAction =new QAction(tr("Next Subwindow"), this);
    m_previousAction = new QAction(tr("Previous Subwindow"), this);
    m_tileAction = new QAction(tr("Tile"), this);
    m_cascadeAction = new QAction(tr("Cascade"), this);

    QList<QAction*> &l = containerActions();
    l.push_front(createSeparator());
    l.push_front(m_tileAction);
    l.push_front(m_cascadeAction);
    l.push_front(m_previousAction);
    l.push_front(m_nextAction);
    l.push_front(createSeparator());
}
Exemplo n.º 5
0
ButtonTaskMenu::ButtonTaskMenu(QAbstractButton *button, QObject *parent)  :
    QDesignerTaskMenu(button, parent),
    m_assignGroupSubMenu(new QMenu),
    m_assignActionGroup(0),
    m_assignToGroupSubMenuAction(new QAction(tr("Assign to button group"), this)),
    m_currentGroupSubMenu(new QMenu),
    m_currentGroupSubMenuAction(new QAction(tr("Button group"), this)),
    m_createGroupAction(new QAction(tr("New button group"), this)),
    m_preferredEditAction(new QAction(tr("Change text..."), this)),
    m_removeFromGroupAction(new QAction(tr("None"), this))
{
    connect(m_createGroupAction, SIGNAL(triggered()), this, SLOT(createGroup()));
    TaskMenuInlineEditor *textEditor = new ButtonTextTaskMenuInlineEditor(button, this);
    connect(m_preferredEditAction, SIGNAL(triggered()), textEditor, SLOT(editText()));
    connect(m_removeFromGroupAction, SIGNAL(triggered()), this, SLOT(removeFromGroup()));

    m_assignToGroupSubMenuAction->setMenu(m_assignGroupSubMenu);

    m_currentGroupSubMenu->addAction(m_groupMenu.breakGroupAction());
    m_currentGroupSubMenu->addAction(m_groupMenu.selectGroupAction());
    m_currentGroupSubMenuAction->setMenu(m_currentGroupSubMenu);


    m_taskActions.append(m_preferredEditAction);
    m_taskActions.append(m_assignToGroupSubMenuAction);
    m_taskActions.append(m_currentGroupSubMenuAction);
    m_taskActions.append(createSeparator());
}
Exemplo n.º 6
0
void
bkStateTransition (RDFFile f, char* token)
{
  if (startsWith("<A", token)) {
    newLeafBkItem(f, token);
    f->status = IN_ITEM_TITLE;
  } else if (startsWith(OPEN_H3_STRING, token)) {
    newFolderBkItem(f, token);
    f->status = IN_H3;
  } else if (startsWith(OPEN_TITLE_STRING, token)) {
    f->status = IN_TITLE;
  } else if (startsWith(OPEN_H3_STRING, token)) {
    f->status = IN_H3;
  } else if (startsWith(DD_STRING, token)) {
    if (nlocalStoreGetSlotValue(gLocalStore, f->lastItem, gWebData->RDF_description, 
				RDF_STRING_TYPE, false, true) 
		== NULL) f->status = IN_ITEM_DESCRIPTION;
  } else if (startsWith(OPEN_DL_STRING, token)) {
    f->stack[f->depth++] = f->lastItem;
  } else if (startsWith(CLOSE_DL_STRING, token)) {
    f->depth--;
  } else if (startsWith("<HR>", token)) {
    addSlotValue(f, createSeparator(), gCoreVocab->RDF_parent, f->stack[f->depth-1], 
		 RDF_RESOURCE_TYPE, true);
    f->status = 0;
  } else if ((f->status == IN_ITEM_DESCRIPTION) && (startsWith("<BR>", token))) {
    addDescription(f, f->lastItem, token);
  } else f->status = 0;
}
Exemplo n.º 7
0
QWidget * ToolBar::createActionWidget(QAction *before, ToolBarAction &action)
{
	if (action.actionName.startsWith(QLatin1String("__separator")))
		return createSeparator(before, action);
	else if (action.actionName.startsWith(QLatin1String("__spacer")))
		return createSpacer(before, action);
	else
		return createPushButton(before, action);
}
Exemplo n.º 8
0
void StatusActions::createActions()
{
	createBasicActions();
	createStatusActions();

	QList<StatusType *> statusTypes = MyStatusContainer->supportedStatusTypes();
	if (statusTypes.isEmpty())
		return;

	StatusType *statusType = statusTypes.at(0);
	if (0 == statusType)
		return;

	StatusGroup *currentGroup = statusType->statusGroup();
	bool setDescriptionAdded = false;

	foreach (StatusType *statusType, statusTypes)
	{
		if (0 == statusType)
			continue;

		if (!setDescriptionAdded && statusType->statusGroup() &&
				statusType->statusGroup()->sortIndex() >= StatusGroup::StatusGroupSortIndexAfterSetDescription)
		{
			Actions.append(createSeparator());
			Actions.append(ChangeDescription);
		}

		if (statusType->statusGroup() != currentGroup)
		{
			Actions.append(createSeparator());
			currentGroup = statusType->statusGroup();
		}

		Actions.append(StatusTypeActions[statusType]);
	}

	Actions.append(createSeparator());
}
Exemplo n.º 9
0
void Menu::rebuildMenu() {
	_controller->clear();
	if (!_menu) {
		return;
	}

	auto &menuItems = _menu->getItems();
	for (auto &item : menuItems) {
		if (item->getType() == MenuSourceItem::Type::Separator) {
			_controller->addItem([this, item] (const ScrollController::Item &) -> cocos2d::Node * {
				auto div = createSeparator();
				div->setTopLevel(false);
				div->setMenuSourceItem(item);
				div->setMenu(this);
				return div;
			}, metrics::menuVerticalPadding(_metrics));
		} else if (item->getType() == MenuSourceItem::Type::Button) {
			_controller->addItem([this, item] (const ScrollController::Item &) -> cocos2d::Node * {
				auto btn = createButton();
				btn->setMenu(this);
				btn->setMenuSourceItem(item);
				return btn;
			}, metrics::menuItemHeight(_metrics));
		} else if (item->getType() == MenuSourceItem::Type::Custom) {
			auto customItem = static_cast<MenuSourceCustom *>(item);
			auto func = customItem->getFactoryFunction();
			if (func) {
				float height = customItem->getHeight();
				if (customItem->isRelativeHeight()) {
					height = _contentSize.width * height;
				}
				_controller->addItem([this, func, item] (const ScrollController::Item &) -> cocos2d::Node * {
					auto node = func();
					if (auto i = dynamic_cast<MenuItemInterface *>(node)) {
						i->setMenu(this);
						i->setMenuSourceItem(item);
					}
					return node;
				}, height);
			}
		}
	}
	_scroll->setScrollDirty(true);
}