Skip to content

Commit 7aa92c1

Browse files
committed
Set the focus to active view when ModelWidget is changed
Create a proper text annotation string.
1 parent 16d9afb commit 7aa92c1

File tree

2 files changed

+24
-11
lines changed

2 files changed

+24
-11
lines changed

OMEdit/OMEdit/OMEditGUI/Annotations/TextAnnotation.cpp

Lines changed: 16 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -183,8 +183,7 @@ void TextAnnotation::parseShapeAnnotation(QString annotation)
183183
mFontSize = list.at(10).toFloat();
184184
// 12th item of the list contains the optional textColor, {-1, -1, -1} if not set
185185
QStringList textColorList = StringHandler::getStrings(StringHandler::removeFirstLastCurlBrackets(list.at(11)));
186-
if (textColorList.size() >= 3)
187-
{
186+
if (textColorList.size() >= 3) {
188187
int red, green, blue = 0;
189188
red = textColorList.at(0).toInt();
190189
green = textColorList.at(1).toInt();
@@ -418,24 +417,30 @@ QString TextAnnotation::getOMCShapeAnnotation()
418417
annotationString.append(QString("\"").append(mOriginalTextString).append("\""));
419418
// get the font size
420419
annotationString.append(QString::number(mFontSize));
420+
// get the text color
421+
QString textColorString;
422+
textColorString.append("{");
423+
textColorString.append(QString::number(mLineColor.red())).append(",");
424+
textColorString.append(QString::number(mLineColor.green())).append(",");
425+
textColorString.append(QString::number(mLineColor.blue()));
426+
textColorString.append("}");
427+
annotationString.append(textColorString);
421428
// get the font name
422-
if (!mFontName.isEmpty()) {
429+
if (!mFontName.isEmpty() && mFontName.compare(Helper::systemFontInfo.family()) != 0) {
423430
annotationString.append(QString("\"").append(mFontName).append("\""));
431+
} else {
432+
annotationString.append(QString("\"\""));
424433
}
425434
// get the font styles
426435
QString textStylesString;
427436
QStringList stylesList;
428-
if (mTextStyles.size() > 0) {
429-
textStylesString.append("{");
430-
}
437+
textStylesString.append("{");
431438
for (int i = 0 ; i < mTextStyles.size() ; i++) {
432439
stylesList.append(StringHandler::getTextStyleString(mTextStyles[i]));
433440
}
434-
if (mTextStyles.size() > 0) {
435-
textStylesString.append(stylesList.join(","));
436-
textStylesString.append("}");
437-
annotationString.append(textStylesString);
438-
}
441+
textStylesString.append(stylesList.join(","));
442+
textStylesString.append("}");
443+
annotationString.append(textStylesString);
439444
// get the font horizontal alignment
440445
annotationString.append(StringHandler::getTextAlignmentString(mHorizontalAlignment));
441446
return annotationString.join(",");

OMEdit/OMEdit/OMEditGUI/Modeling/ModelWidgetContainer.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7507,6 +7507,14 @@ void ModelWidgetContainer::currentModelWidgetChanged(QMdiSubWindow *pSubWindow)
75077507
}
75087508
}
75097509
}
7510+
// set the focus when ModelWidget is changed so that the keyboard shortcuts can work e.g., ctrl+v
7511+
if (pModelWidget->getIconGraphicsView() && pModelWidget->getIconGraphicsView()->isVisible()) {
7512+
pModelWidget->getIconGraphicsView()->setFocus(Qt::ActiveWindowFocusReason);
7513+
} else if (pModelWidget->getDiagramGraphicsView() && pModelWidget->getDiagramGraphicsView()->isVisible()) {
7514+
pModelWidget->getDiagramGraphicsView()->setFocus(Qt::ActiveWindowFocusReason);
7515+
} else if (pModelWidget->getEditor() && pModelWidget->getEditor()) {
7516+
pModelWidget->getEditor()->getPlainTextEdit()->setFocus(Qt::ActiveWindowFocusReason);
7517+
}
75107518
} else {
75117519
MainWindow::instance()->getUndoAction()->setEnabled(false);
75127520
MainWindow::instance()->getRedoAction()->setEnabled(false);

0 commit comments

Comments
 (0)