testing, ability to build without kwallet, translations, disabling unsupported storage types in combobox

This commit is contained in:
Blue 2020-04-11 01:15:08 +03:00
parent 543538fc56
commit b95028e33e
15 changed files with 315 additions and 163 deletions

View file

@ -23,13 +23,21 @@ Account::Account():
QDialog(),
m_ui(new Ui::Account)
{
m_ui->setupUi (this);
m_ui->setupUi(this);
connect(m_ui->passwordType, qOverload<int>(&QComboBox::currentIndexChanged), this, &Account::onComboboxChange);
for (int i = static_cast<int>(Shared::AccountPasswordLowest); i < static_cast<int>(Shared::AccountPasswordHighest) + 1; ++i) {
Shared::AccountPassword ap = static_cast<Shared::AccountPassword>(i);
m_ui->passwordType->addItem(Shared::Global::getName(ap));
}
m_ui->passwordType->setCurrentIndex(static_cast<int>(Shared::AccountPassword::plain));
if (!Shared::Global::supported("KWallet")) {
QStandardItemModel *model = static_cast<QStandardItemModel*>(m_ui->passwordType->model());
QStandardItem *item = model->item(static_cast<int>(Shared::AccountPassword::kwallet));
item->setFlags(item->flags() & ~Qt::ItemIsEnabled);
}
}
Account::~Account()
@ -63,3 +71,9 @@ void Account::setData(const QMap<QString, QVariant>& data)
m_ui->resource->setText(data.value("resource").toString());
m_ui->passwordType->setCurrentIndex(data.value("passwordType").toInt());
}
void Account::onComboboxChange(int index)
{
QString description = Shared::Global::getDescription(Shared::Global::fromInt<Shared::AccountPassword>(index));
m_ui->comment->setText(description);
}

View file

@ -24,6 +24,7 @@
#include <QMap>
#include <QString>
#include <QVariant>
#include <QStandardItemModel>
#include "shared/global.h"
@ -44,6 +45,9 @@ public:
void setData(const QMap<QString, QVariant>& data);
void lockId();
private slots:
void onComboboxChange(int index);
private:
QScopedPointer<Ui::Account> m_ui;
};

View file

@ -114,14 +114,14 @@
</property>
</widget>
</item>
<item row="5" column="0">
<item row="6" column="0">
<widget class="QLabel" name="label_5">
<property name="text">
<string>Resource</string>
</property>
</widget>
</item>
<item row="5" column="1">
<item row="6" column="1">
<widget class="QLineEdit" name="resource">
<property name="toolTip">
<string>A resource name like &quot;Home&quot; or &quot;Work&quot;</string>
@ -141,6 +141,22 @@
<item row="4" column="1">
<widget class="QComboBox" name="passwordType"/>
</item>
<item row="5" column="1">
<widget class="QLabel" name="comment">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string/>
</property>
<property name="wordWrap">
<bool>true</bool>
</property>
</widget>
</item>
</layout>
</item>
<item>

View file

@ -37,6 +37,7 @@ Accounts::Accounts(Models::Accounts* p_model, QWidget *parent) :
m_ui->tableView->setModel(model);
connect(m_ui->tableView->selectionModel(), &QItemSelectionModel::selectionChanged, this, &Accounts::onSelectionChanged);
connect(p_model, &Models::Accounts::changed, this, &Accounts::updateConnectButton);
connect(m_ui->tableView, &QTableView::doubleClicked, this, &Accounts::onEditButton);
}
Accounts::~Accounts() = default;