QgsRendererV2DataDefinedMenus::QgsRendererV2DataDefinedMenus( QMenu* menu, const QgsFields& flds, QString rotationField, QString sizeScaleField, QgsSymbolV2::ScaleMethod scaleMethod )
    : QObject( menu ), mFlds( flds )
{
  mRotationMenu = new QMenu( tr( "Rotation field" ) );
  mSizeScaleMenu = new QMenu( tr( "Size scale field" ) );

  mRotationAttributeActionGroup = new QActionGroup( mRotationMenu );
  mSizeAttributeActionGroup = new QActionGroup( mSizeScaleMenu );
  mSizeMethodActionGroup = new QActionGroup( mSizeScaleMenu );

  populateMenu( mRotationMenu, SLOT( rotationFieldSelected( QAction* a ) ), rotationField, mRotationAttributeActionGroup );
  populateMenu( mSizeScaleMenu, SLOT( sizeScaleFieldSelected( QAction* a ) ), sizeScaleField, mSizeAttributeActionGroup );

  mSizeScaleMenu->addSeparator();

  QAction* aScaleByArea = new QAction( tr( "Scale area" ), mSizeMethodActionGroup ) ;
  QAction* aScaleByDiameter = new QAction( tr( "Scale diameter" ), mSizeMethodActionGroup );

  aScaleByArea->setCheckable( true );
  aScaleByDiameter->setCheckable( true );

  if ( scaleMethod == QgsSymbolV2::ScaleDiameter )
  {
    aScaleByDiameter->setChecked( true );
  }
  else
  {
    aScaleByArea->setChecked( true );
  }

  mSizeScaleMenu->addActions( mSizeMethodActionGroup->actions() );

  menu->addMenu( mRotationMenu );
  menu->addMenu( mSizeScaleMenu );
}
void CDisplaySettingsButton::reset(const QList<CSwordModuleInfo*>& useModules) {
    m_modules = useModules;
    populateMenu();
    //disable the settings button if no options are available
    if (!populateMenu()) {
        setEnabled(false);
        setToolTip(tr("Display settings: No options available"));
    }
    else {
        setEnabled(true);
        setToolTip(tr("Display settings"));
    }
}
Example #3
0
void SinglePopupEditor::edit(MenuTreeWidgetItem * it)
{
	saveLastSelectedItem();

	m_pLastSelectedItem = nullptr;

	m_pTreeWidget->clear();

	selectionChanged();

	if(it)
	{
		m_pNameEditor->setText(it->m_pPopup->popupName());
		populateMenu(it->m_pPopup, nullptr, nullptr);
	}
	else
	{
		m_pIconEditor->setText("");
		m_pIconEditor->setEnabled(false);
		m_pIdEditor->setText("");
		m_pIdEditor->setEnabled(false);
		m_pConditionEditor->setText("");
		m_pConditionEditor->setEnabled(false);
		m_pTextEditor->setText("");
		m_pTextEditor->setEnabled(false);
		m_pEditor->setText("");
		m_pEditor->setEnabled(false);
		m_pNameEditor->setText("");
		m_pExtNameEditor->setText("");
		m_pExtNameEditor->setEnabled(false);
	}
	m_pTreeWidget->setEnabled(it);
	m_pNameEditor->setEnabled(it);
	m_pMenuButton->setEnabled(it);
}
NBCategoryMenu::NBCategoryMenu( QString catName, QPixmap icon, QString wNode, QModelIndexList nodeList, QWidget *parent ) : QMenu( parent ) {

	mCategory = catName;
	mWorkNode = wNode;
	sNodes << nodeList;

	QWidgetAction *title = new QWidgetAction( this );
	QWidget *actBase = new QWidget( this );

	QLabel *pix = new QLabel();
	pix->setFixedSize( 20, 20 );
	pix->setPixmap( icon.scaled( 16, 16, Qt::KeepAspectRatio, Qt::SmoothTransformation ) );
	pix->setAlignment( Qt::AlignCenter );

	QLabel *name = new QLabel( "<b>" + catName + "</b>" );
	name->setFixedHeight( 20 );
	name->setAlignment( Qt::AlignVCenter );

	QHBoxLayout *lyt = new QHBoxLayout();
	lyt->setContentsMargins( QMargins( 4, 4, 4, 0 ) );
	lyt->addWidget( pix );
	lyt->addWidget( name );

	actBase->setLayout( lyt );
	title->setDefaultWidget( actBase );
	addAction( title );

	addSeparator();

	populateMenu();
};
void populateMenu(QSet<ActionInterface* > &actionInterfaces,
                  const QByteArray &category,
                  QMenu* menu,
                  const SelectionContext &selectionContext)
{
    QSet<ActionInterface* > matchingFactories = findMembers(actionInterfaces, category);

    actionInterfaces.subtract(matchingFactories);

    QList<ActionInterface* > matchingFactoriesList = matchingFactories.toList();
    Utils::sort(matchingFactoriesList, [](ActionInterface *l, ActionInterface *r) {
        return l->priority() > r->priority();
    });

    foreach (ActionInterface* actionInterface, matchingFactoriesList) {
        if (actionInterface->type() == ActionInterface::ContextMenu) {
            actionInterface->currentContextChanged(selectionContext);
            QMenu *newMenu = actionInterface->action()->menu();
            if (newMenu && !newMenu->title().isEmpty())
                menu->addMenu(newMenu);

            //recurse

            populateMenu(actionInterfaces, actionInterface->menuId(), newMenu, selectionContext);
       } else if (actionInterface->type() == ActionInterface::ContextMenuAction
                  || actionInterface->type() == ActionInterface::Action) {
           QAction* action = actionInterface->action();
           actionInterface->currentContextChanged(selectionContext);
           action->setIconVisibleInMenu(false);
           menu->addAction(action);
       }
    }
}
Example #6
0
void DefaultProxyAction::prepareMenu()
{
	QMenu *menu = qobject_cast<QMenu *>(sender());
	if (!menu)
		return;

	menu->clear();

	NetworkProxy defaultProxy = m_networkProxyManager->defaultProxy();

	QAction *proxyAction = menu->addAction(tr(" - No proxy - "));

	// this parenting allows proxyActions to be removed on menu->clear() whats prevents memory leak
	QActionGroup *proxyActions = new QActionGroup(proxyAction);
	proxyActions->addAction(proxyAction);
	proxyAction->setCheckable(true);
	if (!defaultProxy)
		proxyAction->setChecked(true);

	populateMenu(menu, proxyActions, defaultProxy);

	menu->addSeparator();
	QAction *editProxyConfigurationAction = menu->addAction(tr("Edit proxy configuration..."));
	connect(editProxyConfigurationAction, SIGNAL(triggered()), this, SLOT(editProxyConfiguration()));
}
Example #7
0
void SinglePopupEditor::contextPasteBelow()
{
	if(!m_pClipboard)
		return;

	PopupTreeWidgetItem * par = m_pLastSelectedItem ? (PopupTreeWidgetItem *)m_pLastSelectedItem->parent() : nullptr;
	populateMenu(m_pClipboard, par, m_pLastSelectedItem);
}
Example #8
0
void SinglePopupEditor::contextPasteAbove()
{
	if(!m_pClipboard)
		return;

	PopupTreeWidgetItem * par = m_pLastSelectedItem ? (PopupTreeWidgetItem *)m_pLastSelectedItem->parent() : nullptr;
	PopupTreeWidgetItem * above = m_pLastSelectedItem ? (PopupTreeWidgetItem *)m_pTreeWidget->itemAbove(m_pLastSelectedItem) : nullptr;
	populateMenu(m_pClipboard, par, above);
}
QgsRendererV2DataDefinedMenus::QgsRendererV2DataDefinedMenus( QMenu* menu, QgsVectorLayer* layer, QString rotationField, QString sizeScaleField, QgsSymbolV2::ScaleMethod scaleMethod )
    : QObject( menu ), mLayer( layer )
{
  mRotationMenu = new QMenu( tr( "Rotation field" ) );
  mSizeScaleMenu = new QMenu( tr( "Size scale field" ) );

  mRotationAttributeActionGroup = new QActionGroup( mRotationMenu );
  mSizeAttributeActionGroup = new QActionGroup( mSizeScaleMenu );
  mSizeMethodActionGroup = new QActionGroup( mSizeScaleMenu );

  populateMenu( mRotationMenu, rotationField, mRotationAttributeActionGroup );
  populateMenu( mSizeScaleMenu, sizeScaleField, mSizeAttributeActionGroup );

  mSizeScaleMenu->addSeparator();

  QAction* aScaleByArea = new QAction( tr( "Scale area" ), mSizeMethodActionGroup );
  QAction* aScaleByDiameter = new QAction( tr( "Scale diameter" ), mSizeMethodActionGroup );

  aScaleByArea->setCheckable( true );
  aScaleByDiameter->setCheckable( true );

  if ( scaleMethod == QgsSymbolV2::ScaleDiameter )
  {
    aScaleByDiameter->setChecked( true );
  }
  else
  {
    aScaleByArea->setChecked( true );
  }

  mSizeScaleMenu->addActions( mSizeMethodActionGroup->actions() );

  //@todo cleanup the class since Rotation and SizeScale are now
  //defined using QgsDataDefinedButton
  //
  //menu->addMenu( mRotationMenu );
  //menu->addMenu( mSizeScaleMenu );

  connect( mSizeMethodActionGroup, SIGNAL( triggered( QAction* ) ), this, SLOT( scaleMethodSelected( QAction* ) ) );
  connect( mRotationAttributeActionGroup, SIGNAL( triggered( QAction* ) ), this, SLOT( rotationFieldSelected( QAction* ) ) );
  connect( mSizeAttributeActionGroup, SIGNAL( triggered( QAction* ) ), this, SLOT( sizeScaleFieldSelected( QAction* ) ) );
}
void omni::ui::entity_placeholder_widget::populateMenu (omni::core::model::meta_info const & meta, QMenu & menu)
{
    if (! meta.isAbstract ()) {
        auto * action = new meta_action (meta, QString::fromStdString (meta.getName ()), & menu);
        connect (action, SIGNAL(triggered()), SLOT(switchToEntityType()));
        menu.addAction (action);
    }
    for (std::size_t i = 0u; i < meta.getChildCount (); ++ i) {
        auto & child = meta.getChildAt (i);
        populateMenu (child, menu);
    }
}
Example #11
0
bool MainWindow::loadPlugins()
{
    bool res = false;
    QDir pluginsDir( qApp->applicationDirPath() );
    pluginsDir.cd( "plugins" );

    Q_FOREACH( const QString& fileName, pluginsDir.entryList( QDir::Files ) )
        if ( const QObject *plugin = QPluginLoader( pluginsDir.absoluteFilePath( fileName ) ).instance() )
            res |= populateMenu( plugin );

    return res;
}
Example #12
0
void Favorites::createMenu()
{
    _menu = new QMenu(parent_widget);
    connect( _menu, SIGNAL(triggered(QAction *)),
             this, SLOT(triggered_slot(QAction *)) );

    _menu->addAction(edit_act);
    //_menu->addAction(jump_act);
    _menu->addSeparator();

    populateMenu();
}
Example #13
0
void Favorites::updateMenu()
{
    // Remove all except the first 2 items
    while (_menu->actions().count() > FIRST_MENU_ENTRY)
    {
        QAction * a = _menu->actions()[FIRST_MENU_ENTRY];
        _menu->removeAction( a );
        a->deleteLater();
    }

    populateMenu();
    markCurrent();
}
MainWindow::MainWindow(QWidget *parent) :
    QMainWindow(parent), ui(new Ui::MainWindow)
{
    ui->setupUi(this);

    setAttribute(Qt::WA_DeleteOnClose);

    connectActions(App::instance());
    ui->menuEdit->addAction(App::instance()->undoAction());
    ui->menuEdit->addAction(App::instance()->redoAction());
    setShortcuts();

    populateMenu(ui->menuAdd);
}
Example #15
0
void SinglePopupEditor::contextPasteInside()
{
	if(!m_pClipboard)
		return;

	if(m_pLastSelectedItem)
	{
		if(m_pLastSelectedItem->m_type != PopupTreeWidgetItem::Menu)
		{
			contextPasteBelow();
			return;
		}
		m_pLastSelectedItem->setExpanded(true);
	}
	populateMenu(m_pClipboard, m_pLastSelectedItem, nullptr);
}
void ModelNodeContextMenu::execute(const QPoint &position, bool selectionMenuBool)
{
    QMenu* mainMenu = new QMenu();

    m_selectionContext.setShowSelectionTools(selectionMenuBool);
    m_selectionContext.setScenePosition(m_scenePos);


     QSet<ActionInterface* > factories =
             QSet<ActionInterface* >::fromList(QmlDesignerPlugin::instance()->designerActionManager().designerActions());

     populateMenu(factories, QByteArray(), mainMenu, m_selectionContext);

     mainMenu->exec(position);
     mainMenu->deleteLater();
}
Example #17
0
void MenuCreator::populatePluginMenu(std::string pluginId, PluginMenu item, IIdGenerator* idgenerator)
{
    int index = getParentMenuIndex(item.mParentMenu);
    if (-1 != index)
    {
        CMenu* menu = mMainMenu->GetSubMenu(index); //TODO::nullpointer check
        INT COUNT = menu->GetMenuItemCount();
for (auto itemMenu : item.menuList)
        {
            populateMenu(pluginId, menu, itemMenu, idgenerator);
        }
        COUNT = menu->GetMenuItemCount();
        CMenu* subMenu = menu->GetSubMenu(19);
        // COUNT = subMenu->GetMenuItemCount();
        COUNT++;
    }
}
Example #18
0
void XTableView::sShowMenu(const QPoint &pntThis)
{
  QModelIndex item = indexAt(pntThis);
  if (item.isValid())
  {
    _menu->clear();
    emit populateMenu(_menu, item);

    bool disableExport = FALSE;
    if(_x_preferences)
      disableExport = (_x_preferences->value("DisableExportContents")=="t");
    if(!disableExport)
      _menu->addAction(tr("Export Contents..."),  this, SLOT(sExport()));

    if(! _menu->isEmpty())
      _menu->popup(mapToGlobal(pntThis));
  }
}
CDisplaySettingsButton::CDisplaySettingsButton(CSwordBackend::DisplayOptions *displaySettings, CSwordBackend::FilterOptions *moduleSettings, const QList<CSwordModuleInfo*>& useModules, QWidget *parent )
        : QToolButton(parent) {
    namespace DU = util::directory;

    //  qWarning("CDisplaySettingsButton::CDisplaySettingsButton");
    QToolButton::setIcon(DU::getIcon(CResMgr::displaywindows::displaySettings::icon));

    m_displaySettings = displaySettings;
    m_moduleSettings = moduleSettings;
    m_modules = useModules;

    m_popup = new QMenu(this);
    setMenu(m_popup);
    setPopupMode(QToolButton::InstantPopup);
    setToolTip(tr("Display options"));

    connect(m_popup, SIGNAL(triggered(QAction*)), this, SLOT(optionToggled(QAction*)));
    populateMenu();
}
Example #20
0
void MenuCreator::populateMenu(std::string pluginId, CMenu* menu, Menu itemMenu, IIdGenerator* idgenerator)
{

    switch (itemMenu.mMenuType)
    {
        case PopUp:
        {
            CMenu* popupmenu = new CMenu();
            popupmenu->CreatePopupMenu();
for (auto subitem : itemMenu.submenulist)
            {
                populateMenu(pluginId, popupmenu, subitem, idgenerator);
            }
            int submenucount = popupmenu->GetMenuItemCount();
            menu->AppendMenuA(MF_POPUP, (UINT)popupmenu->GetSafeHmenu(), itemMenu.mName.c_str());
            break;
        }


        case MenuItem:
        {
            //int id;
            idgenerator->generateId(itemMenu.mId, idgenerator->id);
            pluginIdtoMenuId pluginMenuId;
            pluginMenuId.mMenuId = itemMenu.mId;
            pluginMenuId.mPluginId = pluginId;
            mMenuIdPluginInfo[idgenerator->id] = pluginMenuId;
            menu->AppendMenu(MF_BYCOMMAND, idgenerator->id, itemMenu.mName.c_str());
            menu->EnableMenuItem(0, MF_ENABLED);
            break;
        }

        case Separator:
        {
            menu->InsertMenu(menu->GetMenuItemCount(), MF_BYPOSITION | MF_SEPARATOR);
            break;
        }

    }

}
Example #21
0
void Canvas::keyPressEvent(QKeyEvent *event)
{
    QGraphicsView::keyPressEvent(event);
    if (event->isAccepted())
        return;

    if (event->key() == Qt::Key_Space)
    {
        QGraphicsItem* i = scene->itemAt(
                mapToScene(mapFromGlobal(QCursor::pos())),
                QTransform());
        Control* control = dynamic_cast<Control*>(i);
        if (control)
        {
            control->toggleInspector();
        }
    }
    else if (event->key() == Qt::Key_Alt)
    {
        hideUI();
    }
    else if (event->key() == Qt::Key_A &&
                (event->modifiers() & Qt::ShiftModifier))
    {
        QMenu* m = new QMenu(this);

        auto window = dynamic_cast<MainWindow*>(parent()->parent());
        Q_ASSERT(window);
        window->populateMenu(m, false);

        m->exec(QCursor::pos());
        m->deleteLater();
    }
    else if (event->key() == Qt::Key_S &&
                (event->modifiers() & Qt::ShiftModifier))
    {
        ports_visible = !ports_visible;
        emit(showPorts(ports_visible));
    }
}
void UIGuestOSTypeSelectionButton::retranslateUi()
{
    populateMenu();
}
Example #23
0
bool InteractiveMarker::processMessage( const visualization_msgs::InteractiveMarker& message )
{
  boost::recursive_mutex::scoped_lock lock(mutex_);

  // copy values
  name_ = message.name;
  description_ = message.description;

  if ( message.controls.size() == 0 )
  {
    Q_EMIT statusUpdate( StatusProperty::Ok, name_, "Marker empty.");
    return false;
  }

  scale_ = message.scale;

  reference_frame_ = message.header.frame_id;
  reference_time_ = message.header.stamp;
  frame_locked_ = (message.header.stamp == ros::Time(0));

  position_ = Ogre::Vector3(
      message.pose.position.x,
      message.pose.position.y,
      message.pose.position.z );

  orientation_ = Ogre::Quaternion(
      message.pose.orientation.w,
      message.pose.orientation.x,
      message.pose.orientation.y,
      message.pose.orientation.z );

  pose_changed_ =false;
  time_since_last_feedback_ = 0;

  // setup axes
  axes_->setPosition(position_);
  axes_->setOrientation(orientation_);
  axes_->set( scale_, scale_*0.05 );

  has_menu_ = message.menu_entries.size() > 0;

  updateReferencePose();

  // Instead of just erasing all the old controls and making new ones
  // here, we want to preserve as much as possible from the old ones,
  // so that we don't lose the drag action in progress if a control is
  // being dragged when this update comes in.
  //
  // Controls are stored in a map from control name to control
  // pointer, so we loop over the incoming control messages looking
  // for names we already know about.  When we find them, we just call
  // the control's processMessage() function to update it.  When we
  // don't find them, we create a new Control.  We also keep track of
  // which control names we used to have but which are not present in
  // the incoming message, which we use to delete the unwanted
  // controls.

  // Make set of old-names called old-names-to-delete.
  std::set<std::string> old_names_to_delete;
  M_ControlPtr::const_iterator ci;
  for( ci = controls_.begin(); ci != controls_.end(); ci++ )
  {
    old_names_to_delete.insert( (*ci).first );
  }

  // Loop over new array:
  for ( unsigned i = 0; i < message.controls.size(); i++ )
  {
    const visualization_msgs::InteractiveMarkerControl& control_message = message.controls[ i ];
    M_ControlPtr::iterator search_iter = controls_.find( control_message.name );
    InteractiveMarkerControlPtr control;

    // If message->name in map,
    if( search_iter != controls_.end() )
    {    
      // Use existing control
      control = (*search_iter).second;
    }
    else
    {
      // Else make new control
      control = boost::make_shared<InteractiveMarkerControl>( context_, reference_node_, this );
      controls_[ control_message.name ] = control;
    }
    // Update the control with the message data
    control->processMessage( control_message );
    control->setShowVisualAids( show_visual_aids_ );

    // Remove message->name from old-names-to-delete
    old_names_to_delete.erase( control_message.name );
  }

  // Loop over old-names-to-delete
  std::set<std::string>::iterator si;
  for( si = old_names_to_delete.begin(); si != old_names_to_delete.end(); si++ )
  {
    // Remove Control object from map for name-to-delete
    controls_.erase( *si );
  }

  description_control_ =
    boost::make_shared<InteractiveMarkerControl>( context_,
                                                  reference_node_, this );

  description_control_->processMessage( interactive_markers::makeTitle( message ));

  //create menu
  menu_entries_.clear();
  menu_.reset();
  if ( has_menu_ )
  {
    menu_.reset( new QMenu() );
    top_level_menu_ids_.clear();

    // Put all menu entries into the menu_entries_ map and create the
    // tree of menu entry ids.
    for ( unsigned m=0; m < message.menu_entries.size(); m++ )
    {
      const visualization_msgs::MenuEntry& entry = message.menu_entries[ m ];
      MenuNode node;
      node.entry = entry;
      menu_entries_[ entry.id ] = node;
      if( entry.parent_id == 0 )
      {
        top_level_menu_ids_.push_back( entry.id );
      }
      else
      {
        // Find the parent node and add this entry to the parent's list of children.
        std::map< uint32_t, MenuNode >::iterator parent_it = menu_entries_.find( entry.parent_id );
        if( parent_it == menu_entries_.end() ) {
          ROS_ERROR("interactive marker menu entry %u found before its parent id %u.  Ignoring.", entry.id, entry.parent_id);
        }
        else
        {
          (*parent_it).second.child_ids.push_back( entry.id );
        }
      }
    }
    populateMenu( menu_.get(), top_level_menu_ids_ );
  }

  if ( frame_locked_ )
  {
    std::ostringstream s;
    s << "Locked to frame " << reference_frame_;
    Q_EMIT statusUpdate( StatusProperty::Ok, name_, s.str() );
  }
  else
  {
    Q_EMIT statusUpdate( StatusProperty::Ok, name_, "Position is fixed." );
  }
  return true;
}
void VBoxOSTypeSelectorButton::retranslateUi()
{
    populateMenu();
}
Example #25
0
MainSynthWindow::MainSynthWindow (gthAudio *audio)
{
    gthPrefs *prefs = gthPrefs::instance();
    string **vals;

    audio_ = audio;

    set_title("thinksynth");
    set_default_size(520, 360);

    midiMap_ = NULL;
    patchSel_ = NULL;
    aboutBox_ = NULL;
    kbWin_ = NULL;

    vals = prefs->Get("dspdir");

    if (vals != NULL)
        prevDir_ = *(vals[0]);
    else
        prevDir_ = DSP_PATH;

    populateMenu();

#ifdef HAVE_JACK
    signal_realize().connect(
        sigc::mem_fun(*this, &MainSynthWindow::jackCheck));
#endif
    
    add(vbox_);

    dspEntryLbl_.set_label("DSP File: ");
    dspBrowseBtn_.set_label("Browse");
    dspEntryBox_.pack_start(dspEntryLbl_, Gtk::PACK_SHRINK);
    dspEntryBox_.pack_start(dspEntry_, Gtk::PACK_EXPAND_WIDGET);
    dspEntryBox_.pack_start(dspBrowseBtn_, Gtk::PACK_SHRINK);

    dspEntry_.signal_activate().connect(
        sigc::mem_fun(*this, &MainSynthWindow::onDspEntryActivate));

    dspBrowseBtn_.signal_clicked().connect(
        sigc::mem_fun(*this, &MainSynthWindow::onBrowseButton));

    vbox_.pack_start(menuBar_, Gtk::PACK_SHRINK);
    vbox_.pack_start(dspEntryBox_, Gtk::PACK_SHRINK);
    vbox_.pack_start(notebook_, Gtk::PACK_EXPAND_WIDGET);

    notebook_.set_scrollable();

    notebook_.signal_switch_page().connect(
        sigc::mem_fun(*this, &MainSynthWindow::onSwitchPage));

    populate();

    show_all_children();

    gthPatchManager *patchMgr = gthPatchManager::instance();
    patchMgr->signal_patches_changed().connect(
        sigc::mem_fun(*this, &MainSynthWindow::onPatchesChanged));
    patchMgr->signal_patch_load_error().connect(
        sigc::mem_fun(*this, &MainSynthWindow::onPatchLoadError));

    debug("signal connections made");

}
Example #26
0
void Viewport::mouseReleaseEvent(QMouseEvent *event)
{
    QGraphicsView::mouseReleaseEvent(event);

    // On right-click, show a menu of items to raise.
    if (event->button() == Qt::RightButton && !_dragging)
    {
        // Find the top-level MainWindow and attach the menu to it
        QObject* w = this;
        while (!dynamic_cast<MainWindow*>(w))
            w = w->parent();
        Q_ASSERT(w);

        // Make a new menu object
        auto menu = new QMenu(static_cast<MainWindow*>(w));

        // Find all of the nodes and proxies at the mouse click position
        auto proxies = getProxiesAtPosition(event->pos());

        // Special menu item to trigger a jump to event in the graph
        QAction* jump_to = NULL;

        for (auto p : proxies)
        {
            auto n = p->getNode();
            QString desc = QString::fromStdString(n->getName());// + " (" + n->getTitle() + ")";

            if (jump_to == NULL)
            {
                jump_to = new QAction("Show " + desc + " in graph", menu);
                menu->addAction(jump_to);
                menu->addSeparator();
                connect(jump_to, &QAction::triggered,
                        [=](){ emit jumpTo(n); });
            }

            auto a = new QAction(desc, menu);
            a->setData(QVariant::fromValue(p));
            menu->addAction(a);
        }

        // If there was only one item in this location, remove all of the
        // menu options other than 'jump to' (which in this case are the
        // separator and the single 'raise' command).
        if (proxies.length() == 1)
            while (menu->actions().back() != jump_to)
                menu->removeAction(menu->actions().back());

        // If we have items in the menu, run it and get the resulting action.
        QAction* chosen = (proxies.length() > 0) ? menu->exec(QCursor::pos())
                                                 : NULL;
        if (chosen && chosen != jump_to)
        {
            if (raised)
                raised->setZValue(0);
            raised = chosen->data().value<ControlProxy*>();
            raised->setZValue(0.1);
        }
        else if (proxies.length() == 0)
        {
            QMenu* m = new QMenu(this);

            Q_ASSERT(dynamic_cast<MainWindow*>(parent()));
            auto window = static_cast<MainWindow*>(parent());
            window->populateMenu(m, false);

            m->exec(QCursor::pos());
            m->deleteLater();
        }


        menu->deleteLater();
    }

    _dragging = false;
}
Configuration::Configuration(Applet *applet, KConfigDialog *parent) : QObject(parent),
    m_applet(applet),
    m_editedLauncher(NULL)
{
    KConfigGroup configuration = m_applet->config();
    KMenu *addLauncherMenu = new KMenu(parent);
    QWidget *generalWidget = new QWidget;
    QWidget *appearanceWidget = new QWidget;
    QWidget *arrangementWidget = new QWidget;
    QWidget *actionsWidget = new QWidget;
    QAction *addLauncherApplicationAction = addLauncherMenu->addAction(KIcon("application-x-executable"), i18n("Add Application..."));
    QAction *addLauncherFromFileAction = addLauncherMenu->addAction(KIcon("inode-directory"), i18n("Add File or Directory..."));
    QAction *addMenuLauncher = addLauncherMenu->addAction(KIcon("start-here"), i18n("Add Menu"));
    KMenu *addMenuLauncherMenu = new KMenu(addLauncherMenu);

    addMenuLauncher->setMenu(addMenuLauncherMenu);

    QAction *action = addMenuLauncherMenu->addAction(QString());
    action->setData("/");
    action->setVisible(false);

    m_generalUi.setupUi(generalWidget);
    m_appearanceUi.setupUi(appearanceWidget);
    m_arrangementUi.setupUi(arrangementWidget);
    m_actionsUi.setupUi(actionsWidget);

    connectWidgets(generalWidget);
    connectWidgets(appearanceWidget);

    m_arrangementUi.addLauncherButton->setMenu(addLauncherMenu);

    m_generalUi.groupingStrategy->addItem(i18n("Do Not Group"), QVariant(TaskManager::GroupManager::NoGrouping));
    m_generalUi.groupingStrategy->addItem(i18n("Manually"), QVariant(TaskManager::GroupManager::ManualGrouping));
    m_generalUi.groupingStrategy->addItem(i18n("By Program Name"), QVariant(TaskManager::GroupManager::ProgramGrouping));
    m_generalUi.groupingStrategy->setCurrentIndex(m_generalUi.groupingStrategy->findData(QVariant(configuration.readEntry("groupingStrategy", static_cast<int>(TaskManager::GroupManager::NoGrouping)))));

    m_generalUi.sortingStrategy->addItem(i18n("Do Not Sort"), QVariant(TaskManager::GroupManager::NoSorting));
    m_generalUi.sortingStrategy->addItem(i18n("Manually"), QVariant(TaskManager::GroupManager::ManualSorting));
    m_generalUi.sortingStrategy->addItem(i18n("Alphabetically"), QVariant(TaskManager::GroupManager::AlphaSorting));
    m_generalUi.sortingStrategy->addItem(i18n("By Desktop"), QVariant(TaskManager::GroupManager::DesktopSorting));
    m_generalUi.sortingStrategy->setCurrentIndex(m_generalUi.sortingStrategy->findData(QVariant(configuration.readEntry("sortingStrategy", static_cast<int>(TaskManager::GroupManager::ManualSorting)))));

    m_generalUi.showOnlyCurrentDesktop->setChecked(configuration.readEntry("showOnlyCurrentDesktop", false));
    m_generalUi.showOnlyCurrentActivity->setChecked(configuration.readEntry("showOnlyCurrentActivity", true));
    m_generalUi.showOnlyCurrentScreen->setChecked(configuration.readEntry("showOnlyCurrentScreen", false));
    m_generalUi.showOnlyMinimized->setChecked(configuration.readEntry("showOnlyMinimized", false));
    m_generalUi.showOnlyTasksWithLaunchers->setChecked(configuration.readEntry("showOnlyTasksWithLaunchers", false));
    m_generalUi.connectJobsWithTasks->setChecked(configuration.readEntry("connectJobsWithTasks", false));
    m_generalUi.groupJobs->setChecked(configuration.readEntry("groupJobs", true));

    m_generalUi.jobCloseMode->addItem(i18n("Instantly"), QVariant(InstantClose));
    m_generalUi.jobCloseMode->addItem(i18n("After delay"), QVariant(DelayedClose));
    m_generalUi.jobCloseMode->addItem(i18n("Manually"), QVariant(ManualClose));
    m_generalUi.jobCloseMode->setCurrentIndex(m_generalUi.jobCloseMode->findData(QVariant(configuration.readEntry("jobCloseMode", static_cast<int>(DelayedClose)))));

    QStringList moveAnimationNames;
    moveAnimationNames << i18n("None") << i18n("Zoom") << i18n("Jump") << i18n("Spotlight") << i18n("Glow") << i18n("Fade");

    QList<AnimationType> moveAnimationIds;
    moveAnimationIds << NoAnimation << ZoomAnimation << JumpAnimation << SpotlightAnimation << GlowAnimation << FadeAnimation;

    for (int i = 0; i < moveAnimationIds.count(); ++i)
    {
        m_appearanceUi.moveAnimation->addItem(moveAnimationNames.at(i), QVariant(moveAnimationIds.at(i)));
    }

    QStringList iconAnimationNames;
    iconAnimationNames << i18n("None") << i18n("Bounce") << i18n("Zoom") << i18n("Blink") << i18n("Spotlight") << i18n("Rotate") << i18n("Glow");

    QList<AnimationType> iconAnimationIds;
    iconAnimationIds << NoAnimation << BounceAnimation << ZoomAnimation << BlinkAnimation << SpotlightAnimation << RotateAnimation << GlowAnimation;

    for (int i = 0; i < iconAnimationIds.count(); ++i)
    {
        m_appearanceUi.demandsAttentionAnimation->addItem(iconAnimationNames.at(i), QVariant(iconAnimationIds.at(i)));
        m_appearanceUi.startupAnimation->addItem(iconAnimationNames.at(i), QVariant(iconAnimationIds.at(i)));
    }

    m_appearanceUi.titleLabelMode->addItem(i18n("Never"), QVariant(NoLabel));
    m_appearanceUi.titleLabelMode->addItem(i18n("On mouse-over"), QVariant(MouseOverLabel));
    m_appearanceUi.titleLabelMode->addItem(i18n("For active icon"), QVariant(ActiveIconLabel));
    m_appearanceUi.titleLabelMode->addItem(i18n("Always"), QVariant(AlwaysShowLabel));
    m_appearanceUi.titleLabelMode->setCurrentIndex(m_appearanceUi.titleLabelMode->findData(QVariant(configuration.readEntry("titleLabelMode", static_cast<int>(AlwaysShowLabel)))));

    m_appearanceUi.activeIconIndication->addItem(i18n("None"), QVariant(NoIndication));
    m_appearanceUi.activeIconIndication->addItem(i18n("Zoom"), QVariant(ZoomIndication));
    m_appearanceUi.activeIconIndication->addItem(i18n("Glow"), QVariant(GlowIndication));
    m_appearanceUi.activeIconIndication->addItem(i18n("Fade"), QVariant(FadeIndication));
    m_appearanceUi.activeIconIndication->setCurrentIndex(m_appearanceUi.activeIconIndication->findData(QVariant(configuration.readEntry("activeIconIndication", static_cast<int>(FadeIndication)))));

    m_appearanceUi.customBackgroundImage->setUrl(KUrl(configuration.readEntry("customBackgroundImage", QString())));
    m_appearanceUi.customBackgroundImage->setFilter("image/svg+xml image/svg+xml-compressed");

    if (m_applet->location() != Plasma::Floating && (!m_applet->containment() || m_applet->containment()->objectName() != "FancyPanel")) {
        m_appearanceUi.customBackgroundImageLabel->hide();
        m_appearanceUi.customBackgroundImage->hide();
    }

    m_appearanceUi.moveAnimation->setCurrentIndex(moveAnimationIds.indexOf(static_cast<AnimationType>(configuration.readEntry("moveAnimation", static_cast<int>(GlowAnimation)))));
    m_appearanceUi.parabolicMoveAnimation->setChecked(configuration.readEntry("parabolicMoveAnimation", false));
    m_appearanceUi.demandsAttentionAnimation->setCurrentIndex(iconAnimationIds.indexOf(static_cast<AnimationType>(configuration.readEntry("demandsAttentionAnimation", static_cast<int>(BlinkAnimation)))));
    m_appearanceUi.startupAnimation->setCurrentIndex(iconAnimationIds.indexOf(static_cast<AnimationType>(configuration.readEntry("startupAnimation", static_cast<int>(BounceAnimation)))));

    m_arrangementUi.removeButton->setIcon(KIcon("go-previous"));
    m_arrangementUi.addButton->setIcon(KIcon("go-next"));
    m_arrangementUi.moveUpButton->setIcon(KIcon("go-up"));
    m_arrangementUi.moveDownButton->setIcon(KIcon("go-down"));

    KConfig kickoffConfiguration("kickoffrc", KConfig::NoGlobals);
    KConfigGroup favoritesGroup(&kickoffConfiguration, "Favorites");
    const QStringList currentEntries = configuration.readEntry("arrangement", QStringList("tasks"));
    QStringList availableEntries;
    availableEntries << i18n("--- separator ---") << i18n("--- tasks area ---") << i18n("--- jobs area ---") << "menu:/";
    availableEntries.append(favoritesGroup.readEntry("FavoriteURLs", QStringList()));

    for (int i = 0; i < currentEntries.count(); ++i)
    {
        QListWidgetItem *item = NULL;

        if (currentEntries.at(i) == "tasks")
        {
            item = new QListWidgetItem(i18n("--- tasks area ---"), m_arrangementUi.currentEntriesListWidget);
        }
        else if (currentEntries.at(i) == "jobs")
        {
            item = new QListWidgetItem(i18n("--- jobs area ---"), m_arrangementUi.currentEntriesListWidget);
        }
        else if (currentEntries.at(i) == "separator")
        {
            item = new QListWidgetItem(i18n("--- separator ---"), m_arrangementUi.currentEntriesListWidget);
        }
        else
        {
            if (hasEntry(currentEntries.at(i), false))
            {
                continue;
            }

            Launcher *launcher = m_applet->launcherForUrl(KUrl(currentEntries.at(i)));

            if (!launcher)
            {
                continue;
            }

            item = new QListWidgetItem(launcher->icon(), launcher->title(), m_arrangementUi.currentEntriesListWidget);
            item->setToolTip(launcher->launcherUrl().pathOrUrl());

            m_rules[launcher->launcherUrl().pathOrUrl()] = qMakePair(launcher->rules(), launcher->isExcluded());
        }

        m_arrangementUi.currentEntriesListWidget->addItem(item);
    }

    for (int i = 0; i < availableEntries.count(); ++i)
    {
        if (i > 0 && hasEntry(availableEntries.at(i), false))
        {
            continue;
        }

        QListWidgetItem *item = NULL;

        if (availableEntries.at(i).startsWith("--- "))
        {
            item = new QListWidgetItem(availableEntries.at(i), m_arrangementUi.availableEntriesListWidget);
        }
        else
        {
            Launcher *launcher = m_applet->launcherForUrl(KUrl(availableEntries.at(i)));

            if (!launcher)
            {
                continue;
            }

            item = new QListWidgetItem(launcher->icon(), launcher->title(), m_arrangementUi.availableEntriesListWidget);
            item->setToolTip(launcher->launcherUrl().pathOrUrl());

            m_rules[launcher->launcherUrl().pathOrUrl()] = qMakePair(launcher->rules(), launcher->isExcluded());
        }

        m_arrangementUi.availableEntriesListWidget->addItem(item);
    }

    QMap<QPair<Qt::MouseButtons, Qt::KeyboardModifiers>, IconAction> iconActions = m_applet->iconActions();
    QMap<QPair<Qt::MouseButtons, Qt::KeyboardModifiers>, IconAction>::iterator iterator;
    int i = 0;

    m_actionsUi.actionsTableWidget->setItemDelegateForColumn(0, new ActionDelegate(this));
    m_actionsUi.actionsTableWidget->setItemDelegateForColumn(1, new TriggerDelegate(this));

    for (iterator = iconActions.begin(); iterator != iconActions.end(); ++iterator)
    {
        if (iterator.key().first == Qt::NoButton)
        {
            continue;
        }

        QStringList action;

        if (iterator.key().first & Qt::LeftButton)
        {
            action.append("left");
        }

        if (iterator.key().first & Qt::MiddleButton)
        {
            action.append("middle");
        }

        if (iterator.key().first & Qt::RightButton)
        {
            action.append("right");
        }

        if (iterator.key().second & Qt::ShiftModifier)
        {
            action.append("shift");
        }

        if (iterator.key().second & Qt::ControlModifier)
        {
            action.append("ctrl");
        }

        if (iterator.key().second & Qt::AltModifier)
        {
            action.append("alt");
        }

        QTableWidgetItem *triggerItem = new QTableWidgetItem(action.join(QChar('+')));
        triggerItem->setFlags(Qt::ItemIsEditable | Qt::ItemIsSelectable | Qt::ItemIsEnabled);

        QTableWidgetItem *actionItem = new QTableWidgetItem(QString::number(static_cast<int>(iterator.value())));
        actionItem->setFlags(Qt::ItemIsEditable | Qt::ItemIsSelectable | Qt::ItemIsEnabled);

        m_actionsUi.actionsTableWidget->setRowCount(i + 1);
        m_actionsUi.actionsTableWidget->setItem(i, 0, actionItem);
        m_actionsUi.actionsTableWidget->setItem(i, 1, triggerItem);

        ++i;
    }

    moveAnimationTypeChanged(m_appearanceUi.moveAnimation->currentIndex());

    parent->addPage(generalWidget, i18n("General"), "go-home");
    parent->addPage(appearanceWidget, i18n("Appearance"), "preferences-desktop-theme");
    parent->addPage(arrangementWidget, i18n("Arrangement"), "format-list-unordered");
    parent->addPage(actionsWidget, i18n("Actions"), "configure-shortcuts");

    connect(parent, SIGNAL(applyClicked()), this, SLOT(save()));
    connect(parent, SIGNAL(okClicked()), this, SLOT(save()));
    connect(m_appearanceUi.moveAnimation, SIGNAL(currentIndexChanged(int)), this, SLOT(moveAnimationTypeChanged(int)));
    connect(m_appearanceUi.customBackgroundImage, SIGNAL(textChanged(QString)), this, SLOT(modify()));
    connect(m_arrangementUi.availableEntriesListWidget, SIGNAL(currentRowChanged(int)), this, SLOT(availableEntriesCurrentItemChanged(int)));
    connect(m_arrangementUi.currentEntriesListWidget, SIGNAL(currentRowChanged(int)), this, SLOT(currentEntriesCurrentItemChanged(int)));
    connect(m_arrangementUi.removeButton, SIGNAL(clicked()), this, SLOT(removeItem()));
    connect(m_arrangementUi.addButton, SIGNAL(clicked()), this, SLOT(addItem()));
    connect(m_arrangementUi.moveUpButton, SIGNAL(clicked()), this, SLOT(moveUpItem()));
    connect(m_arrangementUi.moveDownButton, SIGNAL(clicked()), this, SLOT(moveDownItem()));
    connect(m_arrangementUi.editLauncherButton, SIGNAL(clicked()), this, SLOT(editLauncher()));
    connect(m_actionsUi.actionsTableWidget, SIGNAL(clicked(QModelIndex)), this, SLOT(actionClicked(QModelIndex)));
    connect(m_actionsUi.actionsTableWidget->selectionModel(), SIGNAL(selectionChanged(QItemSelection,QItemSelection)), this, SLOT(actionSelectionChanged()));
    connect(m_actionsUi.addButton, SIGNAL(clicked()), this, SLOT(addAction()));
    connect(m_actionsUi.removeButton, SIGNAL(clicked()), this, SLOT(removeAction()));
    connect(addLauncherApplicationAction, SIGNAL(triggered()), this, SLOT(findLauncher()));
    connect(addLauncherFromFileAction, SIGNAL(triggered()), this, SLOT(addLauncher()));
    connect(addMenuLauncherMenu, SIGNAL(aboutToShow()), this, SLOT(populateMenu()));
    connect(addMenuLauncherMenu, SIGNAL(triggered(QAction*)), this, SLOT(addMenu(QAction*)));
}
Example #28
0
EditMenu::EditMenu(MainWindow* mainWin) :
    Menu(mainWin,"Edit",true)
{
    createActions();
    populateMenu(this);
}
void omni::ui::entity_placeholder_widget::contextMenuEvent (QContextMenuEvent * event)
{
    _selectorPopup.clear ();
    populateMenu (_entityMeta, _selectorPopup);
    _selectorPopup.popup (QPoint (event->globalX (), event->globalY ()));
}
Example #30
0
void SinglePopupEditor::populateMenu(KviKvsPopupMenu * pop, PopupTreeWidgetItem * par, PopupTreeWidgetItem * theItem)
{
	if(!pop)
		return;

	for(KviKvsScript * sp = pop->prologues()->first(); sp; sp = pop->prologues()->next())
	{
		if(par)
			theItem = new PopupTreeWidgetItem(par, theItem, PopupTreeWidgetItem::Prologue);
		else
			theItem = new PopupTreeWidgetItem(m_pTreeWidget, theItem, PopupTreeWidgetItem::Prologue);
		theItem->setCode(sp->code());
		theItem->setId(sp->name());
	}

	for(KviKvsPopupMenuItem * item = pop->itemList()->first(); item; item = pop->itemList()->next())
	{
		switch(item->type())
		{
			case KviKvsPopupMenuItem::Item:
				if(par)
					theItem = new PopupTreeWidgetItem(par, theItem, PopupTreeWidgetItem::Item);
				else
					theItem = new PopupTreeWidgetItem(m_pTreeWidget, theItem, PopupTreeWidgetItem::Item);
				theItem->setIcon(item->kvsIcon() ? item->kvsIcon()->code() : QString());
				theItem->setItemText(item->kvsText() ? item->kvsText()->code() : QString());
				theItem->setCondition(item->kvsCondition() ? item->kvsCondition()->code() : QString());
				theItem->setCode(item->kvsCode() ? item->kvsCode()->code() : QString());
				theItem->setId(item->name());
				break;
			case KviKvsPopupMenuItem::ExtMenu:
				if(par)
					theItem = new PopupTreeWidgetItem(par, theItem, PopupTreeWidgetItem::ExtMenu);
				else
					theItem = new PopupTreeWidgetItem(m_pTreeWidget, theItem, PopupTreeWidgetItem::ExtMenu);
				theItem->setIcon(item->kvsIcon() ? item->kvsIcon()->code() : QString());
				theItem->setItemText(item->kvsText() ? item->kvsText()->code() : QString());
				theItem->setCondition(item->kvsCondition() ? item->kvsCondition()->code() : QString());
				theItem->setCode(((KviKvsPopupMenuItemExtMenu *)item)->extName());
				theItem->setId(item->name());
				break;
			case KviKvsPopupMenuItem::Label:
				if(par)
					theItem = new PopupTreeWidgetItem(par, theItem, PopupTreeWidgetItem::Label);
				else
					theItem = new PopupTreeWidgetItem(m_pTreeWidget, theItem, PopupTreeWidgetItem::Label);
				theItem->setIcon(item->kvsIcon() ? item->kvsIcon()->code() : QString());
				theItem->setItemText(item->kvsText() ? item->kvsText()->code() : QString());
				theItem->setCondition(item->kvsCondition() ? item->kvsCondition()->code() : QString());
				theItem->setId(item->name());
				break;
			case KviKvsPopupMenuItem::Separator:
				if(par)
					theItem = new PopupTreeWidgetItem(par, theItem, PopupTreeWidgetItem::Separator);
				else
					theItem = new PopupTreeWidgetItem(m_pTreeWidget, theItem, PopupTreeWidgetItem::Separator);
				theItem->setCondition(item->kvsCondition() ? item->kvsCondition()->code() : QString());
				theItem->setId(item->name());
				break;
			case KviKvsPopupMenuItem::Menu:
				if(par)
					theItem = new PopupTreeWidgetItem(par, theItem, PopupTreeWidgetItem::Menu);
				else
					theItem = new PopupTreeWidgetItem(m_pTreeWidget, theItem, PopupTreeWidgetItem::Menu);
				theItem->setIcon(item->kvsIcon() ? item->kvsIcon()->code() : QString());
				theItem->setItemText(item->kvsText() ? item->kvsText()->code() : QString());
				theItem->setCondition(item->kvsCondition() ? item->kvsCondition()->code() : QString());
				theItem->setId(item->name());
				populateMenu(((KviKvsPopupMenuItemMenu *)item)->menu(), theItem, nullptr);
				break;
			default:
				break;
		}
	}

	for(KviKvsScript * se = pop->epilogues()->first(); se; se = pop->epilogues()->next())
	{
		if(par)
			theItem = new PopupTreeWidgetItem(par, theItem, PopupTreeWidgetItem::Epilogue);
		else
			theItem = new PopupTreeWidgetItem(m_pTreeWidget, theItem, PopupTreeWidgetItem::Epilogue);
		theItem->setCode(se->code());
		theItem->setId(se->name());
	}

	m_pTreeWidget->resizeColumnToContents(0);
}