Git: inline branchcheckoutdialog.ui

Change-Id: I105f63dd7ae0110ecb0afbd13ff70027fb9431b1
Reviewed-by: Orgad Shaneh <orgads@gmail.com>
This commit is contained in:
hjk
2022-08-05 11:51:35 +02:00
parent e572bdd90c
commit 4cf40b2456
5 changed files with 71 additions and 161 deletions

View File

@@ -3,7 +3,7 @@ add_qtc_plugin(Git
SOURCES
annotationhighlighter.cpp annotationhighlighter.h
branchadddialog.cpp branchadddialog.h
branchcheckoutdialog.cpp branchcheckoutdialog.h branchcheckoutdialog.ui
branchcheckoutdialog.cpp branchcheckoutdialog.h
branchmodel.cpp branchmodel.h
branchview.cpp branchview.h
changeselectiondialog.cpp changeselectiondialog.h changeselectiondialog.ui

View File

@@ -24,7 +24,14 @@
****************************************************************************/
#include "branchcheckoutdialog.h"
#include "ui_branchcheckoutdialog.h"
#include <utils/layoutbuilder.h>
#include <QApplication>
#include <QCheckBox>
#include <QDialogButtonBox>
#include <QGroupBox>
#include <QRadioButton>
namespace Git {
namespace Internal {
@@ -32,63 +39,90 @@ namespace Internal {
BranchCheckoutDialog::BranchCheckoutDialog(QWidget *parent,
const QString &currentBranch,
const QString &nextBranch) :
QDialog(parent),
m_ui(new Ui::BranchCheckoutDialog)
QDialog(parent)
{
m_ui->setupUi(this);
setWindowModality(Qt::WindowModal);
resize(394, 199);
setModal(true);
setWindowTitle(tr("Checkout branch \"%1\"").arg(nextBranch));
m_ui->moveChangesRadioButton->setText(tr("Move Local Changes to \"%1\"").arg(nextBranch));
m_ui->popStashCheckBox->setText(tr("Pop Stash of \"%1\"").arg(nextBranch));
m_localChangesGroupBox = new QGroupBox(tr("Local Changes Found. Choose Action:"));
m_moveChangesRadioButton = new QRadioButton(tr("Move Local Changes to \"%1\"").arg(nextBranch));
m_discardChangesRadioButton = new QRadioButton(tr("Discard Local Changes"));
m_discardChangesRadioButton->setEnabled(true);
m_popStashCheckBox = new QCheckBox(tr("Pop Stash of \"%1\"").arg(nextBranch));
m_popStashCheckBox->setEnabled(false);
m_makeStashRadioButton = new QRadioButton;
m_makeStashRadioButton->setChecked(true);
if (!currentBranch.isEmpty()) {
m_ui->makeStashRadioButton->setText(tr("Create Branch Stash for \"%1\"").arg(currentBranch));
m_makeStashRadioButton->setText(tr("Create Branch Stash for \"%1\"").arg(currentBranch));
} else {
m_ui->makeStashRadioButton->setText(tr("Create Branch Stash for Current Branch"));
m_makeStashRadioButton->setText(tr("Create Branch Stash for Current Branch"));
foundNoLocalChanges();
}
connect(m_ui->moveChangesRadioButton, &QRadioButton::toggled,
auto buttonBox = new QDialogButtonBox(QDialogButtonBox::Cancel|QDialogButtonBox::Ok);
using namespace Utils::Layouting;
Column {
m_makeStashRadioButton,
m_moveChangesRadioButton,
m_discardChangesRadioButton
}.attachTo(m_localChangesGroupBox);
Column {
m_localChangesGroupBox,
m_popStashCheckBox,
st,
buttonBox
}.attachTo(this);
connect(m_moveChangesRadioButton, &QRadioButton::toggled,
this, &BranchCheckoutDialog::updatePopStashCheckBox);
connect(buttonBox, &QDialogButtonBox::accepted, this, &QDialog::accept);
connect(buttonBox, &QDialogButtonBox::rejected, this, &QDialog::reject);
}
BranchCheckoutDialog::~BranchCheckoutDialog()
{
delete m_ui;
}
BranchCheckoutDialog::~BranchCheckoutDialog() = default;
void BranchCheckoutDialog::foundNoLocalChanges()
{
m_ui->discardChangesRadioButton->setChecked(true);
m_ui->localChangesGroupBox->setEnabled(false);
m_discardChangesRadioButton->setChecked(true);
m_localChangesGroupBox->setEnabled(false);
m_hasLocalChanges = false;
}
void BranchCheckoutDialog::foundStashForNextBranch()
{
m_ui->popStashCheckBox->setChecked(true);
m_ui->popStashCheckBox->setEnabled(true);
m_popStashCheckBox->setChecked(true);
m_popStashCheckBox->setEnabled(true);
m_foundStashForNextBranch = true;
}
bool BranchCheckoutDialog::makeStashOfCurrentBranch()
{
return m_ui->makeStashRadioButton->isChecked();
return m_makeStashRadioButton->isChecked();
}
bool BranchCheckoutDialog::moveLocalChangesToNextBranch()
{
return m_ui->moveChangesRadioButton->isChecked();
return m_moveChangesRadioButton->isChecked();
}
bool BranchCheckoutDialog::discardLocalChanges()
{
return m_ui->discardChangesRadioButton->isChecked() && m_ui->localChangesGroupBox->isEnabled();
return m_discardChangesRadioButton->isChecked() && m_localChangesGroupBox->isEnabled();
}
bool BranchCheckoutDialog::popStashOfNextBranch()
{
return m_ui->popStashCheckBox->isChecked();
return m_popStashCheckBox->isChecked();
}
bool BranchCheckoutDialog::hasStashForNextBranch()
@@ -103,8 +137,8 @@ bool BranchCheckoutDialog::hasLocalChanges()
void BranchCheckoutDialog::updatePopStashCheckBox(bool moveChangesChecked)
{
m_ui->popStashCheckBox->setChecked(!moveChangesChecked && m_foundStashForNextBranch);
m_ui->popStashCheckBox->setEnabled(!moveChangesChecked && m_foundStashForNextBranch);
m_popStashCheckBox->setChecked(!moveChangesChecked && m_foundStashForNextBranch);
m_popStashCheckBox->setEnabled(!moveChangesChecked && m_foundStashForNextBranch);
}
} // namespace Internal

View File

@@ -27,11 +27,15 @@
#include <QDialog>
QT_BEGIN_NAMESPACE
class QCheckBox;
class QGroupBox;
class QRadioButton;
QT_END_NAMESPACE
namespace Git {
namespace Internal {
namespace Ui { class BranchCheckoutDialog; }
class BranchCheckoutDialog : public QDialog
{
Q_OBJECT
@@ -55,9 +59,14 @@ public:
private:
void updatePopStashCheckBox(bool moveChangesChecked);
Ui::BranchCheckoutDialog *m_ui;
bool m_foundStashForNextBranch = false;
bool m_hasLocalChanges = true;
QGroupBox *m_localChangesGroupBox;
QRadioButton *m_makeStashRadioButton;
QRadioButton *m_moveChangesRadioButton;
QRadioButton *m_discardChangesRadioButton;
QCheckBox *m_popStashCheckBox;
};
} // namespace Internal

View File

@@ -1,132 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>Git::Internal::BranchCheckoutDialog</class>
<widget class="QDialog" name="Git::Internal::BranchCheckoutDialog">
<property name="windowModality">
<enum>Qt::WindowModal</enum>
</property>
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>394</width>
<height>199</height>
</rect>
</property>
<property name="modal">
<bool>true</bool>
</property>
<layout class="QVBoxLayout" name="verticalLayout_2">
<item>
<widget class="QGroupBox" name="localChangesGroupBox">
<property name="title">
<string>Local Changes Found. Choose Action:</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="QRadioButton" name="makeStashRadioButton">
<property name="text">
<string>RadioButton</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QRadioButton" name="moveChangesRadioButton">
<property name="text">
<string>RadioButton</string>
</property>
</widget>
</item>
<item>
<widget class="QRadioButton" name="discardChangesRadioButton">
<property name="enabled">
<bool>true</bool>
</property>
<property name="text">
<string>Discard Local Changes</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item>
<widget class="QCheckBox" name="popStashCheckBox">
<property name="enabled">
<bool>false</bool>
</property>
<property name="text">
<string>CheckBox</string>
</property>
</widget>
</item>
<item>
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</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>
<tabstops>
<tabstop>makeStashRadioButton</tabstop>
<tabstop>moveChangesRadioButton</tabstop>
<tabstop>discardChangesRadioButton</tabstop>
<tabstop>popStashCheckBox</tabstop>
</tabstops>
<resources/>
<connections>
<connection>
<sender>buttonBox</sender>
<signal>accepted()</signal>
<receiver>Git::Internal::BranchCheckoutDialog</receiver>
<slot>accept()</slot>
<hints>
<hint type="sourcelabel">
<x>227</x>
<y>219</y>
</hint>
<hint type="destinationlabel">
<x>157</x>
<y>179</y>
</hint>
</hints>
</connection>
<connection>
<sender>buttonBox</sender>
<signal>rejected()</signal>
<receiver>Git::Internal::BranchCheckoutDialog</receiver>
<slot>reject()</slot>
<hints>
<hint type="sourcelabel">
<x>295</x>
<y>219</y>
</hint>
<hint type="destinationlabel">
<x>286</x>
<y>179</y>
</hint>
</hints>
</connection>
</connections>
</ui>

View File

@@ -20,7 +20,6 @@ QtcPlugin {
"branchadddialog.h",
"branchcheckoutdialog.cpp",
"branchcheckoutdialog.h",
"branchcheckoutdialog.ui",
"branchmodel.cpp",
"branchmodel.h",
"branchview.cpp",