diff options
| author | Andreas Grois <andi@grois.info> | 2022-10-10 21:30:02 +0200 |
|---|---|---|
| committer | Andreas Grois <andi@grois.info> | 2022-10-10 21:37:15 +0200 |
| commit | e4ad766315879e1ff05bb111229f073f8f0ed68e (patch) | |
| tree | 4b043ff47c78b2c00c80c94ebda622c32c8b6d3d /src/Bindings.h | |
PassFish: Initial Commit
Well, that's a lie. But nobody needs to see all the iterations I decided
to sweep under the rug.
That said, I think the repo is, while not clean, clean enough now, to
not be embarrassed by uploading it to github.
Diffstat (limited to 'src/Bindings.h')
| -rw-r--r-- | src/Bindings.h | 180 |
1 files changed, 180 insertions, 0 deletions
diff --git a/src/Bindings.h b/src/Bindings.h new file mode 100644 index 0000000..3aa3e77 --- /dev/null +++ b/src/Bindings.h @@ -0,0 +1,180 @@ +/* generated by rust_qt_binding_generator */ +/* Beware: a lot of const pointers mentioned in this file are mutating data on the Rust side. */ +#ifndef BINDINGS_H +#define BINDINGS_H + +#include <QtCore/QObject> +#include <QtCore/QAbstractItemModel> + +class PasswordMaker; +class Profiles; +class Settings; + +class PasswordMaker : public QObject +{ + Q_OBJECT +public: + class Private; +private: + Profiles* const m_profiles; + Settings* const m_settings; + const Private * m_d; + Private * const m_d_owned; + Q_PROPERTY(QString generated_password READ generated_password NOTIFY generated_passwordChanged FINAL) + Q_PROPERTY(quint8 generator_state READ generator_state NOTIFY generator_stateChanged FINAL) + Q_PROPERTY(bool i_say_sexy_things_to_myself_while_im_dancing READ i_say_sexy_things_to_myself_while_im_dancing WRITE setI_say_sexy_things_to_myself_while_im_dancing NOTIFY i_say_sexy_things_to_myself_while_im_dancingChanged FINAL) + Q_PROPERTY(QString master_password READ master_password WRITE setMaster_password NOTIFY master_passwordChanged FINAL) + Q_PROPERTY(Profiles* profiles READ profiles NOTIFY profilesChanged FINAL) + Q_PROPERTY(Settings* settings READ settings NOTIFY settingsChanged FINAL) + Q_PROPERTY(QString url READ url WRITE setUrl NOTIFY urlChanged FINAL) + Q_PROPERTY(QString used_text READ used_text WRITE setUsed_text NOTIFY used_textChanged FINAL) + explicit PasswordMaker(bool owned, QObject *parent); +public: + explicit PasswordMaker(QObject *parent = nullptr); + ~PasswordMaker(); + QString generated_password() const; + quint8 generator_state() const; + bool i_say_sexy_things_to_myself_while_im_dancing() const; + void setI_say_sexy_things_to_myself_while_im_dancing(bool v); + QString master_password() const; + void setMaster_password(const QString& v); + const Profiles* profiles() const; + Profiles* profiles(); + const Settings* settings() const; + Settings* settings(); + QString url() const; + void setUrl(const QString& v); + QString used_text() const; + void setUsed_text(const QString& v); + Q_INVOKABLE void profile_changed() const; + Q_INVOKABLE bool store_settings() const; +Q_SIGNALS: + void generated_passwordChanged(); + void generator_stateChanged(); + void i_say_sexy_things_to_myself_while_im_dancingChanged(); + void master_passwordChanged(); + void profilesChanged(); + void settingsChanged(); + void urlChanged(); + void used_textChanged(); +}; + +class Profiles : public QAbstractItemModel +{ + Q_OBJECT + friend class PasswordMaker; +public: + class Private; +private: + const Private * m_d; + Private * const m_d_owned; + Q_PROPERTY(quint32 current_profile READ current_profile WRITE setCurrent_profile NOTIFY current_profileChanged FINAL) + Q_PROPERTY(QString current_profile_name READ current_profile_name NOTIFY current_profile_nameChanged FINAL) + explicit Profiles(bool owned, QObject *parent); +public: + explicit Profiles(QObject *parent = nullptr); + ~Profiles(); + quint32 current_profile() const; + void setCurrent_profile(quint32 v); + QString current_profile_name() const; + Q_INVOKABLE bool store() const; + + int columnCount(const QModelIndex &parent = QModelIndex()) const override; + QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override; + QModelIndex index(int row, int column, const QModelIndex &parent = QModelIndex()) const override; + QModelIndex parent(const QModelIndex &index) const override; + bool hasChildren(const QModelIndex &parent = QModelIndex()) const override; + int rowCount(const QModelIndex &parent = QModelIndex()) const override; + bool canFetchMore(const QModelIndex &parent) const override; + void fetchMore(const QModelIndex &parent) override; + Qt::ItemFlags flags(const QModelIndex &index) const override; + void sort(int column, Qt::SortOrder order = Qt::AscendingOrder) override; + int role(const char* name) const; + QHash<int, QByteArray> roleNames() const override; + QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const override; + bool setHeaderData(int section, Qt::Orientation orientation, const QVariant &value, int role = Qt::EditRole) override; + Q_INVOKABLE bool insertRows(int row, int count, const QModelIndex &parent = QModelIndex()) override; + Q_INVOKABLE bool removeRows(int row, int count, const QModelIndex &parent = QModelIndex()) override; + bool setData(const QModelIndex &index, const QVariant &value, int role = Qt::EditRole) override; + Q_INVOKABLE QString characters(int row) const; + Q_INVOKABLE bool setCharacters(int row, const QString& value); + Q_INVOKABLE quint8 hash_algorithm(int row) const; + Q_INVOKABLE bool setHash_algorithm(int row, quint8 value); + Q_INVOKABLE quint8 leet_level(int row) const; + Q_INVOKABLE bool setLeet_level(int row, quint8 value); + Q_INVOKABLE QString modifier(int row) const; + Q_INVOKABLE bool setModifier(int row, const QString& value); + Q_INVOKABLE QString name(int row) const; + Q_INVOKABLE bool setName(int row, const QString& value); + Q_INVOKABLE quint32 password_length(int row) const; + Q_INVOKABLE bool setPassword_length(int row, quint32 value); + Q_INVOKABLE QString prefix(int row) const; + Q_INVOKABLE bool setPrefix(int row, const QString& value); + Q_INVOKABLE QString suffix(int row) const; + Q_INVOKABLE bool setSuffix(int row, const QString& value); + Q_INVOKABLE bool use_domain(int row) const; + Q_INVOKABLE bool setUse_domain(int row, bool value); + Q_INVOKABLE quint8 use_leet(int row) const; + Q_INVOKABLE bool setUse_leet(int row, quint8 value); + Q_INVOKABLE bool use_port_path(int row) const; + Q_INVOKABLE bool setUse_port_path(int row, bool value); + Q_INVOKABLE bool use_protocol(int row) const; + Q_INVOKABLE bool setUse_protocol(int row, bool value); + Q_INVOKABLE bool use_subdomains(int row) const; + Q_INVOKABLE bool setUse_subdomains(int row, bool value); + Q_INVOKABLE bool use_undefined_as_protocol_fallback(int row) const; + Q_INVOKABLE bool setUse_undefined_as_protocol_fallback(int row, bool value); + Q_INVOKABLE bool use_user_info(int row) const; + Q_INVOKABLE bool setUse_user_info(int row, bool value); + Q_INVOKABLE QString username(int row) const; + Q_INVOKABLE bool setUsername(int row, const QString& value); + +Q_SIGNALS: + // new data is ready to be made available to the model with fetchMore() + // the passed QVariant contains a quintptr which is the internal id. + // This is the same index that the fetch_more function typically expects on the Rust side. + // Previously this Signal sent a QModelIndex, but that was changed due to threading issues. + // If you need to create a QModelIndex from the internal id, you can expose the profiles_row() method + // on the underlying Rust object as a function and use it. Just beware that this Signal is + // typically sent from arbitrary threads, so compute the index at the Slot side. + // While speaking of threads: Make sure the internal ID of your model entries is stable. + // If it can change, it's up to you to ensure that it does not do so between sending this + // signal and receiving the corresponding fetchMore() call on the other side of the Connection. + void newDataReady(const QVariant &parent) const; +private: + QHash<QPair<int,Qt::ItemDataRole>, QVariant> m_headerData; + void initHeaderData(); + void updatePersistentIndexes(); +Q_SIGNALS: + void current_profileChanged(); + void current_profile_nameChanged(); +}; + +class Settings : public QObject +{ + Q_OBJECT + friend class PasswordMaker; +public: + class Private; +private: + const Private * m_d; + Private * const m_d_owned; + Q_PROPERTY(QVariant clear_generated_password_seconds READ clear_generated_password_seconds WRITE setClear_generated_password_seconds NOTIFY clear_generated_password_secondsChanged FINAL) + Q_PROPERTY(QVariant clear_master_password_seconds READ clear_master_password_seconds WRITE setClear_master_password_seconds NOTIFY clear_master_password_secondsChanged FINAL) + Q_PROPERTY(bool hide_generated_password READ hide_generated_password WRITE setHide_generated_password NOTIFY hide_generated_passwordChanged FINAL) + explicit Settings(bool owned, QObject *parent); +public: + explicit Settings(QObject *parent = nullptr); + ~Settings(); + QVariant clear_generated_password_seconds() const; + void setClear_generated_password_seconds(const QVariant& v); + QVariant clear_master_password_seconds() const; + void setClear_master_password_seconds(const QVariant& v); + bool hide_generated_password() const; + void setHide_generated_password(bool v); +Q_SIGNALS: + void clear_generated_password_secondsChanged(); + void clear_master_password_secondsChanged(); + void hide_generated_passwordChanged(); +}; +#endif // BINDINGS_H |
