void QCustomTreeWidget::mousePressEvent(QMouseEvent *e)
{
    QTreeWidgetItem *item = itemAt(e->pos());
    switch (e->button())
    {
        case Qt::LeftButton:    if (item !=NULL)
                                {
                                    bNewlySelected = !item->isSelected();
                                    // the item will be selected (and not be unselected by mouseReleaseEvent)
                                }
                                QTreeWidget::mousePressEvent(e);
                                break;
        case Qt::RightButton:   if (item != NULL)
                                {
                                    setCurrentItem(item);
                                    QCustomTreeWidgetItem *qItem = dynamic_cast<QCustomTreeWidgetItem*>(item);
                                    Item *treeItem = qItem->branch()->item();
                                    QAction* action = menuIcons->exec(e->globalPos());
                                    if (action == actionNone)
                                    {
                                        item->setIcon(1,QIcon());
                                        treeItem->setState(Item::sNone);
                                    }
                                    else if (action == actionProgress)
                                    {
                                        item->setIcon(1,action->icon());
                                        treeItem->setState(Item::sProgress);
                                    }
                                    else if (action == actionFailure)
                                    {
                                        item->setIcon(1,action->icon());
                                        treeItem->setState(Item::sFailure);
                                    }
                                    else if (action == actionSuccess)
                                    {
                                        item->setIcon(1,action->icon());
                                        treeItem->setState(Item::sSuccess);
                                    }
                                    else if (action == actionDelete)
                                    {
                                        deleteItem(item);
                                    }
                                    else if (action == actionAdd)
                                    {
                                        addItem(qItem);
                                    }
                                }
                                else if (topLevelItemCount()==0)
                                {
                                    addItem(NULL);
                                }
                                break;
        default:    break;
    }
}
Example #2
0
void ToolBarEditor::populateActionList(bool reset)
{
    QStringList names = ActionManager::instance()->toolBarActionNames();
    if(!reset)
    {
        QSettings settings (Qmmp::configFile(), QSettings::IniFormat);
        names = settings.value("Simple/toolbar_actions", names).toStringList();
    }

    for(int id = ActionManager::PLAY; id <= ActionManager::QUIT; ++id)
    {
        QAction *action = ACTION(id);
        if(action->icon().isNull())
            continue;
        QListWidgetItem *item = new QListWidgetItem();
        item->setIcon(action->icon());
        item->setText(action->text().replace("&", ""));
        item->setData(Qt::UserRole, action->objectName());
        if(!names.contains(action->objectName()))
            m_ui->actionsListWidget->addItem(item);
    }

    {
        QListWidgetItem *item = new QListWidgetItem();
        item->setText("-- " + tr("Separator") + " --");
        item->setData(Qt::UserRole, "separator");
        m_ui->actionsListWidget->addItem(item);
    }

    foreach (QString name, names)
    {
        QAction *action = ActionManager::instance()->findChild<QAction *>(name);
        if(action)
        {
            QListWidgetItem *item = new QListWidgetItem();
            item->setIcon(action->icon());
            item->setText(action->text().replace("&", ""));
            item->setData(Qt::UserRole, action->objectName());
            m_ui->activeActionsListWidget->addItem(item);
        }
        else if(name == "separator")
        {
            QListWidgetItem *item = new QListWidgetItem();
            item->setText("-- " + tr("Separator") + " --");
            item->setData(Qt::UserRole, "separator");
            m_ui->activeActionsListWidget->addItem(item);
        }
    }
Example #3
0
void ShortcutsImpl::initTable(MainImpl *main)
{
    QList<QObject*> childrens = main->children();
    QListIterator<QObject*> iterator(childrens);
    int row = 0;

    while( iterator.hasNext() )
    {
        QObject *object = iterator.next();
        QAction *action = qobject_cast<QAction*>(object);

        if (action)
        {
            QString text = action->text().remove("&");

            if ( !text.isEmpty() && !(action->data().toString().contains("Recent|")) )
            {
                QString shortcut = action->shortcut();
                QTableWidgetItem *newItem = new QTableWidgetItem(text);

                newItem->setFlags( Qt::ItemIsSelectable | Qt::ItemIsEnabled );
                newItem->setData(Qt::UserRole, addressToVariant(object));
                newItem->setIcon(action->icon());
                table->setRowCount(row+1);
                table->setItem(row, 0, newItem);
                table->setItem(row++, 1, new QTableWidgetItem(shortcut));
            }
        }
        table->sortItems( 0 );
    }

    QHeaderView *header = table->horizontalHeader();
    header->resizeSection( 0, 230 );
    table->verticalHeader()->hide();
}
Example #4
0
Palette* MuseScore::newNoteHeadsPalette()
      {
      Palette* sp = new Palette;
      sp->setName(QT_TRANSLATE_NOOP("Palette", "Note Heads"));
      sp->setMag(1.3);
      sp->setGrid(33, 36);
      sp->setDrawGrid(true);

      for (int i = 0; i < int(NoteHead::Group::HEAD_GROUPS); ++i) {
            SymId sym = Note::noteHead(0, NoteHead::Group(i), NoteHead::Type::HEAD_HALF);
            // HEAD_BREVIS_ALT shows up only for brevis value
            if (i == int(NoteHead::Group::HEAD_BREVIS_ALT) )
                  sym = Note::noteHead(0, NoteHead::Group(i), NoteHead::Type::HEAD_BREVIS);
            NoteHead* nh = new NoteHead(gscore);
            nh->setSym(sym);
            sp->append(nh, Sym::id2userName(sym));
            }
      Icon* ik = new Icon(gscore);
      ik->setIconType(IconType::BRACKETS);
      Shortcut* s = Shortcut::getShortcut("add-brackets");
      QAction* action = s->action();
      QIcon icon(action->icon());
      ik->setAction("add-brackets", icon);
      sp->append(ik, s->help());
      return sp;
      }
Example #5
0
ToolbarDialog::ToolbarDialog(QWidget* parent)
    : QDialog(parent),m_defaultToolBars()
{
    setupUi(this);

    createDefaultToolBars();
    // populate all available actions
    QList<QAction*> actions = parent->findChildren<QAction*>(QRegExp("action*"));
    QAction* action;
    foreach(action, actions) {
        if (action->actionGroup()->objectName() != "extraGroup")
            continue;
        QListWidgetItem* item = new QListWidgetItem(action->toolTip());
        item->setIcon(action->icon());
        item->setData(Qt::UserRole, QVariant::fromValue((QObject*)action));
        listAllActions->addItem(item);
    }
    // Important to add special Separator
    listAllActions->addItem("Separator");

    QList<QToolBar*> toolbars = parent->findChildren<QToolBar*>();
    QToolBar* toolbar = NULL;
    int index = 0;
    foreach(toolbar, toolbars) {
        index = (int)(toolbar->iconSize().height()/10)-1;
        if (toolbar->objectName() != "keyToolBar")
            comboToolbars->addItem(toolbar->windowTitle(), QVariant::fromValue((QObject*)toolbar));
    }
Example #6
0
    KoGroupButton *addViewButton(KoGroupButton::GroupPosition pos,
                                 Kexi::ViewMode mode, QWidget *parent, const char *slot,
                                 const QString &text, QHBoxLayout *btnLyr)
    {
        if (!window->supportsViewMode(mode)) {
            return 0;
        }
        QAction *a = new KexiToggleViewModeAction(mode, q);
        toggleViewModeActions.insert(mode, a);

        KoGroupButton *btn = new KoGroupButton(pos, parent);
        toggleViewModeButtons.insert(mode, btn);
        connect(btn, SIGNAL(toggled(bool)), q, slot);
        btn->setToolButtonStyle(Qt::ToolButtonTextBesideIcon);
        btn->setText(text);
        btn->setIcon(a->icon());
        QFont f(KGlobalSettings::toolBarFont());
        f.setPixelSize(KexiUtils::smallFont().pixelSize());
        btn->setFont(f);
        btn->setToolTip(a->toolTip());
        btn->setWhatsThis(a->whatsThis());
        btn->setCheckable(true);
        btn->setAutoRaise(true);
        btnLyr->addWidget(btn);
        return btn;
    }
Example #7
0
void ActionsManager::setupLocalAction(QAction *localAction, const QLatin1String &globalAction, bool connectTrigger)
{
	if (!localAction)
	{
		return;
	}

	QAction *action = getAction(globalAction);

	if (action)
	{
		localAction->setCheckable(action->isCheckable());
		localAction->setChecked(action->isChecked());
		localAction->setEnabled(action->isEnabled());
		localAction->setIcon(action->icon());
		localAction->setText(action->text());
		localAction->setShortcut(action->shortcut());
		localAction->setObjectName(action->objectName());

		if (connectTrigger)
		{
			connect(localAction, SIGNAL(triggered()), action, SLOT(trigger()));
		}
	}
}
Example #8
0
void gui_mode::update(){
    /// Clear the menus
    mainWindow()->modeToolbar->clear();
    mainWindow()->modeMenu->clear();

    /// Add the "default" mode action (modes disactivated)
    mainWindow()->modeToolbar->addAction(defaultModeAction);
    mainWindow()->modeMenu->addAction(defaultModeAction);
    modeActionGroup->addAction(defaultModeAction);
    
    /// Re-fill the menu with plugin names and make connections
    foreach(ModePlugin* plugin, pluginManager()->modePlugins()){
        if(!plugin->isApplicable()) continue;
        QAction* action = plugin->action();
        action->setCheckable(true);
        /// Make GUI elements exclusive
        modeActionGroup->addAction(action);
        /// Add to menus and toolbars
        mainWindow()->modeMenu->addAction(action);
        if(!action->icon().isNull())
            mainWindow()->modeToolbar->addAction(action);
    }
    
    /// Remember trackball is always there, thus>1
    bool showtoolbar = (mainWindow()->modeToolbar->children().size() > 1);
    mainWindow()->modeToolbar->setVisible(showtoolbar);
}
void PreferredLineEditWidget::shouldChangePreferredValue()
{
    Akonadi::PreferredLineEditWidget w;
    QAction *act = w.findChild<QAction *>(QStringLiteral("preferredaction"));
    QIcon disabled = act->icon();
    w.setPreferred(true);
    QVERIFY(w.preferred());
    QIcon enabled = act->icon();
    w.setPreferred(false);
    QVERIFY(!w.preferred());
    QCOMPARE(act->icon(), disabled);

    w.setPreferred(true);
    QCOMPARE(act->icon(), enabled);

}
Example #10
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;
}
Example #11
0
void TaskGroup::actionEvent (QActionEvent* e)
{
    QAction *action = e->action();
    switch (e->type()) {
    case QEvent::ActionAdded:
        {
            TaskIconLabel *label = new TaskIconLabel(
                action->icon(), action->text(), this);
            this->addIconLabel(label);
            connect(label,SIGNAL(clicked()),action,SIGNAL(triggered()));
            break;
        }
    case QEvent::ActionChanged:
        {
            // update label when action changes
            QBoxLayout* bl = this->groupLayout();
            int index = this->actions().indexOf(action);
            if (index < 0) break;
            QWidgetItem* item = static_cast<QWidgetItem*>(bl->itemAt(index));
            TaskIconLabel* label = static_cast<TaskIconLabel*>(item->widget());
            label->setTitle(action->text());
            break;
        }
    case QEvent::ActionRemoved:
        {
            // cannot change anything
            break;
        }
    default:
        break;
    }
}
Example #12
0
QIcon QActionProto::icon() const
{
  QAction *item = qscriptvalue_cast<QAction*>(thisObject());
  if (item)
    return item->icon();
  return QIcon();
}
void ToolbarEditor::populateList(QListWidget * w, QList<QAction *> actions_list, bool add_separators) {
	w->clear();

	QAction * action;
	for (int n = 0; n < actions_list.count(); n++) {
		action = static_cast<QAction*> (actions_list[n]);
		if (action) {
			if (!action->objectName().isEmpty()) {
				QListWidgetItem * i = new QListWidgetItem;
				QString text = fixname(action->text(), action->objectName());
				i->setText(text + " ("+ action->objectName() +")");
				QIcon icon = action->icon();
				if (icon.isNull()) {
					icon = Images::icon("empty_icon");
				}
				i->setIcon(icon);
				i->setData(Qt::UserRole, action->objectName());
				w->addItem(i);
			}
			else
			if ((action->isSeparator()) && (add_separators)) {
				QListWidgetItem * i = new QListWidgetItem;
				//i->setText(tr("(separator)"));
				i->setText("---------");
				i->setData(Qt::UserRole, "separator");
				i->setIcon(Images::icon("empty_icon"));
				w->addItem(i);
			}
		}
	}
}
Example #14
0
void ScServer::updateToggleRunningAction()
{
    QAction *targetAction = isRunning() ? mActions[Quit] : mActions[Boot];
    mActions[ToggleRunning]->setText( targetAction->text() );
    mActions[ToggleRunning]->setIcon( targetAction->icon() );
    mActions[ToggleRunning]->setShortcut( targetAction->shortcut() );
}
Example #15
0
KexiFindDialog::KexiFindDialog(QWidget* parent)
        : QDialog(parent,
                  Qt::Dialog | Qt::WindowTitleHint | Qt::WindowSystemMenuHint | Qt::Tool)
        , d(new Private())
{
    setObjectName("KexiFindDialog");
    setupUi(this);
    m_search->setCurrentIndex(
        (int)KexiSearchAndReplaceViewInterface::Options::SearchDown);
    layout()->setMargin(KDialog::marginHint());
    layout()->setSpacing(KDialog::spacingHint());
    QAction *a = KStandardAction::findNext(0, 0, 0);
    m_btnFind->setText(a->text());
    m_btnFind->setIcon(a->icon());
    delete a;
    m_btnClose->setText(KStandardGuiItem::close().text());
    m_btnClose->setIcon(KStandardGuiItem::close().icon());
    connect(m_btnFind, SIGNAL(clicked()), this, SIGNAL(findNext()));
    connect(m_btnClose, SIGNAL(clicked()), this, SLOT(slotCloseClicked()));
    connect(m_btnReplace, SIGNAL(clicked()), this, SIGNAL(replaceNext()));
    connect(m_btnReplaceAll, SIGNAL(clicked()), this, SIGNAL(replaceAll()));
    // clear message after the text is changed
    connect(m_textToFind, SIGNAL(editTextChanged(QString)), this, SLOT(updateMessage(QString)));
    connect(m_textToReplace, SIGNAL(editTextChanged(QString)), this, SLOT(updateMessage(QString)));

    d->replaceMode = true; //to force updating by setReplaceMode()
    setReplaceMode(false);

    setLookInColumnList(QStringList(), QStringList());
}
Example #16
0
    /// Fill the menu with plugin names and make connections
    foreach(FilterPlugin* plugin, pluginManager()->filterPlugins()){
        QAction* action = plugin->action();

        QString pluginName = plugin->name();
        QMenu * assignedMenu = mainWindow()->filterMenu;

        // Check for categories
        if(pluginName.contains("|")){
            QStringList pluginNames = pluginName.split("|");

            action->setText( pluginNames.back() );

            // Try to locate exciting submenu
            QString catName = pluginNames.front();
            QMenu * m = assignedMenu->findChild<QMenu*>( catName );
            if(!m) m = mainWindow()->filterMenu->addMenu(catName);

            assignedMenu = m;
        }

        assignedMenu->addAction(action);
        
        // Action refers to this filter, so we can retrieve it later
        // QAction* action = new QAction(plugin->name(),plugin);

        /// Does the filter have an icon? Add it to the toolbar
        /// @todo add functionality to ModelFilter
        if(!action->icon().isNull())
            mainWindow()->filterToolbar->addAction(action);

        /// Connect after it has been added        
        connect(action,SIGNAL(triggered()),this,SLOT(startFilter()));
    }
Example #17
0
void ScProcess::updateToggleRunningAction()
{
    QAction *targetAction = state() == QProcess::NotRunning ? mActions[Start] : mActions[Stop];

    mActions[ToggleRunning]->setText( targetAction->text() );
    mActions[ToggleRunning]->setIcon( targetAction->icon() );
    mActions[ToggleRunning]->setShortcut( targetAction->shortcut() );
}
Example #18
0
static void addActionsToToolBar(const ActionList &actions, QToolBar *t)
{
    const ActionList::const_iterator cend = actions.constEnd();
    for (ActionList::const_iterator it = actions.constBegin(); it != cend; ++it) {
        QAction *action = *it;
        if (!action->icon().isNull())
            t->addAction(action);
    }
}
void
NavigationTree_UpdatePresenceIcon(EMenuAction eMenuAction_Presence)
	{
	QAction * pAction = PGetMenuAction(eMenuAction_Presence);
	Assert(pAction != NULL);
	if (pAction != NULL)
		{
		g_pwButtonStatusOfNavigationTree->setIcon(pAction->icon());
		g_pwButtonStatusOfNavigationTree->setText(pAction->text());
		}
	}
Example #20
0
void
ITreeItem::TreeItemW_SetIconWithToolTip(EMenuAction eMenuIcon, const QString & sToolTip)
	{
	if (m_paTreeItemW_YZ == NULL)
		return;	// Sometimes the Tree Item is not visible in the Navigation Tree, so there is no need to update its icon or tool tip
	QAction * pAction = PGetMenuAction(eMenuIcon);
	Assert(pAction != NULL);
	if (pAction != NULL)
		m_paTreeItemW_YZ->setIcon(0, pAction->icon());
	m_paTreeItemW_YZ->setToolTip(0, sToolTip);
	}
Example #21
0
QAction* Menu::exec(const QPoint& point)
{
	QAction* action = QMenu::exec(point);
	if (action == nullptr)
	{
		return nullptr;
	}
	QIcon icon = action->icon();
	action->setIcon(ChangeIcon(action, icon));
	return action;
}
Example #22
0
QVariant pActionsModel::data( const QModelIndex& index, int role ) const
{
    QAction* action = this->action( index );

    if ( !action ) {
        return QVariant();
    }

    switch ( role ) {
        case Qt::DecorationRole:
            switch ( index.column() ) {
                case 0:
                    return action->icon();
                default:
                    break;
            }

            break;
        case Qt::DisplayRole:
        case Qt::ToolTipRole:
            switch ( index.column() ) {
                case pActionsModel::Action:
                    return cleanText( action->text() );
                case pActionsModel::Shortcut:
                    return action->shortcut().toString( QKeySequence::NativeText );
                case pActionsModel::DefaultShortcut:
                    return defaultShortcut( action ).toString( QKeySequence::NativeText );
            }

            break;

        case Qt::FontRole: {
            QFont font = action->font();

            if ( action->menu() ) {
                font.setBold( true );
            }

            return font;
        }

        /*case Qt::BackgroundRole:
            return action->menu() ? QBrush( QColor( 0, 0, 255, 20 ) ) : QVariant();*/

        case pActionsModel::MenuRole:
            return QVariant::fromValue( action->menu() );
        case pActionsModel::ActionRole:
            return QVariant::fromValue( action );
    }

    return QVariant();
}
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;
}
Example #24
0
void PopupProxy::tryInsertItem( HistoryItem const * const item,
                                int& remainingHeight,
                                const int index )
{
    QAction *action = new QAction(m_proxy_for_menu);
    QPixmap image( item->image() );
    if ( image.isNull() ) {
        // Squeeze text strings so that do not take up the entire screen (or more)
        QString text = m_proxy_for_menu->fontMetrics().elidedText( item->text().simplified(), Qt::ElideMiddle, m_menu_width );
        text.replace( '&', "&&" );
        action->setText(text);
    } else {
#if 0 // not used because QAction#setIcon does not respect this size; it does scale anyway. TODO: find a way to set a bigger image
        const QSize max_size( m_menu_width,m_menu_height/4 );
        if ( image.height() > max_size.height() || image.width() > max_size.width() ) {
            image = image.scaled( max_size, Qt::KeepAspectRatio, Qt::SmoothTransformation );
        }
#endif
        action->setIcon(QIcon(image));
    }

    action->setData(item->uuid());

    // if the m_proxy_for_menu is a submenu (aka a "More" menu) then it may the case, that there is no other action in that menu yet.
    QAction *before = index < m_proxy_for_menu->actions().count() ? m_proxy_for_menu->actions().at(index) : 0;
    // insert the new action to the m_proxy_for_menu
    m_proxy_for_menu->insertAction(before, action);

    // Determine height of a menu item.
    QStyleOptionMenuItem style_options;
    // It would be much easier to use QMenu::initStyleOptions. But that is protected, so until we have a better
    // excuse to subclass that, I'd rather implement this manually.
    // Note 2 properties, tabwidth and maxIconWidth, are not available from the public interface, so those are left out (probably not 
    // important for height. Also, Exlsive checkType is disregarded as  I don't think we will ever use it)
    style_options.initFrom(m_proxy_for_menu);
    style_options.checkType = action->isCheckable() ? QStyleOptionMenuItem::NonExclusive : QStyleOptionMenuItem::NotCheckable;
    style_options.checked = action->isChecked();
    style_options.font = action->font();
    style_options.icon = action->icon();
    style_options.menuHasCheckableItems = true;
    style_options.menuRect = m_proxy_for_menu->rect();
    style_options.text = action->text();

    int font_height = QFontMetrics(m_proxy_for_menu->fontMetrics()).height();

    int itemheight = m_proxy_for_menu->style()->sizeFromContents(QStyle::CT_MenuItem,
                                                              &style_options,
                                                              QSize( 0, font_height ),
                                                              m_proxy_for_menu).height();
    // Subtract the used height
    remainingHeight -= itemheight;
}
Example #25
0
void populateIconPalette(Palette* p, const IconAction* a)
      {
      while (a->subtype != IconType::NONE) {
            Icon* ik = new Icon(gscore);
            ik->setIconType(a->subtype);
            Shortcut* s = Shortcut::getShortcut(a->action);
            QAction* action = s->action();
            QIcon icon(action->icon());
            ik->setAction(a->action, icon);
            p->append(ik, s->help());
            ++a;
            }
      }
Example #26
0
static void populateIconPalette(Palette* p, const IconAction* a)
      {
      while (a->subtype != -1) {
            Icon* ik = new Icon(gscore);
            ik->setSubtype(a->subtype);
            Shortcut* s = getShortcut(a->action);
            QAction* action = getAction(s);
            QIcon icon(action->icon());
            ik->setAction(a->action, icon);
            p->append(ik, s->help);
            ++a;
            }
      }
Example #27
0
void KeysPage::init() {
	QStringList ids = storage_->actionIDs();
	foreach (QString id, ids) {
		QAction* a = storage_->action(id);
		if ( NULL != a ) {
			QStringList list;
			list << ""<< a->text() << a->shortcut().toString();
			QTreeWidgetItem* item = new QTreeWidgetItem(list);
			item->setIcon(0, a->icon());
			item->setData(3, Qt::UserRole + 1, id);
			ui.keysTree->addTopLevelItem(item);
		}
	}
Example #28
0
void KeysPage::init() {
	QStringList ids = storage_->actionIDs();
	foreach (QString id, ids) {
		QAction* a = storage_->action(id);
		if ( NULL != a ) {
			QStringList list;
			// let's remove "&" from action's text to fix #6: Shortcut manager shows extra "&"
			list << ""<< a->text().replace("&", "") << a->shortcut().toString();
			QTreeWidgetItem* item = new QTreeWidgetItem(list);
			item->setIcon(0, a->icon());
			item->setData(3, Qt::UserRole + 1, id);
			ui.keysTree->addTopLevelItem(item);
		}
	}
Example #29
0
void ToolbarEditor::populateLists(const std::list<const char*>& all, std::list<const char*>* current)
      {
      actionList->clear();
      availableList->clear();
      for (auto i : *current) {
            QAction* a = getAction(i);
            QListWidgetItem* item;
            if (a)
                  item = new QListWidgetItem(a->icon(), QString(i));
            else
                  item = new QListWidgetItem(QString(i));
            item->setData(Qt::UserRole, QVariant::fromValue((void*)i));
            actionList->addItem(item);
            }
      for (auto i : all) {
            bool found = false;
            for (auto k : *current) {
                  if (strcmp(k, i) == 0) {
                        found = true;
                        break;
                        }
                  }
            if (!found) {
                  QAction* a = getAction(i);
                  QListWidgetItem* item;
                  if (a)
                        item = new QListWidgetItem(a->icon(), QString(i));
                  else
                        item = new QListWidgetItem(QString(i));
                  item->setData(Qt::UserRole, QVariant::fromValue((void*)i));
                  availableList->addItem(item);
                  }
            }
      QListWidgetItem* item = new QListWidgetItem(tr("spacer"));
      item->setData(Qt::UserRole, QVariant::fromValue((void*)""));
      availableList->addItem(item);
      }
Example #30
0
QVariant ActionModel::data(const QModelIndex &index, int role) const
{
  if (!index.isValid())
    return QVariant();

  QMutexLocker lock(Probe::objectLock());
  QAction *action = m_actions.at(index.row());
  if (!Probe::instance()->isValidObject(action))
    return QVariant();

  const int column = index.column();
  if (role == Qt::DisplayRole) {
    switch (column) {
    case AddressColumn:
      return Util::addressToString(action);
    case NameColumn:
      return action->text();
    case CheckablePropColumn:
      return action->isCheckable();
    case CheckedPropColumn:
      return VariantHandler::displayString(action->isChecked());
    case PriorityPropColumn:
      return Util::enumToString(action->priority(), 0, action);
    case ShortcutsPropColumn:
      return toString(action->shortcuts());
    default:
      return QVariant();
    }
  } else if (role == Qt::DecorationRole) {
    if (column == NameColumn) {
      return action->icon();
    } else if (column == ShortcutsPropColumn && m_duplicateFinder->hasAmbiguousShortcut(action)) {
      QIcon icon = QIcon::fromTheme(QStringLiteral("dialog-warning"));
      if (!icon.isNull()) {
        return icon;
      } else {
        return QColor(Qt::red);
      }
    }
  } else if (role == Qt::ToolTipRole) {
    if (column == ShortcutsPropColumn && m_duplicateFinder->hasAmbiguousShortcut(action)) {
      return tr("Warning: Ambiguous shortcut detected.");
    }
  } else if (role == ObjectModel::ObjectRole) {
    return QVariant::fromValue<QObject*>(action);
  }

  return QVariant();
}