当前位置: 首页>>代码示例>>C++>>正文


C++ Shortcut类代码示例

本文整理汇总了C++中Shortcut的典型用法代码示例。如果您正苦于以下问题:C++ Shortcut类的具体用法?C++ Shortcut怎么用?C++ Shortcut使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了Shortcut类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: NoteHead

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;
      }
开发者ID:jasonmarkbeaton,项目名称:MuseScore,代码行数:26,代码来源:menus.cpp

示例2: qDeleteAll

void PluginManager::init()
      {
      //
      // initialize local shortcut table
      //    we need a deep copy to be able to rewind all
      //    changes on "Abort"
      //
      qDeleteAll(localShortcuts);
      localShortcuts.clear();
      foreach(const Shortcut* s, Shortcut::shortcuts())
            localShortcuts[s->key()] = new Shortcut(*s);
      shortcutsChanged = false;

      preferences.updatePluginList();
      int n = preferences.pluginList.size();
      pluginList->clear();
      for (int i = 0; i < n; ++i) {
            PluginDescription& d = preferences.pluginList[i];
            Shortcut* s = &d.shortcut;
            localShortcuts[s->key()] = new Shortcut(*s);

            QListWidgetItem* item = new QListWidgetItem(QFileInfo(d.path).completeBaseName(),  pluginList);
            item->setFlags(item->flags() | Qt::ItemIsEnabled);
            item->setCheckState(d.load ? Qt::Checked : Qt::Unchecked);
            item->setData(Qt::UserRole, i);
            }
      prefs = preferences;
      if (n) {
            pluginList->setCurrentRow(0);
            pluginListItemChanged(pluginList->item(0), 0);
            }
      connect(pluginList, SIGNAL(itemChanged(QListWidgetItem*)), SLOT(pluginLoadToggled(QListWidgetItem*)));
      connect(pluginList, SIGNAL(currentItemChanged(QListWidgetItem*, QListWidgetItem*)),
         SLOT(pluginListItemChanged(QListWidgetItem*, QListWidgetItem*)));
      }
开发者ID:Fyrult,项目名称:MuseScore,代码行数:35,代码来源:pluginManager.cpp

示例3: cmd

void QmlPlugin::cmd(const QString& s)
      {
      Shortcut* sc = Shortcut::getShortcut(s.toLatin1().data());
      if (sc)
            msc->cmd(sc->action());
      else
            printf("QmlPlugin:cmd: not found <%s>\n", qPrintable(s));
      }
开发者ID:AndresDose,项目名称:MuseScore,代码行数:8,代码来源:qmlplugin.cpp

示例4: loadDefaultShortcuts

void Shortcut::resetToDefault()
      {
      QList<Shortcut1*> sl = loadDefaultShortcuts();
      foreach(Shortcut1* sc, sl) {
            Shortcut* s = getShortcut(sc->key);
            if (s) {
                  s->setKeys(sc->keys);
                  s->setStandardKey(sc->standardKey);
                  }
            }
开发者ID:DrAwkward2592,项目名称:MuseScore,代码行数:10,代码来源:shortcut.cpp

示例5: f

void Shortcut::load()
      {
      QFile f(dataPath + "/shortcuts.xml");
      if (!f.exists())
            f.setFileName(":/data/shortcuts.xml");
      if (!f.open(QIODevice::ReadOnly)) {
            qDebug("Cannot open shortcuts <%s>", qPrintable(f.fileName()));
            return;
            }
      if (MScore::debugMode)
            qDebug("read shortcuts from <%s>", qPrintable(f.fileName()));

      XmlReader e(&f);

      while (e.readNextStartElement()) {
            if (e.name() == "Shortcuts") {
                  while (e.readNextStartElement()) {
                        if (e.name() == "SC") {
                              Shortcut* sc = 0;
                              while (e.readNextStartElement()) {
                                    const QStringRef& tag(e.name());
                                    if (tag == "key") {
                                          QString val(e.readElementText());
                                          sc = getShortcut(val.toLatin1().data());
                                          if (!sc)
                                                qDebug("cannot find shortcut <%s>", qPrintable(val));
                                          else
                                                sc->clear();
                                          }
                                    else if (tag == "std") {
                                          int i = e.readInt();
                                          if(sc)
                                                sc->_standardKey = QKeySequence::StandardKey(i);
                                          }
                                    else if (tag == "seq") {
                                          QString s = e.readElementText();
                                          if(sc)
                                                sc->_keys.append(Shortcut::keySeqFromString(s, QKeySequence::PortableText));
//                                          sc->_keys.append(QKeySequence::fromString(e.readElementText(), QKeySequence::PortableText));
                                          }
                                    else
                                          e.unknown();
                                    }
                              }
                        else
                              e.unknown();
                        }
                  }
            else
                  e.unknown();
            }
      dirty = false;
      }
开发者ID:DrAwkward2592,项目名称:MuseScore,代码行数:53,代码来源:shortcut.cpp

示例6: f

void Shortcut::load()
      {
      QFile f(dataPath + "/shortcuts.xml");
      if (!f.exists())
            f.setFileName(":/data/shortcuts.xml");
      if (!f.open(QIODevice::ReadOnly)) {
            printf("cannot open shortcuts\n");
            return;
            }
      QDomDocument doc;
      int line, column;
      QString err;
      if (!doc.setContent(&f, false, &err, &line, &column)) {
            printf("error reading shortcuts.xml at line %d column %d: %s\n",
               line, column, qPrintable(err));
            return;
            }
      f.close();

      QString key;
      for (QDomElement e = doc.documentElement(); !e.isNull(); e = e.nextSiblingElement()) {
            if (e.tagName() == "Shortcuts") {
                  for (QDomElement ee = e.firstChildElement(); !ee.isNull(); ee = ee.nextSiblingElement()) {
                        if (ee.tagName() == "SC") {
                              Shortcut* sc = 0;
                              for (QDomElement eee = ee.firstChildElement(); !eee.isNull(); eee = eee.nextSiblingElement()) {
                                    const QString& tag(eee.tagName());
                                    const QString& val(eee.text());
                                    if (tag == "key") {
                                          sc = getShortcut(val.toAscii().data());
                                          if (!sc) {
                                                printf("cannot find shortcut <%s>\n", qPrintable(val));
                                                break;
                                                }
                                          sc->clear();
                                          }
                                    else if (tag == "std")
                                          sc->_standardKey = QKeySequence::StandardKey(val.toInt());
                                    else if (tag == "seq")
                                          sc->_keys.append(QKeySequence::fromString(val, QKeySequence::PortableText));
                                    else
                                          domError(eee);
                                    }
                              }
                        else
                              domError(ee);
                        }
                  }
            else
                  domError(e);
            }
      dirty = false;
      }
开发者ID:klushund,项目名称:MuseScore,代码行数:53,代码来源:shortcut.cpp

示例7: add_keyboard_shortcut_to_quicktool

Accelerator* add_keyboard_shortcut_to_quicktool(const char* shortcut_string, tools::Tool* tool)
{
    Shortcut* shortcut = get_keyboard_shortcut_for_quicktool(tool);
    if (!shortcut) {
        shortcut = new Shortcut(Shortcut::Type::EditorQuicktool);
        shortcut->tool = tool;

        shortcuts->push_back(shortcut);
    }

    shortcut->add_shortcut(shortcut_string);
    return shortcut->accel;
}
开发者ID:Julien-B,项目名称:aseprite,代码行数:13,代码来源:gui.cpp

示例8: add_keyboard_shortcut_to_spriteeditor

Accelerator* add_keyboard_shortcut_to_spriteeditor(const char* shortcut_string, const char* action_name)
{
    Shortcut* shortcut = get_keyboard_shortcut_for_spriteeditor(action_name);
    if (!shortcut) {
        shortcut = new Shortcut(Shortcut::Type::SpriteEditor);
        shortcut->action = action_name;

        shortcuts->push_back(shortcut);
    }

    shortcut->add_shortcut(shortcut_string);
    return shortcut->accel;
}
开发者ID:Julien-B,项目名称:aseprite,代码行数:13,代码来源:gui.cpp

示例9: populateIconPalette

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;
            }
      }
开发者ID:jasonmarkbeaton,项目名称:MuseScore,代码行数:13,代码来源:menus.cpp

示例10: add_keyboard_shortcut_to_execute_command

Accelerator* add_keyboard_shortcut_to_execute_command(const char* shortcut_string,
        const char* command_name, Params* params, KeyContext keyContext)
{
    Shortcut* shortcut = get_keyboard_shortcut_for_command(command_name, params);
    if (!shortcut) {
        shortcut = new Shortcut(Shortcut::Type::ExecuteCommand);
        shortcut->command = CommandsModule::instance()->getCommandByName(command_name);
        shortcut->params = params ? params->clone(): new Params;
        shortcut->keycontext = keyContext;
        shortcuts->push_back(shortcut);
    }
    shortcut->add_shortcut(shortcut_string);
    return shortcut->accel;
}
开发者ID:Julien-B,项目名称:aseprite,代码行数:14,代码来源:gui.cpp

示例11: f

void Shortcut::load()
      {
      QFile f(dataPath + "/shortcuts.xml");
      if (!f.exists())
            f.setFileName(":/data/shortcuts.xml");
      if (!f.open(QIODevice::ReadOnly)) {
            printf("cannot open shortcuts\n");
            return;
            }

      XmlReader e(&f);

      QString key;
      while (e.readNextStartElement()) {
            if (e.name() == "Shortcuts") {
                  while (e.readNextStartElement()) {
                        if (e.name() == "SC") {
                              Shortcut* sc = 0;
                              while (e.readNextStartElement()) {
                                    const QStringRef& tag(e.name());
                                    if (tag == "key") {
                                          QString val(e.readElementText());
                                          sc = getShortcut(val.toLatin1().data());
                                          if (!sc) {
                                                printf("cannot find shortcut <%s>\n", qPrintable(val));
                                                break;
                                                }
                                          sc->clear();
                                          }
                                    else if (tag == "std")
                                          sc->_standardKey = QKeySequence::StandardKey(e.readInt());
                                    else if (tag == "seq")
                                          sc->_keys.append(QKeySequence::fromString(e.readElementText(), QKeySequence::PortableText));
                                    else if (tag == "code")
                                          sc->_keys.append(QKeySequence(e.readInt()));
                                    else
                                          e.unknown();
                                    }
                              }
                        else
                              e.unknown();
                        }
                  }
            else
                  e.unknown();
            }
      dirty = false;
      }
开发者ID:bojan88,项目名称:MuseScore,代码行数:48,代码来源:shortcut.cpp

示例12: QTC_ASSERT

/*!
    Removes the knowledge about a shortcut under the specified \a id.

    Usually you do not need to unregister shortcuts. The only valid use case for unregistering
    shortcuts, is for shortcuts that represent user definable actions. If the user removes such an action,
    a corresponding shortcut also has to be unregistered from the action manager,
    to make it disappear from shortcut settings etc.
*/
void ActionManager::unregisterShortcut(Id id)
{
    Shortcut *sc = 0;
    CommandPrivate *c = d->m_idCmdMap.value(id, 0);
    QTC_ASSERT(c, return);
    sc = qobject_cast<Shortcut *>(c);
    if (!sc) {
        qWarning() << "unregisterShortcut: id" << id.name()
                   << "is registered with a different command type.";
        return;
    }
    delete sc->shortcut();
    d->m_idCmdMap.remove(id);
    delete sc;
    emit m_instance->commandListChanged();
}
开发者ID:edwardZhang,项目名称:qt-creator,代码行数:24,代码来源:actionmanager.cpp

示例13: Init

void Shortcut::Init(){
	lastkb = NULL;

	// install defaults
	InstallDefaults();

	YPreferences prefs(SETTINGS_DIR"/KeyBindings");
	if(prefs.InitCheck() == B_OK){
		// Init from prefs file
		const char *ID = NULL;
		int32 key, keyAlt;
		int32 mod, modAlt;
		uint32 message;
		bool menuItem;
		int32 i = 0;
		while(prefs.FindString("IkbID",i,&ID) == B_OK){
			if(prefs.FindInt32("IkbKey",i,&key) != B_OK)			key = 0;
			if(prefs.FindInt32("IkbMod",i,&mod) != B_OK)					mod = 0;
			if(prefs.FindInt32("IkbKeyAlt",i,&keyAlt) != B_OK)		keyAlt = 0;
			if(prefs.FindInt32("IkbModAlt",i,&modAlt) != B_OK)				modAlt = 0;
			if(prefs.FindInt32("IkbMessage",i,(int32*)&message) != B_OK)	message = 0;
			if(prefs.FindBool("IkbMenu",i,&menuItem) != B_OK)				menuItem = 0;

			char *I = new char[strlen(ID)+1]; strcpy(I,ID);
			KeyBind.Install(menuItem, I, key, mod, keyAlt, modAlt, message);
			i++;
		}
	}
}
开发者ID:BackupTheBerlios,项目名称:beae-svn,代码行数:29,代码来源:Shortcut.cpp

示例14: get_selected_quicktool

tools::Tool* get_selected_quicktool(tools::Tool* currentTool)
{
    if (currentTool && currentTool->getInk(0)->isSelection()) {
        Accelerator* copyselection_accel = get_accel_to_copy_selection();
        if (copyselection_accel && copyselection_accel->checkFromAllegroKeyArray())
            return NULL;
    }

    tools::ToolBox* toolbox = App::instance()->getToolBox();

    // Iterate over all tools
    for (tools::ToolIterator it = toolbox->begin(); it != toolbox->end(); ++it) {
        Shortcut* shortcut = get_keyboard_shortcut_for_quicktool(*it);

        // Collect all tools with the pressed keyboard-shortcut
        if (shortcut && shortcut->is_pressed_from_key_array()) {
            return *it;
        }
    }

    return NULL;
}
开发者ID:Julien-B,项目名称:aseprite,代码行数:22,代码来源:gui.cpp

示例15: qWarning

Command *ActionManagerPrivate::registerShortcut(QShortcut *shortcut, const QString &id, const QList<int> &context)
{
    Shortcut *sc = 0;
    int uid = UniqueIDManager::instance()->uniqueIdentifier(id);

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

    if (sc->shortcut()) {
        qWarning() << "registerShortcut: action already registered (id" << id << ".";
        return sc;
    }

    if (!hasContext(context)) {
        shortcut->setEnabled(false);
    }
    shortcut->setObjectName(id);
    shortcut->setParent(m_mainWnd);
    sc->setShortcut(shortcut);

    if (context.isEmpty()) {
        sc->setContext(QList<int>() << 0);
    } else {
        sc->setContext(context);
    }

    sc->setKeySequence(shortcut->key());
    sc->setDefaultKeySequence(QKeySequence());

    return sc;
}
开发者ID:MorS25,项目名称:OpenPilot,代码行数:39,代码来源:actionmanager.cpp


注:本文中的Shortcut类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。