forked from qt-creator/qt-creator
Todo: Inline keyworddialog.ui
Change-Id: I0e571b4cab0bcbc540a7710e2ee0b6253af0f532 Reviewed-by: Christian Stenger <christian.stenger@qt.io>
This commit is contained in:
@@ -5,7 +5,7 @@ add_qtc_plugin(Todo
|
|||||||
constants.h
|
constants.h
|
||||||
cpptodoitemsscanner.cpp cpptodoitemsscanner.h
|
cpptodoitemsscanner.cpp cpptodoitemsscanner.h
|
||||||
keyword.cpp keyword.h
|
keyword.cpp keyword.h
|
||||||
keyworddialog.cpp keyworddialog.h keyworddialog.ui
|
keyworddialog.cpp keyworddialog.h
|
||||||
lineparser.cpp lineparser.h
|
lineparser.cpp lineparser.h
|
||||||
optionsdialog.cpp optionsdialog.h optionsdialog.ui
|
optionsdialog.cpp optionsdialog.h optionsdialog.ui
|
||||||
qmljstodoitemsscanner.cpp qmljstodoitemsscanner.h
|
qmljstodoitemsscanner.cpp qmljstodoitemsscanner.h
|
||||||
|
|||||||
@@ -25,12 +25,18 @@
|
|||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
#include "keyworddialog.h"
|
#include "keyworddialog.h"
|
||||||
|
|
||||||
#include "keyword.h"
|
#include "keyword.h"
|
||||||
#include "ui_keyworddialog.h"
|
|
||||||
#include "constants.h"
|
|
||||||
#include "lineparser.h"
|
#include "lineparser.h"
|
||||||
|
|
||||||
|
#include <utils/layoutbuilder.h>
|
||||||
|
#include <utils/qtcolorbutton.h>
|
||||||
|
|
||||||
#include <QColorDialog>
|
#include <QColorDialog>
|
||||||
|
#include <QDialogButtonBox>
|
||||||
|
#include <QLabel>
|
||||||
|
#include <QLineEdit>
|
||||||
|
#include <QListWidget>
|
||||||
|
|
||||||
namespace Todo {
|
namespace Todo {
|
||||||
namespace Internal {
|
namespace Internal {
|
||||||
@@ -38,37 +44,72 @@ namespace Internal {
|
|||||||
KeywordDialog::KeywordDialog(const Keyword &keyword, const QSet<QString> &alreadyUsedKeywordNames,
|
KeywordDialog::KeywordDialog(const Keyword &keyword, const QSet<QString> &alreadyUsedKeywordNames,
|
||||||
QWidget *parent) :
|
QWidget *parent) :
|
||||||
QDialog(parent),
|
QDialog(parent),
|
||||||
ui(new Ui::KeywordDialog),
|
|
||||||
m_alreadyUsedKeywordNames(alreadyUsedKeywordNames)
|
m_alreadyUsedKeywordNames(alreadyUsedKeywordNames)
|
||||||
{
|
{
|
||||||
ui->setupUi(this);
|
setWindowTitle(tr("Keyword"));
|
||||||
|
|
||||||
|
m_listWidget = new QListWidget(this);
|
||||||
|
|
||||||
|
m_colorEdit = new QLineEdit;
|
||||||
|
m_colorEdit->setInputMask(QString::fromUtf8("\\#HHHHHH; "));
|
||||||
|
m_colorEdit->setText(QString::fromUtf8("#000000"));
|
||||||
|
|
||||||
|
m_colorButton = new Utils::QtColorButton;
|
||||||
|
m_colorButton->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Preferred);
|
||||||
|
m_colorButton->setMinimumSize(QSize(64, 0));
|
||||||
|
|
||||||
|
m_keywordNameEdit = new QLineEdit(keyword.name);
|
||||||
|
|
||||||
|
m_errorLabel = new QLabel(tr("errorLabel"), this);
|
||||||
|
m_errorLabel->setStyleSheet(QString::fromUtf8("color: red;"));
|
||||||
|
m_errorLabel->hide();
|
||||||
|
|
||||||
|
m_buttonBox = new QDialogButtonBox(this);
|
||||||
|
m_buttonBox->setOrientation(Qt::Horizontal);
|
||||||
|
m_buttonBox->setStandardButtons(QDialogButtonBox::Cancel|QDialogButtonBox::Ok);
|
||||||
|
|
||||||
|
using namespace Utils::Layouting;
|
||||||
|
|
||||||
|
Column {
|
||||||
|
new QLabel(tr("Icon")),
|
||||||
|
m_listWidget,
|
||||||
|
Row {
|
||||||
|
Group {
|
||||||
|
Title(tr("Color")),
|
||||||
|
Row { m_colorEdit, m_colorButton }
|
||||||
|
},
|
||||||
|
Group {
|
||||||
|
Title(tr("Keyword")),
|
||||||
|
m_keywordNameEdit
|
||||||
|
}
|
||||||
|
},
|
||||||
|
m_errorLabel,
|
||||||
|
m_buttonBox
|
||||||
|
}.attachTo(this);
|
||||||
|
|
||||||
setupListWidget(keyword.iconType);
|
setupListWidget(keyword.iconType);
|
||||||
setupColorWidgets(keyword.color);
|
setupColorWidgets(keyword.color);
|
||||||
ui->keywordNameEdit->setText(keyword.name);
|
|
||||||
ui->errorLabel->hide();
|
|
||||||
|
|
||||||
connect(ui->buttonBox, &QDialogButtonBox::accepted, this, &KeywordDialog::acceptButtonClicked);
|
connect(m_buttonBox, &QDialogButtonBox::rejected, this, &QDialog::reject);
|
||||||
connect(ui->keywordNameEdit, &QLineEdit::textChanged, ui->errorLabel, &QWidget::hide);
|
connect(m_buttonBox, &QDialogButtonBox::accepted, this, &KeywordDialog::acceptButtonClicked);
|
||||||
|
connect(m_keywordNameEdit, &QLineEdit::textChanged, m_errorLabel, &QWidget::hide);
|
||||||
}
|
}
|
||||||
|
|
||||||
KeywordDialog::~KeywordDialog()
|
KeywordDialog::~KeywordDialog() = default;
|
||||||
{
|
|
||||||
delete ui;
|
|
||||||
}
|
|
||||||
|
|
||||||
Keyword KeywordDialog::keyword()
|
Keyword KeywordDialog::keyword()
|
||||||
{
|
{
|
||||||
Keyword result;
|
Keyword result;
|
||||||
result.name = keywordName();
|
result.name = keywordName();
|
||||||
result.iconType = static_cast<IconType>(ui->listWidget->currentItem()->data(Qt::UserRole).toInt());
|
result.iconType = static_cast<IconType>(m_listWidget->currentItem()->data(Qt::UserRole).toInt());
|
||||||
result.color = ui->colorEdit->text();
|
result.color = m_colorEdit->text();
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
void KeywordDialog::colorSelected(const QColor &color)
|
void KeywordDialog::colorSelected(const QColor &color)
|
||||||
{
|
{
|
||||||
ui->colorEdit->setText(color.name());
|
m_colorEdit->setText(color.name());
|
||||||
}
|
}
|
||||||
|
|
||||||
void KeywordDialog::acceptButtonClicked()
|
void KeywordDialog::acceptButtonClicked()
|
||||||
@@ -79,33 +120,33 @@ void KeywordDialog::acceptButtonClicked()
|
|||||||
|
|
||||||
void KeywordDialog::setupListWidget(IconType selectedIcon)
|
void KeywordDialog::setupListWidget(IconType selectedIcon)
|
||||||
{
|
{
|
||||||
ui->listWidget->setViewMode(QListWidget::IconMode);
|
m_listWidget->setViewMode(QListWidget::IconMode);
|
||||||
ui->listWidget->setDragEnabled(false);
|
m_listWidget->setDragEnabled(false);
|
||||||
|
|
||||||
QListWidgetItem *item = new QListWidgetItem(icon(IconType::Info), "information");
|
QListWidgetItem *item = new QListWidgetItem(icon(IconType::Info), "information");
|
||||||
item->setData(Qt::UserRole, static_cast<int>(IconType::Info));
|
item->setData(Qt::UserRole, static_cast<int>(IconType::Info));
|
||||||
ui->listWidget->addItem(item);
|
m_listWidget->addItem(item);
|
||||||
|
|
||||||
item = new QListWidgetItem(icon(IconType::Warning), "warning");
|
item = new QListWidgetItem(icon(IconType::Warning), "warning");
|
||||||
item->setData(Qt::UserRole, static_cast<int>(IconType::Warning));
|
item->setData(Qt::UserRole, static_cast<int>(IconType::Warning));
|
||||||
ui->listWidget->addItem(item);
|
m_listWidget->addItem(item);
|
||||||
|
|
||||||
item = new QListWidgetItem(icon(IconType::Error), "error");
|
item = new QListWidgetItem(icon(IconType::Error), "error");
|
||||||
item->setData(Qt::UserRole, static_cast<int>(IconType::Error));
|
item->setData(Qt::UserRole, static_cast<int>(IconType::Error));
|
||||||
ui->listWidget->addItem(item);
|
m_listWidget->addItem(item);
|
||||||
|
|
||||||
item = new QListWidgetItem(icon(IconType::Bug), "bug");
|
item = new QListWidgetItem(icon(IconType::Bug), "bug");
|
||||||
item->setData(Qt::UserRole, static_cast<int>(IconType::Bug));
|
item->setData(Qt::UserRole, static_cast<int>(IconType::Bug));
|
||||||
ui->listWidget->addItem(item);
|
m_listWidget->addItem(item);
|
||||||
|
|
||||||
item = new QListWidgetItem(icon(IconType::Todo), "todo");
|
item = new QListWidgetItem(icon(IconType::Todo), "todo");
|
||||||
item->setData(Qt::UserRole, static_cast<int>(IconType::Todo));
|
item->setData(Qt::UserRole, static_cast<int>(IconType::Todo));
|
||||||
ui->listWidget->addItem(item);
|
m_listWidget->addItem(item);
|
||||||
|
|
||||||
for (int i = 0; i < ui->listWidget->count(); ++i) {
|
for (int i = 0; i < m_listWidget->count(); ++i) {
|
||||||
item = ui->listWidget->item(i);
|
item = m_listWidget->item(i);
|
||||||
if (static_cast<IconType>(item->data(Qt::UserRole).toInt()) == selectedIcon) {
|
if (static_cast<IconType>(item->data(Qt::UserRole).toInt()) == selectedIcon) {
|
||||||
ui->listWidget->setCurrentItem(item);
|
m_listWidget->setCurrentItem(item);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -113,9 +154,9 @@ void KeywordDialog::setupListWidget(IconType selectedIcon)
|
|||||||
|
|
||||||
void KeywordDialog::setupColorWidgets(const QColor &color)
|
void KeywordDialog::setupColorWidgets(const QColor &color)
|
||||||
{
|
{
|
||||||
ui->colorButton->setColor(color);
|
m_colorButton->setColor(color);
|
||||||
ui->colorEdit->setText(color.name());
|
m_colorEdit->setText(color.name());
|
||||||
connect(ui->colorButton, &Utils::QtColorButton::colorChanged, this, &KeywordDialog::colorSelected);
|
connect(m_colorButton, &Utils::QtColorButton::colorChanged, this, &KeywordDialog::colorSelected);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool KeywordDialog::canAccept()
|
bool KeywordDialog::canAccept()
|
||||||
@@ -156,13 +197,13 @@ bool KeywordDialog::isKeywordNameAlreadyUsed()
|
|||||||
|
|
||||||
void KeywordDialog::showError(const QString &text)
|
void KeywordDialog::showError(const QString &text)
|
||||||
{
|
{
|
||||||
ui->errorLabel->setText(text);
|
m_errorLabel->setText(text);
|
||||||
ui->errorLabel->show();
|
m_errorLabel->show();
|
||||||
}
|
}
|
||||||
|
|
||||||
QString KeywordDialog::keywordName()
|
QString KeywordDialog::keywordName()
|
||||||
{
|
{
|
||||||
return ui->keywordNameEdit->text().trimmed();
|
return m_keywordNameEdit->text().trimmed();
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace Internal
|
} // namespace Internal
|
||||||
|
|||||||
@@ -29,11 +29,18 @@
|
|||||||
#include <QDialog>
|
#include <QDialog>
|
||||||
#include <QSet>
|
#include <QSet>
|
||||||
|
|
||||||
|
QT_BEGIN_NAMESPACE
|
||||||
|
class QDialogButtonBox;
|
||||||
|
class QLabel;
|
||||||
|
class QLineEdit;
|
||||||
|
class QListWidget;
|
||||||
|
QT_END_NAMESPACE
|
||||||
|
|
||||||
|
namespace Utils { class QtColorButton; }
|
||||||
|
|
||||||
namespace Todo {
|
namespace Todo {
|
||||||
namespace Internal {
|
namespace Internal {
|
||||||
|
|
||||||
namespace Ui { class KeywordDialog; }
|
|
||||||
|
|
||||||
class Keyword;
|
class Keyword;
|
||||||
enum class IconType;
|
enum class IconType;
|
||||||
|
|
||||||
@@ -58,8 +65,14 @@ private:
|
|||||||
void showError(const QString &text);
|
void showError(const QString &text);
|
||||||
QString keywordName();
|
QString keywordName();
|
||||||
|
|
||||||
Ui::KeywordDialog *ui;
|
|
||||||
QSet<QString> m_alreadyUsedKeywordNames;
|
QSet<QString> m_alreadyUsedKeywordNames;
|
||||||
|
|
||||||
|
QListWidget *m_listWidget;
|
||||||
|
QLineEdit *m_colorEdit;
|
||||||
|
Utils::QtColorButton *m_colorButton;
|
||||||
|
QLineEdit *m_keywordNameEdit;
|
||||||
|
QLabel *m_errorLabel;
|
||||||
|
QDialogButtonBox *m_buttonBox;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace Internal
|
} // namespace Internal
|
||||||
|
|||||||
@@ -1,130 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<ui version="4.0">
|
|
||||||
<class>Todo::Internal::KeywordDialog</class>
|
|
||||||
<widget class="QDialog" name="Todo::Internal::KeywordDialog">
|
|
||||||
<property name="geometry">
|
|
||||||
<rect>
|
|
||||||
<x>0</x>
|
|
||||||
<y>0</y>
|
|
||||||
<width>379</width>
|
|
||||||
<height>233</height>
|
|
||||||
</rect>
|
|
||||||
</property>
|
|
||||||
<property name="windowTitle">
|
|
||||||
<string>Keyword</string>
|
|
||||||
</property>
|
|
||||||
<layout class="QVBoxLayout" name="verticalLayout_3">
|
|
||||||
<item>
|
|
||||||
<widget class="QLabel" name="label">
|
|
||||||
<property name="text">
|
|
||||||
<string>Icon</string>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<widget class="QListWidget" name="listWidget"/>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<layout class="QVBoxLayout" name="verticalLayout">
|
|
||||||
<item>
|
|
||||||
<layout class="QHBoxLayout" name="horizontalLayout_2">
|
|
||||||
<item>
|
|
||||||
<widget class="QGroupBox" name="groupBox">
|
|
||||||
<property name="title">
|
|
||||||
<string>Color</string>
|
|
||||||
</property>
|
|
||||||
<layout class="QHBoxLayout" name="horizontalLayout_3">
|
|
||||||
<item>
|
|
||||||
<widget class="QLineEdit" name="colorEdit">
|
|
||||||
<property name="inputMask">
|
|
||||||
<string notr="true">\#HHHHHH; </string>
|
|
||||||
</property>
|
|
||||||
<property name="text">
|
|
||||||
<string notr="true">#000000</string>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<widget class="Utils::QtColorButton" name="colorButton">
|
|
||||||
<property name="sizePolicy">
|
|
||||||
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
|
|
||||||
<horstretch>0</horstretch>
|
|
||||||
<verstretch>0</verstretch>
|
|
||||||
</sizepolicy>
|
|
||||||
</property>
|
|
||||||
<property name="minimumSize">
|
|
||||||
<size>
|
|
||||||
<width>64</width>
|
|
||||||
<height>0</height>
|
|
||||||
</size>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
</layout>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<widget class="QGroupBox" name="groupBox_2">
|
|
||||||
<property name="title">
|
|
||||||
<string>Keyword</string>
|
|
||||||
</property>
|
|
||||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
|
||||||
<item>
|
|
||||||
<widget class="QLineEdit" name="keywordNameEdit"/>
|
|
||||||
</item>
|
|
||||||
</layout>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
</layout>
|
|
||||||
</item>
|
|
||||||
</layout>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<widget class="QLabel" name="errorLabel">
|
|
||||||
<property name="styleSheet">
|
|
||||||
<string notr="true">color: red;</string>
|
|
||||||
</property>
|
|
||||||
<property name="text">
|
|
||||||
<string>errorLabel</string>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</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>
|
|
||||||
<customwidgets>
|
|
||||||
<customwidget>
|
|
||||||
<class>Utils::QtColorButton</class>
|
|
||||||
<extends>QToolButton</extends>
|
|
||||||
<header location="global">utils/qtcolorbutton.h</header>
|
|
||||||
</customwidget>
|
|
||||||
</customwidgets>
|
|
||||||
<resources/>
|
|
||||||
<connections>
|
|
||||||
<connection>
|
|
||||||
<sender>buttonBox</sender>
|
|
||||||
<signal>rejected()</signal>
|
|
||||||
<receiver>Todo::Internal::KeywordDialog</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>
|
|
||||||
@@ -20,7 +20,6 @@ QtcPlugin {
|
|||||||
"keyword.h",
|
"keyword.h",
|
||||||
"keyworddialog.cpp",
|
"keyworddialog.cpp",
|
||||||
"keyworddialog.h",
|
"keyworddialog.h",
|
||||||
"keyworddialog.ui",
|
|
||||||
"lineparser.cpp",
|
"lineparser.cpp",
|
||||||
"lineparser.h",
|
"lineparser.h",
|
||||||
"optionsdialog.cpp",
|
"optionsdialog.cpp",
|
||||||
|
|||||||
Reference in New Issue
Block a user