8#include <QCoreApplication>
11bool QtPassSettings::initialized =
false;
13Pass *QtPassSettings::pass;
18QScopedPointer<RealPass> QtPassSettings::realPass;
19QScopedPointer<ImitatePass> QtPassSettings::imitatePass;
23 if (!QtPassSettings::initialized) {
24 QString portable_ini = QCoreApplication::applicationDirPath() +
25 QDir::separator() +
"qtpass.ini";
26 if (QFile(portable_ini).exists()) {
27 m_instance =
new QtPassSettings(portable_ini, QSettings::IniFormat);
66 QHash<QString, QHash<QString, QString>> profiles;
69 QStringList childKeys = getInstance()->childKeys();
70 if (!childKeys.empty()) {
71 foreach (QString key, childKeys) {
72 QHash<QString, QString> profile;
73 profile.insert(
"path", getInstance()->value(key).toString());
74 profile.insert(
"signingKey",
"");
75 profiles.insert(key, profile);
80 QStringList childGroups = getInstance()->childGroups();
81 foreach (QString group, childGroups) {
82 QHash<QString, QString> profile;
83 profile.insert(
"path", getInstance()->value(group +
"/path").toString());
84 profile.insert(
"signingKey",
85 getInstance()->value(group +
"/signingKey").toString());
87 profiles.insert(group, profile);
90 getInstance()->endGroup();
96 const QHash<QString, QHash<QString, QString>> &profiles) {
100 QHash<QString, QHash<QString, QString>>::const_iterator i = profiles.begin();
101 for (; i != profiles.end(); ++i) {
102 getInstance()->setValue(i.key() +
"/path", i.value().value(
"path"));
104 i.value().value(
"signingKey"));
113 QtPassSettings::pass = getRealPass();
115 QtPassSettings::pass = getImitatePass();
246 const int &autoClearPanelSeconds) {
248 autoClearPanelSeconds);
306 QString returnValue = getInstance()
311 returnValue = QDir(returnValue).absolutePath();
315 if (!QDir(returnValue).exists()) {
316 if (!QDir().mkdir(returnValue)) {
317 qWarning() <<
"Failed to create password store directory:" << returnValue;
322 if (!returnValue.endsWith(
"/") && !returnValue.endsWith(QDir::separator())) {
323 returnValue += QDir::separator();
342 QString passExecutable =
346 QString gitExecutable =
350 QString gpgExecutable =
354 QString pwgenExecutable =
531 const int &passwordCharsselection) {
533 passwordCharsselection);
622 if (realPass.isNull()) {
625 return realPass.data();
628 if (imitatePass.isNull()) {
631 return imitatePass.data();
Imitates pass features when pass is not enabled or available.
Acts as an abstraction for pass or pass imitation.
Singleton that stores qtpass' settings, saves and loads config.
static auto isUseSelection(const bool &defaultValue=QVariant().toBool()) -> bool
static void setMaximized(const bool &maximized)
static void setStartMinimized(const bool &startMinimized)
static void setUseWebDav(const bool &useWebDav)
static auto isUseAutoclear(const bool &defaultValue=QVariant().toBool()) -> bool
static void setAutoclearPanelSeconds(const int &autoClearPanelSeconds)
static void setPassExecutable(const QString &passExecutable)
static auto getWebDavPassword(const QString &defaultValue=QVariant().toString()) -> QString
static auto isStartMinimized(const bool &defaultValue=QVariant().toBool()) -> bool
static auto getClipBoardTypeRaw(const Enums::clipBoardType &defaultvalue=Enums::CLIPBOARD_NEVER) -> int
static void setHidePassword(const bool &hidePassword)
static auto isUseOtp(const bool &defaultValue=QVariant().toBool()) -> bool
static void setPwgenExecutable(const QString &pwgenExecutable)
static auto getPwgenExecutable(const QString &defaultValue=QVariant().toString()) -> QString
static void setProfile(const QString &profile)
static void setUseTrayIcon(const bool &useTrayIcon)
static void setWebDavPassword(const QString &webDavPassword)
static auto getInstance() -> QtPassSettings *
static auto isNoLineWrapping(const bool &defaultValue=QVariant().toBool()) -> bool
static auto getWebDavUser(const QString &defaultValue=QVariant().toString()) -> QString
static void setPassStore(const QString &passStore)
static auto isHideContent(const bool &defaultValue=QVariant().toBool()) -> bool
static void setPasswordConfiguration(const PasswordConfiguration &config)
static auto getSize(const QSize &defaultValue=QVariant().toSize()) -> QSize
static void setHideOnClose(const bool &hideOnClose)
static auto getPass() -> Pass *
static auto getPasswordConfiguration() -> PasswordConfiguration
static auto getGpgHome(const QString &defaultValue=QVariant().toString()) -> QString
static auto isUseQrencode(const bool &defaultValue=QVariant().toBool()) -> bool
static void setPasswordLength(const int &passwordLength)
static auto isUseAutoclearPanel(const bool &defaultValue=QVariant().toBool()) -> bool
static auto isAutoPull(const bool &defaultValue=QVariant().toBool()) -> bool
static void setGitExecutable(const QString &gitExecutable)
static void setPasswordChars(const QString &passwordChars)
static auto isUseGit(const bool &defaultValue=QVariant().toBool()) -> bool
static void setUseOtp(const bool &useOtp)
static void setProfiles(const QHash< QString, QHash< QString, QString > > &profiles)
static void setUsePwgen(const bool &usePwgen)
static auto isTemplateAllFields(const bool &defaultValue=QVariant().toBool()) -> bool
static void setPassSigningKey(const QString &passSigningKey)
static auto isUsePass(const bool &defaultValue=QVariant().toBool()) -> bool
static auto getPassStore(const QString &defaultValue=QVariant().toString()) -> QString
static auto getVersion(const QString &defaultValue=QVariant().toString()) -> QString
static void setPasswordCharsselection(const int &passwordCharsselection)
static auto isUseTemplate(const bool &defaultValue=QVariant().toBool()) -> bool
static auto isUseTrayIcon(const bool &defaultValue=QVariant().toBool()) -> bool
static void initExecutables()
static void setUseTemplate(const bool &useTemplate)
static auto isAvoidCapitals(const bool &defaultValue=QVariant().toBool()) -> bool
static auto isAddGPGId(const bool &defaultValue=QVariant().toBool()) -> bool
static auto getGpgExecutable(const QString &defaultValue=QVariant().toString()) -> QString
static void setAutoPull(const bool &autoPull)
static auto getPassSigningKey(const QString &defaultValue=QVariant().toString()) -> QString
static void setPassTemplate(const QString &passTemplate)
static auto isUseSymbols(const bool &defaultValue=QVariant().toBool()) -> bool
static auto getQrencodeExecutable(const QString &defaultValue=QVariant().toString()) -> QString
static void setGpgExecutable(const QString &gpgExecutable)
static void setPos(const QPoint &pos)
static void setVersion(const QString &version)
static void setUseAutoclear(const bool &useAutoclear)
static auto getRealPass() -> RealPass *
static auto isLessRandom(const bool &defaultValue=QVariant().toBool()) -> bool
static void setAlwaysOnTop(const bool &alwaysOnTop)
static auto getPassTemplate(const QString &defaultValue=QVariant().toString()) -> QString
static void setWebDavUser(const QString &webDavUser)
static void setDisplayAsIs(const bool &displayAsIs)
static auto getClipBoardType(const Enums::clipBoardType &defaultvalue=Enums::CLIPBOARD_NEVER) -> Enums::clipBoardType
static auto isMaximized(const bool &defaultValue=QVariant().toBool()) -> bool
static void setUseMonospace(const bool &useMonospace)
static void setAvoidCapitals(const bool &avoidCapitals)
static void setQrencodeExecutable(const QString &qrencodeExecutable)
static void setWebDavUrl(const QString &webDavUrl)
static auto getProfile(const QString &defaultValue=QVariant().toString()) -> QString
static auto getWebDavUrl(const QString &defaultValue=QVariant().toString()) -> QString
static auto isUseMonospace(const bool &defaultValue=QVariant().toBool()) -> bool
static void setAddGPGId(const bool &addGPGId)
static void setUsePass(const bool &usePass)
static auto isUseWebDav(const bool &defaultValue=QVariant().toBool()) -> bool
static auto getAutoclearPanelSeconds(const int &defaultValue=QVariant().toInt()) -> int
static auto isUsePwgen(const bool &defaultValue=QVariant().toBool()) -> bool
static void setSavestate(const QByteArray &saveState)
static auto isAlwaysOnTop(const bool &defaultValue=QVariant().toBool()) -> bool
static auto isAvoidNumbers(const bool &defaultValue=QVariant().toBool()) -> bool
static auto isHidePassword(const bool &defaultValue=QVariant().toBool()) -> bool
static auto getPassExecutable(const QString &defaultValue=QVariant().toString()) -> QString
static void setUseAutoclearPanel(const bool &useAutoclearPanel)
static void setAutoclearSeconds(const int &autoClearSeconds)
static void setNoLineWrapping(const bool &noLineWrapping)
static void setUseQrencode(const bool &useQrencode)
static auto getPos(const QPoint &defaultValue=QVariant().toPoint()) -> QPoint
static void setAvoidNumbers(const bool &avoidNumbers)
static auto getImitatePass() -> ImitatePass *
static auto isHideOnClose(const bool &defaultValue=QVariant().toBool()) -> bool
static void setAutoPush(const bool &autoPush)
static void setClipBoardType(const int &clipBoardType)
static auto getProfiles() -> QHash< QString, QHash< QString, QString > >
static void setSize(const QSize &size)
static void setLessRandom(const bool &lessRandom)
static auto getAutoclearSeconds(const int &defaultValue=QVariant().toInt()) -> int
static void setHideContent(const bool &hideContent)
static auto isAutoPush(const bool &defaultValue=QVariant().toBool()) -> bool
static void setGeometry(const QByteArray &geometry)
static void setUseSelection(const bool &useSelection)
static auto getGitExecutable(const QString &defaultValue=QVariant().toString()) -> QString
static void setTemplateAllFields(const bool &templateAllFields)
static auto getGeometry(const QByteArray &defaultValue=QVariant().toByteArray()) -> QByteArray
static void setUseSymbols(const bool &useSymbols)
static auto isDisplayAsIs(const bool &defaultValue=QVariant().toBool()) -> bool
static void setUseGit(const bool &useGit)
static auto getSavestate(const QByteArray &defaultValue=QVariant().toByteArray()) -> QByteArray
Wrapper for executing pass to handle the password-store.
static const QString maximized
static const QString savestate
static const QString useSelection
static const QString passExecutable
static const QString noLineWrapping
static const QString autoPull
static const QString lessRandom
static const QString pwgenExecutable
static const QString geometry
static const QString gpgHome
static const QString version
static const QString passTemplate
static const QString useAutoclear
static const QString webDavUrl
static const QString clipBoardType
static const QString autoclearPanelSeconds
static const QString avoidNumbers
static const QString useAutoclearPanel
static const QString useWebDav
static const QString usePass
static const QString hideOnClose
static const QString alwaysOnTop
static const QString useGit
static const QString gitExecutable
static const QString gpgExecutable
static const QString profile
static const QString useTrayIcon
static const QString size
static const QString useOtp
static const QString startMinimized
static const QString hideContent
static const QString avoidCapitals
static const QString webDavUser
static const QString autoclearSeconds
static const QString usePwgen
static const QString useMonospace
static const QString passwordLength
static const QString qrencodeExecutable
static const QString passStore
static const QString passwordChars
static const QString webDavPassword
static const QString displayAsIs
static const QString useSymbols
static const QString passSigningKey
static const QString templateAllFields
static const QString passwordCharsselection
static const QString addGPGId
static const QString useQrencode
static const QString useTemplate
static const QString autoPush
static const QString hidePassword
static auto findBinaryInPath(QString binary) -> QString
Util::findBinaryInPath search for executables.
Holds the Password configuration settings.
int length
Length of the password.
enum PasswordConfiguration::characterSet selected
characterSet
The selected character set.
QString Characters[CHARSETS_COUNT]
The different character sets.