Example #1
0
void Notepad::showNotepadContextMenu(const QPoint &pt)
{
    // Set Notepad popup menu
    QMenu *menu = ui->notepadTextEdit->createStandardContextMenu();
    QTextCursor cur = ui->notepadTextEdit->textCursor();
    QAction* first = menu->actions().at(0);

    if (cur.hasSelection()) {
        // Get selected text
        //this->main->add_debug_output("Selected text: " + cur.selectedText());
        this->addr = cur.selectedText();
    } else {
        // Get word under the cursor
        cur.select( QTextCursor::WordUnderCursor);
        //this->main->add_debug_output("Word: " + cur.selectedText());
        this->addr = cur.selectedText();
    }
    ui->actionDisassmble_bytes->setText( "Disassemble bytes at: " + this->addr);
    ui->actionDisassmble_function->setText( "Disassemble function at: " + this->addr);
    ui->actionHexdump_bytes->setText( "Hexdump bytes at: " + this->addr);
    ui->actionCompact_Hexdump->setText( "Compact Hexdump at: " + this->addr);
    ui->actionHexdump_function->setText( "Hexdump function at: " + this->addr);
    menu->insertAction(first, ui->actionDisassmble_bytes);
    menu->insertAction(first, ui->actionDisassmble_function);
    menu->insertAction(first, ui->actionHexdump_bytes);
    menu->insertAction(first, ui->actionCompact_Hexdump);
    menu->insertAction(first, ui->actionHexdump_function);
    menu->insertSeparator(first);
    ui->notepadTextEdit->setContextMenuPolicy(Qt::DefaultContextMenu);
    menu->exec(ui->notepadTextEdit->mapToGlobal(pt));
    delete menu;
    ui->notepadTextEdit->setContextMenuPolicy(Qt::CustomContextMenu);
}
Example #2
0
void AddressWidget::contextMenuEvent(QContextMenuEvent *event)
{
	const QString shortcut = QKeySequence(QKeySequence::Paste).toString(QKeySequence::NativeText);
	QMenu *menu = createStandardContextMenu();
	bool found = false;

	if (!shortcut.isEmpty())
	{
		for (int i = 0; i < menu->actions().count(); ++i)
		{
			if (menu->actions().at(i)->text().endsWith(shortcut))
			{
				menu->insertAction(menu->actions().at(i + 1), ActionsManager::getAction(PasteAndGoAction));

				found = true;

				break;
			}
		}
	}

	if (!found)
	{
		menu->insertAction(menu->actions().at(6), ActionsManager::getAction(PasteAndGoAction));
	}

	menu->exec(event->globalPos());
	menu->deleteLater();
}
Example #3
0
void DoNothingPlugin::createMenuItems()
{
    // Fetch the action manager
    Core::ActionManager* am = Core::ICore::instance()->actionManager();

    // Create a command for "About DoNothing"
    Core::Command* cmd = am->registerAction(new QAction(this), "DoNothingPlugin.AboutDoNothingItem", QList<int>() << Core::Constants::C_GLOBAL_ID);
    cmd->action()->setText("About DoNothing");

    // Add the command "Do Nothing" in the beginning of Help menu
    am->actionContainer(Core::Constants::M_HELP)->addAction(cmd);

    // Since menu-items are QActions, we can connect to their triggered(bool) or
    // toggled(bool) signal and respond to trigger/toggled events
    connect(cmd->action(), SIGNAL(triggered(bool)), this, SLOT(about()));

    // Create a command for "About DoNothing 2"
    Core::Command* cmd2 = am->registerAction(new QAction(this), "DoNothingPlugin.AboutDoNothing2Item", QList<int>() << Core::Constants::C_GLOBAL_ID);
    cmd2->action()->setText("About DoNothing 2");

    // Insert the "DoNothing 2" item before "About Plugins..."
    QMenu* helpMenu = am->actionContainer(Core::Constants::M_HELP)->menu();
    QAction* aboutPluginsAction = am->command(Core::Constants::ABOUT_PLUGINS)->action();
    helpMenu->insertAction(aboutPluginsAction, cmd2->action());

    // Connect the action
    connect(cmd2->action(), SIGNAL(triggered(bool)), this, SLOT(about()));
}
Example #4
0
SessionViewlet::SessionViewlet(QMainWindow *mainWindow, QObject *parent):
    QObject(parent)
{
    QMenu *sessionMenu = synthclone::getChild<QMenu>(mainWindow, "sessionMenu");

    loadAction = synthclone::getChild<QAction>(mainWindow, "loadSessionAction");
    connect(loadAction, SIGNAL(triggered()), SIGNAL(loadRequest()));

    quitAction = synthclone::getChild<QAction>(mainWindow, "quitSessionAction");
    connect(quitAction, SIGNAL(triggered()), SIGNAL(quitRequest()));

    saveAction = synthclone::getChild<QAction>(mainWindow, "saveSessionAction");
    connect(saveAction, SIGNAL(triggered()), SIGNAL(saveRequest()));

    saveAsAction = synthclone::getChild<QAction>(mainWindow,
                                                 "saveSessionAsAction");
    connect(saveAsAction, SIGNAL(triggered()), SIGNAL(saveAsRequest()));

    // Hack: Optimally, we'd like to give an object name to the separator we
    // want to retrieve from the QtDesigner file.  Unfortunately, QtDesigner
    // doesn't allow the naming of QAction items that are separators (they all
    // have to be named 'separator').  So, we have to add the separator here.
    customItemsSeparator = new QAction(this);
    customItemsSeparator->setSeparator(true);
    sessionMenu->insertAction(quitAction, customItemsSeparator);

    menuViewlet = new MenuViewlet(sessionMenu, customItemsSeparator, this);
}
Example #5
0
void QImageDocumentSelectorDialog::init()
{
    setWindowTitle( tr( "Select Image" ) );
    QVBoxLayout *vb = new QVBoxLayout( this );
    vb->setContentsMargins(0, 0, 0, 0);

    connect( selector, SIGNAL(documentSelected(QContent)), this, SLOT(accept()) );
    connect( selector, SIGNAL(documentsChanged()), this, SLOT(setContextBar()) );

    vb->addWidget( selector );

    // Set thumbnail view
    selector->setViewMode( QImageDocumentSelector::Thumbnail );

    QAction *viewAction = new QAction( QIcon( ":icon/view" ), tr( "View" ), this );
    connect( viewAction, SIGNAL(triggered()), this, SLOT(viewImage()) );
    QMenu *menu = QSoftMenuBar::menuFor( selector );
    menu->actions().count() ? menu->insertAction(menu->actions().at(0), viewAction)
    : menu->addAction(viewAction);
    QSoftMenuBar::addMenuTo( this, menu );

    setContextBar();

    setModal( true );
    QtopiaApplication::setMenuLike( this, true );
}
Example #6
0
bool QtKeySequenceEdit::eventFilter(QObject *o, QEvent *e)
{
    if (o == m_lineEdit && e->type() == QEvent::ContextMenu) {
        QContextMenuEvent *c = static_cast<QContextMenuEvent *>(e);
        QMenu *menu = m_lineEdit->createStandardContextMenu();
        const QList<QAction *> actions = menu->actions();
        QListIterator<QAction *> itAction(actions);
        while (itAction.hasNext()) {
            QAction *action = itAction.next();
            action->setShortcut(QKeySequence());
            QString actionString = action->text();
            const int pos = actionString.lastIndexOf(QLatin1Char('\t'));
            if (pos > 0)
                actionString.remove(pos, actionString.length() - pos);
            action->setText(actionString);
        }
        QAction *actionBefore = 0;
        if (actions.count() > 0)
            actionBefore = actions[0];
        QAction *clearAction = new QAction(tr("Clear Shortcut"), menu);
        menu->insertAction(actionBefore, clearAction);
        menu->insertSeparator(actionBefore);
        clearAction->setEnabled(!m_keySequence.isEmpty());
        connect(clearAction, SIGNAL(triggered()), this, SLOT(slotClearShortcut()));
        menu->exec(c->globalPos());
        delete menu;
        e->accept();
        return true;
    }

    return QWidget::eventFilter(o, e);
}
void ToolBarActionProvider::networkUpdated(const Network *net)
{
    if (!net)
        net = qobject_cast<const Network *>(sender());
    if (!net)
        return;
    Action *act = _networkActions.value(net->networkId());
    if (!act)
        return;

    _networksConnectMenu->removeAction(act);
    _networksDisconnectMenu->removeAction(act);

    QMenu *newMenu = net->connectionState() != Network::Disconnected ? _networksDisconnectMenu : _networksConnectMenu;
    act->setText(net->networkName());

    const int lastidx = newMenu->actions().count() - 2;
    QAction *beforeAction = newMenu->actions().at(lastidx);
    for (int i = 0; i < newMenu->actions().count() - 2; i++) {
        QAction *action = newMenu->actions().at(i);
        if (net->networkName().localeAwareCompare(action->text()) < 0) {
            beforeAction = action;
            break;
        }
    }
    newMenu->insertAction(beforeAction, act);

    action(NetworkConnectAll)->setEnabled(_networksConnectMenu->actions().count() > 2);
    action(NetworkDisconnectAll)->setEnabled(_networksDisconnectMenu->actions().count() > 2);
    action(JoinChannel)->setEnabled(_networksDisconnectMenu->actions().count() > 2);
}
Example #8
0
bool ActionManager::insertMenuActions(const QString &idMenu, const QString &idBeforeSep, bool newGroup,  QList<QAction*> &actions)
{
    if (idMenu.isEmpty()) {
        return false;
    }
    QMenu *menu = loadMenu(idMenu);
    if (!menu) {
        return false;
    }
    if (newGroup) {
        QMenu *realMenu = menu->menuAction()->menu();
        if (realMenu) {
            if (!realMenu->actions().isEmpty() && !realMenu->actions().last()->isSeparator()) {
                menu->addSeparator();
            }
        } else {
            menu->addSeparator();
        }
    }
    QAction *sep = 0;
    if (!idBeforeSep.isEmpty()) {
        sep = m_idMenuSepMap[idMenu][idBeforeSep];
        if (!sep) {
            sep = menu->addSeparator();
            m_idMenuSepMap[idMenu].insert(idBeforeSep,sep);
        }
    }
    foreach (QAction *act, actions) {
        menu->insertAction(sep,act);
    }
Example #9
0
static void InsertMenuItemAction( const wxMenu *menu, const wxMenuItem *previousItem,
    const wxMenuItem *item, const wxMenuItem *successiveItem )
{
    QMenu *qtMenu = menu->GetHandle();
    QAction *itemAction = item->GetHandle();
    if ( item->GetKind() == wxITEM_RADIO )
    {
        // If the previous menu item is a radio item then add this item to the
        // same action group, otherwise start a new group:

        if ( previousItem != NULL && previousItem->GetKind() == wxITEM_RADIO )
        {
            QAction *previousItemAction = previousItem->GetHandle();
            QActionGroup *previousItemActionGroup = previousItemAction->actionGroup();
            wxASSERT_MSG( previousItemActionGroup != NULL, "An action group should have been setup" );
            previousItemActionGroup->addAction( itemAction );
        }
        else
        {
            QActionGroup *actionGroup = new QActionGroup( qtMenu );
            actionGroup->addAction( itemAction );
            wxASSERT_MSG( itemAction->actionGroup() == actionGroup, "Must be the same action group" );
        }
    }
    // Insert the action into the actual menu:
    QAction *successiveItemAction = ( successiveItem != NULL ) ? successiveItem->GetHandle() : NULL;
    qtMenu->insertAction( successiveItemAction, itemAction );
}
Example #10
0
QMenu* CartesianPlotLegend::createContextMenu(){
	QMenu *menu = WorksheetElement::createContextMenu();
	QAction* firstAction = menu->actions().at(1); //skip the first action because of the "title-action"

	visibilityAction->setChecked(isVisible());
	menu->insertAction(firstAction, visibilityAction);

	return menu;
}
Example #11
0
void MainWindow::webViewContextMenu(const QPoint &pos)
{
    QMenu *contextMenu = new QMenu(this);

    contextMenu->insertAction(0, ui->webView->pageAction(QWebPage::Copy));

    contextMenu->exec(ui->webView->mapToGlobal(pos));
    delete contextMenu;
}
Example #12
0
void LogWindow::contextMenuEvent(QContextMenuEvent *event) {
    QMenu *menu = createStandardContextMenu();
    QAction *a = new QAction("Clear", this);
    a->setEnabled(!document()->isEmpty());
    connect(a, SIGNAL(triggered()), this, SLOT(clear()));
    QList<QAction*> L = menu->actions();
    menu->insertAction(L[0], a);
    menu->exec(event->globalPos());
    delete menu;
}
Example #13
0
void VMdEditor::contextMenuEvent(QContextMenuEvent *p_event)
{
    QMenu *menu = createStandardContextMenu();
    menu->setToolTipsVisible(true);

    VEditTab *editTab = dynamic_cast<VEditTab *>(parent());
    Q_ASSERT(editTab);
    if (editTab->isEditMode()) {
        const QList<QAction *> actions = menu->actions();

        if (textCursor().hasSelection()) {
            initCopyAsMenu(actions.isEmpty() ? NULL : actions.last(), menu);
        } else {
            QAction *saveExitAct = new QAction(VIconUtils::menuIcon(":/resources/icons/save_exit.svg"),
                                               tr("&Save Changes And Read"),
                                               menu);
            saveExitAct->setToolTip(tr("Save changes and exit edit mode"));
            connect(saveExitAct, &QAction::triggered,
                    this, [this]() {
                        emit m_object->saveAndRead();
                    });

            QAction *discardExitAct = new QAction(VIconUtils::menuIcon(":/resources/icons/discard_exit.svg"),
                                                  tr("&Discard Changes And Read"),
                                                  menu);
            discardExitAct->setToolTip(tr("Discard changes and exit edit mode"));
            connect(discardExitAct, &QAction::triggered,
                    this, [this]() {
                        emit m_object->discardAndRead();
                    });

            menu->insertAction(actions.isEmpty() ? NULL : actions[0], discardExitAct);
            menu->insertAction(discardExitAct, saveExitAct);
        }

        if (!actions.isEmpty()) {
            menu->insertSeparator(actions[0]);
        }
    }

    menu->exec(p_event->globalPos());
    delete menu;
}
Example #14
0
/*!
    Return a new context menu
*/
QMenu* DatapickerCurve::createContextMenu() {
	QMenu *menu = AbstractAspect::createContextMenu();
	Q_ASSERT(menu);

	QAction* firstAction = 0;
	if (menu->actions().size()>1)
		firstAction = menu->actions().at(1);

	menu->insertAction(firstAction, updateDatasheetAction);

	return menu;
}
Example #15
0
QMenu* FileDataSource::createContextMenu(){
	QMenu* menu = AbstractPart::createContextMenu();

	QAction* firstAction = 0;
	// if we're populating the context menu for the project explorer, then
	//there're already actions available there. Skip the first title-action
	//and insert the action at the beginning of the menu.
	if (menu->actions().size()>1)
		firstAction = menu->actions().at(1);

	if (!m_fileWatched)
		menu->insertAction(firstAction, m_reloadAction);

	m_toggleWatchAction->setChecked(m_fileWatched);
	menu->insertAction(firstAction, m_toggleWatchAction);

	m_toggleLinkAction->setChecked(m_fileLinked);
	menu->insertAction(firstAction, m_toggleLinkAction);

	return menu;
}
Example #16
0
void QtMenu::addMenuAction(QMenu& qMenu, QAction& qAction, const char* path)
{
	QMenu* menu = addMenuPath(qMenu, path);

	TF_ASSERT(menu != nullptr);
	auto order = qAction.property("order").toInt();

	auto actions = menu->actions();
	auto it = std::find_if(actions.begin(), actions.end(),
	                       [&](QAction* action) { return action->property("order").toInt() > order; });
	menu->insertAction(it == actions.end() ? nullptr : *it, &qAction);
}
Example #17
0
QObject * ScriptToolbox::menuInsertAction(QObject * menu, QObject * before, const QString & name, const bool enabled)
{
    QMenu * m = qobject_cast<QMenu*>(menu);
    QAction * ba = qobject_cast<QAction*>(before);
    QAction * na = new QAction(name,m);
    na->setEnabled(enabled);
    if(m && ba && na)
    {
        m->insertAction(ba, na);
        return na;
    }
    return 0;
}
Example #18
0
void SessionMgr::updateSessions()
{
    QDir dir(getFolder());
    m_sessions = dir.entryList((QStringList() << "[^_]*.cldta"), (QDir::Files | QDir::Readable), QDir::Name);

    for(std::set<QMenu*>::iterator itr = m_menus.begin(); itr != m_menus.end(); ++itr)
    {
        QMenu *menu = *itr;

        QAction *separator = NULL;
        QList<QAction*> actions = menu->actions();
        for(int i = 0; i < actions.size(); ++i)
        {
            if(actions[i]->isSeparator())
            {
                separator = actions[i];
                break;
            }
            delete actions[i];
        }

        if(m_sessions.empty())
        {
            QAction *empty = new QAction(tr("No saved sessions"), this);
            menu->insertAction(separator, empty);
            empty->setEnabled(false);
        }
        else
        {
            for(int i = 0; i < m_sessions.size(); ++i)
            {
                QAction *act = new QAction(m_sessions[i].remove(".cldta"), this);
                menu->insertAction(separator, act);
                m_sig_map->setMapping(act, act->text());
                connect(act, SIGNAL(triggered()), m_sig_map, SLOT(map()));
            }
        }
    }
}
Example #19
0
void ChatbarTextEdit::contextMenuEvent(QContextMenuEvent *qcme) {
	QMenu *menu = createStandardContextMenu();

	QAction *action = new QAction(tr("Paste and &Send") + QLatin1Char('\t'), menu);
	action->setEnabled(!QApplication::clipboard()->text().isEmpty());
	connect(action, SIGNAL(triggered()), this, SLOT(pasteAndSend_triggered()));
	if (menu->actions().count() > 6)
		menu->insertAction(menu->actions()[6], action);
	else
		menu->addAction(action);

	menu->exec(qcme->globalPos());
	delete menu;
}
Example #20
0
void ExprTextEdit::contextMenuEvent(QContextMenuEvent *event)
{
    QMenu *menu = createStandardContextMenu();
    
    if (!menu->actions().empty())
    {
	QAction* f = menu->actions().first();
	menu->insertAction(f, _popupEnabledAction);
	menu->insertSeparator(f);
    }
    
    menu->exec(event->globalPos());
    delete menu;
}
Example #21
0
static QMenu* createContextMenu(QWebPage* page, QPoint position)
{
    QMenu* menu = page->createStandardContextMenu();

    QWebHitTestResult r = page->mainFrame()->hitTestContent(position);

    if (!r.linkUrl().isEmpty()) {
        WebPage* webPage = qobject_cast<WebPage*>(page);
        QAction* newTabAction = menu->addAction("Open in Default &Browser", webPage, SLOT(openUrlInDefaultBrowser()));
        newTabAction->setData(r.linkUrl());
        menu->insertAction(menu->actions().at(2), newTabAction);
    }
    return menu;
}
Example #22
0
    virtual void contextMenuEvent(QContextMenuEvent* event)
    {
        QMenu* menu = page()->createStandardContextMenu();

        QWebHitTestResult r = page()->mainFrame()->hitTestContent(event->pos());

        if (!r.linkUrl().isEmpty()) {
            QAction* newTabAction = menu->addAction(tr("Open in Default &Browser"), this, SLOT(openUrlInDefaultBrowser()));
            newTabAction->setData(r.linkUrl());
            menu->insertAction(menu->actions().at(2), newTabAction);
        }

        menu->exec(mapToGlobal(event->pos()));
        delete menu;
    }
Example #23
0
void
ZoneViewlet::initializeControlColumnShowActions(const QString &menuId,
                                                synthclone::MIDIData start,
                                                synthclone::MIDIData end)
{
    QMenu *menu = synthclone::getChild<QMenu>(zonesMenu, menuId);
    for (synthclone::MIDIData i = start; i < end; i++) {
        QAction *action =
            new QAction(synthclone::getMIDIControlString(i), menu);
        int column = ZONETABLECOLUMN_CONTROL_0 + static_cast<int>(i);
        action->setCheckable(true);
        action->setData(column);
        connect(action, SIGNAL(triggered()), SLOT(handleColumnShowAction()));
        coreColumnShowActions[column] = action;
        menu->insertAction(0, action);
    }
}
Example #24
0
void SubmitEditorWidget::editorCustomContextMenuRequested(const QPoint &pos)
{
    QMenu *menu = m_d->m_ui.description->createStandardContextMenu();

    // Extend
    foreach(const SubmitEditorWidgetPrivate::AdditionalContextMenuAction & a, m_d->descriptionEditContextMenuActions) {
        if (a.second) {
            if (a.first >= 0) {
                menu->insertAction(menu->actions().at(a.first), a.second);
            } else {
                menu->addAction(a.second);
            }
        }
    }
    menu->exec(m_d->m_ui.description->mapToGlobal(pos));
    delete menu;
}
Example #25
0
QObject * ScriptToolbox::menuInsertSeparator(QObject * menu, QObject * before)
{
    QMenu * m = qobject_cast<QMenu*>(menu);
    QAction * ba = qobject_cast<QAction*>(before);
    if (!ba)
    {
        QMenu * bm = qobject_cast<QMenu*>(before);
        ba = bm->menuAction();
    }
    QAction * na = new QAction(m);
    if(m && ba && na)
    {
        na->setSeparator(true);
        m->insertAction(ba, na);
        return na;
    }
    return 0;
}
Example #26
0
void MenuActionContainer::insertAction(Action *act, const ID &before) {
    if (before.isValid()) {
        QMenu* menu = qobject_cast<QMenu* > (this);
        Action * bact = ActionManager::instance()->getAction(before);

        if (bact == 0) {
            qWarning() << tr("%1 not exist").arg(before);
        }

        else {
            menu->insertAction(bact
                               , qobject_cast<QAction*> (act));
        }
    }

    else {
        this->addAction(qobject_cast<QAction*> (act));
    }
}
void LDViewMainWindow::populateRecentFileMenuItems(void)
{
#ifdef __APPLE__
    if (!openRecentMenu)
    {
        return;
    }
#endif // __APPLE__
    clearRecentFileMenuItems();

    if (recentFiles->stringAtIndex(0))
    {
        int i;
        long maxRecentFiles = Preferences::getMaxRecentFiles();

        for (i = 0; i < maxRecentFiles; i++)
        {
            char *filename = truncateFilename(recentFiles->stringAtIndex(i));

            if (filename)
            {
#ifdef __APPLE__
                QMenu *menu = openRecentMenu;
#else // __APPLE__
                QMenu *menu = fileMenu;
#endif // __APPLE__
				QAction *act;
				act = new QAction(filename,this);
				act->setData(i);
				menu->insertAction(fileMenu->actions()[fileMenu->actions().count() - 1],
								   act);
				connect( act, SIGNAL( triggered() ), this, SLOT(doRecentFile()) );
                delete filename;
            }
        }
#ifndef __APPLE__
        fileMenu->insertSeparator(fileMenu->actions()[fileMenu->actions().count() - 1]);
#endif // __APPLE__
    }
}
Example #28
0
void MainWindow::createMenusAndToolBars()
{
    QAction *separator = 0;
    setUnifiedTitleAndToolBarOnMac(true);

    QMenu *fileMenu = menuBar()->addMenu(tr("File"));
    QToolBar *fileToolBar = addToolBar(tr("File"));
    populateMenuAndToolBar(fileMenu, fileToolBar, QList<QAction*>()
                           << fileNewAction << fileOpenAction << fileSaveAction
                           << fileExportAction << separator << filePrintAction);
    fileMenu->insertAction(fileExportAction, fileSaveAsAction);
    fileMenu->addSeparator();
    fileMenu->addAction(fileQuitAction);

    QMenu *alignmentMenu = new QMenu(tr("Align"), this);
    foreach (QAction *action, QList<QAction*>()
             << editAlignLeftAction << editAlignRightAction
             << editAlignTopAction << editAlignBottomAction)
        alignmentMenu->addAction(action);
    editAlignmentAction->setMenu(alignmentMenu);

    QMenu *editMenu = menuBar()->addMenu(tr("Edit"));
    QToolBar *editToolBar = addToolBar(tr("Edit"));
    populateMenuAndToolBar(editMenu, editToolBar, QList<QAction*>()
                           << editSelectedItemAction << separator
                           << editAddTextAction << editAddBoxAction
                           << editAddSmileyAction << separator << editCopyAction
                           << editCutAction << editPasteAction << separator
                           << editAlignmentAction << editClearTransformsAction);

    QMenu *viewMenu = menuBar()->addMenu(tr("View"));
    QToolBar *viewToolBar = addToolBar(tr("View"));
    populateMenuAndToolBar(viewMenu, viewToolBar, QList<QAction*>()
                           << viewZoomInAction << viewZoomOutAction << separator
                           << viewShowGridAction);

    AQP::accelerateMenu(menuBar());
}
Example #29
0
void WebView::contextMenuEvent(QContextMenuEvent* event)
{
    QSettings settings;
    return;
    if(settings.value("disableDebug").toBool()) {
        return;
    }

    QMenu* menu = m_page->createStandardContextMenu();

    QWebHitTestResult r = page()->mainFrame()->hitTestContent(event->pos());

    if (!r.linkUrl().isEmpty()) {
        QAction* newTabAction = menu->addAction(tr("Test Menu"));
        newTabAction->setData(r.linkUrl());
        menu->insertAction(menu->actions().at(2), newTabAction);
    }
    for(int i=0; i< menu->actions().size(); i++) {
        QAction *qa = menu->actions().at(i);
    }

    menu->exec(mapToGlobal(event->pos()));
    delete menu;
}
Example #30
0
void MainWindow::createMenus()
{
	QMenu *fileMenu = menuBar()->addMenu(tr("&File"));
	fileMenu->addAction(m_newAction);
	fileMenu->addAction(m_openAction);
	fileMenu->addAction(m_openRecentAction);
	fileMenu->addSeparator();
	fileMenu->addAction(m_saveAction);
	fileMenu->addAction(m_saveAsAction);
	fileMenu->addAction(m_tikzPreviewController->exportAction());
	fileMenu->addSeparator();
	fileMenu->addAction(m_reloadAction);
	fileMenu->addSeparator();
	fileMenu->addAction(m_tikzPreviewController->printPreviewAction());
	fileMenu->addAction(m_tikzPreviewController->printAction());
	fileMenu->addSeparator();
	fileMenu->addAction(m_closeAction);
	fileMenu->addSeparator();
	fileMenu->addAction(m_exitAction);

	menuBar()->addMenu(m_tikzEditorView->editMenu());
	menuBar()->addMenu(m_tikzEditorView->bookmarksMenu());

	QMenu *viewMenu = m_tikzPreviewController->menu();
	viewMenu->insertAction(viewMenu->actions().at(viewMenu->actions().size() - 2), m_buildAction);
	viewMenu->addAction(m_viewLogAction);
	menuBar()->addMenu(viewMenu);

	m_settingsMenu = menuBar()->addMenu(tr("&Settings"));
	QMenu *toolBarMenu = new QMenu(tr("&Toolbars"), this);
	toolBarMenu->setIcon(Icon(QLatin1String("configure-toolbars")));
	toolBarMenu->menuAction()->setStatusTip(tr("Show or hide toolbars"));
	toolBarMenu->addAction(m_fileToolBar->toggleViewAction());
	toolBarMenu->addAction(m_editToolBar->toggleViewAction());
	toolBarMenu->addAction(m_viewToolBar->toggleViewAction());
	toolBarMenu->addAction(m_runToolBar->toggleViewAction());
	m_fileToolBar->toggleViewAction()->setStatusTip(tr("Show toolbar \"%1\"").arg(m_fileToolBar->windowTitle()));
	m_editToolBar->toggleViewAction()->setStatusTip(tr("Show toolbar \"%1\"").arg(m_editToolBar->windowTitle()));
	m_viewToolBar->toggleViewAction()->setStatusTip(tr("Show toolbar \"%1\"").arg(m_viewToolBar->windowTitle()));
	m_runToolBar->toggleViewAction()->setStatusTip(tr("Show toolbar \"%1\"").arg(m_runToolBar->windowTitle()));
	m_settingsMenu->addMenu(toolBarMenu);
	m_sideBarMenu = new QMenu(tr("&Sidebars"), this);
	m_sideBarMenu->setIcon(Icon(QLatin1String("configure-toolbars")));
	m_sideBarMenu->menuAction()->setStatusTip(tr("Show or hide sidebars"));
	m_sideBarMenu->addAction(m_previewDock->toggleViewAction());
	m_sideBarMenu->addAction(m_logDock->toggleViewAction());
	m_previewDock->toggleViewAction()->setStatusTip(tr("Show sidebar \"%1\"").arg(m_previewDock->windowTitle()));
	m_logDock->toggleViewAction()->setStatusTip(tr("Show sidebar \"%1\"").arg(m_logDock->windowTitle()));
	m_settingsMenu->addMenu(m_sideBarMenu);
	m_settingsMenu->addSeparator();
	m_settingsMenu->addAction(m_configureAction);
	connect(m_fileToolBar->toggleViewAction(), SIGNAL(toggled(bool)), this, SLOT(setToolBarStatusTip(bool)));
	connect(m_editToolBar->toggleViewAction(), SIGNAL(toggled(bool)), this, SLOT(setToolBarStatusTip(bool)));
	connect(m_viewToolBar->toggleViewAction(), SIGNAL(toggled(bool)), this, SLOT(setToolBarStatusTip(bool)));
	connect(m_runToolBar->toggleViewAction(), SIGNAL(toggled(bool)), this, SLOT(setToolBarStatusTip(bool)));
	connect(m_previewDock->toggleViewAction(), SIGNAL(toggled(bool)), this, SLOT(setDockWidgetStatusTip(bool)));
	connect(m_logDock->toggleViewAction(), SIGNAL(toggled(bool)), this, SLOT(setDockWidgetStatusTip(bool)));

	menuBar()->addSeparator();

	QMenu *helpMenu = menuBar()->addMenu(tr("&Help"));
	helpMenu->addAction(m_helpAction);
	helpMenu->addAction(m_showTikzDocAction);
	helpMenu->addAction(m_whatsThisAction);
	helpMenu->addSeparator();
	helpMenu->addAction(m_aboutAction);
	helpMenu->addAction(m_aboutQtAction);
}