summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Winkelmann <michael.winkelmann@qt.io>2021-06-20 15:54:51 +0200
committerMichael Winkelmann <michael.winkelmann@qt.io>2021-06-21 13:41:55 +0000
commitbe33e67fc57a327c224c84d5a2034f45cc6afc23 (patch)
tree666eba324fb0a8ca27b2a9eb458455f2f3ddae95
parentae8d9af6f43a909b2a7006e4268d2faca5efa8c1 (diff)
downloadqt-creator-be33e67fc57a327c224c84d5a2034f45cc6afc23.tar.gz
AnnotationEditor: Merge dialogs
Change-Id: Ibabd7d0d328af8cae8a4ced6747db52b33274bf0 Reviewed-by: Tim Jenssen <tim.jenssen@qt.io>
-rw-r--r--src/plugins/qmldesigner/CMakeLists.txt1
-rw-r--r--src/plugins/qmldesigner/components/annotationeditor/annotationeditor.pri3
-rw-r--r--src/plugins/qmldesigner/components/annotationeditor/annotationeditordialog.cpp172
-rw-r--r--src/plugins/qmldesigner/components/annotationeditor/annotationeditordialog.h66
-rw-r--r--src/plugins/qmldesigner/components/annotationeditor/annotationeditordialog.ui100
-rw-r--r--src/plugins/qmldesigner/components/annotationeditor/annotationtableview.h1
-rw-r--r--src/plugins/qmldesigner/components/annotationeditor/globalannotationeditor.cpp16
-rw-r--r--src/plugins/qmldesigner/components/annotationeditor/globalannotationeditor.h1
-rw-r--r--src/plugins/qmldesigner/components/annotationeditor/globalannotationeditordialog.cpp179
-rw-r--r--src/plugins/qmldesigner/components/annotationeditor/globalannotationeditordialog.h80
-rw-r--r--src/plugins/qmldesigner/components/annotationeditor/globalannotationeditordialog.ui198
-rw-r--r--src/plugins/qmldesigner/qmldesignerplugin.qbs3
12 files changed, 283 insertions, 537 deletions
diff --git a/src/plugins/qmldesigner/CMakeLists.txt b/src/plugins/qmldesigner/CMakeLists.txt
index e79c69ea6c..e13d909076 100644
--- a/src/plugins/qmldesigner/CMakeLists.txt
+++ b/src/plugins/qmldesigner/CMakeLists.txt
@@ -636,7 +636,6 @@ extend_qtc_plugin(QmlDesigner
SOURCES_PREFIX components/annotationeditor
SOURCES annotationcommenttab.cpp annotationcommenttab.h annotationcommenttab.ui
annotationeditordialog.cpp annotationeditordialog.h annotationeditordialog.ui
- globalannotationeditordialog.cpp globalannotationeditordialog.h globalannotationeditordialog.ui
annotationeditor.cpp annotationeditor.h
globalannotationeditor.cpp globalannotationeditor.h
defaultannotations.cpp defaultannotations.h
diff --git a/src/plugins/qmldesigner/components/annotationeditor/annotationeditor.pri b/src/plugins/qmldesigner/components/annotationeditor/annotationeditor.pri
index 63ba86609b..ff79353960 100644
--- a/src/plugins/qmldesigner/components/annotationeditor/annotationeditor.pri
+++ b/src/plugins/qmldesigner/components/annotationeditor/annotationeditor.pri
@@ -2,7 +2,6 @@ HEADERS += $$PWD/annotationcommenttab.h
HEADERS += $$PWD/annotationeditordialog.h
HEADERS += $$PWD/annotationeditor.h
HEADERS += $$PWD/globalannotationeditor.h
-HEADERS += $$PWD/globalannotationeditordialog.h
HEADERS += $$PWD/defaultannotations.h
HEADERS += $$PWD/annotationtableview.h
HEADERS += $$PWD/annotationtabwidget.h
@@ -11,14 +10,12 @@ SOURCES += $$PWD/annotationcommenttab.cpp
SOURCES += $$PWD/annotationeditordialog.cpp
SOURCES += $$PWD/annotationeditor.cpp
SOURCES += $$PWD/globalannotationeditor.cpp
-SOURCES += $$PWD/globalannotationeditordialog.cpp
SOURCES += $$PWD/defaultannotations.cpp
SOURCES += $$PWD/annotationtableview.cpp
SOURCES += $$PWD/annotationtabwidget.cpp
FORMS += $$PWD/annotationcommenttab.ui
FORMS += $$PWD/annotationeditordialog.ui
-FORMS += $$PWD/globalannotationeditordialog.ui
INCLUDEPATH += $$PWD
diff --git a/src/plugins/qmldesigner/components/annotationeditor/annotationeditordialog.cpp b/src/plugins/qmldesigner/components/annotationeditor/annotationeditordialog.cpp
index 3269540466..48c8c34f18 100644
--- a/src/plugins/qmldesigner/components/annotationeditor/annotationeditordialog.cpp
+++ b/src/plugins/qmldesigner/components/annotationeditor/annotationeditordialog.cpp
@@ -39,67 +39,115 @@
#include <QToolBar>
namespace QmlDesigner {
-BasicAnnotationEditorDialog::BasicAnnotationEditorDialog(QWidget *parent)
+AnnotationEditorDialog::AnnotationEditorDialog(QWidget *parent,
+ const QString &targetId,
+ const QString &customId)
: QDialog(parent)
, m_defaults(std::make_unique<DefaultAnnotationsModel>())
+ , m_customId(customId)
+ , ui(std::make_unique<Ui::AnnotationEditorDialog>())
+ , m_statusIsActive(false)
{
+ ui->setupUi(this);
+ setGlobal(m_isGlobal);
+
setWindowFlag(Qt::Tool, true);
setModal(true);
loadDefaultAnnotations(DefaultAnnotationsModel::defaultJsonFilePath());
+ ui->tabWidget->setDefaultAnnotations(defaultAnnotations());
+ ui->tableView->setDefaultAnnotations(defaultAnnotations());
+
+ connect(ui->tableView,
+ &AnnotationTableView::richTextEditorRequested,
+ this,
+ [&](int index, QString const &) {
+ switchToTabView();
+ ui->tabWidget->setCurrentIndex(index);
+ });
+
+ connect(ui->statusAddButton, &QPushButton::clicked, this, [&](bool) {
+ setStatusVisibility(true);
+ });
+
+ connect(ui->rbTableView,
+ &QRadioButton::clicked,
+ this,
+ &AnnotationEditorDialog::switchToTableView);
+ connect(ui->rbTabView,
+ &QRadioButton::clicked,
+ this, &AnnotationEditorDialog::switchToTabView);
+
+ setStatus(m_globalStatus);
+ switchToTabView();
+
+ connect(this, &QDialog::accepted, this, &AnnotationEditorDialog::acceptedClicked);
+
+ ui->targetIdEdit->setText(targetId);
- connect(this, &QDialog::accepted, this, &BasicAnnotationEditorDialog::acceptedClicked);
}
-BasicAnnotationEditorDialog::~BasicAnnotationEditorDialog() {}
+AnnotationEditorDialog::~AnnotationEditorDialog() {
+}
-Annotation const &BasicAnnotationEditorDialog::annotation() const
-{
- return m_annotation;
+bool AnnotationEditorDialog::isGlobal() const {
+ return m_isGlobal;
}
-void BasicAnnotationEditorDialog::setAnnotation(const Annotation &annotation)
-{
- m_annotation = annotation;
- fillFields();
+void AnnotationEditorDialog::setGlobal(bool global) {
+ ui->annotationContainer->setVisible(!global);
+ ui->statusAddButton->setVisible(global);
+ ui->statusComboBox->setVisible(global);
+
+ setWindowTitle(global ? tr("Global Annotation Editor") : tr("Annotation Editor"));
+
+ if (m_isGlobal != global) {
+ m_isGlobal = global;
+ emit globalChanged();
+ }
}
-void BasicAnnotationEditorDialog::loadDefaultAnnotations(QString const &filename)
+AnnotationEditorDialog::ViewMode AnnotationEditorDialog::viewMode() const
{
- m_defaults->loadFromFile(filename);
+ return ui->rbTableView->isChecked() ? TableView : TabsView;
}
-DefaultAnnotationsModel *BasicAnnotationEditorDialog::defaultAnnotations() const
+void AnnotationEditorDialog::setStatus(GlobalAnnotationStatus status)
{
- return m_defaults.get();
+ m_globalStatus = status;
+ bool hasStatus = status.status() != GlobalAnnotationStatus::NoStatus;
+
+ if (hasStatus)
+ ui->statusComboBox->setCurrentIndex(int(status.status()));
+
+ setStatusVisibility(hasStatus);
}
-AnnotationEditorDialog::AnnotationEditorDialog(QWidget *parent,
- const QString &targetId,
- const QString &customId)
- : BasicAnnotationEditorDialog(parent)
- , ui(new Ui::AnnotationEditorDialog)
- , m_customId(customId)
+GlobalAnnotationStatus AnnotationEditorDialog::globalStatus() const
{
- ui->setupUi(this);
- ui->targetIdEdit->setText(targetId);
-
- setWindowTitle(annotationEditorTitle);
+ return m_globalStatus;
}
-AnnotationEditorDialog::~AnnotationEditorDialog()
+void AnnotationEditorDialog::showStatusContainer(bool show)
{
- delete ui;
+ ui->statusContainer->setVisible(show);
}
-void AnnotationEditorDialog::setCustomId(const QString &customId)
+void AnnotationEditorDialog::switchToTabView()
{
- m_customId = customId;
- ui->customIdEdit->setText(m_customId);
+ m_annotation.setComments(ui->tableView->fetchComments());
+ ui->rbTabView->setChecked(true);
+ ui->tableView->hide();
+ ui->tabWidget->show();
+ fillFields();
}
-QString AnnotationEditorDialog::customId() const
+void AnnotationEditorDialog::switchToTableView()
{
- return m_customId;
+ m_annotation.setComments(ui->tabWidget->fetchComments());
+ ui->rbTableView->setChecked(true);
+ ui->tabWidget->hide();
+ ui->tableView->show();
+ fillFields();
}
void AnnotationEditorDialog::acceptedClicked()
@@ -112,14 +160,26 @@ void AnnotationEditorDialog::fillFields()
{
ui->customIdEdit->setText(m_customId);
ui->tabWidget->setupComments(m_annotation.comments());
+ ui->tableView->setupComments(m_annotation.comments());
}
void AnnotationEditorDialog::updateAnnotation()
{
m_customId = ui->customIdEdit->text();
Annotation annotation;
- annotation.setComments(ui->tabWidget->fetchComments());
+ switch (viewMode()) {
+ case TabsView:
+ annotation.setComments(ui->tabWidget->fetchComments());
+ break;
+ case TableView:
+ annotation.setComments(ui->tableView->fetchComments());
+ break;
+ }
+
m_annotation = annotation;
+
+ if (m_statusIsActive && m_isGlobal)
+ m_globalStatus.setStatus(ui->statusComboBox->currentIndex());
}
void AnnotationEditorDialog::addComment(const Comment &comment)
@@ -130,8 +190,52 @@ void AnnotationEditorDialog::addComment(const Comment &comment)
void AnnotationEditorDialog::removeComment(int index)
{
- m_annotation.removeComment(index);
- ui->tabWidget->removeTab(index);
+ if ((m_annotation.commentsSize() > index) && (index >= 0)) {
+ m_annotation.removeComment(index);
+ ui->tabWidget->removeTab(index);
+ }
+}
+
+void AnnotationEditorDialog::setStatusVisibility(bool hasStatus)
+{
+ ui->statusAddButton->setVisible(!hasStatus && m_isGlobal);
+ ui->statusComboBox->setVisible(hasStatus && m_isGlobal);
+
+ m_statusIsActive = hasStatus;
+}
+
+
+Annotation const &AnnotationEditorDialog::annotation() const
+{
+ return m_annotation;
}
+void AnnotationEditorDialog::setAnnotation(const Annotation &annotation)
+{
+ m_annotation = annotation;
+ fillFields();
+}
+
+void AnnotationEditorDialog::loadDefaultAnnotations(QString const &filename)
+{
+ m_defaults->loadFromFile(filename);
+}
+
+DefaultAnnotationsModel *AnnotationEditorDialog::defaultAnnotations() const
+{
+ return m_defaults.get();
+}
+
+void AnnotationEditorDialog::setCustomId(const QString &customId)
+{
+ m_customId = customId;
+ ui->customIdEdit->setText(m_customId);
+}
+
+QString AnnotationEditorDialog::customId() const
+{
+ return m_customId;
+}
+
+
} //namespace QmlDesigner
diff --git a/src/plugins/qmldesigner/components/annotationeditor/annotationeditordialog.h b/src/plugins/qmldesigner/components/annotationeditor/annotationeditordialog.h
index 856eb9bb60..eefccba6ef 100644
--- a/src/plugins/qmldesigner/components/annotationeditor/annotationeditordialog.h
+++ b/src/plugins/qmldesigner/components/annotationeditor/annotationeditordialog.h
@@ -36,60 +36,62 @@ class AnnotationEditorDialog;
}
class DefaultAnnotationsModel;
-class BasicAnnotationEditorDialog : public QDialog
+class AnnotationEditorDialog : public QDialog
{
Q_OBJECT
public:
- explicit BasicAnnotationEditorDialog(QWidget *parent);
- ~BasicAnnotationEditorDialog();
+ enum ViewMode { TableView, TabsView };
- Annotation const &annotation() const;
- void setAnnotation(const Annotation &annotation);
-
- void loadDefaultAnnotations(QString const &filename);
+ explicit AnnotationEditorDialog(QWidget *parent,
+ const QString &targetId = {},
+ const QString &customId = {});
+ ~AnnotationEditorDialog();
- DefaultAnnotationsModel *defaultAnnotations() const;
+ ViewMode viewMode() const;
-signals:
- void acceptedDialog(); //use instead of QDialog::accepted
+ Annotation const &annotation() const;
+ void setAnnotation(const Annotation &annotation);
-protected:
- virtual void fillFields() = 0;
- virtual void acceptedClicked() = 0;
+ QString customId() const;
+ void setCustomId(const QString &customId);
- Annotation m_annotation;
- std::unique_ptr<DefaultAnnotationsModel> m_defaults;
-};
+ bool isGlobal() const;
+ void setGlobal(bool = true);
-class AnnotationEditorDialog : public BasicAnnotationEditorDialog
-{
- Q_OBJECT
+ void loadDefaultAnnotations(QString const &filename);
-public:
- explicit AnnotationEditorDialog(QWidget *parent,
- const QString &targetId,
- const QString &customId);
- ~AnnotationEditorDialog();
+ DefaultAnnotationsModel *defaultAnnotations() const;
+ void setStatus(GlobalAnnotationStatus status);
+ GlobalAnnotationStatus globalStatus() const;
- void setCustomId(const QString &customId);
- QString customId() const;
+public slots:
+ void showStatusContainer(bool show);
+ void switchToTabView();
+ void switchToTableView();
private slots:
- void acceptedClicked() override;
+ void acceptedClicked();
+signals:
+ void acceptedDialog(); //use instead of QDialog::accepted
+ void globalChanged();
private:
- void fillFields() override;
+ void fillFields();
void updateAnnotation();
void addComment(const Comment &comment);
void removeComment(int index);
-private:
- const QString annotationEditorTitle = {tr("Annotation Editor")};
-
- Ui::AnnotationEditorDialog *ui;
+ void setStatusVisibility(bool hasStatus);
+ std::unique_ptr<Ui::AnnotationEditorDialog> ui;
+ GlobalAnnotationStatus m_globalStatus = GlobalAnnotationStatus::NoStatus;
+ bool m_statusIsActive = false;
+ bool m_isGlobal = false;
+ Annotation m_annotation;
QString m_customId;
+ std::unique_ptr<DefaultAnnotationsModel> m_defaults;
};
+
} //namespace QmlDesigner
diff --git a/src/plugins/qmldesigner/components/annotationeditor/annotationeditordialog.ui b/src/plugins/qmldesigner/components/annotationeditor/annotationeditordialog.ui
index 5dd747a7dc..5f30cc3815 100644
--- a/src/plugins/qmldesigner/components/annotationeditor/annotationeditordialog.ui
+++ b/src/plugins/qmldesigner/components/annotationeditor/annotationeditordialog.ui
@@ -15,6 +15,98 @@
</property>
<layout class="QVBoxLayout" name="verticalLayout_2">
<item>
+ <widget class="QWidget" name="statusContainer" native="true">
+ <layout class="QHBoxLayout" name="horizontalLayout_3">
+ <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>
+ <widget class="QPushButton" name="statusAddButton">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Preferred" vsizetype="Fixed">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="text">
+ <string>Add Status</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QComboBox" name="statusComboBox">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Preferred" vsizetype="Fixed">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="minimumSize">
+ <size>
+ <width>100</width>
+ <height>0</height>
+ </size>
+ </property>
+ <item>
+ <property name="text">
+ <string>In Progress</string>
+ </property>
+ </item>
+ <item>
+ <property name="text">
+ <string>In Review</string>
+ </property>
+ </item>
+ <item>
+ <property name="text">
+ <string>Done</string>
+ </property>
+ </item>
+ </widget>
+ </item>
+ <item>
+ <widget class="QRadioButton" name="rbTabView">
+ <property name="text">
+ <string>Tab View</string>
+ </property>
+ <property name="checked">
+ <bool>true</bool>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QRadioButton" name="rbTableView">
+ <property name="text">
+ <string>Table View</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>
+ </widget>
+ </item>
+ <item>
<widget class="QWidget" name="annotationContainer" native="true">
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
@@ -76,6 +168,9 @@
</widget>
</item>
<item>
+ <widget class="AnnotationTableView" name="tableView"/>
+ </item>
+ <item>
<widget class="QDialogButtonBox" name="buttonBox">
<property name="focusPolicy">
<enum>Qt::StrongFocus</enum>
@@ -97,6 +192,11 @@
<header>annotationtabwidget.h</header>
<container>1</container>
</customwidget>
+ <customwidget>
+ <class>AnnotationTableView</class>
+ <extends>QTableView</extends>
+ <header>annotationtableview.h</header>
+ </customwidget>
</customwidgets>
<tabstops>
<tabstop>targetIdEdit</tabstop>
diff --git a/src/plugins/qmldesigner/components/annotationeditor/annotationtableview.h b/src/plugins/qmldesigner/components/annotationeditor/annotationtableview.h
index bd3443ee87..b30fe271de 100644
--- a/src/plugins/qmldesigner/components/annotationeditor/annotationtableview.h
+++ b/src/plugins/qmldesigner/components/annotationeditor/annotationtableview.h
@@ -22,6 +22,7 @@
** be met: https://www.gnu.org/licenses/gpl-3.0.html.
**
****************************************************************************/
+#pragma once
#include <QItemDelegate>
#include <QLabel>
diff --git a/src/plugins/qmldesigner/components/annotationeditor/globalannotationeditor.cpp b/src/plugins/qmldesigner/components/annotationeditor/globalannotationeditor.cpp
index 0b04ed5f1c..6dfdf0f285 100644
--- a/src/plugins/qmldesigner/components/annotationeditor/globalannotationeditor.cpp
+++ b/src/plugins/qmldesigner/components/annotationeditor/globalannotationeditor.cpp
@@ -26,7 +26,8 @@
#include "globalannotationeditor.h"
#include "annotation.h"
-#include "globalannotationeditordialog.h"
+#include "annotationeditordialog.h"
+
#include <coreplugin/icore.h>
#include <QMessageBox>
@@ -41,15 +42,18 @@ GlobalAnnotationEditor::~GlobalAnnotationEditor() {}
QWidget *GlobalAnnotationEditor::createWidget()
{
- auto* dialog = new GlobalAnnotationEditorDialog(Core::ICore::dialogParent(),
- this->m_modelNode.globalStatus());
+ auto *dialog = new AnnotationEditorDialog(Core::ICore::dialogParent());
+
+ dialog->setGlobal(true);
+ dialog->setStatus(m_modelNode.globalStatus());
+
dialog->setAnnotation(this->m_modelNode.globalAnnotation());
QObject::connect(dialog,
- &GlobalAnnotationEditorDialog::acceptedDialog,
+ &AnnotationEditorDialog::acceptedDialog,
this,
&GlobalAnnotationEditor::acceptedClicked);
QObject::connect(dialog,
- &GlobalAnnotationEditorDialog::rejected,
+ &AnnotationEditorDialog::rejected,
this,
&GlobalAnnotationEditor::cancelClicked);
return dialog;
@@ -73,7 +77,7 @@ void GlobalAnnotationEditor::removeFullAnnotation()
void GlobalAnnotationEditor::acceptedClicked()
{
- if (const auto *dialog = qobject_cast<GlobalAnnotationEditorDialog *>(widget())) {
+ if (const auto *dialog = qobject_cast<AnnotationEditorDialog *>(widget())) {
auto &node = this->m_modelNode;
const Annotation annotation = dialog->annotation();
diff --git a/src/plugins/qmldesigner/components/annotationeditor/globalannotationeditor.h b/src/plugins/qmldesigner/components/annotationeditor/globalannotationeditor.h
index ed8973380f..6b14fb892f 100644
--- a/src/plugins/qmldesigner/components/annotationeditor/globalannotationeditor.h
+++ b/src/plugins/qmldesigner/components/annotationeditor/globalannotationeditor.h
@@ -31,7 +31,6 @@
#include "abstractaction.h"
#include "annotation.h"
-#include "globalannotationeditordialog.h"
#include "editorproxy.h"
#include "modelnode.h"
diff --git a/src/plugins/qmldesigner/components/annotationeditor/globalannotationeditordialog.cpp b/src/plugins/qmldesigner/components/annotationeditor/globalannotationeditordialog.cpp
deleted file mode 100644
index 3722935643..0000000000
--- a/src/plugins/qmldesigner/components/annotationeditor/globalannotationeditordialog.cpp
+++ /dev/null
@@ -1,179 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2020 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of Qt Creator.
-**
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3 as published by the Free Software
-** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-3.0.html.
-**
-****************************************************************************/
-
-#include "globalannotationeditordialog.h"
-#include "annotation.h"
-#include "annotationcommenttab.h"
-#include "ui_globalannotationeditordialog.h"
-
-#include <timelineicons.h>
-#include <utils/qtcassert.h>
-
-#include <QAction>
-#include <QMessageBox>
-#include <QObject>
-#include <QToolBar>
-
-namespace QmlDesigner {
-
-GlobalAnnotationEditorDialog::GlobalAnnotationEditorDialog(QWidget *parent,
- GlobalAnnotationStatus status)
- : BasicAnnotationEditorDialog(parent)
- , ui(new Ui::GlobalAnnotationEditorDialog)
- , m_globalStatus(status)
- , m_statusIsActive(false)
-{
- ui->setupUi(this);
- ui->tabWidget->setDefaultAnnotations(defaultAnnotations());
- ui->tableView->setDefaultAnnotations(defaultAnnotations());
-
- connect(ui->tableView,
- &AnnotationTableView::richTextEditorRequested,
- this,
- [&](int index, QString const &) {
- switchToTabView();
- ui->tabWidget->setCurrentIndex(index);
- });
-
- connect(ui->statusAddButton, &QPushButton::clicked, this, [&](bool) {
- setStatusVisibility(true);
- });
-
- connect(ui->rbTableView,
- &QRadioButton::clicked,
- this,
- &GlobalAnnotationEditorDialog::switchToTableView);
- connect(ui->rbTabView,
- &QRadioButton::clicked,
- this,
- &GlobalAnnotationEditorDialog::switchToTabView);
-
- setStatus(m_globalStatus);
- setWindowTitle(globalEditorTitle);
- switchToTabView();
-}
-
-GlobalAnnotationEditorDialog::~GlobalAnnotationEditorDialog()
-{
- delete ui;
-}
-
-GlobalAnnotationEditorDialog::ViewMode GlobalAnnotationEditorDialog::viewMode() const
-{
- return ui->rbTableView->isChecked() ? TableView : TabsView;
-}
-
-void GlobalAnnotationEditorDialog::setStatus(GlobalAnnotationStatus status)
-{
- m_globalStatus = status;
- bool hasStatus = status.status() != GlobalAnnotationStatus::NoStatus;
-
- if (hasStatus)
- ui->statusComboBox->setCurrentIndex(int(status.status()));
-
- setStatusVisibility(hasStatus);
-}
-
-GlobalAnnotationStatus GlobalAnnotationEditorDialog::globalStatus() const
-{
- return m_globalStatus;
-}
-
-void GlobalAnnotationEditorDialog::showStatusContainer(bool show)
-{
- ui->statusContainer->setVisible(show);
-}
-
-void GlobalAnnotationEditorDialog::switchToTabView()
-{
- m_annotation.setComments(ui->tableView->fetchComments());
- ui->rbTabView->setChecked(true);
- ui->tableView->hide();
- ui->tabWidget->show();
- fillFields();
-}
-
-void GlobalAnnotationEditorDialog::switchToTableView()
-{
- m_annotation.setComments(ui->tabWidget->fetchComments());
- ui->rbTableView->setChecked(true);
- ui->tabWidget->hide();
- ui->tableView->show();
- fillFields();
-}
-
-void GlobalAnnotationEditorDialog::acceptedClicked()
-{
- updateAnnotation();
- emit GlobalAnnotationEditorDialog::acceptedDialog();
-}
-
-void GlobalAnnotationEditorDialog::fillFields()
-{
- ui->tabWidget->setupComments(m_annotation.comments());
- ui->tableView->setupComments(m_annotation.comments());
-}
-
-void GlobalAnnotationEditorDialog::updateAnnotation()
-{
- Annotation annotation;
- switch (viewMode()) {
- case TabsView:
- annotation.setComments(ui->tabWidget->fetchComments());
- break;
- case TableView:
- annotation.setComments(ui->tableView->fetchComments());
- break;
- }
-
- m_annotation = annotation;
-
- if (m_statusIsActive)
- m_globalStatus.setStatus(ui->statusComboBox->currentIndex());
-}
-
-void GlobalAnnotationEditorDialog::addComment(const Comment &comment)
-{
- m_annotation.addComment(comment);
- ui->tabWidget->addCommentTab(comment);
-}
-
-void GlobalAnnotationEditorDialog::removeComment(int index)
-{
- if ((m_annotation.commentsSize() > index) && (index >= 0)) {
- m_annotation.removeComment(index);
- ui->tabWidget->removeTab(index);
- }
-}
-
-void GlobalAnnotationEditorDialog::setStatusVisibility(bool hasStatus)
-{
- ui->statusAddButton->setVisible(!hasStatus);
- ui->statusComboBox->setVisible(hasStatus);
-
- m_statusIsActive = hasStatus;
-}
-
-} //namespace QmlDesigner
diff --git a/src/plugins/qmldesigner/components/annotationeditor/globalannotationeditordialog.h b/src/plugins/qmldesigner/components/annotationeditor/globalannotationeditordialog.h
deleted file mode 100644
index 2f4c942809..0000000000
--- a/src/plugins/qmldesigner/components/annotationeditor/globalannotationeditordialog.h
+++ /dev/null
@@ -1,80 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2020 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of Qt Creator.
-**
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3 as published by the Free Software
-** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-3.0.html.
-**
-****************************************************************************/
-
-#pragma once
-
-#include "annotationeditordialog.h"
-
-namespace QmlDesigner {
-
-namespace Ui {
-class GlobalAnnotationEditorDialog;
-}
-
-class GlobalAnnotationEditorDialog : public BasicAnnotationEditorDialog
-{
- Q_OBJECT
-public:
- enum ViewMode {
- TableView,
- TabsView
- };
-
- explicit GlobalAnnotationEditorDialog(
- QWidget *parent = nullptr, GlobalAnnotationStatus status = GlobalAnnotationStatus::NoStatus);
- ~GlobalAnnotationEditorDialog();
-
- ViewMode viewMode() const;
-
- void setStatus(GlobalAnnotationStatus status);
- GlobalAnnotationStatus globalStatus() const;
-
-public slots:
- void showStatusContainer(bool show);
- void switchToTabView();
- void switchToTableView();
-
-private slots:
- void acceptedClicked() override;
-
-private:
-
- void fillFields() override;
- void updateAnnotation();
- void addComment(const Comment &comment);
- void removeComment(int index);
-
- void setStatusVisibility(bool hasStatus);
-
-private:
- const QString globalEditorTitle = {tr("Global Annotation Editor")};
-
- Ui::GlobalAnnotationEditorDialog *ui;
-
- GlobalAnnotationStatus m_globalStatus;
- bool m_statusIsActive;
-};
-
-} //namespace QmlDesigner
diff --git a/src/plugins/qmldesigner/components/annotationeditor/globalannotationeditordialog.ui b/src/plugins/qmldesigner/components/annotationeditor/globalannotationeditordialog.ui
deleted file mode 100644
index 75d99d26e0..0000000000
--- a/src/plugins/qmldesigner/components/annotationeditor/globalannotationeditordialog.ui
+++ /dev/null
@@ -1,198 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<ui version="4.0">
- <class>QmlDesigner::GlobalAnnotationEditorDialog</class>
- <widget class="QDialog" name="QmlDesigner::GlobalAnnotationEditorDialog">
- <property name="geometry">
- <rect>
- <x>0</x>
- <y>0</y>
- <width>1344</width>
- <height>819</height>
- </rect>
- </property>
- <property name="windowTitle">
- <string notr="true">Dialog</string>
- </property>
- <layout class="QVBoxLayout" name="verticalLayout_2">
- <item>
- <widget class="QWidget" name="statusContainer" native="true">
- <layout class="QHBoxLayout" name="horizontalLayout_2">
- <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>
- <widget class="QPushButton" name="statusAddButton">
- <property name="sizePolicy">
- <sizepolicy hsizetype="Preferred" vsizetype="Fixed">
- <horstretch>0</horstretch>
- <verstretch>0</verstretch>
- </sizepolicy>
- </property>
- <property name="text">
- <string>Add Status</string>
- </property>
- </widget>
- </item>
- <item>
- <widget class="QComboBox" name="statusComboBox">
- <property name="sizePolicy">
- <sizepolicy hsizetype="Preferred" vsizetype="Fixed">
- <horstretch>0</horstretch>
- <verstretch>0</verstretch>
- </sizepolicy>
- </property>
- <property name="minimumSize">
- <size>
- <width>100</width>
- <height>0</height>
- </size>
- </property>
- <item>
- <property name="text">
- <string>In Progress</string>
- </property>
- </item>
- <item>
- <property name="text">
- <string>In Review</string>
- </property>
- </item>
- <item>
- <property name="text">
- <string>Done</string>
- </property>
- </item>
- </widget>
- </item>
- <item>
- <widget class="QRadioButton" name="rbTabView">
- <property name="text">
- <string>Tab View</string>
- </property>
- <property name="checked">
- <bool>true</bool>
- </property>
- </widget>
- </item>
- <item>
- <widget class="QRadioButton" name="rbTableView">
- <property name="text">
- <string>Table View</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>
- </widget>
- </item>
- <item>
- <widget class="AnnotationTabWidget" name="tabWidget">
- <property name="currentIndex">
- <number>0</number>
- </property>
- <property name="movable">
- <bool>true</bool>
- </property>
- <widget class="QWidget" name="tab">
- <attribute name="title">
- <string>Tab 1</string>
- </attribute>
- </widget>
- <widget class="QWidget" name="tab_2">
- <attribute name="title">
- <string>Tab 2</string>
- </attribute>
- </widget>
- </widget>
- </item>
- <item>
- <widget class="AnnotationTableView" name="tableView"/>
- </item>
- <item>
- <widget class="QDialogButtonBox" name="buttonBox">
- <property name="focusPolicy">
- <enum>Qt::StrongFocus</enum>
- </property>
- <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>AnnotationTabWidget</class>
- <extends>QTabWidget</extends>
- <header>annotationtabwidget.h</header>
- <container>1</container>
- </customwidget>
- <customwidget>
- <class>AnnotationTableView</class>
- <extends>QTableView</extends>
- <header>annotationtableview.h</header>
- </customwidget>
- </customwidgets>
- <tabstops>
- <tabstop>tabWidget</tabstop>
- </tabstops>
- <resources/>
- <connections>
- <connection>
- <sender>buttonBox</sender>
- <signal>accepted()</signal>
- <receiver>QmlDesigner::GlobalAnnotationEditorDialog</receiver>
- <slot>accept()</slot>
- <hints>
- <hint type="sourcelabel">
- <x>261</x>
- <y>473</y>
- </hint>
- <hint type="destinationlabel">
- <x>157</x>
- <y>274</y>
- </hint>
- </hints>
- </connection>
- <connection>
- <sender>buttonBox</sender>
- <signal>rejected()</signal>
- <receiver>QmlDesigner::GlobalAnnotationEditorDialog</receiver>
- <slot>reject()</slot>
- <hints>
- <hint type="sourcelabel">
- <x>329</x>
- <y>473</y>
- </hint>
- <hint type="destinationlabel">
- <x>286</x>
- <y>274</y>
- </hint>
- </hints>
- </connection>
- </connections>
-</ui>
diff --git a/src/plugins/qmldesigner/qmldesignerplugin.qbs b/src/plugins/qmldesigner/qmldesignerplugin.qbs
index 9f9124691f..b80e0c01ed 100644
--- a/src/plugins/qmldesigner/qmldesignerplugin.qbs
+++ b/src/plugins/qmldesigner/qmldesignerplugin.qbs
@@ -737,9 +737,6 @@ Project {
"annotationeditor/annotationeditordialog.cpp",
"annotationeditor/annotationeditordialog.h",
"annotationeditor/annotationeditordialog.ui",
- "annotationeditor/globalannotationeditordialog.cpp",
- "annotationeditor/globalannotationeditordialog.h",
- "annotationeditor/globalannotationeditordialog.ui",
"annotationeditor/defaultannotations.cpp",
"annotationeditor/defaultannotations.h",
"annotationeditor/annotationtableview.cpp",