Esempio n. 1
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;
}
Esempio n. 2
0
	void PhotosTab::on_CollectionsTree__customContextMenuRequested (const QPoint& point)
	{
		const auto& idx = Ui_.CollectionsTree_->indexAt (point);
		if (!idx.isValid ())
			return;

		const auto type = idx.data (CollectionRole::Type).toInt ();
		const auto isAll = type == ItemType::AllPhotos;
		const auto isColl = type == ItemType::Collection;
		const auto isImage = type == ItemType::Image;

		QMenu menu;
		if (isImage)
		{
			menu.addAction (Proxy_->GetIconThemeManager ()->GetIcon ("go-jump-locationbar"),
					tr ("Open in browser"),
					this,
					SLOT (handleImageOpenRequested ()));
			menu.addAction (Proxy_->GetIconThemeManager ()->GetIcon ("download"),
					tr ("Download original"),
					this,
					SLOT (handleImageDownloadRequested ()));
			menu.addAction (Proxy_->GetIconThemeManager ()->GetIcon ("edit-copy"),
					tr ("Copy image URL"),
					this,
					SLOT (handleCopyURLRequested ()));
		}

		if (auto isd = qobject_cast<ISupportDeletes*> (CurAccObj_))
		{
			if ((isColl && isd->SupportsFeature (DeleteFeature::DeleteCollections)) ||
				(isImage && isd->SupportsFeature (DeleteFeature::DeleteImages)))
				menu.addAction (Proxy_->GetIconThemeManager ()->GetIcon ("list-remove"),
						tr ("Delete"),
						this,
						SLOT (handleDeleteRequested ()));
		}

		if (auto isu = qobject_cast<ISupportUploads*> (CurAccObj_))
			if (isColl || (isAll && !isu->HasUploadFeature (ISupportUploads::Feature::RequiresAlbumOnUpload)))
				menu.addAction (Proxy_->GetIconThemeManager ()->GetIcon ("svn-commit"),
						tr ("Upload"),
						this,
						SLOT (handleUploadRequested ()));

		const auto idxVar = QVariant::fromValue (idx);
		for (auto act : menu.actions ())
			act->setProperty ("Blasq/Index", idxVar);

		if (!menu.actions ().isEmpty ())
			menu.exec (Ui_.CollectionsTree_->viewport ()->mapToGlobal (point));
	}
Esempio n. 3
0
void VCButton_Test::customMenu()
{
    QWidget w;

    VCButton btn(&w, m_doc);
    QMenu* menu = btn.customMenu(NULL);
    QVERIFY(menu != NULL);
    QCOMPARE(menu->title(), tr("Icon"));
    QCOMPARE(menu->actions().size(), 2);
    QCOMPARE(menu->actions()[0], btn.m_chooseIconAction);
    QCOMPARE(menu->actions()[1], btn.m_resetIconAction);
    delete menu;
}
void QgsBrowserDockWidget::showContextMenu( const QPoint & pt )
{
    QModelIndex idx = mBrowserView->indexAt( pt );
    QgsDataItem* item = mModel->dataItem( idx );
    if ( !item )
        return;

    QMenu* menu = new QMenu( this );

    if ( item->type() == QgsDataItem::Directory )
    {
        QSettings settings;
        QStringList favDirs = settings.value( "/browser/favourites" ).toStringList();
        bool inFavDirs = favDirs.contains( item->path() );

        if ( item->parent() != NULL && !inFavDirs )
        {
            // only non-root directories can be added as favourites
            menu->addAction( tr( "Add as a favourite" ), this, SLOT( addFavourite() ) );
        }
        else if ( inFavDirs )
        {
            // only favourites can be removed
            menu->addAction( tr( "Remove favourite" ), this, SLOT( removeFavourite() ) );
        }
    }

    else if ( item->type() == QgsDataItem::Layer )
    {
        menu->addAction( tr( "Add Layer" ), this, SLOT( addCurrentLayer( ) ) );
        menu->addAction( tr( "Add Selected Layers" ), this, SLOT( addSelectedLayers() ) );
        menu->addAction( tr( "Properties" ), this, SLOT( showProperties( ) ) );
    }

    QList<QAction*> actions = item->actions();
    if ( !actions.isEmpty() )
    {
        if ( !menu->actions().isEmpty() )
            menu->addSeparator();
        // add action to the menu
        menu->addActions( actions );
    }

    if ( menu->actions().count() == 0 )
    {
        delete menu;
        return;
    }

    menu->popup( mBrowserView->mapToGlobal( pt ) );
}
Esempio n. 5
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;
}
Esempio n. 6
0
void ActionLineEdit::contextMenuEvent(QContextMenuEvent *e)
{
	QMenu *menu = createStandardContextMenu();
	if (actions().count() > 0) {
		QAction *before = NULL;
		if (menu->actions().count() > 0) {
			before = menu->actions().first();
		}
		menu->insertActions(before, actions());
		menu->insertSeparator(before);
	}
	menu->exec(e->globalPos());
	delete menu;
}
Esempio n. 7
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;
}
Esempio n. 8
0
/**
 * NOTE: we assume kate is installed
 */
void KMoreToolsTest2::test_buildMenu_ShowConfigureMenuItem()
{
    {
        KMoreTools kmt(_("unittest-kmoretools/2"));
        const auto kateApp = kmt.registerServiceByDesktopEntryName(_("org.kde.kate"));
        // porcelain: other (interactive) tests will reuse the kmt id so we make sure that
        // no user configurment disburbs this test:
        const auto menuBuilder = kmt.menuBuilder(_("porcelain"));
        menuBuilder->addMenuItem(kateApp);
        QMenu menu;
        menuBuilder->buildByAppendingToMenu(&menu); // == KMoreTools::ConfigureDialogAccessible_Always
        qDebug() << menuBuilder->menuStructureAsString(true);
        QVERIFY(menuAtLeastOneActionWithText(&menu, _("Configure..."))); // "Kate", "Separator", "Configure..."

        {
            menu.clear();
            menuBuilder->buildByAppendingToMenu(&menu, KMoreTools::ConfigureDialogAccessible_Defensive);
            QVERIFY(menuAtLeastNoActionWithText(&menu, _("Configure...")));
        }
    }

    {
        KMoreTools kmt(_("unittest-kmoretools/2"));
        const auto kateApp = kmt.registerServiceByDesktopEntryName(_("org.kde.kate"));
        const auto mynotInstalledApp = kmt.registerServiceByDesktopEntryName(_("mynotinstalledapp"));
        const auto menuBuilder = kmt.menuBuilder(_("porcelain"));
        menuBuilder->addMenuItem(kateApp);
        menuBuilder->addMenuItem(mynotInstalledApp);
        QMenu menu;
        menuBuilder->buildByAppendingToMenu(&menu); // == KMoreTools::ConfigureDialogAccessible_Always

        auto doAssert = [](QMenu* menu) {
            QCOMPARE(menu->actions().count(), 3); // "Kate", "Separator", "More..."
            auto moreMenu = menu->actions()[2]->menu();
            QCOMPARE(moreMenu->actions().count(), 4); // "Not-installed-section", "Not installed app", "Separator", "Configure menu..."
            auto configureMenu = moreMenu->actions()[3];
            QCOMPARE(configureMenu->data().toString(), QString(_("configureItem")));
        };

        doAssert(&menu);

        {
            menu.clear();
            menuBuilder->buildByAppendingToMenu(&menu, KMoreTools::ConfigureDialogAccessible_Defensive);
            doAssert(&menu); // = same as _Always because there is one not-installed item
        }
    }
}
Esempio n. 9
0
void Controls::addRecentFiles(const QString &fileName)
{
    QMenu *rf = m_ui->menuRecent_Models;
    QStringList files;
    {
        QSettings settings;
        settings.beginGroup("General");
        int numFiles = settings.beginReadArray("RecentFiles");
        for (int i = 0; i < numFiles; ++i)
        {
            settings.setArrayIndex(i);
            QByteArray coded = settings.value("file").toByteArray();
            files.append(QUrl::fromPercentEncoding(coded));
        }
    }
    files.removeAll(fileName);
    files.push_front(fileName);
    if (files.size() > 10)
        files.pop_back();
    QAction *act;
    while (rf->actions().count() > 0)
    {
        act = rf->actions().at(0);
        rf->removeAction(act);
        delete act;
    }
    for (int i = 0; i < files.count(); ++i)
    {
        act = new QAction(files.at(i), this);
        connect(act, SIGNAL(triggered()),
                this, SLOT(load()));
        rf->addAction(act);
    }
    {
        QSettings settings;
        settings.beginGroup("General");
        settings.beginWriteArray("RecentFiles", files.count());
        for (int i = 0; i < files.count(); ++i)
        {
            settings.setArrayIndex(i);
            QByteArray coded = QUrl::toPercentEncoding(files.at(i));
            settings.setValue("file", coded);
        }
        settings.endArray();
        settings.endGroup();
        settings.sync();
    }
}
Esempio n. 10
0
/**
 * View Menu
 * Interface modification, load other interfaces, activate Extensions
 * \param current, set to NULL for menu creation, else for menu update
 **/
QMenu *VLCMenuBar::ViewMenu( intf_thread_t *p_intf, QMenu *current, MainInterface *_mi )
{
    QAction *action;
    QMenu *menu;

    MainInterface *mi = _mi ? _mi : p_intf->p_sys->p_mi;
    assert( mi );

    if( !current )
    {
        menu = new QMenu( qtr( "&View" ), mi );
    }
    else
    {
        menu = current;
        //menu->clear();
        //HACK menu->clear() does not delete submenus
        QList<QAction*> actions = menu->actions();
        foreach( QAction *a, actions )
        {
            QMenu *m = a->menu();
            if( a->parent() == menu ) delete a;
            else menu->removeAction( a );
            if( m && m->parent() == menu ) delete m;
        }
    }
Esempio n. 11
0
 void MacroItem::contextMenuEvent(QGraphicsSceneContextMenuEvent* event)
 {
   bool selected = this->isSelected();
   event->accept();
   if (!selected)
   {
     this->setSelected(true);
   }
   QMenu popup;
   QAction* edtCut = Resource::action(Resource::EDIT_CUT);
   QAction* edtCopy = Resource::action(Resource::EDIT_COPY);
   QAction* edtDel = Resource::action(Resource::EDIT_DELETE);
   if ((vertex().isInCycle() && !vertex().topologicalOrderForced() && vertex().topologicalOrder() < 0) || vertex().topologicalOrderForced())
   {
     QAction* edtAnchor = Resource::action(Resource::EDIT_SETANCHOR);
     void* ptrMacro = reinterpret_cast<void*>(&vertex());
     edtAnchor->setData(QVariant::fromValue(ptrMacro));
     edtAnchor->setChecked(vertex().topologicalOrderForced());
     popup.addAction(edtAnchor);
     popup.addSeparator();
   }
   popup.addAction(edtCut);
   popup.addAction(edtCopy);
   popup.addAction(edtDel);
   popup.exec(event->screenPos(),popup.actions().first());
   if (!selected)
   {
     this->setSelected(false);
   }
 }
Esempio n. 12
0
 void MacroLinkItem::contextMenuEvent(QGraphicsSceneContextMenuEvent* event)
 {
   bool selected = this->isSelected();
   event->accept();
   if (!selected)
   {
     this->setSelected(true);
   }
   QMenu popup;
   QAction* edtCut = Resource::action(Resource::EDIT_CUT);
   QAction* edtCopy = Resource::action(Resource::EDIT_COPY);
   QAction* edtDel = Resource::action(Resource::EDIT_DELETE);
   QAction* macroWatch = Resource::action(Resource::MACRO_WATCHOUTPUT);
   macroWatch->setData(reinterpret_cast<qulonglong>(edge().srcPin().data()));
   popup.addAction(macroWatch);
   popup.addSeparator();
   if (scene()->selectedItems().count() > 1)
   {
     popup.addAction(edtCut);
     popup.addAction(edtCopy);
   }
   popup.addAction(edtDel);
   popup.exec(event->screenPos(),popup.actions().first());
   if (!selected)
   {
     this->setSelected(false);
   }
 }
Esempio n. 13
0
void LayoutManagement::initializeLayouts()
{
    QMenu *saveLayout = static_cast<QMenu*>(pCore->window()->factory()->container(QStringLiteral("layout_save_as"), pCore->window()));
    if (m_loadLayout == NULL || saveLayout == NULL) return;
    KSharedConfigPtr config = KSharedConfig::openConfig();
    KConfigGroup layoutGroup(config, "Layouts");
    QStringList entries = layoutGroup.keyList();
    QList<QAction *> loadActions = m_loadLayout->actions();
    QList<QAction *> saveActions = saveLayout->actions();
    for (int i = 1; i < 5; ++i) {
        // Rename the layouts actions
        foreach(const QString & key, entries) {
            if (key.endsWith(QStringLiteral("_%1").arg(i))) {
                // Found previously saved layout
                QString layoutName = key.section('_', 0, -2);
                for (int j = 0; j < loadActions.count(); ++j) {
                    if (loadActions.at(j)->data().toString().endsWith('_' + QString::number(i))) {
                        loadActions[j]->setText(layoutName);
                        loadActions[j]->setData(key);
                        break;
                    }
                }
                for (int j = 0; j < saveActions.count(); ++j) {
                    if (saveActions.at(j)->data().toString().endsWith('_' + QString::number(i))) {
                        saveActions[j]->setText(i18n("Save as %1", layoutName));
                        saveActions[j]->setData(key);
                        break;
                    }
                }
            }
        }
    }
}
Esempio n. 14
0
int ScriptToolbox::menuActionCount(QObject * menu)
{
    QMenu * m = qobject_cast<QMenu*>(menu);
    if (m)
        return m->actions().count();
    return 0;
}
Esempio n. 15
0
void WebWidget::openInApplicationMenuAboutToShow()
{
	QMenu *menu = qobject_cast<QMenu*>(sender());

	if (!menu || !menu->actions().isEmpty())
	{
		return;
	}

	const QList<ApplicationInformation> applications = Utils::getApplicationsForMimeType(QMimeDatabase().mimeTypeForName(QLatin1String("text/html")));

	if (applications.isEmpty())
	{
		menu->addAction(tr("Default Application"));
	}
	else
	{
		for (int i = 0; i < applications.count(); ++i)
		{
			menu->addAction(applications.at(i).icon, ((applications.at(i).name.isEmpty()) ? tr("Unknown") : applications.at(i).name))->setData(applications.at(i).command);

			if (i == 0)
			{
				menu->addSeparator();
			}
		}
	}

	connect(menu, SIGNAL(triggered(QAction*)), this, SLOT(openInApplication(QAction*)));
}
Esempio n. 16
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);
}
Esempio n. 17
0
	void Plugin::fillMenu ()
	{
		auto menu = Proxy_->GetMWProxy ()->GetMainMenu ();

		QMenu *lcMenu = 0;
		QList<QAction*> firstLevelActions;
		Q_FOREACH (auto action, menu->actions ())
			if (action->menu ())
			{
				MenuBar_->addAction (action);
				if (!lcMenu)
					lcMenu = action->menu ();
			}
			else
			{
				if (action->menuRole () == QAction::TextHeuristicRole)
					action->setMenuRole (QAction::ApplicationSpecificRole);
				firstLevelActions << action;
			}

		Q_FOREACH (auto act, firstLevelActions)
			lcMenu->addAction (act);

		if (!lcMenu->actions ().isEmpty ())
			MenuBar_->addMenu (lcMenu);

		const auto& actors = Proxy_->GetPluginsManager ()->
				GetAllCastableRoots<IActionsExporter*> ();
		Q_FOREACH (auto actor, actors)
			connect (actor,
					SIGNAL (gotActions (QList<QAction*>, LeechCraft::ActionsEmbedPlace)),
					this,
					SLOT (handleGotActions (QList<QAction*>, LeechCraft::ActionsEmbedPlace)));
	}
Esempio n. 18
0
void EC_MediaPlayer::EntityClicked(Entity *entity, Qt::MouseButton button, RaycastResult *raycastResult)
{
    if (!getinteractive() || !ParentEntity())
        return;

    // We are only interested in left clicks on our entity.
    if (!raycastResult)
        return;
    if (button != Qt::LeftButton)
        return;

    if (entity == ParentEntity())
    {
        // We are only interested in clicks to our target submesh index.
        if (raycastResult->submesh != (unsigned)getrenderSubmeshIndex())
            return;

        // Entities have EC_Highlight if it is being manipulated.
        // At this situation we don't want to show any ui.
        if (entity->GetComponent("EC_Highlight"))
            return;

        QMenu *popupInteract = GetContextMenu();
        if (!popupInteract->actions().empty())
            popupInteract->exec(QCursor::pos());
    }
}
Esempio n. 19
0
QMenu* QtMenu::addMenuPath(QMenu& qMenu, const char* path)
{
	QMenu* menu = &qMenu;
	while (path != nullptr)
	{
		auto tok = strchr(path, '.');
		auto subPath = tok != nullptr ? QString::fromUtf8(path, tok - path) : path;
		if (!subPath.isEmpty())
		{
			QMenu* subMenu = nullptr;
			auto actions = menu->actions();
			for (auto& action : actions)
			{
				subMenu = action->menu();
				if (subMenu != nullptr &&
					subMenu->objectName() == subPath)
				{
					break;
				}
				subMenu = nullptr;
			}

			if (subMenu == nullptr)
			{
				subMenu = menu->addMenu(subPath);
				subMenu->setObjectName(subPath);
			}
			menu = subMenu;
		}
		path = tok != nullptr ? tok + 1 : nullptr;
	}
	return menu;
}
Esempio n. 20
0
void SBI_NetworkIcon::showMenu(const QPoint &pos)
{
    QFont boldFont = font();
    boldFont.setBold(true);

    QMenu menu;
    menu.addAction(QIcon::fromTheme("preferences-system-network", QIcon(":sbi/data/preferences-network.png")), tr("Proxy configuration"))->setFont(boldFont);

    QMenu* proxyMenu = menu.addMenu(tr("Select proxy"));

    const QHash<QString, SBI_NetworkProxy*> &proxies = SBINetManager->proxies();

    QHashIterator<QString, SBI_NetworkProxy*> it(proxies);
    while (it.hasNext()) {
        it.next();
        QAction* act = proxyMenu->addAction(it.key(), this, SLOT(useProxy()));
        act->setData(it.key());
        act->setCheckable(true);
        act->setChecked(it.value() == SBINetManager->currentProxy());
    }

    if (proxyMenu->actions().count() == 0) {
        proxyMenu->addAction(tr("Empty"))->setEnabled(false);
    }

    menu.addSeparator();
    menu.addAction(tr("Manage proxies"), this, SLOT(showDialog()));
    menu.exec(pos);
}
Esempio n. 21
0
QList<QAction*> QMenuProto::actions() const
{
  QMenu *item = qscriptvalue_cast<QMenu*>(thisObject());
  if (item)
    return item->actions();
  return QList<QAction*>();
}
Esempio n. 22
0
	void MainWindowMenuManager::AddMenus (const QMap<QString, QList<QAction*>>& menus)
	{
		for (const auto& menuName : menus.keys ())
		{
			QMenu *toInsert = nullptr;
			if (menuName == "view")
				toInsert = MenuView_;
			else if (menuName == "tools")
				toInsert = MenuTools_;
			else
				for (auto action : Menu_->actions ())
					if (action->menu () &&
						action->text () == menuName)
					{
						toInsert = action->menu ();
						break;
					}

			const auto& actions = menus [menuName];

			if (toInsert)
				toInsert->insertActions (toInsert->actions ().value (0, 0), actions);
			else
			{
				auto menu = new QMenu { menuName, Menu_.get () };
				menu->addActions (actions);
				Menu_->insertMenu (MenuTools_->menuAction (), menu);
			}

			IconThemeEngine::Instance ().UpdateIconset (actions);
		}
	}
Esempio n. 23
0
void InventoryTreeView::contextMenuEvent(QContextMenuEvent *event)
{
    // Do mousePressEvent so that the right item gets selected before we show the menu
    // (right-click doesn't do this automatically).
    QMouseEvent mouseEvent(QEvent::MouseButtonPress, event->pos(), event->globalPos(),
        Qt::LeftButton, Qt::LeftButton, Qt::NoModifier);

    mousePressEvent(&mouseEvent);

    QModelIndex index = selectionModel()->currentIndex();
    if (!index.isValid())
        return;

    QMenu *menu = new QMenu(this);
    QListIterator<QAction *> it(actions());
    while(it.hasNext())
    {
        QAction *action = it.next();
        if (action->isEnabled())
        {
            // This is kind of hack, but we might have case that base language is not english. 
            InventoryAction* act = qobject_cast<InventoryAction* >(action);
            QString text = QApplication::translate("Inventory::InventoryWindow", act->GetText().toStdString().c_str());
            action->setText(text);

            menu->addAction(action);
        } 
   }

    if (menu->actions().size() > 1) // separator "action" is always enabled, hence the 1
        menu->popup(event->globalPos());
}
Esempio n. 24
0
void FileSystemWidget::treeViewContextMenuRequested(const QPoint &pos)
{
    QMenu *contextMenu = 0;
    QModelIndex index = m_tree->indexAt(pos);
    if (index.isValid()) {
        FileNode *node = m_model->nodeFromIndex(index);
        if (node) {
            m_contextInfo = node->fileInfo();
            m_contextIndex = index;
            if (node->isDir()) {
                contextMenu = m_folderMenu;
                if (m_model->isRootPathNode(node)) {
                    m_closeFolerAct->setVisible(true);
                    m_removeFolderAct->setVisible(false);
                } else {
                    m_closeFolerAct->setVisible(false);
                    m_removeFolderAct->setVisible(true);
                }
            } else {
                contextMenu = m_fileMenu;
            }
        }
    } else {
        contextMenu = m_rootMenu;
    }
    if (contextMenu && contextMenu->actions().count() > 0) {
        contextMenu->popup(m_tree->mapToGlobal(pos));
    }
}
Esempio n. 25
0
void TextInputWidget::showContextMenu(const QPoint &pt)
{
    QMenu *menu = createStandardContextMenu();
    QList<QAction *> actions=menu->actions();

    //hack menu
    for(int i=0;i<actions.size();i++)
    {
        //qDebug()<<actions[i]->text();
        if(actions[i]->text().contains("undo",Qt::CaseInsensitive))
        {
            menu->removeAction(actions[i]);
        }
        if(actions[i]->text().contains("redo",Qt::CaseInsensitive))
        {
            menu->removeAction(actions[i]);
        }
        if(actions[i]->text().contains("delete",Qt::CaseInsensitive))
        {
            menu->removeAction(actions[i]);
        }
        if(actions[i]->text().contains("cu",Qt::CaseInsensitive))
        {
            actions[i]->disconnect(SIGNAL(triggered(bool)));
            connect(actions[i],SIGNAL(triggered(bool)),this,SLOT(cut()));
        }
        if(actions[i]->text().contains("paste",Qt::CaseInsensitive))
        {
            actions[i]->disconnect(SIGNAL(triggered(bool)));
            connect(actions[i],SIGNAL(triggered(bool)),this,SLOT(paste()));
        }
void
PlayableItemWidget::contextMenuEvent( QContextMenuEvent* event )
{
    QMenu* contextMenu = new QMenu( this );

    contextMenu->addAction( tr( "Play %1" ).arg( m_rs.title() ), this, SLOT(play()));

    if ( RadioService::instance().state() == Playing )
        contextMenu->addAction( tr( "Cue %1" ).arg( m_rs.title() ), this, SLOT(playNext()));

    if ( m_rs.url().startsWith( "lastfm://user/" )
         &&  ( m_rs.url().endsWith( "/library" ) || m_rs.url().endsWith( "/personal" ) )
         && m_rs.url() != RadioStation::library( User() ).url() )
    {
        int endPos = m_rs.url().indexOf( "/", 14 );
        if ( endPos == -1 )
            endPos = m_rs.url().length();

        // if it's a user station that isn't yours we should
        // let them start a multi-station with yours
        contextMenu->addSeparator();
        contextMenu->addAction( tr( "Play %1 and %2 Library Radio" ).arg( m_rs.url().mid( 14, endPos - 14 ), User().name() ), this, SLOT(playMulti()));
        if ( RadioService::instance().state() == Playing )
            contextMenu->addAction( tr( "Cue %1 and %2 Library Radio" ).arg( m_rs.url().mid( 14, endPos - 14 ), User().name() ), this, SLOT(playMultiNext()));
    }

    if ( contextMenu->actions().count() )
        contextMenu->exec( event->globalPos() );
}
Esempio n. 27
0
void MainWindow::joystickTrayShow()
{
    QMenu *tempmenu = (QMenu*) sender();
    QList<QAction*> menuactions = tempmenu->actions();
    QListIterator<QAction*> listiter (menuactions);
    while (listiter.hasNext())
    {
        QAction *action = listiter.next();
        action->setChecked(false);

        QHash<QString, QVariant> tempmap = action->data().toHash();
        QHashIterator<QString, QVariant> iter(tempmap);
        while (iter.hasNext())
        {
            iter.next();
            int joyindex = iter.key().toInt();
            int configindex = iter.value().toInt();
            JoyTabWidget *widget = (JoyTabWidget*)ui->tabWidget->widget(joyindex);

            if (configindex == widget->getCurrentConfigIndex())
            {
                action->setChecked(true);
            }
        }
    }
}
Esempio n. 28
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);
}
Esempio n. 29
0
void Pane::on_list_customContextMenuRequested(const QPoint &pos) {
  File_info file = file_list_model.get_file_info(ui->list->indexAt(pos));
  App_info_list apps = main_window->get_apps(file.mime_type);
  QMenu* menu = new QMenu(this);
  if (file.is_folder()) {
    menu->addAction(tr("Browse"))->setEnabled(false);
  }
  if (file.is_file) {
    menu->addAction(main_window->get_ui()->action_view);
    menu->addAction(main_window->get_ui()->action_edit);
  }
  if (file.is_executable) {
    menu->addAction(main_window->get_ui()->action_execute);
  }
  if (menu->actions().count() > 0) menu->addSeparator();

  foreach(App_info app, apps) {
    QAction* a = menu->addAction(tr("Open with %1 (%2)").arg(app.name()).arg(app.command()), this, SLOT(action_launch_triggered()));
    QVariantList data;
    data << QVariant::fromValue(app) << QVariant::fromValue(file);
    a->setData(data);
    if (app == apps.default_app) {
      QFont f = a->font();
      f.setBold(true);
      a->setFont(f);
    }
  }
Esempio n. 30
0
QMenu *WulforUtil::buildUserCmdMenu(const StringList& hub_list, int ctx, QWidget* parent) {
    UserCommand::List userCommands = FavoriteManager::getInstance()->getUserCommands(ctx, hub_list);

    if (userCommands.empty())
        return nullptr;

    QMenu *ucMenu = new QMenu(tr("User commands"), parent);

    QMenu *menuPtr = ucMenu;
    for (size_t n = 0; n < userCommands.size(); ++n) {
        UserCommand *uc = &userCommands[n];
        if (uc->getType() == UserCommand::TYPE_SEPARATOR) {
            // Avoid double separators...
            if (!menuPtr->actions().isEmpty() &&
                !menuPtr->actions().last()->isSeparator())
            {
                menuPtr->addSeparator();
            }
        } else if (uc->isRaw() || uc->isChat()) {
            menuPtr = ucMenu;
            auto _begin = uc->getDisplayName().begin();
            auto _end = uc->getDisplayName().end();
            for(; _begin != _end; ++_begin) {
                const QString name = _q(*_begin);
                if (_begin + 1 == _end) {
                    menuPtr->addAction(name)->setData(uc->getId());
                } else {
                    bool found = false;
                    QListIterator<QAction*> iter(menuPtr->actions());
                    while(iter.hasNext()) {
                        QAction *item = iter.next();
                        if (item->menu() && item->text() == name) {
                            found = true;
                            menuPtr = item->menu();
                            break;
                        }
                    }

                    if (!found)
                        menuPtr = menuPtr->addMenu(name);
                }
            }
        }
    }
    return ucMenu;
}