Example #1
0
ToolBarTaskMenu::ToolBarTaskMenu(QToolBar *toolbar, QObject *parent)
    : QDesignerTaskMenu(toolbar, parent),
      m_toolbar(toolbar),
      m_editTextAction(new QAction(tr("Customize..."), this))
{
    connect(m_editTextAction, SIGNAL(triggered()), this, SLOT(editToolBar()));
    m_taskActions.append(m_editTextAction);

    QAction *sep = new QAction(this);
    sep->setSeparator(true);
    m_taskActions.append(sep);
}
Example #2
0
K3b::MovixView::MovixView( K3b::MovixDoc* doc, QWidget* parent )
:
    View( doc, parent ),
    m_doc( doc ),
    m_model( new MovixProjectModel( m_doc, this ) ),
    m_view( new QTreeView( this ) )
{
    m_view->setModel( m_model );
    m_view->setAcceptDrops( true );
    m_view->setDragEnabled( true );
    m_view->setDragDropMode( QTreeView::DragDrop );
    m_view->setItemsExpandable( false );
    m_view->setRootIsDecorated( false );
    m_view->setSelectionMode( QTreeView::ExtendedSelection );
    m_view->setVerticalScrollMode( QAbstractItemView::ScrollPerPixel );
    m_view->setContextMenuPolicy( Qt::ActionsContextMenu );
    // FIXME: make QHeaderView::Interactive the default but connect to model changes and call header()->resizeSections( QHeaderView::ResizeToContents );
    m_view->header()->setResizeMode( QHeaderView::ResizeToContents );
    m_view->setEditTriggers( QAbstractItemView::NoEditTriggers );
    setMainWidget( m_view );

    // setup actions
    m_actionProperties = K3b::createAction( this, i18n("Properties"), "document-properties",
                                            0, this, SLOT(showPropertiesDialog()),
                                            actionCollection(), "movix_show_props" );
    m_actionRemove = K3b::createAction( this, i18n( "Remove" ), "edit-delete",
                                        Qt::Key_Delete, this, SLOT(slotRemove()),
                                        actionCollection(), "movix_remove_item" );
    m_actionRemoveSubTitle = K3b::createAction( this, i18n( "Remove Subtitle File" ), "edit-delete",
                                                0, this, SLOT(slotRemoveSubTitleItems()),
                                                actionCollection(), "movix_remove_subtitle_item" );
    m_actionAddSubTitle = K3b::createAction( this, i18n("Add Subtitle File..."), 0,
                                             0, this, SLOT(slotAddSubTitleFile()),
                                             actionCollection(), "movix_add_subtitle" );

    connect( m_view->selectionModel(), SIGNAL(selectionChanged(QItemSelection,QItemSelection)),
             this, SLOT(slotSelectionChanged()) );

    QAction* separator = new QAction( this );
    separator->setSeparator( true );
    m_view->addAction( m_actionRemove );
    m_view->addAction( m_actionRemoveSubTitle );
    m_view->addAction( m_actionAddSubTitle );
    m_view->addAction( separator );
    m_view->addAction( m_actionProperties );
    m_view->addAction( separator );
    m_view->addAction( actionCollection()->action("project_burn") );

    // Setup toolbar
    toolBox()->addActions( createPluginsActions( m_doc->type() ) );
    toolBox()->addWidget( new VolumeNameWidget( doc, toolBox() ) );
}
Example #3
0
EntitiesTreeWidget::EntitiesTreeWidget(QWidget *parent) : QTreeWidget(parent)
{

    applicationNode = new QTreeWidgetItem(this,QStringList() << "Application");
    modulesNode = new QTreeWidgetItem(this,QStringList() << "Modules");
    resourcesNode = new QTreeWidgetItem(this,QStringList() << "Resources");
    templatesNode = new QTreeWidgetItem(this,QStringList() << "Templates");

    applicationNode->setIcon(0,QIcon(":/images/folderapp_ico.png"));
    modulesNode->setIcon(0,QIcon(":/images/foldermod_ico.png"));
    resourcesNode->setIcon(0,QIcon(":/images/folderres_ico.png"));
    templatesNode->setIcon(0,QIcon(":/images/folder_ico.png"));

    addTopLevelItem(applicationNode);
    addTopLevelItem(modulesNode);
    addTopLevelItem(resourcesNode);
    addTopLevelItem(templatesNode);

    setExpandsOnDoubleClick(false);
    setContextMenuPolicy(Qt::CustomContextMenu);
    resizeColumnToContents(0);

    connect(this, SIGNAL(itemDoubleClicked(QTreeWidgetItem*,int)),this,SLOT(onItemDoubleClicked(QTreeWidgetItem*,int)));
    connect(this,SIGNAL(customContextMenuRequested(QPoint)),this,SLOT(onContext(QPoint)));

    openFile = new QAction("Open File",this);
    importFile = new QAction("Import Files...",this);

    topLevelMenu.addAction(openFile);
    topLevelMenu.addAction(importFile);

    loadFiles = new QAction("Load",this);
    QAction *separator = new QAction(this);
    separator->setSeparator(true);
    reopen = new QAction("Reopen",this);
    remove = new QAction("Remove",this);

    secondLevelMenu.addAction(loadFiles);
    secondLevelMenu.addAction(separator);
    secondLevelMenu.addAction(reopen);
    secondLevelMenu.addAction(remove);

    edit = new QAction("Edit",this);
    leafLevelMenu.addAction(edit);

    connect(loadFiles,SIGNAL(triggered()),this,SLOT(onLoadFile()));
    connect(openFile,SIGNAL(triggered()),this,SIGNAL(openFiles()));
    connect(importFile,SIGNAL(triggered()),this,SIGNAL(importFiles()));
    connect(edit,SIGNAL(triggered()),this,SLOT(onEdit()));
    connect(remove,SIGNAL(triggered()),this,SLOT(onRemove()));

}
Example #4
0
  ExampleSearchExtension::ExampleSearchExtension(QObject *parent) :
    Extension(parent),
    m_dialog(0)
  {
    QAction *action = new QAction( this );
    action->setSeparator(true);
    m_actions.append( action );

    action = new QAction(this);
    // This is the name of the menu entry:
    action->setText(tr("&Example Search..."));
    m_actions.append(action);
  }
Example #5
0
ComboBoxTaskMenu::ComboBoxTaskMenu(QComboBox *button, QObject *parent)
    : QDesignerTaskMenu(button, parent),
      m_comboBox(button)
{
    m_editItemsAction = new QAction(this);
    m_editItemsAction->setText(tr("Edit Items..."));
    connect(m_editItemsAction, SIGNAL(triggered()), this, SLOT(editItems()));
    m_taskActions.append(m_editItemsAction);

    QAction *sep = new QAction(this);
    sep->setSeparator(true);
    m_taskActions.append(sep);
}
Example #6
0
GroupBoxTaskMenu::GroupBoxTaskMenu(QGroupBox *groupbox, QObject *parent)
    : QDesignerTaskMenu(groupbox, parent),
      m_editTitleAction(new QAction(tr("Change title..."), this))

{
    TaskMenuInlineEditor *editor = new GroupBoxTaskMenuInlineEditor(groupbox, this);
    connect(m_editTitleAction, SIGNAL(triggered()), editor, SLOT(editText()));
    m_taskActions.append(m_editTitleAction);

    QAction *sep = new QAction(this);
    sep->setSeparator(true);
    m_taskActions.append(sep);
}
Example #7
0
// Create a menu separator
static QAction *createSeparator(QObject *parent,
                                 Core::ActionManager *am,
                                 const Core::Context &context,
                                 Core::ActionContainer *container,
                                 const Core::Id &id,
                                 const Core::Id &group = Core::Id())
{
    QAction *actSeparator = new QAction(parent);
    actSeparator->setSeparator(true);
    Core::Command *command = am->registerAction(actSeparator, id, context);
    container->addAction(command, group);
    return actSeparator;
}
Example #8
0
  LinMorphExtension::LinMorphExtension( QObject *parent ) :Extension( parent ), m_molecule(0), m_secondMolecule(0), m_widget(0), m_linMorphDialog(0), m_timeLine(0), m_frameCount(0)
  {  
    
    setFrameCount(10);

    QAction *action = new QAction(this);
    action->setText(tr("Lin Morph..."));
    m_actions.append(action);
    
    action = new QAction( this );
    action->setSeparator(true);
    m_actions.append(action);

  }
Example #9
0
AccountWindow::AccountWindow(QWidget* parent, const QString &name, Qt::WindowFlags wflags)
	:TableWindow(parent, name, wflags)
{
	QStringList nameList;
	QTableWidget *pTable;
	QAction* pAction;

  pTable = TableWindow::getTable();
	m_pDb = ISql::pInstance();

	pAction = new QAction(tr("&New..."), this);
	connect(pAction, SIGNAL(triggered()), this, SLOT(file_new()));
	MDIWindow::addAction(pAction);

	pAction = new QAction(tr("&Edit..."), this);
	connect(pAction, SIGNAL(triggered()), this, SLOT(file_edit()));
	MDIWindow::addAction(pAction, true);

	pAction = new QAction(tr("&Delete"), this);
	connect(pAction, SIGNAL(triggered()), this, SLOT(file_delete()));
	MDIWindow::addAction(pAction);

	pAction = new QAction(this);
	pAction->setSeparator(true);
	MDIWindow::addAction(pAction);

	pAction = new QAction(tr("&Export all..."), this);
	connect(pAction, SIGNAL(triggered()), this, SLOT(exportTable()));
	MDIWindow::addAction(pAction);

	// configure the table
	TableWindow::setWindowIcon(QIcon(":/document.xpm"));
	pTable->setEditTriggers(QAbstractItemView::NoEditTriggers);
	pTable->setSelectionMode(QAbstractItemView::SingleSelection);

	// header
  nameList += tr("Username");
  nameList += tr("Contest");
  nameList += tr("Description");

	setupHeader(nameList);

  pTable->setColumnWidth(Username, 100);
  pTable->setColumnWidth(Contest, 100);
  pTable->setColumnWidth(Description, 200);

  connect(m_pDb, SIGNAL(accountsChanged()), this, SLOT(file_update()));

	file_update();
}
void TFileAttachmentWidget::ConfigureContextMenu()
  {
  /** Register all actions to be displayed in ctx menu in a table widget (it should have configured
      ContextMenuPolicy to ActionsContextMenu).
  */
  ui->attachmentTable->addAction(ui->actionAdd);
  ui->attachmentTable->addAction(ui->actionDel);
  ui->attachmentTable->addAction(ui->actionSave);
  ui->attachmentTable->addAction(ui->actionRename);
  QAction* sep = new QAction(this);
  sep->setSeparator(true);
  ui->attachmentTable->addAction(sep);
  ui->attachmentTable->addAction(ui->actionSelectAll);
  }
Example #11
0
void MainWindow::showInstanceContextMenu(const QPoint &pos)
{
	QList<QAction *> actions;

	QAction *actionSep = new QAction("", this);
	actionSep->setSeparator(true);

	bool onInstance = view->indexAt(pos).isValid();
	if (onInstance)
	{
		actions = ui->instanceToolBar->actions();

		QAction *actionVoid = new QAction(m_selectedInstance->name(), this);
		actionVoid->setEnabled(false);

		QAction *actionRename = new QAction(tr("Rename"), this);
		actionRename->setToolTip(ui->actionRenameInstance->toolTip());

		QAction *actionCopyInstance = new QAction(tr("Copy instance"), this);
		actionCopyInstance->setToolTip(ui->actionCopyInstance->toolTip());


		connect(actionRename, SIGNAL(triggered(bool)), SLOT(on_actionRenameInstance_triggered()));
		connect(actionCopyInstance, SIGNAL(triggered(bool)), SLOT(on_actionCopyInstance_triggered()));

		actions.replace(1, actionRename);
		actions.prepend(actionSep);
		actions.prepend(actionVoid);
		actions.append(actionCopyInstance);
	}
	else
	{
		QAction *actionVoid = new QAction(tr("MultiMC"), this);
		actionVoid->setEnabled(false);

		QAction *actionCreateInstance = new QAction(tr("Create instance"), this);
		actionCreateInstance->setToolTip(ui->actionAddInstance->toolTip());

		connect(actionCreateInstance, SIGNAL(triggered(bool)), SLOT(on_actionAddInstance_triggered()));

		actions.prepend(actionSep);
		actions.prepend(actionVoid);
		actions.append(actionCreateInstance);
	}
	QMenu myMenu;
	myMenu.addActions(actions);
	if(onInstance)
		myMenu.setEnabled(m_selectedInstance->canLaunch());
	myMenu.exec(view->mapToGlobal(pos));
}
Example #12
0
  XtalOptExtension::XtalOptExtension(QObject *parent) : Extension(parent),
                                                        m_dialog(0),
                                                        m_molecule(NULL)
  {
    QAction *action = new QAction( this );
    action->setSeparator(true);
    m_actions.append( action );

    action = new QAction(this);
    action->setText(tr("&XtalOpt"));
    action->setIcon(
          QIcon(QString::fromUtf8(":/xtalopt/images/xtalopt-logo.png")));
    m_actions.append(action);
  }
QList<QAction *> QgsGeoPackageCollectionItem::actions( QWidget *parent )
{
  QList<QAction *> lst = QgsDataCollectionItem::actions( parent );

  if ( QgsOgrDbConnection::connectionList( QStringLiteral( "GPKG" ) ).contains( mName ) )
  {
    QAction *actionDeleteConnection = new QAction( tr( "Remove Connection" ), parent );
    connect( actionDeleteConnection, &QAction::triggered, this, &QgsGeoPackageConnectionItem::deleteConnection );
    lst.append( actionDeleteConnection );
  }
  else
  {
    // Add to stored connections
    QAction *actionAddConnection = new QAction( tr( "Add Connection" ), parent );
    connect( actionAddConnection, &QAction::triggered, this, &QgsGeoPackageCollectionItem::addConnection );
    lst.append( actionAddConnection );
  }

  // Add table to existing DB
  QAction *actionAddTable = new QAction( tr( "Create a New Layer or Table…" ), parent );
  connect( actionAddTable, &QAction::triggered, this, &QgsGeoPackageCollectionItem::addTable );
  lst.append( actionAddTable );

  QAction *sep = new QAction( parent );
  sep->setSeparator( true );
  lst.append( sep );

  QString message = QObject::tr( "Delete %1…" ).arg( mName );
  QAction *actionDelete = new QAction( message, parent );

  // IMPORTANT - we need to capture the stuff we need, and then hand the slot
  // off to a static method. This is because it's possible for this item
  // to be deleted in the background on us (e.g. by a parent directory refresh)
  const QString path = mPath;
  QPointer< QgsDataItem > parentItem( mParent );
  connect( actionDelete, &QAction::triggered, this, [ path, parentItem ]
  {
    deleteGpkg( path, parentItem );
  } );
  lst.append( actionDelete );

  // Run VACUUM
  QAction *actionVacuumDb = new QAction( tr( "Compact Database (VACUUM)" ), parent );
  connect( actionVacuumDb, &QAction::triggered, this, &QgsGeoPackageConnectionItem::vacuumGeoPackageDbAction );
  lst.append( actionVacuumDb );


  return lst;
}
Example #14
0
PreviewActionGroup::PreviewActionGroup(QDesignerFormEditorInterface *core, QObject *parent) :
    QActionGroup(parent),
    m_core(core)
{
    /* Create a list of up to MaxDeviceActions invisible actions to be
     * populated with device profiles (actiondata: index) followed by the
     * standard style actions (actiondata: style name). */
    connect(this, SIGNAL(triggered(QAction*)), this, SLOT(slotTriggered(QAction*)));
    setExclusive(true);

    const QString objNamePostfix = QStringLiteral("_action");
    // Create invisible actions for devices. Set index as action data.
    QString objNamePrefix = QStringLiteral("__qt_designer_device_");
    for (int i = 0; i < MaxDeviceActions; i++) {
        QAction *a = new QAction(this);
        QString objName = objNamePrefix;
        objName += QString::number(i);
        objName += objNamePostfix;
        a->setObjectName(objName);
        a->setVisible(false);
        a->setData(i);
        addAction(a);
    }
    // Create separator at index MaxDeviceActions
    QAction *sep = new QAction(this);
    sep->setObjectName(QStringLiteral("__qt_designer_deviceseparator"));
    sep->setSeparator(true);
    sep->setVisible(false);
    addAction(sep);
    // Populate devices
    updateDeviceProfiles();

    // Add style actions
    const QStringList styles = QStyleFactory::keys();
    const QStringList::const_iterator cend = styles.constEnd();
    // Make sure ObjectName  is unique in case toolbar solution is used.
    objNamePrefix = QStringLiteral("__qt_designer_style_");
    // Create styles. Set style name string as action data.
    for (QStringList::const_iterator it = styles.constBegin(); it !=  cend ;++it) {
        QAction *a = new QAction(tr("%1 Style").arg(*it), this);
        QString objName = objNamePrefix;
        objName += *it;
        objName += objNamePostfix;
        a->setObjectName(objName);
        a->setData(*it);
        addAction(a);
    }
}
QAction *ToolBarEventFilter::createAction(QDesignerFormWindowInterface *fw, const QString &objectName, bool separator)
{
    QAction *action = new QAction(fw);
    fw->core()->widgetFactory()->initialize(action);
    if (separator)
        action->setSeparator(true);

    action->setObjectName(objectName);
    fw->ensureUniqueObjectName(action);

    qdesigner_internal::AddActionCommand *cmd = new  qdesigner_internal::AddActionCommand(fw);
    cmd->init(action);
    fw->commandHistory()->push(cmd);

    return action;
}
Example #16
0
void Qtilities::CoreGui::MenuContainer::addSeperator(const QString &before) {
    QAction* sep = new QAction(d->this_menu);
    sep->setSeparator(true);

    // Find the action with the given string.
    QList<QString> actions = d->id_action_map.keys();
    int count = actions.count();
    for (int i = 0; i < count; ++i) {
        if (actions.at(i) == before) {
            d->this_menu->insertAction(d->id_action_map[actions.at(i)],sep);
            return;
        }
    }

    d->this_menu->addSeparator();
}
LabelTaskMenu::LabelTaskMenu(QLabel *label, QObject *parent)
    : QDesignerTaskMenu(label, parent),
      m_label(label),
      m_editRichTextAction(new QAction(tr("Change rich text..."), this)),
      m_editPlainTextAction(new QAction(tr("Change plain text..."), this))
{
    LabelTaskMenuInlineEditor *editor = new LabelTaskMenuInlineEditor(label, this);
    connect(m_editPlainTextAction, SIGNAL(triggered()), editor, SLOT(editText()));
    m_taskActions.append(m_editPlainTextAction);

    connect(m_editRichTextAction, SIGNAL(triggered()), this, SLOT(editRichText()));
    m_taskActions.append(m_editRichTextAction);

    QAction *sep = new QAction(this);
    sep->setSeparator(true);
    m_taskActions.append(sep);
}
Example #18
0
void RobotsPlugin::initActions()
{
	m2dModelAction = new QAction(QIcon(":/icons/kcron.png"), QObject::tr("2d model"), NULL);
	ActionInfo d2ModelActionInfo(m2dModelAction, "interpreters", "tools");
	QObject::connect(m2dModelAction, SIGNAL(triggered()), this, SLOT(show2dModel()));

	mRunAction = new QAction(QIcon(":/icons/robots_run.png"), QObject::tr("Run"), NULL);
	ActionInfo runActionInfo(mRunAction, "interpreters", "tools");
	QObject::connect(mRunAction, SIGNAL(triggered()), &mInterpreter, SLOT(interpret()));

	mStopRobotAction = new QAction(QIcon(":/icons/robots_stop.png"), QObject::tr("Stop robot"), NULL);
	ActionInfo stopRobotActionInfo(mStopRobotAction, "interpreters", "tools");
	QObject::connect(mStopRobotAction, SIGNAL(triggered()), &mInterpreter, SLOT(stopRobot()));

	mConnectToRobotAction = new QAction(QIcon(":/icons/robots_connect.png"), QObject::tr("Connect to robot"), NULL);
	mConnectToRobotAction->setCheckable(true);
	ActionInfo connectToRobotActionInfo(mConnectToRobotAction, "interpreters", "tools");
	mInterpreter.setConnectRobotAction(mConnectToRobotAction);
	QObject::connect(mConnectToRobotAction, SIGNAL(triggered()), &mInterpreter, SLOT(connectToRobot()));

	mRobotSettingsAction = new QAction(QIcon(":/icons/robots_settings.png"), QObject::tr("Robot settings"), NULL);
	ActionInfo robotSettingsActionInfo(mRobotSettingsAction, "interpreters", "tools");
	QObject::connect(mRobotSettingsAction, SIGNAL(triggered()), this, SLOT(showRobotSettings()));

	mTitlesAction = new QAction(tr("Text under pictogram"), NULL);
	mTitlesAction->setCheckable(true);
	connect(mTitlesAction, SIGNAL(toggled(bool)), this, SLOT(titlesVisibilityChecked(bool)));
	ActionInfo titlesActionInfo(mTitlesAction, "", "settings");

	QAction *separator = new QAction(NULL);
	ActionInfo separatorActionInfo(separator, "interpreters", "tools");
	separator->setSeparator(true);

	mActionInfos << d2ModelActionInfo << runActionInfo
			<< stopRobotActionInfo << connectToRobotActionInfo
			<< separatorActionInfo << robotSettingsActionInfo
			<< titlesActionInfo;

	// Set tabs, unused at the opening, enabled
	bool isTabEnable = false;
	QList<ActionInfo> unusedTab;
	unusedTab << d2ModelActionInfo << runActionInfo << stopRobotActionInfo
			<< connectToRobotActionInfo << titlesActionInfo;
	changeActiveTab(unusedTab, isTabEnable);
}
Example #19
0
void PropertyWidgetContainer::setObject( GluonCore::GluonObject* theObject )
{
    d->object = theObject;

    QString classname( theObject->metaObject()->className() );
    classname = classname.right( classname.length() - classname.lastIndexOf( ':' ) - 1 );
    setTitle( d->humanifyString( classname ) );

    if( !theObject->property( "enabled" ).isNull() )
        setEnabled( theObject->property( "enabled" ).value<bool>() );
    if( !theObject->property( "expanded" ).isNull() )
        setExpanded( theObject->property( "expanded" ).value<bool>() );
    connect( this, SIGNAL( propertyChanged( QObject*, QString, QVariant, QVariant ) ), parentWidget(), SIGNAL( propertyChanged( QObject*, QString, QVariant, QVariant ) ) );

    // Manually add the name and description widgets, as we wish to handle those a little differently
    PropertyWidgetItem* nameWidget = PropertyWidgetItemFactory::instance()->create( theObject, "QString", parentWidget() );
    nameWidget->setEditObject( theObject );
    nameWidget->setEditProperty( "name" );
    d->addPropertyItem( "name", nameWidget );

    PropertyWidgetItem* descriptionWidget = PropertyWidgetItemFactory::instance()->create( theObject, "QString", parentWidget() );
    descriptionWidget->setEditObject( theObject );
    descriptionWidget->setEditProperty( "description" );
    d->addPropertyItem( "description", descriptionWidget );

    QFrame* separator = new QFrame( this );
    separator->setFrameShape( QFrame::HLine );
    d->containerLayout->addWidget( separator, d->containerLayout->rowCount(), 0, 1, 2 );

    // Set up us the menu...
    if( classname != QString( "GameObject" ) )
    {
        // Don't show moving up and down stuff for the GameObject
        QAction* upAction = new QAction( this );
        upAction->setText( i18n( "Move Up" ) );
        connect( upAction, SIGNAL( triggered( bool ) ), this, SLOT( upTriggered() ) );
        d->menu->addAction( upAction );
        QAction* downAction = new QAction( this );
        downAction->setText( i18n( "Move Down" ) );
        connect( downAction, SIGNAL( triggered( bool ) ), this, SLOT( downTriggered() ) );
        d->menu->addAction( downAction );
        QAction* sepAction = new QAction( this );
        sepAction->setSeparator( true );
        d->menu->addAction( sepAction );
    }
Example #20
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;
}
  HydrogensExtension::HydrogensExtension(QObject *parent) : Extension(parent), m_molecule(0)
  {
    QAction *action = new QAction(this);
    action->setText(tr("Add Hydrogens"));
    m_actions.append(action);

    action = new QAction(this);
    action->setText(tr("Add Hydrogens for pH..."));
    m_actions.append(action);

    action = new QAction(this);
    action->setText(tr("Remove Hydrogens"));
    m_actions.append(action);

    action = new QAction( this );
    action->setSeparator(true);
    m_actions.append( action );
  }
Example #22
0
Command *ActionManagerPrivate::registerOverridableAction(QAction *action, const QString &id, bool checkUnique)
{
    OverrideableAction *a = 0;
    const int uid = UniqueIDManager::instance()->uniqueIdentifier(id);

    if (CommandPrivate * c = m_idCmdMap.value(uid, 0)) {
        a = qobject_cast<OverrideableAction *>(c);
        if (!a) {
            qWarning() << "registerAction: id" << id << "is registered with a different command type.";
            return c;
        }
    } else {
        a = new OverrideableAction(uid);
        m_idCmdMap.insert(uid, a);
    }

    if (!a->action()) {
        QAction *baseAction = new QAction(m_mainWnd);
        baseAction->setObjectName(id);
        baseAction->setCheckable(action->isCheckable());
        baseAction->setIcon(action->icon());
        baseAction->setIconText(action->iconText());
        baseAction->setText(action->text());
        baseAction->setToolTip(action->toolTip());
        baseAction->setStatusTip(action->statusTip());
        baseAction->setWhatsThis(action->whatsThis());
        baseAction->setChecked(action->isChecked());
        baseAction->setSeparator(action->isSeparator());
        baseAction->setShortcutContext(Qt::ApplicationShortcut);
        baseAction->setEnabled(false);
        baseAction->setParent(m_mainWnd);
#ifdef Q_WS_MAC
        baseAction->setIconVisibleInMenu(false);
#endif
        a->setAction(baseAction);
        m_mainWnd->addAction(baseAction);
        a->setKeySequence(a->keySequence());
        a->setDefaultKeySequence(QKeySequence());
    } else if (checkUnique) {
        qWarning() << "registerOverridableAction: id" << id << "is already registered.";
    }

    return a;
}
void tst_QActionGroup::separators()
{
    QMainWindow mw;
    QMenu menu(&mw);
    QActionGroup actGroup(&mw);

    mw.show();

#ifdef QT_SOFTKEYS_ENABLED
    // Softkeys add extra "Select" and "Back" actions to menu by default.
    // Two first actions will be Select and Back when softkeys are enabled
    int numSoftkeyActions = 2;
#else
    int numSoftkeyActions = 0;
#endif

    QAction *action = new QAction(&actGroup);
    action->setText("test one");

    QAction *separator = new QAction(&actGroup);
    separator->setSeparator(true);
    actGroup.addAction(separator);

    QListIterator<QAction*> it(actGroup.actions());
    while (it.hasNext())
        menu.addAction(it.next());

    QCOMPARE((int)menu.actions().size(), 2 + numSoftkeyActions);

    it = QListIterator<QAction*>(actGroup.actions());
    while (it.hasNext())
        menu.removeAction(it.next());

    QCOMPARE((int)menu.actions().size(), 0 + numSoftkeyActions);

    action = new QAction(&actGroup);
    action->setText("test two");

    it = QListIterator<QAction*>(actGroup.actions());
    while (it.hasNext())
        menu.addAction(it.next());

    QCOMPARE((int)menu.actions().size(), 3 + numSoftkeyActions);
}
void ToolbarEditor::restoreDefaults() {
	qDebug("ToolbarEditor::restoreDefaults");
	populateList(all_actions_list, all_actions_copy, false);

	// Create list of actions
	QList<QAction *> actions;
	QAction * a = 0;
	for (int n = 0; n < default_actions.count(); n++) {
		if (default_actions[n] == "separator") {
			QAction * sep = new QAction(this);
			sep->setSeparator(true);
			actions.push_back(sep);
		} else {
			a = findAction(default_actions[n], all_actions_copy);
			if (a) actions.push_back(a);
		}
	}
	setActiveActions(actions);
}
Example #25
0
QList<ActionInfo> RobotsPlugin::actions()
{
	m2dModelAction = new QAction(QObject::tr("2d model"), NULL);
	ActionInfo d2ModelActionInfo(m2dModelAction, "interpreters", "tools");
	QObject::connect(m2dModelAction, SIGNAL(triggered()), this, SLOT(show2dModel()));

	mRunAction = new QAction(QObject::tr("Run"), NULL);
	ActionInfo runActionInfo(mRunAction, "interpreters", "tools");
	QObject::connect(mRunAction, SIGNAL(triggered()), &mInterpreter, SLOT(interpret()));

	mStopAction = new QAction(QObject::tr("Stop"), NULL);
	ActionInfo stopActionInfo(mStopAction, "interpreters", "tools");
	QObject::connect(mStopAction, SIGNAL(triggered()), &mInterpreter, SLOT(stop()));

	QAction *stopRobotAction = new QAction(QObject::tr("Stop robot"), NULL);
	ActionInfo stopRobotActionInfo(stopRobotAction, "interpreters", "tools");
	QObject::connect(stopRobotAction, SIGNAL(triggered()), &mInterpreter, SLOT(stopRobot()));

	QAction *connectToRobotAction = new QAction(QObject::tr("Connect to robot"), NULL);
	connectToRobotAction->setCheckable(true);
	ActionInfo connectToRobotActionInfo(connectToRobotAction, "interpreters", "tools");
	mInterpreter.setConnectRobotAction(connectToRobotAction);
	QObject::connect(connectToRobotAction, SIGNAL(triggered()), &mInterpreter, SLOT(connectToRobot()));

	QAction *robotSettingsAction = new QAction(QObject::tr("Robot settings"), NULL);
	ActionInfo robotSettingsActionInfo(robotSettingsAction, "interpreters", "tools");
	QObject::connect(robotSettingsAction, SIGNAL(triggered()), this, SLOT(showRobotSettings()));

	QAction *watchListAction = new QAction(QObject::tr("Show watch list"), NULL);
	ActionInfo watchListActionInfo(watchListAction, "interpreters", "tools");
	QObject::connect(watchListAction, SIGNAL(triggered()), &mInterpreter, SLOT(showWatchList()));

	QAction *separator = new QAction(NULL);
	ActionInfo separatorActionInfo(separator, "interpreters", "tools");
	separator->setSeparator(true);

	updateSettings();

	return QList<ActionInfo>() << d2ModelActionInfo << runActionInfo << stopActionInfo
			<< stopRobotActionInfo << connectToRobotActionInfo
			<< separatorActionInfo << robotSettingsActionInfo << separatorActionInfo << watchListActionInfo;
}
Example #26
0
void ccTranslationManager::populateMenu( QMenu *menu, const QString &pathToTranslationFiles )
{
	const LanguageList	cList = availableLanguages( QStringLiteral( "CloudCompare" ), pathToTranslationFiles );
	
	QActionGroup	*group = new QActionGroup( menu );
	
	group->setExclusive( true );
	
	QAction	*action = group->addAction( tr( "No Translation (English)" ) );
	
	action->setCheckable( true );
	action->setChecked( true );
	
	connect( action, &QAction::triggered, this, [this] ()
	{
		setLanguagePref( QStringLiteral( "en" ) );
	} );
	
	QAction	*separator = new QAction( group );
	separator->setSeparator( true );
	
	const QString	currentLanguage = languagePref();
	
	for ( auto &langInfo : cList )
	{
		action = group->addAction( langInfo.second );
	
		action->setCheckable( true );
		
		if ( currentLanguage == langInfo.first )
		{
			action->setChecked( true );
		}
		
		connect( action, &QAction::triggered, this, [=] ()
		{
			setLanguagePref( langInfo.first );
		} );
	}
	
	menu->addActions( group->actions() );
}
void BCI2000Viewer::SetupActions()
{
  // setup context menu for signal display
  ui->signalDisplay->setContextMenuPolicy( Qt::CustomContextMenu );
  // create context menu for channel list
  ui->channelList->addAction( ui->actionShow_Channel_s );
  ui->channelList->addAction( ui->actionHide_Channel_s );
  QAction* pSeparator = new QAction( NULL );
  pSeparator->setSeparator( true );
  ui->channelList->addAction( pSeparator );
  ui->channelList->addAction( ui->actionState_Help );
  ui->channelList->setContextMenuPolicy( Qt::ActionsContextMenu );

  // connect actions to slots and create action groups
  map<string, QActionGroup*> groups;
  for( size_t i = 0; i < sizeof( sActions ) / sizeof( *sActions ); ++i )
  {
    QAction* pAction = findChild<QAction*>( sActions[i].object );
    if( pAction )
    {
      connect( pAction, SIGNAL(triggered()), this, SLOT(ExecuteAction()) );
      if( sActions[i].checked != NULL )
        pAction->setCheckable( true );
      else if( sActions[i].group != NULL )
      {
        pAction->setCheckable( true );
        string g = sActions[i].group;
        if( groups[g] == NULL )
        {
          groups[g] = new QActionGroup( this );
          pAction->setChecked( true );
        }
        groups[g]->addAction( pAction );
      }
    }
    QPushButton* pButton = findChild<QPushButton*>( sActions[i].object );
    if( pButton )
    {
      connect( pButton, SIGNAL(clicked()), this, SLOT(ExecuteAction()) );
    }
  }
}
Example #28
0
void
MainWindow::
ShowContextMenu(const QPoint& pos) {

    QMenu contextMenu(tr("Context menu"), this);

    QAction action1("Add New Script", this);
    connect(&action1, SIGNAL(triggered()), this, SLOT(InsertScript()));
    contextMenu.addAction(&action1);

    QAction *separator = new QAction(this);
    separator->setSeparator(true);
    contextMenu.addAction(separator);

    QAction action3("Delete Script", this);
    connect(&action3, SIGNAL(triggered()), this, SLOT(DeleteScript()));
    contextMenu.addAction(&action3);

    contextMenu.exec(mapToGlobal(pos));
}
Example #29
0
void Service::init_actions()
{
    frame_->evaluateJavaScript("CloudmusService.actions = {};");

    QAction* a;
    a = new QAction(QIcon::fromTheme("media-playback-start"), "play", this);
    install_action(a, "play");

    a = new QAction(QIcon::fromTheme("media-playback-pause"), "pause", this);
    install_action(a, "pause");

    a = new QAction(QIcon::fromTheme("media-playback-stop"), "stop", this);
    install_action(a, "stop");

    a = new QAction(QIcon::fromTheme("media-skip-forward"), "next", this);
    install_action(a, "next");

    a = new QAction(this);
    a->setSeparator(true);
    //     Q_EMIT addAction(a);
}
Example #30
0
QAction *KBookmarkMenu::actionForBookmark(const KBookmark &bm)
{
    if (bm.isGroup()) {
        //qDebug() << "Creating bookmark submenu named " << bm.text();
        KActionMenu *actionMenu = new KBookmarkActionMenu(bm, this);
        m_actions.append(actionMenu);
        KBookmarkMenu *subMenu = new KBookmarkMenu(m_pManager, m_pOwner, actionMenu->menu(), bm.address());
        m_lstSubMenus.append(subMenu);
        return actionMenu;
    } else if (bm.isSeparator()) {
        QAction *sa = new QAction(this);
        sa->setSeparator(true);
        m_actions.append(sa);
        return sa;
    } else {
        //qDebug() << "Creating bookmark menu item for " << bm.text();
        QAction *action = new KBookmarkAction(bm, m_pOwner, this);
        m_actions.append(action);
        return action;
    }
}