Utils: Inline removefiledialog.ui

Change-Id: Iaff681b83cb0e4b0bf0c993734a3a715ddcedd9e
Reviewed-by: Alessandro Portale <alessandro.portale@qt.io>
This commit is contained in:
hjk
2022-07-22 17:24:59 +02:00
parent 5297cfb3c9
commit c4ac72066e
5 changed files with 46 additions and 158 deletions

View File

@@ -135,7 +135,7 @@ add_qtc_library(Utils
qtcprocess.cpp qtcprocess.h qtcprocess.cpp qtcprocess.h
qtcsettings.cpp qtcsettings.h qtcsettings.cpp qtcsettings.h
reloadpromptutils.cpp reloadpromptutils.h reloadpromptutils.cpp reloadpromptutils.h
removefiledialog.cpp removefiledialog.h removefiledialog.ui removefiledialog.cpp removefiledialog.h
runextensions.cpp runextensions.h runextensions.cpp runextensions.h
savefile.cpp savefile.h savefile.cpp savefile.h
scopedswap.h scopedswap.h

View File

@@ -24,36 +24,62 @@
****************************************************************************/ ****************************************************************************/
#include "removefiledialog.h" #include "removefiledialog.h"
#include "ui_removefiledialog.h"
#include "filepath.h" #include "filepath.h"
#include "layoutbuilder.h"
#include <QApplication>
#include <QCheckBox>
#include <QDialogButtonBox>
#include <QLabel>
namespace Utils { namespace Utils {
RemoveFileDialog::RemoveFileDialog(const FilePath &filePath, QWidget *parent) : RemoveFileDialog::RemoveFileDialog(const FilePath &filePath, QWidget *parent)
QDialog(parent), : QDialog(parent)
m_ui(new Ui::RemoveFileDialog)
{ {
m_ui->setupUi(this); setWindowTitle(tr("Remove File"));
m_ui->fileNameLabel->setText(filePath.toUserOutput()); resize(514, 159);
// TODO QFont font;
m_ui->removeVCCheckBox->setVisible(false); font.setFamilies({"Courier New"});
auto fileNameLabel = new QLabel(filePath.toUserOutput());
fileNameLabel->setFont(font);
fileNameLabel->setWordWrap(true);
m_deleteFileCheckBox = new QCheckBox(tr("&Delete file permanently"));
auto removeVCCheckBox = new QCheckBox(tr("&Remove from version control"));
removeVCCheckBox->setVisible(false); // TODO
auto buttonBox = new QDialogButtonBox(QDialogButtonBox::Cancel|QDialogButtonBox::Ok);
using namespace Layouting;
Column {
tr("File to remove:"),
fileNameLabel,
Space(10),
m_deleteFileCheckBox,
removeVCCheckBox,
buttonBox
}.attachTo(this);
connect(buttonBox, &QDialogButtonBox::accepted, this, &QDialog::accept);
connect(buttonBox, &QDialogButtonBox::rejected, this, &QDialog::reject);
} }
RemoveFileDialog::~RemoveFileDialog() RemoveFileDialog::~RemoveFileDialog() = default;
{
delete m_ui;
}
void RemoveFileDialog::setDeleteFileVisible(bool visible) void RemoveFileDialog::setDeleteFileVisible(bool visible)
{ {
m_ui->deleteFileCheckBox->setVisible(visible); m_deleteFileCheckBox->setVisible(visible);
} }
bool RemoveFileDialog::isDeleteFileChecked() const bool RemoveFileDialog::isDeleteFileChecked() const
{ {
return m_ui->deleteFileCheckBox->isChecked(); return m_deleteFileCheckBox->isChecked();
} }
} // Utils } // Utils

View File

@@ -29,10 +29,13 @@
#include <QDialog> #include <QDialog>
QT_BEGIN_NAMESPACE
class QCheckBox;
QT_END_NAMESPACE
namespace Utils { namespace Utils {
class FilePath; class FilePath;
namespace Ui { class RemoveFileDialog; }
class QTCREATOR_UTILS_EXPORT RemoveFileDialog : public QDialog class QTCREATOR_UTILS_EXPORT RemoveFileDialog : public QDialog
{ {
@@ -46,7 +49,7 @@ public:
bool isDeleteFileChecked() const; bool isDeleteFileChecked() const;
private: private:
Ui::RemoveFileDialog *m_ui; QCheckBox *m_deleteFileCheckBox;
}; };
} // namespace Utils } // namespace Utils

View File

@@ -1,140 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>Utils::RemoveFileDialog</class>
<widget class="QDialog" name="Utils::RemoveFileDialog">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>514</width>
<height>159</height>
</rect>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="windowTitle">
<string>Remove File</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="QLabel" name="fileToDeleteLabel">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>File to remove:</string>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="fileNameLabel">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="font">
<font>
<family>Courier New</family>
</font>
</property>
<property name="text">
<string notr="true">placeholder</string>
</property>
<property name="wordWrap">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeType">
<enum>QSizePolicy::Fixed</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>10</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QCheckBox" name="deleteFileCheckBox">
<property name="text">
<string>&amp;Delete file permanently</string>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="removeVCCheckBox">
<property name="text">
<string>&amp;Remove from version control</string>
</property>
</widget>
</item>
<item>
<widget class="QDialogButtonBox" name="buttonBox">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<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>Utils::RemoveFileDialog</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>Utils::RemoveFileDialog</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

@@ -261,7 +261,6 @@ Project {
"reloadpromptutils.h", "reloadpromptutils.h",
"removefiledialog.cpp", "removefiledialog.cpp",
"removefiledialog.h", "removefiledialog.h",
"removefiledialog.ui",
"runextensions.cpp", "runextensions.cpp",
"runextensions.h", "runextensions.h",
"savefile.cpp", "savefile.cpp",