forked from qt-creator/qt-creator
QmlDesigner: minor fixes for Annotations
- Mac dialog window fix - Changed behavior on add new tabs action - Removed unused code Change-Id: I0579b1ba85fb535464b2d5160a85a898f2e78a76 Reviewed-by: Thomas Hartmann <thomas.hartmann@qt.io>
This commit is contained in:
@@ -213,6 +213,7 @@ Rectangle {
|
|||||||
iconFont: StudioTheme.Constants.font
|
iconFont: StudioTheme.Constants.font
|
||||||
Layout.fillWidth: true
|
Layout.fillWidth: true
|
||||||
Layout.preferredWidth: 240
|
Layout.preferredWidth: 240
|
||||||
|
width: 240
|
||||||
|
|
||||||
onClicked: annotationEditor.showWidget()
|
onClicked: annotationEditor.showWidget()
|
||||||
|
|
||||||
|
@@ -66,7 +66,8 @@ void AnnotationEditor::showWidget()
|
|||||||
|
|
||||||
m_dialog->setAttribute(Qt::WA_DeleteOnClose);
|
m_dialog->setAttribute(Qt::WA_DeleteOnClose);
|
||||||
|
|
||||||
m_dialog->open();
|
m_dialog->show();
|
||||||
|
m_dialog->raise();
|
||||||
}
|
}
|
||||||
|
|
||||||
void AnnotationEditor::showWidget(int x, int y)
|
void AnnotationEditor::showWidget(int x, int y)
|
||||||
|
@@ -30,7 +30,8 @@
|
|||||||
|
|
||||||
#include "ui_annotationcommenttab.h"
|
#include "ui_annotationcommenttab.h"
|
||||||
|
|
||||||
#include <timelineicons.h> //replace timeline icons with our own?
|
#include <timelineicons.h>
|
||||||
|
#include <utils/qtcassert.h>
|
||||||
|
|
||||||
#include <QObject>
|
#include <QObject>
|
||||||
#include <QToolBar>
|
#include <QToolBar>
|
||||||
@@ -50,6 +51,7 @@ AnnotationEditorDialog::AnnotationEditorDialog(QWidget *parent, const QString &t
|
|||||||
setWindowFlags(windowFlags() & ~Qt::WindowContextHelpButtonHint);
|
setWindowFlags(windowFlags() & ~Qt::WindowContextHelpButtonHint);
|
||||||
setWindowFlag(Qt::Tool, true);
|
setWindowFlag(Qt::Tool, true);
|
||||||
setWindowTitle(titleString);
|
setWindowTitle(titleString);
|
||||||
|
setModal(true);
|
||||||
|
|
||||||
connect(this, &QDialog::accepted, this, &AnnotationEditorDialog::acceptedClicked);
|
connect(this, &QDialog::accepted, this, &AnnotationEditorDialog::acceptedClicked);
|
||||||
|
|
||||||
@@ -67,8 +69,10 @@ AnnotationEditorDialog::AnnotationEditorDialog(QWidget *parent, const QString &t
|
|||||||
|
|
||||||
connect(commentRemoveAction, &QAction::triggered, this, [this]() {
|
connect(commentRemoveAction, &QAction::triggered, this, [this]() {
|
||||||
|
|
||||||
if (ui->tabWidget->count() == 0) //it is not even supposed to happen but lets be sure
|
if (ui->tabWidget->count() == 0) { //it is not even supposed to happen but lets be sure
|
||||||
|
QTC_ASSERT(true, return);
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
int currentIndex = ui->tabWidget->currentIndex();
|
int currentIndex = ui->tabWidget->currentIndex();
|
||||||
QString currentTitle = ui->tabWidget->tabText(currentIndex);
|
QString currentTitle = ui->tabWidget->tabText(currentIndex);
|
||||||
@@ -202,11 +206,18 @@ void AnnotationEditorDialog::addCommentTab(const Comment &comment)
|
|||||||
{
|
{
|
||||||
auto commentTab = new AnnotationCommentTab();
|
auto commentTab = new AnnotationCommentTab();
|
||||||
commentTab->setComment(comment);
|
commentTab->setComment(comment);
|
||||||
int tabIndex = ui->tabWidget->addTab(commentTab, comment.title());
|
|
||||||
|
|
||||||
if (comment.title().isEmpty())
|
QString tabTitle(comment.title());
|
||||||
ui->tabWidget->setTabText(tabIndex,
|
int tabIndex = ui->tabWidget->addTab(commentTab, tabTitle);
|
||||||
(defaultTabName + " " + QString::number(tabIndex+1)));
|
ui->tabWidget->setCurrentIndex(tabIndex);
|
||||||
|
|
||||||
|
if (tabTitle.isEmpty()) {
|
||||||
|
const QString appendix = ((tabIndex > 0) ? QString::number(tabIndex+1) : "");
|
||||||
|
|
||||||
|
tabTitle = QString("%1 %2").arg(defaultTabName).arg(appendix);
|
||||||
|
|
||||||
|
ui->tabWidget->setTabText(tabIndex, tabTitle);
|
||||||
|
}
|
||||||
|
|
||||||
connect(commentTab, &AnnotationCommentTab::titleChanged,
|
connect(commentTab, &AnnotationCommentTab::titleChanged,
|
||||||
this, &AnnotationEditorDialog::commentTitleChanged);
|
this, &AnnotationEditorDialog::commentTitleChanged);
|
||||||
@@ -230,18 +241,7 @@ void AnnotationEditorDialog::deleteAllTabs()
|
|||||||
|
|
||||||
void AnnotationEditorDialog::tabChanged(int index)
|
void AnnotationEditorDialog::tabChanged(int index)
|
||||||
{
|
{
|
||||||
QWidget *w = ui->tabWidget->widget(index);
|
(void) index;
|
||||||
AnnotationCommentTab *tab = nullptr;
|
|
||||||
if (w)
|
|
||||||
tab = reinterpret_cast<AnnotationCommentTab*>(w);
|
|
||||||
|
|
||||||
if (tab) {
|
|
||||||
//this tab order resetting doesn't work
|
|
||||||
QWidget::setTabOrder(ui->targetIdEdit, ui->customIdEdit);
|
|
||||||
QWidget::setTabOrder(ui->customIdEdit, ui->tabWidget);
|
|
||||||
QWidget::setTabOrder(ui->tabWidget, tab);
|
|
||||||
QWidget::setTabOrder(tab, ui->buttonBox);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
} //namespace QmlDesigner
|
} //namespace QmlDesigner
|
||||||
|
@@ -163,19 +163,20 @@ void AnnotationTool::selectedItemsChanged(const QList<FormEditorItem*> &itemList
|
|||||||
if (!itemList.isEmpty()) {
|
if (!itemList.isEmpty()) {
|
||||||
m_formEditorItem = itemList.constFirst();
|
m_formEditorItem = itemList.constFirst();
|
||||||
|
|
||||||
m_oldCustomId = m_formEditorItem->qmlItemNode().modelNode().customId();
|
ModelNode itemModelNode = m_formEditorItem->qmlItemNode().modelNode();
|
||||||
m_oldAnnotation = m_formEditorItem->qmlItemNode().modelNode().annotation();
|
m_oldCustomId = itemModelNode.customId();
|
||||||
|
m_oldAnnotation = itemModelNode.annotation();
|
||||||
|
|
||||||
if (m_annotationEditor.isNull()) {
|
if (m_annotationEditor.isNull()) {
|
||||||
m_annotationEditor = new AnnotationEditorDialog(view()->formEditorWidget()->parentWidget(),
|
m_annotationEditor = new AnnotationEditorDialog(view()->formEditorWidget()->parentWidget(),
|
||||||
m_formEditorItem->qmlItemNode().modelNode().displayName(),
|
itemModelNode.displayName(),
|
||||||
m_oldCustomId, m_oldAnnotation);
|
m_oldCustomId, m_oldAnnotation);
|
||||||
|
|
||||||
connect(m_annotationEditor, &AnnotationEditorDialog::accepted, this, &AnnotationTool::annotationDialogAccepted);
|
connect(m_annotationEditor, &AnnotationEditorDialog::accepted, this, &AnnotationTool::annotationDialogAccepted);
|
||||||
connect(m_annotationEditor, &QDialog::rejected, this, &AnnotationTool::annotationDialogRejected);
|
connect(m_annotationEditor, &QDialog::rejected, this, &AnnotationTool::annotationDialogRejected);
|
||||||
// connect(m_colorDialog.data(), &QColorDialog::currentColorChanged, this, &ColorTool::currentColorChanged);
|
|
||||||
|
|
||||||
m_annotationEditor->exec();
|
m_annotationEditor->show();
|
||||||
|
m_annotationEditor->raise();
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
view()->changeToSelectionTool();
|
view()->changeToSelectionTool();
|
||||||
|
@@ -96,7 +96,7 @@ void FormEditorAnnotationIcon::paint(QPainter *painter, const QStyleOptionGraphi
|
|||||||
if (scene)
|
if (scene)
|
||||||
m_readerIsActive = scene->annotationVisibility();
|
m_readerIsActive = scene->annotationVisibility();
|
||||||
|
|
||||||
QPixmap icon( (m_readerIsActive ? m_activeIconStr : m_normalIconStr) );
|
QPixmap icon(m_readerIsActive ? m_activeIconStr : m_normalIconStr);
|
||||||
|
|
||||||
painter->drawPixmap(0, 0,
|
painter->drawPixmap(0, 0,
|
||||||
static_cast<int>(m_iconW), static_cast<int>(m_iconH),
|
static_cast<int>(m_iconW), static_cast<int>(m_iconH),
|
||||||
@@ -277,11 +277,8 @@ void FormEditorAnnotationIcon::drawReader()
|
|||||||
|
|
||||||
void FormEditorAnnotationIcon::hideReader()
|
void FormEditorAnnotationIcon::hideReader()
|
||||||
{
|
{
|
||||||
if (!childItems().isEmpty()) {
|
if (!childItems().isEmpty())
|
||||||
for (QGraphicsItem *item : childItems()) {
|
qDeleteAll(childItems());
|
||||||
delete item;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
QGraphicsItem *FormEditorAnnotationIcon::createCommentBubble(const QRectF &rect, const QString &title,
|
QGraphicsItem *FormEditorAnnotationIcon::createCommentBubble(const QRectF &rect, const QString &title,
|
||||||
@@ -398,7 +395,8 @@ void FormEditorAnnotationIcon::createAnnotationEditor()
|
|||||||
connect(m_annotationEditor, &QDialog::rejected,
|
connect(m_annotationEditor, &QDialog::rejected,
|
||||||
this, &FormEditorAnnotationIcon::annotationDialogRejected);
|
this, &FormEditorAnnotationIcon::annotationDialogRejected);
|
||||||
|
|
||||||
m_annotationEditor->open();
|
m_annotationEditor->show();
|
||||||
|
m_annotationEditor->raise();
|
||||||
}
|
}
|
||||||
|
|
||||||
void FormEditorAnnotationIcon::removeAnnotationDialog()
|
void FormEditorAnnotationIcon::removeAnnotationDialog()
|
||||||
|
@@ -216,17 +216,18 @@ void SelectionIndicator::adjustAnnotationPosition(const QRectF &itemRect, const
|
|||||||
{
|
{
|
||||||
if (!m_annotationItem) return;
|
if (!m_annotationItem) return;
|
||||||
|
|
||||||
const qreal iconW = 40 * 0.5; //*0.5 for a shift of an icon outide the item
|
const qreal iconWShift = m_annotationItem->iconWidth() * 0.5;
|
||||||
|
const qreal iconHShift = (m_annotationItem->iconHeight() * 0.45)/scaleFactor;
|
||||||
qreal iconX = 0.0;
|
qreal iconX = 0.0;
|
||||||
qreal iconY = -15.0/scaleFactor; //small offset
|
qreal iconY = -(iconHShift);
|
||||||
|
|
||||||
if (((labelRect.width() + iconW)/scaleFactor) > itemRect.width())
|
if (((labelRect.width() + iconWShift)/scaleFactor) > itemRect.width())
|
||||||
iconY -= labelRect.height()/scaleFactor;
|
iconY -= labelRect.height()/scaleFactor;
|
||||||
|
|
||||||
if ((iconW/scaleFactor) > itemRect.width())
|
if ((iconWShift/scaleFactor) > itemRect.width())
|
||||||
iconX = 0.0;
|
iconX = 0.0;
|
||||||
else
|
else
|
||||||
iconX = (itemRect.width()) - (iconW/scaleFactor);
|
iconX = (itemRect.width()) - (iconWShift/scaleFactor);
|
||||||
|
|
||||||
m_annotationItem->setPos(iconX*scaleFactor, iconY*scaleFactor);
|
m_annotationItem->setPos(iconX*scaleFactor, iconY*scaleFactor);
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user