Mercurial: Inline authenticationdialog.ui

Change-Id: I235c8aaf7d2dd8e49e8a22b81523a322b5f596bc
Reviewed-by: Alessandro Portale <alessandro.portale@qt.io>
This commit is contained in:
hjk
2022-10-04 10:10:58 +02:00
parent 8d80623a0f
commit 1f5eb9e62f
5 changed files with 43 additions and 118 deletions

View File

@@ -2,7 +2,7 @@ add_qtc_plugin(Mercurial
PLUGIN_DEPENDS Core TextEditor VcsBase PLUGIN_DEPENDS Core TextEditor VcsBase
SOURCES SOURCES
annotationhighlighter.cpp annotationhighlighter.h annotationhighlighter.cpp annotationhighlighter.h
authenticationdialog.cpp authenticationdialog.h authenticationdialog.ui authenticationdialog.cpp authenticationdialog.h
commiteditor.cpp commiteditor.h commiteditor.cpp commiteditor.h
constants.h constants.h
mercurialclient.cpp mercurialclient.h mercurialclient.cpp mercurialclient.h

View File

@@ -2,39 +2,55 @@
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0+ OR GPL-3.0 WITH Qt-GPL-exception-1.0 // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0+ OR GPL-3.0 WITH Qt-GPL-exception-1.0
#include "authenticationdialog.h" #include "authenticationdialog.h"
#include "ui_authenticationdialog.h"
namespace Mercurial { #include <utils/layoutbuilder.h>
namespace Internal {
AuthenticationDialog::AuthenticationDialog(const QString &username, const QString &password, QWidget *parent) : #include <QDialogButtonBox>
QDialog(parent), #include <QLineEdit>
ui(new Ui::AuthenticationDialog)
namespace Mercurial::Internal {
AuthenticationDialog::AuthenticationDialog(const QString &username, const QString &password, QWidget *parent)
: QDialog(parent)
{ {
ui->setupUi(this); resize(312, 116);
ui->username->setText(username);
ui->password->setText(password); m_username = new QLineEdit(username);
m_password = new QLineEdit(password);
m_password->setEchoMode(QLineEdit::Password);
auto buttonBox = new QDialogButtonBox(QDialogButtonBox::Cancel|QDialogButtonBox::Ok);
using namespace Utils::Layouting;
Column {
Form {
tr("Username:"), m_username, br,
tr("Password:"), m_password
},
buttonBox
}.attachTo(this);
connect(buttonBox, &QDialogButtonBox::accepted, this, &QDialog::accept);
connect(buttonBox, &QDialogButtonBox::rejected, this, &QDialog::reject);
} }
AuthenticationDialog::~AuthenticationDialog() AuthenticationDialog::~AuthenticationDialog() = default;
{
delete ui;
}
void AuthenticationDialog::setPasswordEnabled(bool enabled) void AuthenticationDialog::setPasswordEnabled(bool enabled)
{ {
ui->password->setEnabled(enabled); m_password->setEnabled(enabled);
} }
QString AuthenticationDialog::getUserName() QString AuthenticationDialog::getUserName()
{ {
return ui->username->text(); return m_username->text();
} }
QString AuthenticationDialog::getPassword() QString AuthenticationDialog::getPassword()
{ {
return ui->password->text(); return m_password->text();
} }
} // namespace Internal } // Mercurial::Internal
} // namespace Mercurial

View File

@@ -5,10 +5,11 @@
#include <QDialog> #include <QDialog>
namespace Mercurial { QT_BEGIN_NAMESPACE
namespace Internal { class QLineEdit;
QT_END_NAMESPACE
namespace Ui { class AuthenticationDialog; } namespace Mercurial::Internal {
class AuthenticationDialog : public QDialog class AuthenticationDialog : public QDialog
{ {
@@ -18,13 +19,14 @@ public:
explicit AuthenticationDialog(const QString &username, const QString &password, explicit AuthenticationDialog(const QString &username, const QString &password,
QWidget *parent = nullptr); QWidget *parent = nullptr);
~AuthenticationDialog() override; ~AuthenticationDialog() override;
void setPasswordEnabled(bool enabled); void setPasswordEnabled(bool enabled);
QString getUserName(); QString getUserName();
QString getPassword(); QString getPassword();
private: private:
Ui::AuthenticationDialog *ui; QLineEdit *m_username;
QLineEdit *m_password;
}; };
} // namespace Internal } // Mercurial::Internal
} // namespace Mercurial

View File

@@ -1,92 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>Mercurial::Internal::AuthenticationDialog</class>
<widget class="QDialog" name="Mercurial::Internal::AuthenticationDialog">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>312</width>
<height>116</height>
</rect>
</property>
<property name="windowTitle">
<string>Dialog</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<layout class="QFormLayout" name="formLayout">
<item row="0" column="0">
<widget class="QLabel" name="usernameLabel">
<property name="text">
<string>Username:</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QLineEdit" name="username"/>
</item>
<item row="1" column="0">
<widget class="QLabel" name="passwordLabel">
<property name="text">
<string>Password:</string>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QLineEdit" name="password">
<property name="echoMode">
<enum>QLineEdit::Password</enum>
</property>
</widget>
</item>
</layout>
</item>
<item>
<widget class="QDialogButtonBox" name="buttonBox">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="standardButtons">
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
</property>
</widget>
</item>
</layout>
</widget>
<resources/>
<connections>
<connection>
<sender>buttonBox</sender>
<signal>accepted()</signal>
<receiver>Mercurial::Internal::AuthenticationDialog</receiver>
<slot>accept()</slot>
<hints>
<hint type="sourcelabel">
<x>248</x>
<y>254</y>
</hint>
<hint type="destinationlabel">
<x>157</x>
<y>274</y>
</hint>
</hints>
</connection>
<connection>
<sender>buttonBox</sender>
<signal>rejected()</signal>
<receiver>Mercurial::Internal::AuthenticationDialog</receiver>
<slot>reject()</slot>
<hints>
<hint type="sourcelabel">
<x>316</x>
<y>260</y>
</hint>
<hint type="destinationlabel">
<x>286</x>
<y>274</y>
</hint>
</hints>
</connection>
</connections>
</ui>

View File

@@ -16,7 +16,6 @@ QtcPlugin {
"annotationhighlighter.h", "annotationhighlighter.h",
"authenticationdialog.cpp", "authenticationdialog.cpp",
"authenticationdialog.h", "authenticationdialog.h",
"authenticationdialog.ui",
"commiteditor.cpp", "commiteditor.cpp",
"commiteditor.h", "commiteditor.h",
"constants.h", "constants.h",