⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 q3accel.cpp

📁 奇趣公司比较新的qt/emd版本
💻 CPP
📖 第 1 页 / 共 3 页
字号:
*/void Q3Accel::setEnabled(bool enable){    d->enabled = enable;}/*!    Returns the number of accelerator items in this accelerator.*/uint Q3Accel::count() const{    return d->aitems.count();}static int get_seq_id(){    static int seq_no = -2;  // -1 is used as return value in findKey()    return seq_no--;}/*!    Inserts an accelerator item and returns the item's identifier.    \a key is a key code and an optional combination of SHIFT, CTRL    and ALT. \a id is the accelerator item id.    If \a id is negative, then the item will be assigned a unique    negative identifier less than -1.    \code        Q3Accel *a = new Q3Accel(myWindow);	   // create accels for myWindow        a->insertItem(CTRL + Key_P, 200);	   // Ctrl+P, e.g. to print document        a->insertItem(ALT + Key_X, 201);	   // Alt+X, e.g. to quit        a->insertItem(UNICODE_ACCEL + 'q', 202); // Unicode 'q', e.g. to quit        a->insertItem(Key_D);			   // gets a unique negative id < -1        a->insertItem(CTRL + SHIFT + Key_P);	   // gets a unique negative id < -1    \endcode*/int Q3Accel::insertItem(const QKeySequence& key, int id){    if (id == -1)        id = get_seq_id();    d->aitems.insert(0, new Q3AccelItem(key,id));    return id;}/*!    Removes the accelerator item with the identifier \a id.*/void Q3Accel::removeItem(int id){    if (find_id(d->aitems, id))        d->aitems.remove();}/*!    Removes all accelerator items.*/void Q3Accel::clear(){    d->aitems.clear();}/*!    Returns the key sequence of the accelerator item with identifier    \a id, or an invalid key sequence (0) if the id cannot be found.*/QKeySequence Q3Accel::key(int id){    Q3AccelItem *item = find_id(d->aitems, id);    return item ? item->key : QKeySequence(0);}/*!    Returns the identifier of the accelerator item with the key code    \a key, or -1 if the item cannot be found.*/int Q3Accel::findKey(const QKeySequence& key) const{    Q3AccelItem *item = find_key(d->aitems, key);    return item ? item->id : -1;}/*!    Returns true if the accelerator item with the identifier \a id is    enabled. Returns false if the item is disabled or cannot be found.    \sa setItemEnabled(), isEnabled()*/bool Q3Accel::isItemEnabled(int id) const{    Q3AccelItem *item = find_id(d->aitems, id);    return item ? item->enabled : false;}/*!    Enables the accelerator item with the identifier \a id if \a    enable is true, and disables item \a id if \a enable is false.    To work, an item must be enabled and be in an enabled Q3Accel.    \sa isItemEnabled(), isEnabled()*/void Q3Accel::setItemEnabled(int id, bool enable){    Q3AccelItem *item = find_id(d->aitems, id);    if (item)        item->enabled = enable;}/*!    Connects the accelerator item \a id to the slot \a member of \a    receiver. Returns true if the connection is successful.    \code        a->connectItem(201, mainView, SLOT(quit()));    \endcode    Of course, you can also send a signal as \a member.    Normally accelerators are connected to slots which then receive    the \c activated(int id) signal with the id of the accelerator    item that was activated. If you choose to connect a specific    accelerator item using this function, the \c activated() signal is    emitted if the associated key sequence is pressed but no \c    activated(int id) signal is emitted.    \sa disconnectItem(), QObject::connect()*/bool Q3Accel::connectItem(int id, const QObject *receiver, const char *member){    Q3AccelItem *item = find_id(d->aitems, id);    if (item) {        if (!item->signal) {            item->signal = new Q3Signal;            Q_CHECK_PTR(item->signal);        }        return item->signal->connect(receiver, member);    }    return false;}/*!    Disconnects the accelerator item identified by \a id from    the function called \a member in the \a receiver object.    Returns true if the connection existed and the disconnect    was successful.    \sa connectItem(), QObject::disconnect()*/bool Q3Accel::disconnectItem(int id, const QObject *receiver,                             const char *member){    Q3AccelItem *item = find_id(d->aitems, id);    if (item && item->signal)        return item->signal->disconnect(receiver, member);    return false;}void Q3AccelPrivate::activate(Q3AccelItem* item){#ifndef QT_NO_WHATSTHIS    if (QWhatsThis::inWhatsThisMode() && !ignorewhatsthis) {        QWhatsThis::showText(QCursor::pos(), item->whatsthis);        return;    }#endif    if (item->signal)        item->signal->activate();    else        emit parent->activated(item->id);}void Q3AccelPrivate::activateAmbiguously(Q3AccelItem* item){    if (item->signal)        item->signal->activate();    else        emit parent->activatedAmbiguously(item->id);}/*!    Returns the shortcut key sequence for \a str, or an invalid key    sequence (0) if \a str has no shortcut sequence.    For example, shortcutKey("E&xit") returns QKeySequence(Qt::ALT +    Qt::Key_X), shortcutKey("&Quit") returns QKeySequence(Qt::ALT +    Qt::Key_Q), and shortcutKey("Quit") returns QKeySequence().*/QKeySequence Q3Accel::shortcutKey(const QString &str){    if(qt_accel_no_shortcuts)        return QKeySequence();    int p = 0;    while (p >= 0) {        p = str.find(QLatin1Char('&'), p) + 1;        if (p <= 0 || p >= (int)str.length())            return 0;        if (str[p] != QLatin1Char('&')) {            QChar c = str[p];            if (c.isPrint()) {                char ltr = c.upper().latin1();                if (ltr >= (char)Key_A && ltr <= (char)Key_Z)                    c = QLatin1Char(ltr);                else                    c = c.lower();                return QKeySequence(c.unicode() + ALT + UNICODE_ACCEL);            }        }        p++;    }    return QKeySequence();}/*! \obsolete   Creates an accelerator string for the key \a k.   For instance CTRL+Key_O gives "Ctrl+O". The "Ctrl" etc.   are translated (using QObject::tr()) in the "Q3Accel" context.   The function is superfluous. Cast the QKeySequence \a k to a   QString for the same effect.*/QString Q3Accel::keyToString(QKeySequence k){    return (QString) k;}/*!\obsolete  Returns an accelerator code for the string \a s. For example  "Ctrl+O" gives CTRL+UNICODE_ACCEL+'O'. The strings "Ctrl",  "Shift", "Alt" are recognized, as well as their translated  equivalents in the "Q3Accel" context (using QObject::tr()). Returns 0  if \a s is not recognized.  This function is typically used with \link QObject::tr() tr  \endlink(), so that accelerator keys can be replaced in  translations:  \code    Q3PopupMenu *file = new Q3PopupMenu(this);    file->insertItem(p1, tr("&Open..."), this, SLOT(open()),                      Q3Accel::stringToKey(tr("Ctrl+O", "File|Open")));  \endcode  Notice the "File|Open" translator comment. It is by no means  necessary, but it provides some context for the human translator.  The function is superfluous. Construct a QKeySequence from the  string \a s for the same effect.  \sa QObject::tr(), {Internationalization with Qt}*/QKeySequence Q3Accel::stringToKey(const QString & s){    return QKeySequence(s);}/*!    Sets a What's This help text for the accelerator item \a id to \a    text.    The text will be shown when the application is in What's This mode    and the user hits the accelerator key.    To set What's This help on a menu item (with or without an    accelerator key), use Q3MenuData::setWhatsThis().    \sa whatsThis(), QWhatsThis::inWhatsThisMode(), QAction::setWhatsThis()*/void Q3Accel::setWhatsThis(int id, const QString& text){    Q3AccelItem *item = find_id(d->aitems, id);    if (item)        item->whatsthis = text;}/*!    Returns the What's This help text for the specified item \a id or    an empty string if no text has been specified.    \sa setWhatsThis()*/QString Q3Accel::whatsThis(int id) const{    Q3AccelItem *item = find_id(d->aitems, id);    return item? item->whatsthis : QString();}/*!\internal */void Q3Accel::setIgnoreWhatsThis(bool b){    d->ignorewhatsthis = b;}/*!\internal */bool Q3Accel::ignoreWhatsThis() const{    return d->ignorewhatsthis;}/*!    \fn void Q3Accel::repairEventFilter()    \internal*/

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -