1
0
Fork 0
mirror of https://github.com/transmission/transmission synced 2024-12-22 15:54:57 +00:00
transmission/qt/AccessibleSqueezeLabel.h
Mike Gelfand 8e7fc76930
Make SqueezeLabel [more] accessible (#6520)
Expose label text as accessible value instead of accessible name, and
get accessible name from buddy label as any proper input widget does.
Don't expose label tooltip as accessible description unless it's
different from its text (which isn't the case when displayed text is
truncated). Notify on label text and selection changes.

Switch to `SqueezeLabel` for values in statistics dialog which has
similar layout to information tab of torrent properties dialog.
2024-01-12 03:35:40 +00:00

47 lines
1.7 KiB
C++

// This file Copyright © Mnemosyne LLC.
// It may be used under GPLv2 (SPDX: GPL-2.0-only), GPLv3 (SPDX: GPL-3.0-only),
// or any future license endorsed by Mnemosyne LLC.
// License text can be found in the licenses/ folder.
#pragma once
#include <qtguiglobal.h>
#if QT_CONFIG(accessibility)
#include <QAccessibleWidget>
class SqueezeLabel;
class AccessibleSqueezeLabel
: public QAccessibleWidget
, public QAccessibleTextInterface
{
public:
explicit AccessibleSqueezeLabel(QWidget* widget);
// QAccessibleWidget
[[nodiscard]] QString text(QAccessible::Text kind) const override;
[[nodiscard]] QAccessible::State state() const override;
void* interface_cast(QAccessible::InterfaceType ifaceType) override;
// QAccessibleTextInterface
void selection(int selectionIndex, int* startOffset, int* endOffset) const override;
[[nodiscard]] int selectionCount() const override;
void addSelection(int startOffset, int endOffset) override;
void removeSelection(int selectionIndex) override;
void setSelection(int selectionIndex, int startOffset, int endOffset) override;
[[nodiscard]] int cursorPosition() const override;
void setCursorPosition(int position) override;
[[nodiscard]] QString text(int startOffset, int endOffset) const override;
[[nodiscard]] int characterCount() const override;
[[nodiscard]] QRect characterRect(int offset) const override;
[[nodiscard]] int offsetAtPoint(QPoint const& point) const override;
void scrollToSubstring(int startIndex, int endIndex) override;
QString attributes(int offset, int* startOffset, int* endOffset) const override;
private:
[[nodiscard]] SqueezeLabel* label() const;
};
#endif // QT_CONFIG(accessibility)