forked from qt-creator/qt-creator
ResourceEditor: inline qrceditor.ui
Change-Id: Ie8ec4a7c333287c1ad6e94691ca2d988547d419c Reviewed-by: <github-actions-qt-creator@cristianadam.eu> Reviewed-by: Eike Ziller <eike.ziller@qt.io>
This commit is contained in:
@@ -2,7 +2,7 @@ add_qtc_plugin(ResourceEditor
|
||||
DEPENDS Qt5::Xml
|
||||
PLUGIN_DEPENDS Core ProjectExplorer
|
||||
SOURCES
|
||||
qrceditor/qrceditor.cpp qrceditor/qrceditor.h qrceditor/qrceditor.ui
|
||||
qrceditor/qrceditor.cpp qrceditor/qrceditor.h
|
||||
qrceditor/resourcefile.cpp qrceditor/resourcefile_p.h
|
||||
qrceditor/resourceview.cpp qrceditor/resourceview.h
|
||||
qrceditor/undocommands.cpp qrceditor/undocommands_p.h
|
||||
|
@@ -28,12 +28,16 @@
|
||||
|
||||
#include <aggregation/aggregate.h>
|
||||
#include <coreplugin/find/itemviewfind.h>
|
||||
#include <utils/layoutbuilder.h>
|
||||
|
||||
#include <QDebug>
|
||||
#include <QScopedPointer>
|
||||
#include <QMenu>
|
||||
#include <QFileDialog>
|
||||
#include <QLabel>
|
||||
#include <QLineEdit>
|
||||
#include <QMenu>
|
||||
#include <QMessageBox>
|
||||
#include <QPushButton>
|
||||
#include <QScopedPointer>
|
||||
|
||||
using namespace ResourceEditor;
|
||||
using namespace ResourceEditor::Internal;
|
||||
@@ -44,14 +48,46 @@ QrcEditor::QrcEditor(RelativeResourceModel *model, QWidget *parent)
|
||||
{
|
||||
addWidget(m_treeview);
|
||||
auto widget = new QWidget;
|
||||
m_ui.setupUi(widget);
|
||||
addWidget(widget);
|
||||
m_treeview->setFrameStyle(QFrame::NoFrame);
|
||||
m_treeview->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::Minimum);
|
||||
|
||||
connect(m_ui.addPrefixButton, &QAbstractButton::clicked, this, &QrcEditor::onAddPrefix);
|
||||
connect(m_ui.addFilesButton, &QAbstractButton::clicked, this, &QrcEditor::onAddFiles);
|
||||
connect(m_ui.removeButton, &QAbstractButton::clicked, this, &QrcEditor::onRemove);
|
||||
connect(m_ui.removeNonExistingButton, &QPushButton::clicked,
|
||||
auto addPrefixButton = new QPushButton(tr("Add Prefix"));
|
||||
m_addFilesButton = new QPushButton(tr("Add Files"));
|
||||
m_removeButton = new QPushButton(tr("Remove"));
|
||||
m_removeNonExistingButton = new QPushButton(tr("Remove Missing Files"));
|
||||
|
||||
m_aliasLabel = new QLabel(tr("Alias:"));
|
||||
m_aliasText = new QLineEdit;
|
||||
m_prefixLabel = new QLabel(tr("Prefix:"));
|
||||
m_prefixText = new QLineEdit;
|
||||
m_languageLabel = new QLabel(tr("Language:"));
|
||||
m_languageText = new QLineEdit;
|
||||
|
||||
using namespace Utils::Layouting;
|
||||
Column {
|
||||
Row {
|
||||
addPrefixButton,
|
||||
m_addFilesButton,
|
||||
m_removeButton,
|
||||
m_removeNonExistingButton,
|
||||
st,
|
||||
},
|
||||
Group {
|
||||
title(tr("Properties")),
|
||||
Form {
|
||||
m_aliasLabel, m_aliasText, br,
|
||||
m_prefixLabel, m_prefixText, br,
|
||||
m_languageLabel, m_languageText, br,
|
||||
}
|
||||
},
|
||||
st,
|
||||
}.attachTo(widget);
|
||||
|
||||
connect(addPrefixButton, &QAbstractButton::clicked, this, &QrcEditor::onAddPrefix);
|
||||
connect(m_addFilesButton, &QAbstractButton::clicked, this, &QrcEditor::onAddFiles);
|
||||
connect(m_removeButton, &QAbstractButton::clicked, this, &QrcEditor::onRemove);
|
||||
connect(m_removeNonExistingButton, &QPushButton::clicked,
|
||||
this, &QrcEditor::onRemoveNonExisting);
|
||||
|
||||
connect(m_treeview, &ResourceView::removeItem, this, &QrcEditor::onRemove);
|
||||
@@ -61,9 +97,9 @@ QrcEditor::QrcEditor(RelativeResourceModel *model, QWidget *parent)
|
||||
connect(m_treeview, &ResourceView::contextMenuShown, this, &QrcEditor::showContextMenu);
|
||||
m_treeview->setFocus();
|
||||
|
||||
connect(m_ui.aliasText, &QLineEdit::textEdited, this, &QrcEditor::onAliasChanged);
|
||||
connect(m_ui.prefixText, &QLineEdit::textEdited, this, &QrcEditor::onPrefixChanged);
|
||||
connect(m_ui.languageText, &QLineEdit::textEdited, this, &QrcEditor::onLanguageChanged);
|
||||
connect(m_aliasText, &QLineEdit::textEdited, this, &QrcEditor::onAliasChanged);
|
||||
connect(m_prefixText, &QLineEdit::textEdited, this, &QrcEditor::onPrefixChanged);
|
||||
connect(m_languageText, &QLineEdit::textEdited, this, &QrcEditor::onLanguageChanged);
|
||||
|
||||
// Prevent undo command merging after a switch of focus:
|
||||
// (0) The initial text is "Green".
|
||||
@@ -73,11 +109,11 @@ QrcEditor::QrcEditor(RelativeResourceModel *model, QWidget *parent)
|
||||
// --> text now is "Red is a color."
|
||||
// (4) The user hits undo --> text now is "Green is a color."
|
||||
// Without calling advanceMergeId() it would have been "Green", instead.
|
||||
connect(m_ui.aliasText, &QLineEdit::editingFinished,
|
||||
connect(m_aliasText, &QLineEdit::editingFinished,
|
||||
m_treeview, &ResourceView::advanceMergeId);
|
||||
connect(m_ui.prefixText, &QLineEdit::editingFinished,
|
||||
connect(m_prefixText, &QLineEdit::editingFinished,
|
||||
m_treeview, &ResourceView::advanceMergeId);
|
||||
connect(m_ui.languageText, &QLineEdit::editingFinished,
|
||||
connect(m_languageText, &QLineEdit::editingFinished,
|
||||
m_treeview, &ResourceView::advanceMergeId);
|
||||
|
||||
connect(&m_history, &QUndoStack::canRedoChanged, this, &QrcEditor::updateHistoryControls);
|
||||
@@ -116,23 +152,23 @@ void QrcEditor::updateCurrent()
|
||||
const bool isPrefix = m_treeview->isPrefix(m_treeview->currentIndex()) && isValid;
|
||||
const bool isFile = !isPrefix && isValid;
|
||||
|
||||
m_ui.aliasLabel->setEnabled(isFile);
|
||||
m_ui.aliasText->setEnabled(isFile);
|
||||
m_aliasLabel->setEnabled(isFile);
|
||||
m_aliasText->setEnabled(isFile);
|
||||
m_currentAlias = m_treeview->currentAlias();
|
||||
m_ui.aliasText->setText(m_currentAlias);
|
||||
m_aliasText->setText(m_currentAlias);
|
||||
|
||||
m_ui.prefixLabel->setEnabled(isPrefix);
|
||||
m_ui.prefixText->setEnabled(isPrefix);
|
||||
m_prefixLabel->setEnabled(isPrefix);
|
||||
m_prefixText->setEnabled(isPrefix);
|
||||
m_currentPrefix = m_treeview->currentPrefix();
|
||||
m_ui.prefixText->setText(m_currentPrefix);
|
||||
m_prefixText->setText(m_currentPrefix);
|
||||
|
||||
m_ui.languageLabel->setEnabled(isPrefix);
|
||||
m_ui.languageText->setEnabled(isPrefix);
|
||||
m_languageLabel->setEnabled(isPrefix);
|
||||
m_languageText->setEnabled(isPrefix);
|
||||
m_currentLanguage = m_treeview->currentLanguage();
|
||||
m_ui.languageText->setText(m_currentLanguage);
|
||||
m_languageText->setText(m_currentLanguage);
|
||||
|
||||
m_ui.addFilesButton->setEnabled(isValid);
|
||||
m_ui.removeButton->setEnabled(isValid);
|
||||
m_addFilesButton->setEnabled(isValid);
|
||||
m_removeButton->setEnabled(isValid);
|
||||
}
|
||||
|
||||
void QrcEditor::updateHistoryControls()
|
||||
@@ -391,8 +427,8 @@ void QrcEditor::onAddPrefix()
|
||||
QUndoCommand * const addEmptyPrefixCommand = new AddEmptyPrefixCommand(m_treeview);
|
||||
m_history.push(addEmptyPrefixCommand);
|
||||
updateHistoryControls();
|
||||
m_ui.prefixText->selectAll();
|
||||
m_ui.prefixText->setFocus();
|
||||
m_prefixText->selectAll();
|
||||
m_prefixText->setFocus();
|
||||
}
|
||||
|
||||
// Slot for 'Undo' button
|
||||
|
@@ -25,12 +25,17 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "ui_qrceditor.h"
|
||||
#include "resourceview.h"
|
||||
|
||||
#include <coreplugin/minisplitter.h>
|
||||
#include <QUndoStack>
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
class QLabel;
|
||||
class QLineEdit;
|
||||
class QPushButton;
|
||||
QT_END_NAMESPACE
|
||||
|
||||
namespace ResourceEditor {
|
||||
namespace Internal {
|
||||
|
||||
@@ -76,13 +81,22 @@ private:
|
||||
void onAddFiles();
|
||||
void onAddPrefix();
|
||||
|
||||
Ui::QrcEditor m_ui;
|
||||
QUndoStack m_history;
|
||||
ResourceView *m_treeview;
|
||||
|
||||
QString m_currentAlias;
|
||||
QString m_currentPrefix;
|
||||
QString m_currentLanguage;
|
||||
|
||||
QPushButton *m_addFilesButton;
|
||||
QPushButton *m_removeButton;
|
||||
QPushButton *m_removeNonExistingButton;
|
||||
QLabel *m_aliasLabel;
|
||||
QLineEdit *m_aliasText;
|
||||
QLabel *m_prefixLabel;
|
||||
QLineEdit *m_prefixText;
|
||||
QLabel *m_languageLabel;
|
||||
QLineEdit *m_languageText;
|
||||
};
|
||||
|
||||
} // namespace Internal
|
||||
|
@@ -1,145 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>QrcEditor</class>
|
||||
<widget class="QWidget" name="QrcEditor">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>521</width>
|
||||
<height>180</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="MinimumExpanding">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<property name="leftMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="topMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="rightMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="bottomMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||
<item>
|
||||
<widget class="QPushButton" name="addPrefixButton">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Minimum" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Add Prefix</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="addFilesButton">
|
||||
<property name="text">
|
||||
<string>Add Files</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="removeButton">
|
||||
<property name="text">
|
||||
<string>Remove</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="removeNonExistingButton">
|
||||
<property name="text">
|
||||
<string>Remove Missing Files</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="horizontalSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QGroupBox" name="groupBox">
|
||||
<property name="title">
|
||||
<string>Properties</string>
|
||||
</property>
|
||||
<layout class="QFormLayout" name="formLayout">
|
||||
<property name="sizeConstraint">
|
||||
<enum>QLayout::SetMinAndMaxSize</enum>
|
||||
</property>
|
||||
<property name="fieldGrowthPolicy">
|
||||
<enum>QFormLayout::ExpandingFieldsGrow</enum>
|
||||
</property>
|
||||
<item row="0" column="0">
|
||||
<widget class="QLabel" name="aliasLabel">
|
||||
<property name="text">
|
||||
<string>Alias:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<widget class="QLineEdit" name="aliasText"/>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="QLabel" name="prefixLabel">
|
||||
<property name="text">
|
||||
<string>Prefix:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="1">
|
||||
<widget class="QLineEdit" name="prefixText"/>
|
||||
</item>
|
||||
<item row="2" column="0">
|
||||
<widget class="QLabel" name="languageLabel">
|
||||
<property name="text">
|
||||
<string>Language:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="1">
|
||||
<widget class="QLineEdit" name="languageText"/>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="verticalSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>0</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<resources/>
|
||||
<connections/>
|
||||
</ui>
|
@@ -28,7 +28,7 @@ Project {
|
||||
name: "QRC Editor"
|
||||
prefix: "qrceditor/"
|
||||
files: [
|
||||
"qrceditor.cpp", "qrceditor.h", "qrceditor.ui",
|
||||
"qrceditor.cpp", "qrceditor.h",
|
||||
"resourcefile.cpp", "resourcefile_p.h",
|
||||
"resourceview.cpp", "resourceview.h",
|
||||
"undocommands.cpp", "undocommands_p.h",
|
||||
|
Reference in New Issue
Block a user