Other: GUI Tester supports the 3 states of user (Signed out/Locked/Connected).

This commit is contained in:
Xavier Michelon
2022-11-29 13:05:48 +01:00
parent 2cce1c7b2a
commit a78b2dee46
7 changed files with 143 additions and 63 deletions

View File

@ -45,7 +45,7 @@ UsersTab::UsersTab(QWidget *parent)
ui_.tableUserList->setColumnWidth(0, 150);
ui_.tableUserList->setColumnWidth(1, 250);
ui_.tableUserList->setColumnWidth(2, 350);
ui_.tableUserList->setColumnWidth(2, 150);
connect(ui_.buttonNewUser, &QPushButton::clicked, this, &UsersTab::onAddUserButton);
connect(ui_.buttonEditUser, &QPushButton::clicked, this, &UsersTab::onEditUserButton);

View File

@ -40,7 +40,7 @@ UserDialog::UserDialog(bridgepp::SPUser &user, QWidget *parent)
ui_.editPassword->setText(user->password());
ui_.editAddresses->setPlainText(user->addresses().join("\n"));
ui_.editAvatarText->setText(user_->avatarText());
ui_.checkLoggedIn->setChecked(user_->state() == UserState::Connected);
this->setState(user->state());
ui_.checkSplitMode->setChecked(user_->splitMode());
ui_.checkSetupGuideSeen->setChecked(user_->setupGuideSeen());
ui_.spinUsedBytes->setValue(user->usedBytes());
@ -58,7 +58,7 @@ void UserDialog::onOK()
user_->setPassword(ui_.editPassword->text());
user_->setAddresses(ui_.editAddresses->toPlainText().split(QRegularExpression(R"(\s+)"), Qt::SkipEmptyParts));
user_->setAvatarText(ui_.editAvatarText->text());
user_->setState(ui_.checkLoggedIn->isChecked() ? UserState::Connected: UserState::SignedOut);
user_->setState(this->state());
user_->setSplitMode(ui_.checkSplitMode->isChecked());
user_->setSetupGuideSeen(ui_.checkSetupGuideSeen->isChecked());
user_->setUsedBytes(float(ui_.spinUsedBytes->value()));
@ -66,3 +66,21 @@ void UserDialog::onOK()
this->accept();
}
//****************************************************************************************************************************************************
/// \return The user state that is currently selected in the dialog.
//****************************************************************************************************************************************************
UserState UserDialog::state()
{
return UserState(ui_.comboState->currentIndex());
}
//****************************************************************************************************************************************************
/// \param[in] state The user state to select in the dialog.
//****************************************************************************************************************************************************
void UserDialog::setState(UserState state)
{
ui_.comboState->setCurrentIndex(qint32(state));
}

View File

@ -37,6 +37,10 @@ public: // member functions.
UserDialog &operator=(UserDialog const &) = delete; ///< Disabled assignment operator.
UserDialog &operator=(UserDialog &&) = delete; ///< Disabled move assignment operator.
private: // member functions
bridgepp::UserState state(); ///< Get the user state selected in the dialog.
void setState(bridgepp::UserState state); ///< Set the user state selected in the dialog
private slots:
void onOK(); ///< Slot for the OK button.

View File

@ -6,8 +6,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>521</width>
<height>432</height>
<width>654</width>
<height>544</height>
</rect>
</property>
<property name="windowTitle">
@ -23,17 +23,13 @@
</property>
</widget>
</item>
<item row="2" column="0">
<widget class="QLabel" name="labelPassword">
<property name="text">
<string>Password</string>
</property>
</widget>
<item row="2" column="1">
<widget class="QLineEdit" name="editPassword"/>
</item>
<item row="1" column="0">
<widget class="QLabel" name="labelUsername">
<property name="text">
<string>Account Name</string>
<item row="0" column="1">
<widget class="QLineEdit" name="editUserID">
<property name="readOnly">
<bool>true</bool>
</property>
</widget>
</item>
@ -44,43 +40,9 @@
</property>
</widget>
</item>
<item row="5" column="0">
<widget class="QLabel" name="labelUsedBytes">
<property name="text">
<string>Used Bytes</string>
</property>
</widget>
</item>
<item row="9" column="0" colspan="2">
<widget class="QCheckBox" name="checkSetupGuideSeen">
<property name="text">
<string>Setup Guide Seen</string>
</property>
</widget>
</item>
<item row="2" column="1">
<widget class="QLineEdit" name="editPassword"/>
</item>
<item row="6" column="0">
<widget class="QLabel" name="labelTotalBytes">
<property name="text">
<string>Total Bytes</string>
</property>
</widget>
</item>
<item row="4" column="1">
<widget class="QLineEdit" name="editAvatarText"/>
</item>
<item row="3" column="0">
<widget class="QLabel" name="labelAddresses">
<property name="text">
<string>Adresses</string>
</property>
<property name="alignment">
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop</set>
</property>
</widget>
</item>
<item row="3" column="1">
<widget class="QPlainTextEdit" name="editAddresses">
<property name="minimumSize">
@ -113,22 +75,51 @@
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QLineEdit" name="editUserID">
<property name="readOnly">
<bool>true</bool>
</property>
</widget>
</item>
<item row="7" column="0" colspan="2">
<widget class="QCheckBox" name="checkLoggedIn">
<item row="5" column="0">
<widget class="QLabel" name="labelUsedBytes">
<property name="text">
<string>Logged in</string>
<string>Used Bytes</string>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QLineEdit" name="editUsername"/>
<item row="7" column="1">
<layout class="QHBoxLayout" name="horizontalLayout_3">
<item>
<widget class="QComboBox" name="comboState">
<property name="sizeAdjustPolicy">
<enum>QComboBox::AdjustToContents</enum>
</property>
<item>
<property name="text">
<string>Signed Out</string>
</property>
</item>
<item>
<property name="text">
<string>Locked</string>
</property>
</item>
<item>
<property name="text">
<string>Connected</string>
</property>
</item>
</widget>
</item>
<item>
<spacer name="horizontalSpacer_2">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>1</height>
</size>
</property>
</spacer>
</item>
</layout>
</item>
<item row="6" column="1">
<widget class="QDoubleSpinBox" name="spinTotalBytes">
@ -143,6 +134,54 @@
</property>
</widget>
</item>
<item row="3" column="0">
<widget class="QLabel" name="labelAddresses">
<property name="text">
<string>Adresses</string>
</property>
<property name="alignment">
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop</set>
</property>
</widget>
</item>
<item row="2" column="0">
<widget class="QLabel" name="labelPassword">
<property name="text">
<string>Password</string>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="labelUsername">
<property name="text">
<string>Account Name</string>
</property>
</widget>
</item>
<item row="6" column="0">
<widget class="QLabel" name="labelTotalBytes">
<property name="text">
<string>Total Bytes</string>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QLineEdit" name="editUsername"/>
</item>
<item row="9" column="0" colspan="2">
<widget class="QCheckBox" name="checkSetupGuideSeen">
<property name="text">
<string>Setup Guide Seen</string>
</property>
</widget>
</item>
<item row="7" column="0">
<widget class="QLabel" name="labelTotalBytes_2">
<property name="text">
<string>State</string>
</property>
</widget>
</item>
<item row="8" column="0" colspan="2">
<widget class="QCheckBox" name="checkSplitMode">
<property name="text">
@ -209,7 +248,6 @@
<tabstop>editAvatarText</tabstop>
<tabstop>spinUsedBytes</tabstop>
<tabstop>spinTotalBytes</tabstop>
<tabstop>checkLoggedIn</tabstop>
<tabstop>checkSplitMode</tabstop>
<tabstop>checkSetupGuideSeen</tabstop>
<tabstop>buttonOK</tabstop>

View File

@ -46,7 +46,7 @@ int UserTable::rowCount(QModelIndex const &) const
//****************************************************************************************************************************************************
int UserTable::columnCount(QModelIndex const &) const
{
return 3;
return 4;
}
@ -72,6 +72,8 @@ QVariant UserTable::data(QModelIndex const &index, int role) const
case 1:
return user->property("addresses").toStringList().join(" ");
case 2:
return User::stateToString(user->state());
case 3:
return user->property("id");
default:
return QVariant();
@ -99,6 +101,8 @@ QVariant UserTable::headerData(int section, Qt::Orientation orientation, int rol
case 1:
return "Addresses";
case 2:
return "State";
case 3:
return "UserID";
default:
return QString();

View File

@ -326,4 +326,19 @@ void User::setTotalBytes(float totalBytes)
}
//****************************************************************************************************************************************************
/// \param[in] state The user state.
/// \return A string describing the state.
//****************************************************************************************************************************************************
QString User::stateToString(UserState state)
{
switch (state) {
case UserState::SignedOut: return "Signed out";
case UserState::Locked: return "Locked";
case UserState::Connected: return "Connected";
default: return "Unknown";
}
}
} // namespace bridgepp

View File

@ -66,6 +66,7 @@ class User : public QObject
Q_OBJECT
public: // static member function
static SPUser newUser(QObject *parent); ///< Create a new user
static QString stateToString(UserState state); ///< Return a string describing a user state.
public: // member functions.
User(User const &) = delete; ///< Disabled copy-constructor.