forked from qt-creator/qt-creator
Todo: Inline optiondialog.ui
Change-Id: I55f170220a075e4d8db86f17eb857325a33bf82c Reviewed-by: Christian Stenger <christian.stenger@qt.io>
This commit is contained in:
@@ -7,7 +7,7 @@ add_qtc_plugin(Todo
|
|||||||
keyword.cpp keyword.h
|
keyword.cpp keyword.h
|
||||||
keyworddialog.cpp keyworddialog.h
|
keyworddialog.cpp keyworddialog.h
|
||||||
lineparser.cpp lineparser.h
|
lineparser.cpp lineparser.h
|
||||||
optionsdialog.cpp optionsdialog.h optionsdialog.ui
|
optionsdialog.cpp optionsdialog.h
|
||||||
qmljstodoitemsscanner.cpp qmljstodoitemsscanner.h
|
qmljstodoitemsscanner.cpp qmljstodoitemsscanner.h
|
||||||
settings.cpp settings.h
|
settings.cpp settings.h
|
||||||
todoicons.cpp todoicons.h
|
todoicons.cpp todoicons.h
|
||||||
|
|||||||
@@ -25,14 +25,20 @@
|
|||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
#include "optionsdialog.h"
|
#include "optionsdialog.h"
|
||||||
#include "ui_optionsdialog.h"
|
|
||||||
#include "keyworddialog.h"
|
#include "keyworddialog.h"
|
||||||
#include "keyword.h"
|
#include "keyword.h"
|
||||||
#include "settings.h"
|
#include "settings.h"
|
||||||
#include "constants.h"
|
|
||||||
|
|
||||||
namespace Todo {
|
#include <utils/layoutbuilder.h>
|
||||||
namespace Internal {
|
|
||||||
|
#include <QCoreApplication>
|
||||||
|
#include <QGroupBox>
|
||||||
|
#include <QListWidget>
|
||||||
|
#include <QPushButton>
|
||||||
|
#include <QRadioButton>
|
||||||
|
|
||||||
|
namespace Todo::Internal {
|
||||||
|
|
||||||
class OptionsDialog final : public Core::IOptionsPageWidget
|
class OptionsDialog final : public Core::IOptionsPageWidget
|
||||||
{
|
{
|
||||||
@@ -56,28 +62,79 @@ private:
|
|||||||
void editKeyword(QListWidgetItem *item);
|
void editKeyword(QListWidgetItem *item);
|
||||||
QSet<QString> keywordNames();
|
QSet<QString> keywordNames();
|
||||||
|
|
||||||
Ui::OptionsDialog ui;
|
|
||||||
Settings *m_settings = nullptr;
|
Settings *m_settings = nullptr;
|
||||||
std::function<void()> m_onApply;
|
std::function<void()> m_onApply;
|
||||||
|
|
||||||
|
QListWidget *m_keywordsList;
|
||||||
|
QPushButton *m_editKeywordButton;
|
||||||
|
QPushButton *m_removeKeywordButton;
|
||||||
|
QPushButton *resetKeywordsButton;
|
||||||
|
QRadioButton *m_scanInProjectRadioButton;
|
||||||
|
QRadioButton *m_scanInCurrentFileRadioButton;
|
||||||
|
QRadioButton *m_scanInSubprojectRadioButton;
|
||||||
};
|
};
|
||||||
|
|
||||||
OptionsDialog::OptionsDialog(Settings *settings, const std::function<void ()> &onApply)
|
OptionsDialog::OptionsDialog(Settings *settings, const std::function<void ()> &onApply)
|
||||||
: m_settings(settings), m_onApply(onApply)
|
: m_settings(settings), m_onApply(onApply)
|
||||||
{
|
{
|
||||||
ui.setupUi(this);
|
m_keywordsList = new QListWidget;
|
||||||
ui.keywordsList->setIconSize(QSize(16, 16));
|
m_keywordsList->setDragDropMode(QAbstractItemView::DragDrop);
|
||||||
|
m_keywordsList->setDefaultDropAction(Qt::MoveAction);
|
||||||
|
m_keywordsList->setSelectionBehavior(QAbstractItemView::SelectRows);
|
||||||
|
m_keywordsList->setSortingEnabled(false);
|
||||||
|
|
||||||
|
auto addKeywordButton = new QPushButton(tr("Add"));
|
||||||
|
m_editKeywordButton = new QPushButton(tr("Edit"));
|
||||||
|
m_removeKeywordButton = new QPushButton(tr("Remove"));
|
||||||
|
resetKeywordsButton = new QPushButton(tr("Reset"));
|
||||||
|
|
||||||
|
m_scanInProjectRadioButton = new QRadioButton(tr("Scan the whole active project"));
|
||||||
|
m_scanInProjectRadioButton->setEnabled(true);
|
||||||
|
|
||||||
|
m_scanInCurrentFileRadioButton = new QRadioButton(tr("Scan only the currently edited document"));
|
||||||
|
m_scanInCurrentFileRadioButton->setChecked(true);
|
||||||
|
|
||||||
|
m_scanInSubprojectRadioButton = new QRadioButton(tr("Scan the current subproject"));
|
||||||
|
|
||||||
|
using namespace Utils::Layouting;
|
||||||
|
|
||||||
|
Column {
|
||||||
|
Group {
|
||||||
|
Title(tr("Keywords")),
|
||||||
|
Row {
|
||||||
|
m_keywordsList,
|
||||||
|
Column {
|
||||||
|
addKeywordButton,
|
||||||
|
m_editKeywordButton,
|
||||||
|
m_removeKeywordButton,
|
||||||
|
resetKeywordsButton,
|
||||||
|
Stretch()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
Group {
|
||||||
|
Title(tr("Scanning scope")),
|
||||||
|
Column {
|
||||||
|
m_scanInProjectRadioButton,
|
||||||
|
m_scanInCurrentFileRadioButton,
|
||||||
|
m_scanInSubprojectRadioButton
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}.attachTo(this);
|
||||||
|
|
||||||
|
m_keywordsList->setIconSize(QSize(16, 16));
|
||||||
setKeywordsButtonsEnabled();
|
setKeywordsButtonsEnabled();
|
||||||
connect(ui.addKeywordButton, &QAbstractButton::clicked,
|
connect(addKeywordButton, &QAbstractButton::clicked,
|
||||||
this, &OptionsDialog::addKeywordButtonClicked);
|
this, &OptionsDialog::addKeywordButtonClicked);
|
||||||
connect(ui.removeKeywordButton, &QAbstractButton::clicked,
|
connect(m_removeKeywordButton, &QAbstractButton::clicked,
|
||||||
this, &OptionsDialog::removeKeywordButtonClicked);
|
this, &OptionsDialog::removeKeywordButtonClicked);
|
||||||
connect(ui.editKeywordButton, &QAbstractButton::clicked,
|
connect(m_editKeywordButton, &QAbstractButton::clicked,
|
||||||
this, &OptionsDialog::editKeywordButtonClicked);
|
this, &OptionsDialog::editKeywordButtonClicked);
|
||||||
connect(ui.resetKeywordsButton, &QAbstractButton::clicked,
|
connect(resetKeywordsButton, &QAbstractButton::clicked,
|
||||||
this, &OptionsDialog::resetKeywordsButtonClicked);
|
this, &OptionsDialog::resetKeywordsButtonClicked);
|
||||||
connect(ui.keywordsList, &QListWidget::itemDoubleClicked,
|
connect(m_keywordsList, &QListWidget::itemDoubleClicked,
|
||||||
this, &OptionsDialog::editKeyword);
|
this, &OptionsDialog::editKeyword);
|
||||||
connect(ui.keywordsList, &QListWidget::itemSelectionChanged,
|
connect(m_keywordsList, &QListWidget::itemSelectionChanged,
|
||||||
this, &OptionsDialog::setKeywordsButtonsEnabled);
|
this, &OptionsDialog::setKeywordsButtonsEnabled);
|
||||||
|
|
||||||
setSettings(*m_settings);
|
setSettings(*m_settings);
|
||||||
@@ -88,7 +145,7 @@ void OptionsDialog::addToKeywordsList(const Keyword &keyword)
|
|||||||
auto item = new QListWidgetItem(icon(keyword.iconType), keyword.name);
|
auto item = new QListWidgetItem(icon(keyword.iconType), keyword.name);
|
||||||
item->setData(Qt::UserRole, static_cast<int>(keyword.iconType));
|
item->setData(Qt::UserRole, static_cast<int>(keyword.iconType));
|
||||||
item->setForeground(keyword.color);
|
item->setForeground(keyword.color);
|
||||||
ui.keywordsList->addItem(item);
|
m_keywordsList->addItem(item);
|
||||||
}
|
}
|
||||||
|
|
||||||
QSet<QString> OptionsDialog::keywordNames()
|
QSet<QString> OptionsDialog::keywordNames()
|
||||||
@@ -114,7 +171,7 @@ void OptionsDialog::addKeywordButtonClicked()
|
|||||||
|
|
||||||
void OptionsDialog::editKeywordButtonClicked()
|
void OptionsDialog::editKeywordButtonClicked()
|
||||||
{
|
{
|
||||||
QListWidgetItem *item = ui.keywordsList->currentItem();
|
QListWidgetItem *item = m_keywordsList->currentItem();
|
||||||
editKeyword(item);
|
editKeyword(item);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -140,7 +197,7 @@ void OptionsDialog::editKeyword(QListWidgetItem *item)
|
|||||||
|
|
||||||
void OptionsDialog::removeKeywordButtonClicked()
|
void OptionsDialog::removeKeywordButtonClicked()
|
||||||
{
|
{
|
||||||
delete ui.keywordsList->takeItem(ui.keywordsList->currentRow());
|
delete m_keywordsList->takeItem(m_keywordsList->currentRow());
|
||||||
}
|
}
|
||||||
|
|
||||||
void OptionsDialog::resetKeywordsButtonClicked()
|
void OptionsDialog::resetKeywordsButtonClicked()
|
||||||
@@ -152,18 +209,18 @@ void OptionsDialog::resetKeywordsButtonClicked()
|
|||||||
|
|
||||||
void OptionsDialog::setKeywordsButtonsEnabled()
|
void OptionsDialog::setKeywordsButtonsEnabled()
|
||||||
{
|
{
|
||||||
const bool isSomethingSelected = !ui.keywordsList->selectedItems().isEmpty();
|
const bool isSomethingSelected = !m_keywordsList->selectedItems().isEmpty();
|
||||||
ui.removeKeywordButton->setEnabled(isSomethingSelected);
|
m_removeKeywordButton->setEnabled(isSomethingSelected);
|
||||||
ui.editKeywordButton->setEnabled(isSomethingSelected);
|
m_editKeywordButton->setEnabled(isSomethingSelected);
|
||||||
}
|
}
|
||||||
|
|
||||||
void OptionsDialog::setSettings(const Settings &settings)
|
void OptionsDialog::setSettings(const Settings &settings)
|
||||||
{
|
{
|
||||||
ui.scanInCurrentFileRadioButton->setChecked(settings.scanningScope == ScanningScopeCurrentFile);
|
m_scanInCurrentFileRadioButton->setChecked(settings.scanningScope == ScanningScopeCurrentFile);
|
||||||
ui.scanInProjectRadioButton->setChecked(settings.scanningScope == ScanningScopeProject);
|
m_scanInProjectRadioButton->setChecked(settings.scanningScope == ScanningScopeProject);
|
||||||
ui.scanInSubprojectRadioButton->setChecked(settings.scanningScope == ScanningScopeSubProject);
|
m_scanInSubprojectRadioButton->setChecked(settings.scanningScope == ScanningScopeSubProject);
|
||||||
|
|
||||||
ui.keywordsList->clear();
|
m_keywordsList->clear();
|
||||||
for (const Keyword &keyword : qAsConst(settings.keywords))
|
for (const Keyword &keyword : qAsConst(settings.keywords))
|
||||||
addToKeywordsList(keyword);
|
addToKeywordsList(keyword);
|
||||||
}
|
}
|
||||||
@@ -172,16 +229,16 @@ Settings OptionsDialog::settingsFromUi()
|
|||||||
{
|
{
|
||||||
Settings settings;
|
Settings settings;
|
||||||
|
|
||||||
if (ui.scanInCurrentFileRadioButton->isChecked())
|
if (m_scanInCurrentFileRadioButton->isChecked())
|
||||||
settings.scanningScope = ScanningScopeCurrentFile;
|
settings.scanningScope = ScanningScopeCurrentFile;
|
||||||
else if (ui.scanInSubprojectRadioButton->isChecked())
|
else if (m_scanInSubprojectRadioButton->isChecked())
|
||||||
settings.scanningScope = ScanningScopeSubProject;
|
settings.scanningScope = ScanningScopeSubProject;
|
||||||
else
|
else
|
||||||
settings.scanningScope = ScanningScopeProject;
|
settings.scanningScope = ScanningScopeProject;
|
||||||
|
|
||||||
settings.keywords.clear();
|
settings.keywords.clear();
|
||||||
for (int i = 0; i < ui.keywordsList->count(); ++i) {
|
for (int i = 0; i < m_keywordsList->count(); ++i) {
|
||||||
QListWidgetItem *item = ui.keywordsList->item(i);
|
QListWidgetItem *item = m_keywordsList->item(i);
|
||||||
|
|
||||||
Keyword keyword;
|
Keyword keyword;
|
||||||
keyword.name = item->text();
|
keyword.name = item->text();
|
||||||
@@ -220,5 +277,4 @@ TodoOptionsPage::TodoOptionsPage(Settings *settings, const std::function<void ()
|
|||||||
setWidgetCreator([settings, onApply] { return new OptionsDialog(settings, onApply); });
|
setWidgetCreator([settings, onApply] { return new OptionsDialog(settings, onApply); });
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace Internal
|
} // Todo::Internal
|
||||||
} // namespace Todo
|
|
||||||
|
|||||||
@@ -28,8 +28,7 @@
|
|||||||
|
|
||||||
#include <coreplugin/dialogs/ioptionspage.h>
|
#include <coreplugin/dialogs/ioptionspage.h>
|
||||||
|
|
||||||
namespace Todo {
|
namespace Todo::Internal {
|
||||||
namespace Internal {
|
|
||||||
|
|
||||||
class Settings;
|
class Settings;
|
||||||
|
|
||||||
@@ -39,5 +38,4 @@ public:
|
|||||||
TodoOptionsPage(Settings *settings, const std::function<void()> &onApply);
|
TodoOptionsPage(Settings *settings, const std::function<void()> &onApply);
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace Internal
|
} // Todo::Internal
|
||||||
} // namespace Todo
|
|
||||||
|
|||||||
@@ -1,127 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<ui version="4.0">
|
|
||||||
<class>Todo::Internal::OptionsDialog</class>
|
|
||||||
<widget class="QWidget" name="Todo::Internal::OptionsDialog">
|
|
||||||
<property name="geometry">
|
|
||||||
<rect>
|
|
||||||
<x>0</x>
|
|
||||||
<y>0</y>
|
|
||||||
<width>444</width>
|
|
||||||
<height>482</height>
|
|
||||||
</rect>
|
|
||||||
</property>
|
|
||||||
<property name="windowTitle">
|
|
||||||
<string/>
|
|
||||||
</property>
|
|
||||||
<layout class="QVBoxLayout" name="verticalLayout_2">
|
|
||||||
<item>
|
|
||||||
<widget class="QGroupBox" name="groupBox">
|
|
||||||
<property name="title">
|
|
||||||
<string>Keywords</string>
|
|
||||||
</property>
|
|
||||||
<layout class="QHBoxLayout" name="horizontalLayout_2">
|
|
||||||
<item>
|
|
||||||
<widget class="QListWidget" name="keywordsList">
|
|
||||||
<property name="dragDropMode">
|
|
||||||
<enum>QAbstractItemView::DragDrop</enum>
|
|
||||||
</property>
|
|
||||||
<property name="defaultDropAction">
|
|
||||||
<enum>Qt::MoveAction</enum>
|
|
||||||
</property>
|
|
||||||
<property name="selectionBehavior">
|
|
||||||
<enum>QAbstractItemView::SelectRows</enum>
|
|
||||||
</property>
|
|
||||||
<property name="sortingEnabled">
|
|
||||||
<bool>false</bool>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<layout class="QVBoxLayout" name="verticalLayout">
|
|
||||||
<item>
|
|
||||||
<widget class="QPushButton" name="addKeywordButton">
|
|
||||||
<property name="text">
|
|
||||||
<string>Add</string>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<widget class="QPushButton" name="editKeywordButton">
|
|
||||||
<property name="text">
|
|
||||||
<string>Edit</string>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<widget class="QPushButton" name="removeKeywordButton">
|
|
||||||
<property name="text">
|
|
||||||
<string>Remove</string>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<widget class="QPushButton" name="resetKeywordsButton">
|
|
||||||
<property name="text">
|
|
||||||
<string>Reset</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>
|
|
||||||
</layout>
|
|
||||||
</item>
|
|
||||||
</layout>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<widget class="QGroupBox" name="scanningScopeGroupBox">
|
|
||||||
<property name="title">
|
|
||||||
<string>Scanning scope</string>
|
|
||||||
</property>
|
|
||||||
<layout class="QVBoxLayout" name="verticalLayout_3">
|
|
||||||
<item>
|
|
||||||
<widget class="QRadioButton" name="scanInProjectRadioButton">
|
|
||||||
<property name="enabled">
|
|
||||||
<bool>true</bool>
|
|
||||||
</property>
|
|
||||||
<property name="text">
|
|
||||||
<string>Scan the whole active project</string>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<widget class="QRadioButton" name="scanInCurrentFileRadioButton">
|
|
||||||
<property name="text">
|
|
||||||
<string>Scan only the currently edited document</string>
|
|
||||||
</property>
|
|
||||||
<property name="checked">
|
|
||||||
<bool>true</bool>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<widget class="QRadioButton" name="scanInSubprojectRadioButton">
|
|
||||||
<property name="text">
|
|
||||||
<string>Scan the current subproject</string>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
</layout>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
</layout>
|
|
||||||
</widget>
|
|
||||||
<resources/>
|
|
||||||
<connections/>
|
|
||||||
</ui>
|
|
||||||
@@ -24,7 +24,6 @@ QtcPlugin {
|
|||||||
"lineparser.h",
|
"lineparser.h",
|
||||||
"optionsdialog.cpp",
|
"optionsdialog.cpp",
|
||||||
"optionsdialog.h",
|
"optionsdialog.h",
|
||||||
"optionsdialog.ui",
|
|
||||||
"todoprojectsettingswidget.cpp",
|
"todoprojectsettingswidget.cpp",
|
||||||
"todoprojectsettingswidget.h",
|
"todoprojectsettingswidget.h",
|
||||||
"todoprojectsettingswidget.ui",
|
"todoprojectsettingswidget.ui",
|
||||||
|
|||||||
Reference in New Issue
Block a user