Fluent-Qt

메뉴 및 도구 모음

CommandBar 명령 바

기본 작업과 오버플로 작업을 제공하는 반응형 명령 바입니다.

예제

CommandBar 명령 바: 반응형 문서 명령 바

사용법

반응형 문서 명령 바

우선순위에 따른 오버플로, 아이콘 또는 오른쪽 레이블, 기본 및 보조 섹션, 구분선, 선택적 명령 바 배경을 확인해 보세요.

#include <FluentQt/MenusToolbars.h>
using namespace fluent::menus_toolbars;

auto* barHost = new QWidget(this);
barHost->setFixedWidth(536);
auto* barLayout = new QHBoxLayout(barHost);
barLayout->setContentsMargins(0, 0, 0, 0);
auto* bar = new CommandBar(barHost);
bar->setAccessibleName("Document commands");
bar->setLabelPosition(
    CommandBar::LabelPosition::Right);
bar->setBackgroundVisible(false);
barLayout->addWidget(bar);

auto* addAction = new QAction(
    QIcon(":/icons/add.svg"), "Add", this);
auto* editAction = new QAction(
    QIcon(":/icons/edit.svg"), "Edit", this);
editAction->setPriority(QAction::HighPriority);
auto* shareAction = new QAction(
    QIcon(":/icons/share.svg"), "Share", this);
auto* separator = new QAction(this);
separator->setSeparator(true);
auto* syncAction = new QAction(
    QIcon(":/icons/sync.svg"), "Sync", this);
syncAction->setPriority(QAction::LowPriority);
auto* pinAction = new QAction(
    QIcon(":/icons/pin.svg"), "Pin", this);
pinAction->setCheckable(true);

bar->addPrimaryAction(addAction);
bar->addPrimaryAction(editAction);
bar->addPrimaryAction(shareAction);
bar->addPrimaryAction(separator);
bar->addPrimaryAction(syncAction);
bar->addPrimaryAction(pinAction);
bar->addSecondaryAction(new QAction(
    QIcon(":/icons/settings.svg"), "Settings", this));
bar->addSecondaryAction(new QAction(
    QIcon(":/icons/help.svg"), "Help", this));

auto* compactButton =
    new Button("Compact view", this);
auto* labelsButton =
    new Button("Labels: Right", this);
auto* backgroundButton =
    new Button("Show background", this);
connect(compactButton, &Button::clicked, barHost,
        [barHost] {
            barHost->setFixedWidth(
                barHost->width() > 300 ? 288 : 536);
        });
connect(labelsButton, &Button::clicked, bar, [=] {
    const bool showLabels =
        bar->labelPosition()
        == CommandBar::LabelPosition::Collapsed;
    bar->setLabelPosition(
        showLabels
            ? CommandBar::LabelPosition::Right
            : CommandBar::LabelPosition::Collapsed);
});
connect(backgroundButton, &Button::clicked, bar, [=] {
    bar->setBackgroundVisible(
        !bar->backgroundVisible());
});
using fluent::status_info::Toast;
for (QAction* action : bar->primaryActions() + bar->secondaryActions()) {
    if (action->isSeparator()) continue;
    connect(action, &QAction::triggered, this, [this, action] {
        QString text = action->text().section('\t', 0, 0).remove('&');
        Toast::showOrUpdateToast(this, "gallery.action-feedback", text + " selected",
            Toast::Informational, 2200, Toast::Top, QMargins(16, 50, 16, 16));
    });
}

fluent::menus_toolbars::CommandBar

상속 대상 QWidget · FluentElement · QMLPlus

기본 작업을 인라인으로 표시하고 초과 항목을 오른쪽 오버플로 메뉴로 이동하는 가로 명령 모음

생성자

소멸자

열거형

enum class LabelPosition

아이콘 옆에 인라인 명령 레이블을 표시할지 여부를 제어합니다.

  • Collapsed
  • Right

메서드

void addAction(QAction* action)

소유권을 가져오지 않고 기본 섹션에 액션을 추가합니다.

void insertAction(QAction* before, QAction* action)

소유권을 가져오지 않고 `before` 앞의 기본 섹션에 동작을 삽입합니다.

void removeAction(QAction* action)

바에서 액션을 삭제하지 않고 제거합니다.

bool addPrimaryAction(QAction* action)

소유권을 가져오지 않고 기본 섹션 끝에 액션을 추가합니다.

bool insertPrimaryAction(QAction* before, QAction* action)

소유권을 가져오지 않고 `before` 앞에 기본 동작을 삽입합니다.

bool addSecondaryAction(QAction* action)

소유권을 가져오지 않고 보조 (오버플로) 섹션 끝에 액션을 추가합니다.

bool insertSecondaryAction(QAction* before, QAction* action)

소유권을 가져오지 않고 `before` 앞에 보조 동작을 삽입합니다.

bool removeCommandAction(QAction* action)

기본 또는 보조 명령에서 액션을 삭제하지 않고 제거합니다.

void clearPrimaryActions()

액션을 삭제하지 않고 모든 기본 명령을 지웁니다.

void clearSecondaryActions()

액션을 삭제하지 않고 모든 보조 명령을 지웁니다.

QList<QAction*> primaryActions() const

기본 액션을 표시 순서대로 반환합니다.

QList<QAction*> secondaryActions() const

보조 액션을 표시 순서대로 반환합니다.

QList<QAction*> overflowedPrimaryActions() const

현재 오버플로 메뉴로 이동된 기본 액션을 반환합니다.

bool isPrimaryActionOverflowed(const QAction* action) const

기본 작업이 현재 오버플로 메뉴에 있는지 여부를 반환합니다.

void setOverflowOpen(bool open)

오버플로 항목이 있을 때 오버플로 메뉴를 열거나 닫습니다.

속성

LabelPosition labelPosition
읽기 labelPosition()쓰기 setLabelPosition()알림 신호 labelPositionChanged()
bool dynamicOverflowEnabled
읽기 isDynamicOverflowEnabled()쓰기 setDynamicOverflowEnabled()알림 신호 dynamicOverflowEnabledChanged()
bool overflowOpen
읽기 isOverflowOpen()쓰기 setOverflowOpen()알림 신호 overflowOpenChanged()
bool backgroundVisible
읽기 backgroundVisible()쓰기 setBackgroundVisible()알림 신호 backgroundVisibleChanged()

시그널

타입 및 별칭

보호된 멤버

메서드

fluent::FluentElement에서 상속됨

열거형

enum Theme

디자인 토큰을 해석할 때 사용되는 전역 시각적 테마.

  • Light = 0
  • Dark = 1
  • HighContrast = 2

메서드

static void setTheme(Theme theme)

전역 테마를 업데이트하고 활성 FluentElement 인스턴스에 알립니다.

static void setThemeDeferred(Theme theme)

현재 상호 작용을 차단하지 않고 보이는 항목 우선의 일괄 테마 새로 고침을 예약합니다.

static Theme currentTheme()

현재 활성화된 전역 테마를 반환합니다.

static bool themeUsesDarkAppearance(Theme theme)

테마가 어두운 배경의 크롬 및 머티리얼 토큰을 사용하는지 여부를 반환합니다.

static void refreshTheme()

디자인 토큰 변경 후 다시 그리도록 현재 테마를 재브로드캐스트합니다.

static int themeGeneration()

유효성 검사를 위해 테마가 변경될 때마다 증가하는 단조 카운터.

Theme effectiveTheme() const

상속된 QWidget 재정의를 준수하여 이 요소에서 사용하는 테마를 확인합니다.

bool effectiveThemeUsesDarkAppearance() const

이 요소의 유효 테마가 어두운 배경의 크롬을 사용하는지 여부를 반환합니다.

bool setThemeOverrides(const QJsonObject& overrides)

이 요소의 희소 색상, 반경 및 글꼴 토큰 재정의를 교체합니다.

QJsonObject themeOverrides() const

이 요소에 지정된 재정의 설정을 반환합니다.

void clearThemeOverrides()

모든 토큰 필드를 전역 테마 기본값으로 복원합니다.

const Colors& themeColorsRef() const

빈번한 그리기 경로를 위한 활성 색상 세트의 무복사 접근.

Material::AcrylicToken themeAcrylic() const

재질, 고도 (elevation) 및 적응형 레이아웃 토큰.

QColor themeBackdrop(bool active) const

지정된 활성화 상태에 대한 창 chrome 배경색.

virtual void onThemeUpdated()

전역 테마가 변경된 후 호출됩니다.

타입 및 별칭

struct Colors

컴포넌트에 반환되는 디자인 토큰 스냅샷.

fluent::QMLPlus에서 상속됨

메서드

AnchorLayout::Anchors* anchors()

QWidget 호스트의 변경 가능한 앵커를 반환합니다.

void setState(const QString& name)

이름으로 등록된 상태를 적용하거나, @p name 값이 비어 있으면 기본 상태를 복원합니다. 알 수 없는 이름은 무시되며, 상태를 벗어날 때 기존 바인딩이 다시 시작됩니다.

void addState(const QMLState& state)

명명된 상태 정의를 등록하거나 교체합니다. 활성 상태를 교체하면 즉시 적용됩니다.

void evaluateStates()

등록 순서대로 상태 조건을 재평가하여 첫 번째로 일치하는 상태를 활성화하며, 일치하는 항목이 없으면 기본 상태를 활성화합니다. 종속성 속성이 알림을 보낼 때도 자동으로 실행되며, extend를 사용하는 파생 상태는 순환하거나 누락되지 않는 한 상위 상태의 변경 사항을 상속합니다.

QMLPlusRuntime* runtime()

이 호스트가 소유하고 지연 생성하는 상태 관찰자를 반환합니다.

void setAnchors(const AnchorLayout::Anchors& anchors)

모든 호스트 앵커를 교체하고 상위 레이아웃을 무효화합니다.

void resetAnchors()

모든 호스트 앵커를 지우고 부모 레이아웃을 무효화합니다.

void bind(const char* targetProp, QObject* source, const char* sourceProp, PropertyBinder::Direction dir = PropertyBinder::OneWay)

PropertyBinder::bind()를 통해 @p source의 @p sourceProp을 이 QWidget 호스트의 @p targetProp에 바인딩합니다.

void addTransition(const StateTransition& transition)

우선순위 순서대로 상태 전환을 등록합니다.

void setBehavior(const char* propertyName, const PropertyAnimation& animation)

writeProperty() 또는 바인딩을 통해 @p propertyName에 쓸 때 사용되는 기본 애니메이션을 설정합니다. 명시적 StateTransition 규칙이 우선하며, 직접 C++ setter 호출에는 애니메이션이 적용되지 않습니다.

void clearBehavior(const char* propertyName)

이후 관리되는 쓰기 작업의 기본 애니메이션을 제거합니다.

bool writeProperty(const char* propertyName, const QVariant& value)

바인딩을 제거하지 않고 Behavior를 통해 호스트 속성을 씁니다.

Qt 기본 클래스 문서: QWidget