Example #1
0
void
Viewer::graphContextMenu(const QPoint& pos)
{
    QPoint globalPos = this->ui.scrollArea->mapToGlobal(pos);

    QAction* selectedItem = graphMenu.exec(globalPos);
    if (selectedItem) {
        if (selectedItem->iconText() == GRAPH_UPDATE_ACTION)
        {
            updateGraphView();
        }
        else if (selectedItem->iconText() == GRAPH_OPTIONS_ACTION)
        {
            showGraphOptions();
        }
        else if (selectedItem->iconText() == GRAPH_VIEW_TO_FILE)
        {
            if (graphView != 0) {
                saveImage(graphView->pixmap());
            }
            else {
                this->ui.statusbar->showMessage( tr("No image to save."));
            }
        }
    }
}
Example #2
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 #3
0
QString QActionProto::iconText() const
{
  QAction *item = qscriptvalue_cast<QAction*>(thisObject());
  if (item)
    return item->iconText();
  return QString();
}
Example #4
0
void QgsColorRampButton::loadColorRamp()
{
  QAction *selectedItem = qobject_cast<QAction *>( sender() );
  if ( selectedItem )
  {
    QString name = selectedItem->iconText();
    setColorRampName( name );
    setColorRampFromName( name );
  }
}
Example #5
0
void
Viewer::nodeContextMenu(const QPoint& pos)
{
    bool clickedOnItem = (this->ui.nodeView->itemAt(pos) != 0);

    QPoint globalPos = this->ui.nodeView->mapToGlobal(pos);

    QAction* selectedItem;

    if (clickedOnItem) {
        selectedItem = nodeMenu.exec(globalPos);
    }
    else {
        selectedItem = nodeViewMenu.exec(globalPos);
    }

    if (selectedItem) {
        if (selectedItem->iconText() == NODE_VIEW_UPDATE_ACTION)
        {
            updateNodeView();
        }
        else if (selectedItem->iconText() == NODE_VIEW_OPTIONS_ACTION)
        {
            showNodeOptions();
        }
        else if (selectedItem->iconText() == NODE_VIEW_TO_FILE)
        {
            if (nodeScene != 0) {
                // create a pixmap
                QPixmap p(nodeScene->width(), nodeScene->height());
                p.fill(); // with white
                QPainter painter(&p);
                painter.setBackgroundMode(Qt::OpaqueMode); // must set opaque otherwise black background generated
                this->ui.nodeView->render(&painter);
                saveImage(&p);
            }
            else {
                this->ui.statusbar->showMessage( tr("No image to save."));
            }
        }
    }
}
Example #6
0
void SettingsDialog::setupActionsList()
{
    QList<QAction*> actionsList = pmchart->toolbarActionsList();
    QList<QAction*> enabledList = pmchart->enabledActionsList();

    actionListWidget->blockSignals(true);
    actionListWidget->clear();
    for (int i = 0; i < actionsList.size(); i++) {
	QAction *action = actionsList.at(i);
	QListWidgetItem *item = new QListWidgetItem(action->icon(), action->iconText());
	actionListWidget->insertItem(i, item);
	if (enabledList.contains(action) == false)
	    item->setBackground(disabled);
    }
    actionListWidget->blockSignals(false);
}
Example #7
0
void PmView::setEnabledActionsList(QStringList tools, bool redisplay)
{
    my.enabledActionsList.clear();
    for (int i = 0; i < my.toolbarActionsList.size(); i++) {
	QAction *action = my.toolbarActionsList.at(i);
	if (tools.contains(action->iconText()))
	    my.enabledActionsList.append(action);
    }

    if (redisplay) {
	my.toolbarHidden = (my.enabledActionsList.size() == 0);
	toolbarAction->setChecked(my.toolbarHidden);
	if (my.toolbarHidden)
	    toolBar->hide();
	else
	    toolBar->show();
    }
}
Example #8
0
void
Viewer::treeContextMenu(const QPoint& pos)
{
    QPoint globalPos = this->ui.repoView->viewport()->mapToGlobal(pos);

    QAction* selectedItem = treeMenu.exec(globalPos);
    if (selectedItem) {
        if (selectedItem->iconText() == EXPAND_ACTION)
        {
            expand(true);
            selectedItem->setText(COLLAPSE_ACTION);
            selectedItem->setIconText(COLLAPSE_ACTION);

        }
        else if (selectedItem->iconText() == COLLAPSE_ACTION)
        {
            expand(false);
            selectedItem->setText(EXPAND_ACTION);
            selectedItem->setIconText(EXPAND_ACTION);
        }
        else if (selectedItem->iconText() == SELECTION_TO_NODE_VIEW ||
                 selectedItem->iconText() == SELECTION_TO_GRAPH_VIEW)
        {
            // reset all the display flags
            this->dataSource_->modelRoot()->resetDisplays();

            QModelIndexList q = this->ui.repoView->selectionModel()->selectedRows();
            for (int c = 0; c < q.size(); ++c) {
                // get the node and set the display flag
                TreeNode *t = model_->getNode(q[c]);
                t->setDisplay(true);
            }

            if (selectedItem->iconText() == SELECTION_TO_NODE_VIEW)
            {
                updateNodeView(true);
            }
            else {
                updateGraphView(true);
            }
        }
        else if (selectedItem->iconText() == NODE_VIEW_OPTIONS_ACTION)
        {
            showNodeOptions();
        }
        else if (selectedItem->iconText() == GRAPH_OPTIONS_ACTION)
        {
            showGraphOptions();
        }
    }
}
Example #9
0
void CustomLabel::contextMenuEvent(QContextMenuEvent* e) {
    if (editable_) {
        QMenu* men = new QMenu(this);
        men->addAction("Rename");
        men->addAction("Set Default");
        QAction* ac = men->exec(e->globalPos());
        if(ac != 0) {
            if(ac->iconText().compare("Rename") == 0) {
                edit_->setText(text());
                edit_->setFocus();
                edit_->setCursorPosition(edit_->text().length());
                edit_->resize(size());
                edit_->show();
            } else {
                propertyWidget_->getProperty()->reset();
                if(dynamic_cast<TransFuncProperty*>(propertyWidget_->getProperty()))
                    propertyWidget_->getProperty()->invalidate();
            }
        }
    }
}
Example #10
0
void ShortcutViewer::keyPressEvent(QKeyEvent *event)
{
	int key = event->key();
	if (key == Qt::Key_Control || key == Qt::Key_Shift || key == Qt::Key_Alt) {
		event->ignore();
		return;
	}
	Qt::KeyboardModifiers modifiers = event->modifiers();

	// Tasti che non possono essere utilizzati come shortcut
	if ((modifiers | (Qt::CTRL | Qt::SHIFT | Qt::ALT)) != (Qt::CTRL | Qt::SHIFT | Qt::ALT) || key == Qt::Key_Home || key == Qt::Key_End || key == Qt::Key_PageDown || key == Qt::Key_PageUp || key == Qt::Key_Escape || key == Qt::Key_Print || key == Qt::Key_Pause || key == Qt::Key_ScrollLock) {
		if (key != Qt::Key_Plus && key != Qt::Key_Minus && key != Qt::Key_Asterisk && key != Qt::Key_Slash) {
			event->ignore();
			return;
		} else
			modifiers = 0;
	}

	if (m_action) {
		CommandManager *cm = CommandManager::instance();
		QKeySequence keySequence(key + modifiers);
		std::string shortcutString = keySequence.toString().toStdString();
		QAction *oldAction = cm->getActionFromShortcut(keySequence.toString().toStdString());
		if (oldAction == m_action)
			return;
		if (oldAction) {
			QString msg = tr("%1 is already assigned to '%2'\nAssign to '%3'?").arg(keySequence.toString()).arg(oldAction->iconText()).arg(m_action->iconText());
			int ret = DVGui::MsgBox(msg, tr("Yes"), tr("No"), 1);
			activateWindow();
			if (ret == 2 || ret == 0)
				return;
		}
		CommandManager::instance()->setShortcut(m_action, shortcutString);
		emit shortcutChanged();
	}
	event->accept();
	update();
}