account connect/disconnect now activate/deactivate, it's a bit less contraversial; async account password asking new concept

This commit is contained in:
Blue 2022-04-12 23:33:10 +03:00
parent 2c26c7e264
commit f64e5c2df0
Signed by: blue
GPG key ID: 9B203B252A63EE38
13 changed files with 248 additions and 200 deletions

View file

@ -53,6 +53,7 @@ QMap<QString, QVariant> Account::value() const
map["name"] = m_ui->name->text();
map["resource"] = m_ui->resource->text();
map["passwordType"] = m_ui->passwordType->currentIndex();
map["active"] = m_ui->active->isChecked();
return map;
}

View file

@ -7,7 +7,7 @@
<x>0</x>
<y>0</y>
<width>438</width>
<height>342</height>
<height>345</height>
</rect>
</property>
<property name="windowTitle">
@ -34,7 +34,7 @@
<property name="verticalSpacing">
<number>6</number>
</property>
<item row="1" column="1">
<item row="2" column="1">
<widget class="QLineEdit" name="login">
<property name="toolTip">
<string>Your account login</string>
@ -44,14 +44,14 @@
</property>
</widget>
</item>
<item row="2" column="0">
<item row="3" column="0">
<widget class="QLabel" name="label_2">
<property name="text">
<string>Server</string>
</property>
</widget>
</item>
<item row="2" column="1">
<item row="3" column="1">
<widget class="QLineEdit" name="server">
<property name="toolTip">
<string>A server address of your account. Like 404.city or macaw.me</string>
@ -61,21 +61,21 @@
</property>
</widget>
</item>
<item row="1" column="0">
<item row="2" column="0">
<widget class="QLabel" name="label">
<property name="text">
<string>Login</string>
</property>
</widget>
</item>
<item row="3" column="0">
<item row="4" column="0">
<widget class="QLabel" name="label_3">
<property name="text">
<string>Password</string>
</property>
</widget>
</item>
<item row="3" column="1">
<item row="4" column="1">
<widget class="QLineEdit" name="password">
<property name="toolTip">
<string>Password of your account</string>
@ -97,14 +97,14 @@
</property>
</widget>
</item>
<item row="0" column="0">
<item row="1" column="0">
<widget class="QLabel" name="label_4">
<property name="text">
<string>Name</string>
</property>
</widget>
</item>
<item row="0" column="1">
<item row="1" column="1">
<widget class="QLineEdit" name="name">
<property name="toolTip">
<string>Just a name how would you call this account, doesn't affect anything</string>
@ -114,14 +114,14 @@
</property>
</widget>
</item>
<item row="6" column="0">
<item row="7" column="0">
<widget class="QLabel" name="label_5">
<property name="text">
<string>Resource</string>
</property>
</widget>
</item>
<item row="6" column="1">
<item row="7" column="1">
<widget class="QLineEdit" name="resource">
<property name="toolTip">
<string>A resource name like &quot;Home&quot; or &quot;Work&quot;</string>
@ -131,17 +131,17 @@
</property>
</widget>
</item>
<item row="4" column="0">
<item row="5" column="0">
<widget class="QLabel" name="label_6">
<property name="text">
<string>Password storage</string>
</property>
</widget>
</item>
<item row="4" column="1">
<item row="5" column="1">
<widget class="QComboBox" name="passwordType"/>
</item>
<item row="5" column="1">
<item row="6" column="1">
<widget class="QLabel" name="comment">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
@ -157,6 +157,23 @@
</property>
</widget>
</item>
<item row="0" column="0">
<widget class="QLabel" name="label_7">
<property name="text">
<string>Active</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QCheckBox" name="active">
<property name="text">
<string>enable</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
</widget>
</item>
</layout>
</item>
<item>

View file

@ -83,7 +83,8 @@ void Accounts::onEditButton()
{"server", mAcc->getServer()},
{"name", mAcc->getName()},
{"resource", mAcc->getResource()},
{"passwordType", QVariant::fromValue(mAcc->getPasswordType())}
{"passwordType", QVariant::fromValue(mAcc->getPasswordType())},
{"active", mAcc->getActive()}
});
acc->lockId();
connect(acc, &Account::accepted, this, &Accounts::onAccountAccepted);
@ -118,17 +119,17 @@ void Accounts::updateConnectButton()
bool allConnected = true;
for (int i = 0; i < selectionSize && allConnected; ++i) {
const Models::Account* mAcc = model->getAccount(sm->selectedRows().at(i).row());
allConnected = mAcc->getState() == Shared::ConnectionState::connected;
allConnected = allConnected && mAcc->getActive();
}
if (allConnected) {
toDisconnect = true;
m_ui->connectButton->setText(tr("Disconnect"));
m_ui->connectButton->setText(tr("Deactivate"));
} else {
toDisconnect = false;
m_ui->connectButton->setText(tr("Connect"));
m_ui->connectButton->setText(tr("Activate"));
}
} else {
m_ui->connectButton->setText(tr("Connect"));
m_ui->connectButton->setText(tr("Activate"));
toDisconnect = false;
m_ui->connectButton->setEnabled(false);
}