Packages icon indicating copy to clipboard operation
Packages copied to clipboard

[C++] Treat Qt macros as built-in visibility modifiers

Open ratijas opened this issue 3 years ago • 1 comments

What happened?

Feature request to support Qt-specific visibility modifiers macros. They act as hints/anchors for MOC (meta-object compiler), and resolve either to plain old C++ visibility modifiers, or to nothing at all:

# define Q_SLOTS
# define Q_SIGNALS public

There are also lowercase prefix-less signals and slots versions, but they are not advised to use except for the sole reason of looking cool.

It would be nice to have at least uppercase versions treated in the same way as private|protected|public triple, including auto-unindenting when a colon : is inserted after one of them. Note that Qt Creator IDE does unindent automatically.

To implement this, we'll have to expand this list of visibility_modifiers right here

https://github.com/sublimehq/Packages/blob/4bd58e57da149eb2fda72af932f8e911db6d9182/C%2B%2B/C%2B%2B.sublime-syntax#L63

and probably modify some scripts elsewhere.

ratijas avatar Oct 14 '21 11:10 ratijas

Example usage:

class Q_QUICK_EXPORT QQuickItem : public QObject, public QQmlParserStatus
{
    Q_OBJECT
    Q_INTERFACES(QQmlParserStatus)
    // ...

public:
    explicit QQuickItem(QQuickItem *parent = nullptr);
    ~QQuickItem() override;
    // ...

public Q_SLOTS:
    void update();

Q_SIGNALS:
    void childrenRectChanged(const QRectF &);
    // ...

protected:
    bool event(QEvent *) override;
    // ...

private:
    Q_PRIVATE_SLOT(d_func(), void _q_resourceObjectDeleted(QObject *))
    // ...
};

ratijas avatar Oct 14 '21 11:10 ratijas