void ExtendedTableWidget::contextMenuEvent(QContextMenuEvent * event)
{
    QTableWidgetItem *item = itemAt(event->pos());
    QAction *action;
    if (item) {
        event->accept();
        QMenu contextMenu( this );
        if (m_editable) {
            action = contextMenu.addAction(tr("&Remove"), this, SLOT(remove()));
            action->setProperty("row", row(item));
        }
        if (PhoneNumber::phone_re().exactMatch(item->text())) {
            action = contextMenu.addAction(tr("&Dial"), this, SLOT(dialNumber()));
            action->setProperty("number", item->text());
        } else if(item->text().contains("@")) {
            action = contextMenu.addAction(tr("Send an E-mail"),
                                           this, SLOT(sendMail()) );
            action->setProperty("email", item->text());
        }
        if(!contextMenu.isEmpty()) {
            contextMenu.exec(event->globalPos());
        }
    } else {
        event->ignore();
    }
}
Example #2
0
	void Plugin::hookEntryActionsRequested (IHookProxy_ptr proxy, QObject *entry)
	{
		if (!Entry2ActionHistory_.contains (entry))
		{
			QAction *action = new QAction (tr ("History..."), entry);
			action->setProperty ("ActionIcon", "view-history");
			action->setProperty ("Azoth/ChatHistory/IsGood", true);
			action->setProperty ("Azoth/ChatHistory/Entry",
					QVariant::fromValue<QObject*> (entry));
			connect (action,
					SIGNAL (triggered ()),
					this,
					SLOT (handleEntryHistoryRequested ()));
			Entry2ActionHistory_ [entry] = action;
		}
		if (!Entry2ActionEnableHistory_.contains (entry))
		{
			QAction *action = new QAction (tr ("Logging enabled"), entry);
			action->setCheckable (true);
			action->setChecked (Core::Instance ()->IsLoggingEnabled (entry));
			action->setProperty ("Azoth/ChatHistory/IsGood", true);
			action->setProperty ("Azoth/ChatHistory/Entry",
					QVariant::fromValue<QObject*> (entry));
			connect (action,
					SIGNAL (toggled (bool)),
					this,
					SLOT (handleEntryEnableHistoryRequested (bool)));
			Entry2ActionEnableHistory_ [entry] = action;
		}
/*! \brief show the context menu
 */
void XletSwitchBoard::contextMenuEvent(QContextMenuEvent *event)
{
    // check if there is a group under the cursor
    Group *group = getGroup(m_layout->getPosInGrid(event->pos()));

    QMenu contextMenu(this);
    QAction *action;
    if (group) {
        action = contextMenu.addAction(tr("Remove group %1").arg(group->name()),
                                       this, SLOT(removeGroup()));
        action->setProperty("group", QVariant::fromValue((void *)group));

        action = contextMenu.addAction(tr("Change color of group %1").arg(group->name()),
                                       this, SLOT(changeGroupColor()));
        action->setProperty("group", QVariant::fromValue((void *)group));

        action = contextMenu.addAction(tr("Rename group %1").arg(group->name()),
                                       this, SLOT(changeGroupName())); 
        action->setProperty("group", QVariant::fromValue((void *)group));
    }

    action = contextMenu.addAction(tr("Add Phone number entry"),
                                   this, SLOT(addPhoneNumberEntry()));
    action->setProperty("pos", m_layout->getPosInGrid(event->pos()));

    action = new QAction(tr("Draw the grid"), this);
    action->setCheckable(true);
    action->setChecked(m_drawGrid);
    connect(action, SIGNAL(toggled(bool)),
            this, SLOT(drawTheGrid(bool)));
    contextMenu.addAction(action);

    contextMenu.exec(event->globalPos());
}
Example #4
0
	void Plugin::handleBatteryInfo (BatteryInfo info)
	{
		if (!Battery2Action_.contains (info.ID_))
		{
			QAction *act = new QAction (tr ("Battery status"), this);
			act->setProperty ("WatchActionIconChange", true);
			act->setProperty ("Liznoo/BatteryID", info.ID_);

			act->setProperty ("Action/Class", GetUniqueID () + "/BatteryAction");
			act->setProperty ("Action/ID", GetUniqueID () + "/" + info.ID_);

			emit gotActions (QList<QAction*> () << act, AEPLCTray);
			Battery2Action_ [info.ID_] = act;

			connect (act,
					SIGNAL (triggered ()),
					this,
					SLOT (handleHistoryTriggered ()));
		}

		UpdateAction (info);
		CheckNotifications (info);

		Battery2LastInfo_ [info.ID_] = info;
	}
Example #5
0
	void Plugin::handleBatteryInfo (BatteryInfo info)
	{
#if QT_VERSION < 0x050000
		const auto& iconName = GetBattIconName (info);
		if (!Battery2Action_.contains (info.ID_))
		{
			QAction *act = new QAction (tr ("Battery status"), this);
			act->setProperty ("WatchActionIconChange", true);
			act->setProperty ("Liznoo/BatteryID", info.ID_);

			act->setProperty ("Action/Class", GetUniqueID () + "/BatteryAction");
			act->setProperty ("Action/ID", GetUniqueID () + "/" + info.ID_);
			act->setProperty ("ActionIcon", iconName);

			emit gotActions ({ act }, ActionsEmbedPlace::LCTray);
			Battery2Action_ [info.ID_] = act;

			connect (act,
					SIGNAL (triggered ()),
					this,
					SLOT (handleHistoryTriggered ()));
		}
		else
			Battery2Action_ [info.ID_]->setProperty ("ActionIcon", iconName);
#endif

		CheckNotifications (info);

		Battery2LastInfo_ [info.ID_] = info;
	}
Example #6
0
UiManager::UiManager(QAction &debugModeAction
		, QAction &editModeAction
		, qReal::gui::MainWindowDockInterface &mainWindow
		, qReal::SystemEvents &systemEvents
		, kitBase::EventsForKitPluginInterface &kitPluginEvents
		, kitBase::robotModel::RobotModelManagerInterface &robotModelManager)
	: mDebugModeAction(debugModeAction)
	, mEditModeAction(editModeAction)
	, mMainWindow(mainWindow)
	, mTabBar(nullptr)
	, mCustomWidgetsBar(new QToolBar(tr("Miscellaneous"), mMainWindow.windowWidget()))
	, mRobotConsole(new qReal::ui::ConsoleDock(tr("Robot console"), mMainWindow.windowWidget()))
{
	mMainWindow.graphicalModelDock()->setWindowTitle(QObject::tr("Blocks"));

	connect(&systemEvents, &qReal::SystemEvents::activeTabChanged, this, &UiManager::onActiveTabChanged);
	connect(&systemEvents, &qReal::SystemEvents::ensureDiagramVisible, this, &UiManager::ensureDiagramVisible);
	connect(&kitPluginEvents, &kitBase::EventsForKitPluginInterface::interpretationStarted
			, this, &UiManager::switchToDebuggerMode);
	connect(&kitPluginEvents, &kitBase::EventsForKitPluginInterface::interpretationStarted
			, mRobotConsole, &qReal::ui::ConsoleDock::clear);
	connect(&kitPluginEvents, &kitBase::EventsForKitPluginInterface::robotModelChanged
			, [=]() { QTimer::singleShot(0, this, SLOT(reloadDocksSavingToolbarsAndErrors())); });
	connect(&robotModelManager, &kitBase::robotModel::RobotModelManagerInterface::robotModelChanged
			, this, &UiManager::onRobotModelChanged);
	connect(&debugModeAction, &QAction::triggered, this, &UiManager::switchToDebuggerMode);
	connect(&editModeAction, &QAction::triggered, this, &UiManager::switchToEditorMode);

	mRobotConsole->hide();
	initTab();
	mCustomWidgetsBar->setObjectName("robotsMiscellaneousBar");
	connect(this, &QObject::destroyed, [this]() { mCustomWidgetsBar->setParent(nullptr); });
	mMainWindow.addToolBar(Qt::TopToolBarArea, mCustomWidgetsBar);
	mMainWindow.addDockWidget(Qt::BottomDockWidgetArea, mRobotConsole);
	mMainWindow.tabifyDockWidget(mRobotConsole, mMainWindow.errorReporterDock());
	mMainWindow.windowWidget()->addAction(mRobotConsole->toggleViewAction());
	mRobotConsole->toggleViewAction()->setShortcut(Qt::ALT + Qt::Key_2);

	mMainWindow.statusBar()->setAutoFillBackground(true);
#ifdef Q_OS_LINUX
	// On Windows and Mac this stylesheet is not needed and will cause segfault on program close.
	mMainWindow.statusBar()->setStyleSheet("QStatusBar::item { border: 0px solid black; padding: 10px; }");
#endif
	editModeAction.setProperty("modeName", tr("edit mode"));
	debugModeAction.setProperty("modeName", tr("debug mode"));
	produceModeButton(Mode::Editing, debugModeAction, mMainWindow.statusBar());
	produceModeButton(Mode::Debugging, editModeAction, mMainWindow.statusBar());

	switchToEditorMode();
	onActiveTabChanged(qReal::TabInfo());

	qReal::SettingsListener::listen("dockableWidgets", this, &UiManager::updateDocksSettings);
}
Gui::Action * CmdDrawingNewPage::createAction(void)
{
    Gui::ActionGroup* pcAction = new Gui::ActionGroup(this, Gui::getMainWindow());
    pcAction->setDropDownMenu(true);
    applyCommandData(this->className(), pcAction);

    QAction* defaultAction = 0;
    int defaultId = 0;

    std::string path = App::Application::getResourceDir();
    path += "Mod/Drawing/Templates/";
    QDir dir(QString::fromUtf8(path.c_str()), QString::fromAscii("*.svg"));
    for (unsigned int i=0; i<dir.count(); i++ ) {
        QRegExp rx(QString::fromAscii("(A|B|C|D|E)(\\d)_(Landscape|Portrait).svg"));
        if (rx.indexIn(dir[i]) > -1) {
            QString paper = rx.cap(1);
            int id = rx.cap(2).toInt();
            QString orientation = rx.cap(3);
            QFile file(QString::fromAscii(":/icons/actions/drawing-landscape-A0.svg"));
            QAction* a = pcAction->addAction(QString());
            if (file.open(QFile::ReadOnly)) {
                QString s = QString::fromAscii("style=\"font-size:22px\">%1%2</tspan></text>").arg(paper).arg(id);
                QByteArray data = file.readAll();
                data.replace("style=\"font-size:22px\">A0</tspan></text>", s.toAscii());
                a->setIcon(Gui::BitmapFactory().pixmapFromSvg(data, QSize(24,24)));
            }

            a->setProperty("TemplatePaper", paper);
            a->setProperty("TemplateOrientation", orientation);
            a->setProperty("TemplateId", id);
            a->setProperty("Template", dir.absoluteFilePath(dir[i]));

            if (id == 3) {
                defaultAction = a;
                defaultId = pcAction->actions().size() - 1;
            }
        }
    }

    _pcAction = pcAction;
    languageChange();
    if (defaultAction) {
        pcAction->setIcon(defaultAction->icon());
        pcAction->setProperty("defaultAction", QVariant(defaultId));
    }
    else if (!pcAction->actions().isEmpty()) {
        pcAction->setIcon(pcAction->actions()[0]->icon());
        pcAction->setProperty("defaultAction", QVariant(0));
    }

    return pcAction;
}
void FilterExpressionToolBar::onCustomMenuHandler(const QPoint& pos)
{
    QAction * filterAction = actionAt(pos);
    if ( ! filterAction )
        return;

    QMenu * filterMenu = new QMenu(this);

    QAction *actFilter = filterMenu->addAction(tr("Filter Button Preferences..."));
    connect(actFilter, SIGNAL(triggered()), this, SLOT(toolBarShowPreferences()));
    actFilter->setProperty(dfe_property_label_, filterAction->property(dfe_property_label_));
    actFilter->setProperty(dfe_property_expression_, filterAction->property(dfe_property_expression_));
    actFilter->setData(filterAction->data());
    filterMenu->addSeparator();
    QAction * actEdit = filterMenu->addAction(tr("Edit"));
    connect(actEdit, SIGNAL(triggered()), this, SLOT(editFilter()));
    actEdit->setProperty(dfe_property_label_, filterAction->property(dfe_property_label_));
    actEdit->setProperty(dfe_property_expression_, filterAction->property(dfe_property_expression_));
    actEdit->setData(filterAction->data());
    QAction * actDisable = filterMenu->addAction(tr("Disable"));
    connect(actDisable, SIGNAL(triggered()), this, SLOT(disableFilter()));
    actDisable->setProperty(dfe_property_label_, filterAction->property(dfe_property_label_));
    actDisable->setProperty(dfe_property_expression_, filterAction->property(dfe_property_expression_));
    actDisable->setData(filterAction->data());
    QAction * actRemove = filterMenu->addAction(tr("Remove"));
    connect(actRemove, SIGNAL(triggered()), this, SLOT(removeFilter()));
    actRemove->setProperty(dfe_property_label_, filterAction->property(dfe_property_label_));
    actRemove->setProperty(dfe_property_expression_, filterAction->property(dfe_property_expression_));
    actRemove->setData(filterAction->data());

    filterMenu->exec(mapToGlobal(pos));
}
void CommandContributionItem::Fill(QToolBar *parent, QAction *before)
{
  if (!command || action || parent == nullptr)
  {
    return;
  }

  QAction* item = nullptr;
  if (before)
  {
    item = parent->addAction(icon, label);
  }
  else
  {
    item = new QAction(icon, label, parent);
    parent->insertAction(before, item);
  }
  item->setData(QVariant::fromValue(Object::Pointer(this)));
  item->setProperty("contributionItem", QVariant::fromValue(Object::Pointer(this)));

  connect(item, SIGNAL(triggered()), SLOT(HandleWidgetSelection()));
  connect(item, SIGNAL(destroyed()), SLOT(HandleActionDestroyed()));
  action = item;

  this->Update();
  this->UpdateIcons();

  //bindingService.addBindingManagerListener(bindingManagerListener);
}
Example #10
0
	void SBWidget::FoldTabClass (const TabClassInfo& tc, QAction *newAct)
	{
		if (!TabClass2Folder_.contains (tc.TabClass_))
		{
			QAction *foldAct = new QAction (tc.VisibleName_, this);
			foldAct->setToolTip (tc.Description_);
			foldAct->setIcon (tc.Icon_);
			foldAct->setProperty ("Sidebar/TabClass", tc.TabClass_);
			connect (foldAct,
					SIGNAL (triggered ()),
					this,
					SLOT (showFolded ()));

			auto tb = new QToolButton;
			tb->setIconSize (IconSize_);
			tb->setDefaultAction (foldAct);
			TabClass2Folder_ [tc.TabClass_] = tb;
			Ui_.TabsLay_->insertWidget (0, tb);

			Q_FOREACH (QAction *act, TabClass2Action_ [tc.TabClass_])
				AddToFolder (tc.TabClass_, act);
		}
		else
			AddToFolder (tc.TabClass_, newAct);
	}
Example #11
0
	foreach(QString filename, files) {
		const QFileInfo file(filename);
		QAction *a = menu->addAction(QString(index<10?"&%1. %2":"%1. %2").arg(index).arg(file.fileName()));
		a->setStatusTip(file.absoluteFilePath());
		a->setProperty("filepath",file.absoluteFilePath());
		++index;
	}
Example #12
0
Gui::Action * CmdRaytracingNewLuxProject::createAction(void)
{
    Gui::ActionGroup* pcAction = new Gui::ActionGroup(this, Gui::getMainWindow());
    pcAction->setDropDownMenu(true);
    applyCommandData(this->className(), pcAction);

    QAction* defaultAction = 0;
    int defaultId = 0;

    std::string path = App::Application::getResourceDir();
    path += "Mod/Raytracing/Templates/";
    QDir dir(QString::fromUtf8(path.c_str()), QString::fromAscii("*.lxs"));
    for (unsigned int i=0; i<dir.count(); i++ ) {
        QFileInfo fi(dir[i]);
        QAction* a = pcAction->addAction(fi.baseName());
        a->setIcon(Gui::BitmapFactory().pixmap("Raytrace_Lux"));

        a->setProperty("Template", dir.absoluteFilePath(dir[i]));
    }

    _pcAction = pcAction;
    languageChange();
    if (defaultAction) {
        pcAction->setIcon(defaultAction->icon());
        pcAction->setProperty("defaultAction", QVariant(defaultId));
    }
    else if (!pcAction->actions().isEmpty()) {
        pcAction->setIcon(pcAction->actions()[0]->icon());
        pcAction->setProperty("defaultAction", QVariant(0));
    }

    return pcAction;
}
void OBSBasic::RefreshProfiles()
{
	QList<QAction*> menuActions = ui->profileMenu->actions();
	int count = 0;

	for (int i = 0; i < menuActions.count(); i++) {
		QVariant v = menuActions[i]->property("file_name");
		if (v.typeName() != nullptr)
			delete menuActions[i];
	}

	const char *curName = config_get_string(App()->GlobalConfig(),
			"Basic", "Profile");

	auto addProfile = [&](const char *name, const char *path)
	{
		std::string file = strrchr(path, '/') + 1;

		QAction *action = new QAction(QT_UTF8(name), this);
		action->setProperty("file_name", QT_UTF8(path));
		connect(action, &QAction::triggered,
				this, &OBSBasic::ChangeProfile);
		action->setCheckable(true);

		action->setChecked(strcmp(name, curName) == 0);

		ui->profileMenu->addAction(action);
		count++;
		return true;
	};

	EnumProfiles(addProfile);

	ui->actionRemoveProfile->setEnabled(count > 1);
}
Example #14
0
QStringList TToolbarEditor::saveActions() {
    logger()->debug("saveActions");

	QStringList list;

	for (int row = 0; row < active_actions_table->rowCount(); row++) {
		QTableWidgetItem* item = active_actions_table->item(row, COL_NAME);
		if (item) {
			QString action_name = item->text();
			if (action_name.startsWith("separator")) {
				action_name = "separator";
			}
			QString s = action_name;

			bool ns = getVis(row, COL_NS);
			bool fs = getVis(row, COL_FS);
			if (ns) {
				if (!fs) {
					s += "|1|0";
				}
			} else if (fs) {
				s += "|0|1";
			} else {
				s += "|0|0";
			}
			list << s;

			if (action_name != "separator") {
				// Update icon text
				QAction* action = findAction(action_name, *all_actions);
				if (action) {
					item = active_actions_table->item(row, COL_DESC);
					if (item) {
						QString action_icon_text = TActionsEditor::actionTextToDescription(
													   item->text(), action_name).trimmed();
						if (!action_icon_text.isEmpty()) {
							QString action_text = TActionsEditor::actionTextToDescription(action->text(), action_name);
							if (action_text != action_icon_text) {
								action->setIconText(action_icon_text);
                                action->setProperty("modified", true);
                                logger()->debug("saveActions: updated icon text '"
                                    + action_name + "' to '" + action_icon_text
                                    + "'");
							} else {
								action_icon_text = TActionsEditor::actionTextToDescription(action->iconText(), action_name);
								if (action_icon_text != action_text) {
                                    action->setIconText(action_text);
                                    logger()->debug("saveActions: cleared icon text "
                                                    + action_name);
								}
							}
						}
					}
				}
			}
		}
	}

	return list;
}
Example #15
0
TabManager::TabManager (SeparateTabWidget *tabWidget, MainWindow *window, QObject *parent)
: QObject (parent)
, TabWidget_ (tabWidget)
, Window_ (window)
{
	for (int i = 0; i < TabWidget_->WidgetCount (); ++i)
		OriginalTabNames_ << TabWidget_->TabText (i);

	connect (TabWidget_,
			SIGNAL (tabCloseRequested (int)),
			this,
			SLOT (remove (int)));
	connect (TabWidget_,
			SIGNAL (currentChanged (int)),
			this,
			SLOT (handleCurrentChanged (int)));
	connect (TabWidget_,
			SIGNAL (tabWasMoved (int, int)),
			this,
			SLOT (handleMoveHappened (int, int)));

	XmlSettingsManager::Instance ()->RegisterObject ("UseTabScrollButtons",
			this, "handleScrollButtons");

	handleScrollButtons ();

	QAction *closeAllButCurrent = new QAction (tr ("Close all but this"),
			this);
	connect (closeAllButCurrent,
			SIGNAL (triggered ()),
			this,
			SLOT (handleCloseAllButCurrent ()));
	closeAllButCurrent->setProperty ("ActionIcon", "tab-close-other");
	TabWidget_->AddAction2TabBar (closeAllButCurrent);
}
Example #16
0
void LogTableView::onViewClick(const QModelIndex &model)
{
    QString caller = model.sibling(model.row(), 0).data().toString();

    if (caller.indexOf("<") != -1) {
        caller.remove(QRegExp("[^<]*<"));
        caller.remove(">");
    }
    caller.remove(QRegExp("[^0-9]"));

    if (caller != "") {
        if (m_lastPressed & Qt::LeftButton) {
            b_engine->pasteToDial(caller);
        } else {
            QMenu *menu = new QMenu(this);

            QAction *action = new QAction(tr("Call %1").arg(caller), menu);
            action->setProperty("num_to_call", caller);
            connect(action, SIGNAL(triggered(bool)),
                    this, SLOT(callOnClick(bool)));

            menu->addAction(action);
            menu->exec(QCursor::pos());
        }
    }
}
Example #17
0
			QToolButton* PackagesDelegate::GetUpdate (const QModelIndex& index) const
			{
				int row = index.row ();
				if (!Row2Update_.contains (row))
				{
					QAction *action = new QAction (Core::Instance ()
								.GetProxy ()->GetIcon ("update"),
							tr ("Update"),
							Viewport_);
					action->setCheckable (true);
					action->setProperty ("Role", "Update");
					connect (action,
							SIGNAL (triggered ()),
							this,
							SLOT (handleAction ()));

					QToolButton *toolButton = new QToolButton ();
					toolButton->resize (CActionsSize, CActionsSize);
					toolButton->setDefaultAction (action);
					Row2Update_ [row] = toolButton;
				}

				QToolButton *button = Row2Update_ [row];
				QAction *action = button->defaultAction ();

				bool upgradable = index.data (PackagesModel::PMRUpgradable).toBool ();
				action->setEnabled (upgradable);
				action->setData (index.data (PackagesModel::PMRPackageID));

				WasUpgradable_ [index] = upgradable;

				return button;
			}
bool GCF::ActionContainerWidget::event(QEvent* e)
{
    switch(e->type())
    {
    case QEvent::ActionAdded:
    {
        QActionEvent* ae = (QActionEvent*)e;
        QAction* action = ae->action();
        QWidget* actionWidget = 0;

        int row=-1, col=-1;
        int rowSpan = action->property("rowSpan").toInt();
        int colSpan = action->property("colSpan").toInt();
        if(!rowSpan)
            rowSpan = 1;
        if(!colSpan)
            colSpan = 1;
        if(rowSpan > d->maxRows)
            rowSpan = d->maxRows;

        actionWidget = createWidget(action, rowSpan, colSpan);

        d->gridLayout->findCell(rowSpan, colSpan, &row, &col);
        d->gridLayout->addWidget(actionWidget, row, col, rowSpan, colSpan, Qt::AlignJustify);

        d->actionWidgetMap[action] = actionWidget;
        action->setProperty("row", row);
        action->setProperty("col", col);

        actionWidget->show();

    }
    return true;

    case QEvent::ActionRemoved:
    {
        QActionEvent* ae = (QActionEvent*)e;
        QAction* action = ae->action();
        QWidget* actionWidget = d->actionWidgetMap.contains(action) ? d->actionWidgetMap[action] : 0;

        int row = action->property("row").toInt();
        int col = action->property("col").toInt();
        int rowSpan = action->property("rowSpan").toInt();
        int colSpan = action->property("colSpan").toInt();

        if(actionWidget && qobject_cast<QToolButton*>(actionWidget))
            delete actionWidget;

        d->actionWidgetMap.remove(action);
        d->gridLayout->markCells(false, row, col, rowSpan, colSpan);
    }
    return true;

    default:
        break;
    }

    return QWidget::event(e);
}
Example #19
0
void MacMenu::addWindow(MainWindow *win)
{
	QAction *a = new QAction(menuWinTitle(win->windowTitle()), this);
	a->setProperty("mainwin", QVariant::fromValue(win));
	a->setCheckable(true);

	_windows->addAction(a);
}
Example #20
0
void DatasetsListWidget::sl_contextMenu(const QPoint &p, int idx) {
    QMenu menu;
    QAction *renameAction = new QAction(tr("Rename dataset"), &menu);
    renameAction->setProperty("idx", idx);
    connect(renameAction, SIGNAL(triggered()), SLOT(sl_renameDataset()));
    menu.addAction(renameAction);
    menu.exec(p);
}
Example #21
0
 foreach (const QString &actionName, timeSpans) {
     QAction *action = new QAction(actionName, timeBar);
     action->setCheckable(true);
     action->setProperty("paramValue", i);
     timeGroup->addAction(action);
     timeBar->addAction(action);
     i++;
 }
Example #22
0
			QToolButton* PackagesDelegate::GetInstallRemove (const QModelIndex& index) const
			{
				int row = index.row ();
				if (!Row2InstallRemove_.contains (row))
				{
					QAction *action = new QAction (Viewport_);
					action->setCheckable (true);
					action->setProperty ("Role", "InstallRemove");
					connect (action,
							SIGNAL (triggered ()),
							this,
							SLOT (handleAction ()));

					QToolButton *toolButton = new QToolButton ();
					toolButton->resize (CActionsSize, CActionsSize);
					toolButton->setDefaultAction (action);
					Row2InstallRemove_ [row] = toolButton;
				}

				QToolButton *button = Row2InstallRemove_ [row];

				bool installed = index.data (PackagesModel::PMRInstalled).toBool ();
				QString label;
				QString iconName;
				if (installed)
				{
					label = tr ("Remove");
					iconName = "remove";
				}
				else
				{
					label = tr ("Install");
					iconName = "addjob";
				}

				QAction *action = button->defaultAction ();
				WasInstalled_ [index] = installed;

				action->setText (label);
				action->setIcon (Core::Instance ().GetProxy ()->GetIcon (iconName));
				action->setData (index.data (PackagesModel::PMRPackageID));
				action->setProperty ("Installed", index.data (PackagesModel::PMRInstalled));

				return button;
			}
Example #23
0
void MethodViewer::contextMenuEvent(QContextMenuEvent *event) {
	Item *item = static_cast<Item*>(itemAt(event->pos()));
	QMenu menu(this);

	if ((item->isSignal() || item->isSlot()) && item->getMethod().parameterNames().count() == 0) {
		QAction *action = menu.addAction("invoke", this, SLOT(_invokeMethod()));
		action->setProperty("treeItem", QVariant::fromValue<MethodViewer::Item*>(item));
		action = menu.addAction(tr("Invoke every n seconds..."), this, SLOT(_invokeMethodEvery()));
		action->setProperty("treeItem", QVariant::fromValue<MethodViewer::Item*>(item));

	}

	if (m_invokeTimer.isActive()) {
		menu.addAction(tr("Stop Invoking %1()").arg(m_invokedMethod.tag()), &m_invokeTimer, SLOT(stop()));
	}

	if (!menu.isEmpty()) menu.exec(mapToGlobal(event->pos()));
}
Example #24
0
	/**
	 * \param text will be shown on screen, and \param groupName is the 
	 * actual group name. Specify true as \param current when group is
	 * currently selected for a contact.
	 */
	void addGroup(QString text, QString groupName, bool selected)
	{
		QAction* action = new QAction(text, this);
		addAction(action);
		action->setCheckable(true);
		action->setChecked(selected);
		action->setProperty("groupName", QVariant(groupName));
		connect(action, SIGNAL(activated()), SLOT(actionActivated()));
	}
Example #25
0
 foreach (const QString &actionName, qualityOptions) {
     QAction *action = new QAction(actionName, timeBar);
     action->setStatusTip(tips.at(i));
     action->setCheckable(true);
     action->setProperty("paramValue", i);
     qualityGroup->addAction(action);
     qualityBar->addAction(action);
     i++;
 }
Example #26
0
void LayerAclMenu::addUser(int index)
{
	const canvas::User &user = m_model->data(m_model->index(index)).value<canvas::User>();
	QAction *userAction = new QAction(user.name, this);
	userAction->setCheckable(true);
	userAction->setProperty("userid", user.id);
	_users.append(userAction);
	addAction(userAction);
}
Example #27
0
QWidget* QgsAttributeTableView::createActionWidget( QgsFeatureId fid )
{
  QgsAttributeTableConfig attributeTableConfig = mFilterModel->layer()->attributeTableConfig();
  QgsActionManager* actions = mFilterModel->layer()->actions();

  QToolButton* toolButton = nullptr;
  QWidget* container = nullptr;

  if ( attributeTableConfig.actionWidgetStyle() == QgsAttributeTableConfig::DropDown )
  {
    toolButton  = new QToolButton( this );
    toolButton->setPopupMode( QToolButton::MenuButtonPopup );
    container = toolButton;
  }
  else
  {
    container = new QWidget( this );
    container->setLayout( new QHBoxLayout() );
    container->layout()->setMargin( 0 );
  }

  for ( int i = 0; i < actions->size(); ++i )
  {
    const QgsAction& action = actions->at( i );

    if ( !action.showInAttributeTable() )
      continue;

    QAction* act = new QAction( action.icon(), action.shortTitle().isEmpty() ? action.name() : action.shortTitle(), toolButton );
    act->setToolTip( action.name() );
    act->setData( i );
    act->setProperty( "fid", fid );

    connect( act, SIGNAL( triggered( bool ) ), this, SLOT( actionTriggered() ) );

    if ( attributeTableConfig.actionWidgetStyle() == QgsAttributeTableConfig::DropDown )
    {
      toolButton->addAction( act );

      if ( actions->defaultAction() == i )
        toolButton->setDefaultAction( act );

      container = toolButton;
    }
    else
    {
      QToolButton* btn = new QToolButton;
      btn->setDefaultAction( act );
      container->layout()->addWidget( btn );
    }
  }

  if ( toolButton && !toolButton->actions().isEmpty() && actions->defaultAction() == -1 )
    toolButton->setDefaultAction( toolButton->actions().first() );

  return container;
}
Example #28
0
void StatusMenu::addStatus(XMPP::Status::Type type)
{
	QAction* action = new QAction(status2txt(type), this);
	action->setCheckable(true);
	action->setChecked(currentStatus_ == type);
	action->setIcon(PsiIconset::instance()->status(type).icon());
	action->setProperty("type", QVariant(type));
	connect(action, SIGNAL(triggered()), SLOT(actionActivated()));
	addAction(action);
}
Example #29
0
void UndoManager::Push(QUndoCommand * command)
{
    actions_.resize(undoStack_->index());

    QAction * action = new QAction(command->text(), 0);
    action->setProperty("index", undoStack_->index());

    actions_.push_back(action);
    undoStack_->push(command);
}
Example #30
0
void StatusLabel::fillStatusMenu(QMenu& menu)
{
    menu.clear();
    menu.setTitle(m_client->name());
    QStringList statusNames = m_client->protocol()->statuses();
    foreach(const QString& statusId, statusNames) {
        IMStatusPtr status = m_client->protocol()->status(statusId);
        QAction* action = menu.addAction(status->icon(), status->name());
        action->setProperty("status_id", status->id());
    }