mirror of
https://github.com/ProtonMail/proton-bridge.git
synced 2025-12-17 23:56:56 +00:00
Other: GUI Tester supports the 3 states of user (Signed out/Locked/Connected).
This commit is contained in:
@ -45,7 +45,7 @@ UsersTab::UsersTab(QWidget *parent)
|
|||||||
|
|
||||||
ui_.tableUserList->setColumnWidth(0, 150);
|
ui_.tableUserList->setColumnWidth(0, 150);
|
||||||
ui_.tableUserList->setColumnWidth(1, 250);
|
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_.buttonNewUser, &QPushButton::clicked, this, &UsersTab::onAddUserButton);
|
||||||
connect(ui_.buttonEditUser, &QPushButton::clicked, this, &UsersTab::onEditUserButton);
|
connect(ui_.buttonEditUser, &QPushButton::clicked, this, &UsersTab::onEditUserButton);
|
||||||
|
|||||||
@ -40,7 +40,7 @@ UserDialog::UserDialog(bridgepp::SPUser &user, QWidget *parent)
|
|||||||
ui_.editPassword->setText(user->password());
|
ui_.editPassword->setText(user->password());
|
||||||
ui_.editAddresses->setPlainText(user->addresses().join("\n"));
|
ui_.editAddresses->setPlainText(user->addresses().join("\n"));
|
||||||
ui_.editAvatarText->setText(user_->avatarText());
|
ui_.editAvatarText->setText(user_->avatarText());
|
||||||
ui_.checkLoggedIn->setChecked(user_->state() == UserState::Connected);
|
this->setState(user->state());
|
||||||
ui_.checkSplitMode->setChecked(user_->splitMode());
|
ui_.checkSplitMode->setChecked(user_->splitMode());
|
||||||
ui_.checkSetupGuideSeen->setChecked(user_->setupGuideSeen());
|
ui_.checkSetupGuideSeen->setChecked(user_->setupGuideSeen());
|
||||||
ui_.spinUsedBytes->setValue(user->usedBytes());
|
ui_.spinUsedBytes->setValue(user->usedBytes());
|
||||||
@ -58,7 +58,7 @@ void UserDialog::onOK()
|
|||||||
user_->setPassword(ui_.editPassword->text());
|
user_->setPassword(ui_.editPassword->text());
|
||||||
user_->setAddresses(ui_.editAddresses->toPlainText().split(QRegularExpression(R"(\s+)"), Qt::SkipEmptyParts));
|
user_->setAddresses(ui_.editAddresses->toPlainText().split(QRegularExpression(R"(\s+)"), Qt::SkipEmptyParts));
|
||||||
user_->setAvatarText(ui_.editAvatarText->text());
|
user_->setAvatarText(ui_.editAvatarText->text());
|
||||||
user_->setState(ui_.checkLoggedIn->isChecked() ? UserState::Connected: UserState::SignedOut);
|
user_->setState(this->state());
|
||||||
user_->setSplitMode(ui_.checkSplitMode->isChecked());
|
user_->setSplitMode(ui_.checkSplitMode->isChecked());
|
||||||
user_->setSetupGuideSeen(ui_.checkSetupGuideSeen->isChecked());
|
user_->setSetupGuideSeen(ui_.checkSetupGuideSeen->isChecked());
|
||||||
user_->setUsedBytes(float(ui_.spinUsedBytes->value()));
|
user_->setUsedBytes(float(ui_.spinUsedBytes->value()));
|
||||||
@ -66,3 +66,21 @@ void UserDialog::onOK()
|
|||||||
|
|
||||||
this->accept();
|
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));
|
||||||
|
}
|
||||||
|
|||||||
@ -37,6 +37,10 @@ public: // member functions.
|
|||||||
UserDialog &operator=(UserDialog const &) = delete; ///< Disabled assignment operator.
|
UserDialog &operator=(UserDialog const &) = delete; ///< Disabled assignment operator.
|
||||||
UserDialog &operator=(UserDialog &&) = delete; ///< Disabled move 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:
|
private slots:
|
||||||
void onOK(); ///< Slot for the OK button.
|
void onOK(); ///< Slot for the OK button.
|
||||||
|
|
||||||
|
|||||||
@ -6,8 +6,8 @@
|
|||||||
<rect>
|
<rect>
|
||||||
<x>0</x>
|
<x>0</x>
|
||||||
<y>0</y>
|
<y>0</y>
|
||||||
<width>521</width>
|
<width>654</width>
|
||||||
<height>432</height>
|
<height>544</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<property name="windowTitle">
|
<property name="windowTitle">
|
||||||
@ -23,17 +23,13 @@
|
|||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="2" column="0">
|
<item row="2" column="1">
|
||||||
<widget class="QLabel" name="labelPassword">
|
<widget class="QLineEdit" name="editPassword"/>
|
||||||
<property name="text">
|
|
||||||
<string>Password</string>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
</item>
|
||||||
<item row="1" column="0">
|
<item row="0" column="1">
|
||||||
<widget class="QLabel" name="labelUsername">
|
<widget class="QLineEdit" name="editUserID">
|
||||||
<property name="text">
|
<property name="readOnly">
|
||||||
<string>Account Name</string>
|
<bool>true</bool>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
@ -44,43 +40,9 @@
|
|||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</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">
|
<item row="4" column="1">
|
||||||
<widget class="QLineEdit" name="editAvatarText"/>
|
<widget class="QLineEdit" name="editAvatarText"/>
|
||||||
</item>
|
</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">
|
<item row="3" column="1">
|
||||||
<widget class="QPlainTextEdit" name="editAddresses">
|
<widget class="QPlainTextEdit" name="editAddresses">
|
||||||
<property name="minimumSize">
|
<property name="minimumSize">
|
||||||
@ -113,22 +75,51 @@
|
|||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="0" column="1">
|
<item row="5" column="0">
|
||||||
<widget class="QLineEdit" name="editUserID">
|
<widget class="QLabel" name="labelUsedBytes">
|
||||||
<property name="readOnly">
|
|
||||||
<bool>true</bool>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item row="7" column="0" colspan="2">
|
|
||||||
<widget class="QCheckBox" name="checkLoggedIn">
|
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>Logged in</string>
|
<string>Used Bytes</string>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="1" column="1">
|
<item row="7" column="1">
|
||||||
<widget class="QLineEdit" name="editUsername"/>
|
<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>
|
||||||
<item row="6" column="1">
|
<item row="6" column="1">
|
||||||
<widget class="QDoubleSpinBox" name="spinTotalBytes">
|
<widget class="QDoubleSpinBox" name="spinTotalBytes">
|
||||||
@ -143,6 +134,54 @@
|
|||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</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">
|
<item row="8" column="0" colspan="2">
|
||||||
<widget class="QCheckBox" name="checkSplitMode">
|
<widget class="QCheckBox" name="checkSplitMode">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
@ -209,7 +248,6 @@
|
|||||||
<tabstop>editAvatarText</tabstop>
|
<tabstop>editAvatarText</tabstop>
|
||||||
<tabstop>spinUsedBytes</tabstop>
|
<tabstop>spinUsedBytes</tabstop>
|
||||||
<tabstop>spinTotalBytes</tabstop>
|
<tabstop>spinTotalBytes</tabstop>
|
||||||
<tabstop>checkLoggedIn</tabstop>
|
|
||||||
<tabstop>checkSplitMode</tabstop>
|
<tabstop>checkSplitMode</tabstop>
|
||||||
<tabstop>checkSetupGuideSeen</tabstop>
|
<tabstop>checkSetupGuideSeen</tabstop>
|
||||||
<tabstop>buttonOK</tabstop>
|
<tabstop>buttonOK</tabstop>
|
||||||
|
|||||||
@ -46,7 +46,7 @@ int UserTable::rowCount(QModelIndex const &) const
|
|||||||
//****************************************************************************************************************************************************
|
//****************************************************************************************************************************************************
|
||||||
int UserTable::columnCount(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:
|
case 1:
|
||||||
return user->property("addresses").toStringList().join(" ");
|
return user->property("addresses").toStringList().join(" ");
|
||||||
case 2:
|
case 2:
|
||||||
|
return User::stateToString(user->state());
|
||||||
|
case 3:
|
||||||
return user->property("id");
|
return user->property("id");
|
||||||
default:
|
default:
|
||||||
return QVariant();
|
return QVariant();
|
||||||
@ -99,6 +101,8 @@ QVariant UserTable::headerData(int section, Qt::Orientation orientation, int rol
|
|||||||
case 1:
|
case 1:
|
||||||
return "Addresses";
|
return "Addresses";
|
||||||
case 2:
|
case 2:
|
||||||
|
return "State";
|
||||||
|
case 3:
|
||||||
return "UserID";
|
return "UserID";
|
||||||
default:
|
default:
|
||||||
return QString();
|
return QString();
|
||||||
|
|||||||
@ -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
|
} // namespace bridgepp
|
||||||
|
|||||||
@ -66,6 +66,7 @@ class User : public QObject
|
|||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public: // static member function
|
public: // static member function
|
||||||
static SPUser newUser(QObject *parent); ///< Create a new user
|
static SPUser newUser(QObject *parent); ///< Create a new user
|
||||||
|
static QString stateToString(UserState state); ///< Return a string describing a user state.
|
||||||
|
|
||||||
public: // member functions.
|
public: // member functions.
|
||||||
User(User const &) = delete; ///< Disabled copy-constructor.
|
User(User const &) = delete; ///< Disabled copy-constructor.
|
||||||
|
|||||||
Reference in New Issue
Block a user