connect dialog: button reworks (#3243)

This commit is contained in:
tooomm 2018-05-26 03:59:42 +02:00 committed by Zach H
parent f97959febc
commit 3a05d063af
2 changed files with 15 additions and 28 deletions

View file

@ -85,16 +85,18 @@ DlgConnect::DlgConnect(QWidget *parent) : QDialog(parent)
updateDisplayInfo(previousHosts->currentText());
btnForgotPassword = new QPushButton(tr("Forgot password"));
btnForgotPassword = new QPushButton(this);
btnForgotPassword->setIcon(QPixmap("theme:icons/lock"));
btnForgotPassword->setToolTip(tr("Forgot Password"));
btnForgotPassword->setFixedWidth(30);
connect(btnForgotPassword, SIGNAL(released()), this, SLOT(actForgotPassword()));
btnOk = new QPushButton(tr("Connect"));
btnOk->setFixedWidth(100);
connect(btnOk, SIGNAL(released()), this, SLOT(actOk()));
btnConnect = new QPushButton(tr("&Connect"));
connect(btnConnect, SIGNAL(released()), this, SLOT(actOk()));
btnCancel = new QPushButton(tr("Cancel"));
btnCancel->setFixedWidth(100);
connect(btnCancel, SIGNAL(released()), this, SLOT(actCancel()));
auto *buttonBox = new QDialogButtonBox(QDialogButtonBox::Cancel);
buttonBox->addButton(btnConnect, QDialogButtonBox::AcceptRole);
connect(buttonBox, SIGNAL(rejected()), this, SLOT(reject()));
newHolderLayout = new QHBoxLayout;
newHolderLayout->addWidget(previousHosts);
@ -112,11 +114,6 @@ DlgConnect::DlgConnect(QWidget *parent) : QDialog(parent)
connectionLayout->addWidget(portEdit, 5, 1);
connectionLayout->addWidget(autoConnectCheckBox, 6, 1);
buttons = new QGridLayout;
buttons->addWidget(btnOk, 0, 0);
buttons->addWidget(btnForgotPassword, 0, 1);
buttons->addWidget(btnCancel, 0, 2);
restrictionsGroupBox = new QGroupBox(tr("Server"));
restrictionsGroupBox->setLayout(connectionLayout);
@ -127,9 +124,10 @@ DlgConnect::DlgConnect(QWidget *parent) : QDialog(parent)
loginLayout = new QGridLayout;
loginLayout->addWidget(playernameLabel, 0, 0);
loginLayout->addWidget(playernameEdit, 0, 1);
loginLayout->addWidget(playernameEdit, 0, 1, 1, 2);
loginLayout->addWidget(passwordLabel, 1, 0);
loginLayout->addWidget(passwordEdit, 1, 1);
loginLayout->addWidget(btnForgotPassword, 1, 2);
loginLayout->addWidget(savePasswordCheckBox, 2, 1);
loginGroupBox = new QGroupBox(tr("Login"));
@ -138,20 +136,17 @@ DlgConnect::DlgConnect(QWidget *parent) : QDialog(parent)
serverInfoGroupBox = new QGroupBox(tr("Server Contact"));
serverInfoGroupBox->setLayout(serverInfoLayout);
btnGroupBox = new QGroupBox(tr(""));
btnGroupBox->setLayout(buttons);
grid = new QGridLayout;
grid->addWidget(restrictionsGroupBox, 0, 0);
grid->addWidget(serverInfoGroupBox, 1, 0);
grid->addWidget(loginGroupBox, 2, 0);
grid->addWidget(btnGroupBox, 3, 0);
mainLayout = new QVBoxLayout;
mainLayout->addLayout(grid);
mainLayout->addWidget(buttonBox);
setLayout(mainLayout);
setWindowTitle(tr("Connect to server"));
setWindowTitle(tr("Connect to Server"));
setFixedHeight(sizeHint().height());
setMinimumWidth(300);
@ -339,13 +334,6 @@ QString DlgConnect::getHost() const
return hostEdit->text().trimmed();
}
void DlgConnect::actCancel()
{
settingsCache->servers().setSavePassword(savePasswordCheckBox->isChecked());
settingsCache->servers().setAutoConnect(autoConnectCheckBox->isChecked());
reject();
}
bool DeleteHighlightedItemWhenShiftDelPressedEventFilter::eventFilter(QObject *obj, QEvent *event)
{
if (event->type() == QEvent::KeyPress) {

View file

@ -49,7 +49,6 @@ public:
private slots:
void actOk();
void actCancel();
void actSaveConfig();
void passwordSaved(int state);
void previousHostSelected(bool state);
@ -61,7 +60,7 @@ private slots:
void downloadThePublicServers();
private:
QGridLayout *newHostLayout, *connectionLayout, *buttons, *loginLayout, *serverInfoLayout, *grid;
QGridLayout *newHostLayout, *connectionLayout, *loginLayout, *serverInfoLayout, *grid;
QHBoxLayout *newHolderLayout;
QGroupBox *loginGroupBox, *serverInfoGroupBox, *btnGroupBox, *restrictionsGroupBox;
QVBoxLayout *mainLayout;
@ -71,7 +70,7 @@ private:
QCheckBox *savePasswordCheckBox, *autoConnectCheckBox;
QComboBox *previousHosts;
QRadioButton *newHostButton, *previousHostButton;
QPushButton *btnOk, *btnCancel, *btnForgotPassword, *btnRefreshServers;
QPushButton *btnConnect, *btnForgotPassword, *btnRefreshServers;
QMap<QString, std::pair<QString, UserConnection_Information>> savedHostList;
HandlePublicServers *hps;
const QString placeHolderText = tr("Downloading...");