이 페이지에서

Core::Command Class

class Core::Command

Command 클래스는 메뉴 항목, 도구 버튼 또는 바로 가기 등의 동작을 나타냅니다. 더 보기...

Header: #include <coreplugin/actionmanager/command.h>
Inherits: QObject

공개 유형

enum CommandAttribute { CA_UpdateText, CA_UpdateIcon, CA_Hide, CA_NonConfigurable }
flags CommandAttributes

공개 함수

QAction *action() const
void augmentActionWithShortcutToolTip(QAction *a) const
Core::Context context() const
QList<QKeySequence> defaultKeySequences() const
QString description() const
bool hasAttribute(Core::Command::CommandAttribute attribute) const
bool isActive() const
bool isScriptable() const
QKeySequence keySequence() const
QList<QKeySequence> keySequences() const
void removeAttribute(Core::Command::CommandAttribute attribute)
void setAttribute(Core::Command::CommandAttribute attribute)
void setDefaultKeySequence(const QKeySequence &key)
void setDefaultKeySequences(const QList<QKeySequence> &keys)
void setDescription(const QString &text)
void setTouchBarIcon(const QIcon &icon)
void setTouchBarText(const QString &text)
QString stringWithAppendedShortcut(const QString &string) const
QIcon touchBarIcon() const
QString touchBarText() const

신호

정적 공용 멤버

QAction *createActionWithShortcutToolTip(Utils::Id commandId, QObject *parent)
QToolButton *createToolButtonWithShortcutToolTip(Utils::Id commandId, QWidget *parent = nullptr)
QToolButton *toolButtonWithAppendedShortcut(QAction *action, Core::Command *cmd)
QToolButton *toolButtonWithAppendedShortcut(QAction *action, Utils::Id commandId)

상세 설명

Command 객체를 직접 생성하는 것이 아니라, ` ActionManager::registerAction()`를 사용하여 액션을 등록하고 Command를 가져옵니다. Command 객체는 사용자에게 표시되는 액션과 그 속성을 나타냅니다. 동일한 ID(그러나 서로 다른 컨텍스트)로 여러 액션이 등록된 경우, 반환되는 Command는 해당 액션들 간에 공유되는 것입니다.

Command에는 두 가지 기본 속성이 있습니다: 기본 단축키 목록과 기본 텍스트입니다. 기본 단축키는 사용자가 Command가 나타내는 활성 동작을 실행하는 데 사용할 수 있는 키 조합입니다. 이 목록의 첫 번째 단축키는 주요 단축키로, 예를 들어 툴팁이나 메뉴에도 표시됩니다. 기본 텍스트는 키보드 단축키 환경 설정 패널에서 Command를 표시하는 데 사용됩니다. 기본 텍스트가 비어 있으면 표시되는 동작의 텍스트가 사용됩니다.

사용자에게 표시되는 액션은 활성 액션(있는 경우)의 상태를 반영하도록 업데이트됩니다. 하지만 성능상의 이유로 기본적으로 활성화 및 표시 상태만 고려됩니다. 해당 속성( attribute)을 설정하여 명령이 액션의 아이콘과 텍스트도 함께 업데이트하도록 지정할 수 있습니다.

활성 액션이 없는 경우, 표시된 액션의 기본 동작은 비활성화되는 것입니다. 명령어의 ` attributes`을 통해 이 동작을 변경하여 표시된 액션이 대신 숨겨지도록 할 수 있습니다.

Core::Command 와 Core::ActionManager 가 어떻게 상호 작용하는지에 대한 개요는 ‘액션 관리자 및 명령’을 참조하십시오.

‘ Core::ActionManager ’ 및 ‘액션 관리자 및 명령’항목도 참조하십시오 .

멤버 유형 문서

enum Command::CommandAttribute
flags Command::CommandAttributes

이 열거형은 활성 액션이 변경될 때 사용자에게 표시되는 액션이 어떻게 업데이트되는지를 정의합니다. 기본값은 활성화된 상태와 표시 상태를 업데이트하고, 활성 액션이 없을 때는 사용자에게 표시되는 액션을 비활성화하는 것입니다.

상수값설명
Core::Command::CA_UpdateText2액션 텍스트도 업데이트합니다.
Core::Command::CA_UpdateIcon4액션 아이콘도 함께 업데이트합니다.
Core::Command::CA_Hide1활성화된 액션이 없을 때, 단순히 비활성화하는 대신 사용자에게 표시되는 액션을 숨깁니다.
Core::Command::CA_NonConfigurable8이 명령의 키보드 단축키를 사용자가 구성할 수 없음을 나타내는 플래그입니다.

CommandAttributes 유형은 QFlags<CommandAttribute>에 대한 typedef입니다. 이 유형은 CommandAttribute 값들의 OR 조합을 저장합니다.

멤버 함수 문서

QAction *Command::action() const

이 명령에 대해 사용자에게 표시되는 액션을 반환합니다. 이 액션을 사용하여, 예를 들어 도구 버튼 등에 배치할 수 있습니다. 이 액션은 ` triggered() ` 및 ` toggled() ` 신호를 이 명령에 대해 현재 활성화된 액션으로 자동으로 전달합니다. 또한 툴팁에 현재 기본 키보드 단축키를 표시하며(활성화된 액션의 툴팁 외에도), 현재 컨텍스트에 활성화된 액션이 없을 경우 비활성화되거나 숨겨집니다.

[signal] void Command::activeStateChanged()

이 신호는 명령의 활성 상태가 변경될 때 발생합니다.

void Command::augmentActionWithShortcutToolTip(QAction *a) const

a 액션의 툴팁을, 해당 액션의 텍스트에 명령어의 기본 키보드 단축키를 추가한 형태로 설정합니다. 기본 키보드 단축키나 액션의 텍스트가 변경될 때마다 툴팁이 자동으로 업데이트됩니다.

stringWithAppendedShortcut() 및 createActionWithShortcutToolTip()도 참조하십시오 .

Core::Context Command::context() const

이 명령어의 컨텍스트를 반환합니다.

[static] QAction *Command::createActionWithShortcutToolTip(Utils::Id commandId, QObject *parent)

commandId 에서 지정된 명령의 아이콘, 아이콘 텍스트 및 텍스트를 가진 새로운 QAction 객체를 반환합니다. 버튼의 부모 객체를 parent 로 설정합니다. 액션의 툴팁은 액션의 텍스트에 명령의 기본 키보드 단축키가 추가된 형태입니다. 액션의 다른 속성은 자동으로 업데이트되지 않습니다.

augmentActionWithShortcutToolTip()도 참조하십시오 .

[static] QToolButton *Command::createToolButtonWithShortcutToolTip(Utils::Id commandId, QWidget *parent = nullptr)

commandId 에서 지정한 명령의 아이콘, 아이콘 텍스트 및 텍스트를 가진 새로운 QToolButton 객체를 반환합니다. 버튼의 부모를 parent 로 설정합니다. 액션의 툴팁은 액션의 텍스트에 명령의 기본 키보드 단축키가 추가된 형태입니다. 버튼의 다른 속성은 자동으로 업데이트되지 않습니다.

createActionWithShortcutToolTip()도 참조하십시오 .

QList<QKeySequence> Command::defaultKeySequences() const

이 명령을 실행하는 데 사용할 수 있는 기본 키보드 단축키를 반환합니다.

setDefaultKeySequences()도 참조하십시오 .

QString Command::description() const

사용자에게 이 명령을 표시하는 데 사용되는 텍스트를 반환합니다.

setDescription()도 참조하십시오 .

bool Command::hasAttribute(Core::Command::CommandAttribute attribute) const

Command에 attribute 가 설정되어 있는지 여부를 반환합니다.

CommandAttribute, removeAttribute(), setAttribute()도 참조하십시오 .

bool Command::isActive() const

Command에 현재 컨텍스트에 대해 활성 액션이 있는지 여부를 반환합니다.

bool Command::isScriptable() const

해당 명령이 스크립트에서 호출 가능한지 여부를 반환합니다. 스크립트에서 호출 가능한 명령은 사용자가 직접 조작할 필요 없이 스크립트에서 호출할 수 있습니다.

QKeySequence Command::keySequence() const

이 명령에 할당된 현재 기본 키보드 단축키를 반환합니다.

defaultKeySequences()도 참조하십시오 .

[signal] void Command::keySequenceChanged()

이 명령에 할당된 키보드 단축키가 변경될 때(예: 사용자가 키보드 단축키 설정 대화 상자에서 단축키를 설정할 때) 전송됩니다.

QList<QKeySequence> Command::keySequences() const

이 명령에 할당된 현재 키보드 단축키를 반환합니다.

defaultKeySequences()도 참조하십시오 .

void Command::removeAttribute(Core::Command::CommandAttribute attribute)

이 명령어의 속성에서 ‘ attribute ’를 제거합니다.

CommandAttribute 및 setAttribute()도 참조하십시오 .

void Command::setAttribute(Core::Command::CommandAttribute attribute)

이 명령의 속성에 ` attribute `를 추가합니다.

CommandAttribute, removeAttribute() 및 hasAttribute()도 참조하십시오 .

void Command::setDefaultKeySequence(const QKeySequence &key)

이 명령을 실행하는 데 사용할 수 있는 기본 키보드 단축키를 key 로 설정합니다. 이 기능은 사용자가 단축키를 사용자 지정하지 않은 경우나 단축키를 기본값으로 재설정할 때 사용됩니다.

void Command::setDefaultKeySequences(const QList<QKeySequence> &keys)

이 명령을 실행하는 데 사용할 수 있는 기본 키보드 단축키를 ‘ keys ’로 설정합니다. 이 기능은 사용자가 단축키를 사용자 지정하지 않은 경우나 단축키를 기본값으로 재설정할 때 사용됩니다.

defaultKeySequences()도 참조하십시오 .

void Command::setDescription(const QString &text)

키보드 단축키 설정 대화 상자에서 명령을 나타내는 데 사용되는 ‘ text ’을 설정합니다. 이 항목을 설정하지 않으면 사용자가 볼 수 있는 동작의 현재 텍스트가 사용됩니다(대부분의 경우 이대로도 무방합니다).

description()도 참조하십시오 .

void Command::setTouchBarIcon(const QIcon &icon)

터치 바의 액션 아이콘을 icon 로 설정합니다.

touchBarIcon()도 참조하십시오 .

void Command::setTouchBarText(const QString &text)

터치 바의 동작에 대한 텍스트를 “ text ”로 설정합니다.

touchBarText()도 참조하십시오 .

QString Command::stringWithAppendedShortcut(const QString &string) const

이 명령에 현재 할당된 기본 키보드 단축키의 표현을 뒤에 추가한 ` string `을 반환합니다.

[static] QToolButton *Command::toolButtonWithAppendedShortcut(QAction *action, Core::Command *cmd)

action 에 대한 도구 버튼을 반환합니다.

작업의 툴팁에 기본 키보드 단축키인 cmd 을 추가합니다.

[static] QToolButton *Command::toolButtonWithAppendedShortcut(QAction *action, Utils::Id commandId)

action 에 대한 도구 버튼을 반환합니다.

ID가 commandId 인 명령의 기본 키보드 단축키를 버튼의 툴팁에 추가합니다.

QIcon Command::touchBarIcon() const

터치 바의 해당 동작에 해당하는 아이콘을 반환합니다.

setTouchBarIcon()도 참조하십시오 .

QString Command::touchBarText() const

터치 바의 해당 액션에 대한 텍스트를 반환합니다.

setTouchBarText()도 참조하십시오 .

Copyright © The Qt Company Ltd. and other contributors. Documentation contributions included herein are the copyrights of their respective owners. The documentation provided herein is licensed under the terms of the GNU Free Documentation License version 1.3 as published by the Free Software Foundation. Qt and respective logos are trademarks of The Qt Company Ltd in Finland and/or other countries worldwide. All other trademarks are property of their respective owners.