Skip to content

Commit

Permalink
Set the focus to active view when ModelWidget is changed
Browse files Browse the repository at this point in the history
Create a proper text annotation string.
  • Loading branch information
adeas31 committed Sep 10, 2019
1 parent 16d9afb commit 7aa92c1
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 11 deletions.
27 changes: 16 additions & 11 deletions OMEdit/OMEdit/OMEditGUI/Annotations/TextAnnotation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -183,8 +183,7 @@ void TextAnnotation::parseShapeAnnotation(QString annotation)
mFontSize = list.at(10).toFloat();
// 12th item of the list contains the optional textColor, {-1, -1, -1} if not set
QStringList textColorList = StringHandler::getStrings(StringHandler::removeFirstLastCurlBrackets(list.at(11)));
if (textColorList.size() >= 3)
{
if (textColorList.size() >= 3) {
int red, green, blue = 0;
red = textColorList.at(0).toInt();
green = textColorList.at(1).toInt();
Expand Down Expand Up @@ -418,24 +417,30 @@ QString TextAnnotation::getOMCShapeAnnotation()
annotationString.append(QString("\"").append(mOriginalTextString).append("\""));
// get the font size
annotationString.append(QString::number(mFontSize));
// get the text color
QString textColorString;
textColorString.append("{");
textColorString.append(QString::number(mLineColor.red())).append(",");
textColorString.append(QString::number(mLineColor.green())).append(",");
textColorString.append(QString::number(mLineColor.blue()));
textColorString.append("}");
annotationString.append(textColorString);
// get the font name
if (!mFontName.isEmpty()) {
if (!mFontName.isEmpty() && mFontName.compare(Helper::systemFontInfo.family()) != 0) {
annotationString.append(QString("\"").append(mFontName).append("\""));
} else {
annotationString.append(QString("\"\""));
}
// get the font styles
QString textStylesString;
QStringList stylesList;
if (mTextStyles.size() > 0) {
textStylesString.append("{");
}
textStylesString.append("{");
for (int i = 0 ; i < mTextStyles.size() ; i++) {
stylesList.append(StringHandler::getTextStyleString(mTextStyles[i]));
}
if (mTextStyles.size() > 0) {
textStylesString.append(stylesList.join(","));
textStylesString.append("}");
annotationString.append(textStylesString);
}
textStylesString.append(stylesList.join(","));
textStylesString.append("}");
annotationString.append(textStylesString);
// get the font horizontal alignment
annotationString.append(StringHandler::getTextAlignmentString(mHorizontalAlignment));
return annotationString.join(",");
Expand Down
8 changes: 8 additions & 0 deletions OMEdit/OMEdit/OMEditGUI/Modeling/ModelWidgetContainer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7507,6 +7507,14 @@ void ModelWidgetContainer::currentModelWidgetChanged(QMdiSubWindow *pSubWindow)
}
}
}
// set the focus when ModelWidget is changed so that the keyboard shortcuts can work e.g., ctrl+v
if (pModelWidget->getIconGraphicsView() && pModelWidget->getIconGraphicsView()->isVisible()) {
pModelWidget->getIconGraphicsView()->setFocus(Qt::ActiveWindowFocusReason);
} else if (pModelWidget->getDiagramGraphicsView() && pModelWidget->getDiagramGraphicsView()->isVisible()) {
pModelWidget->getDiagramGraphicsView()->setFocus(Qt::ActiveWindowFocusReason);
} else if (pModelWidget->getEditor() && pModelWidget->getEditor()) {
pModelWidget->getEditor()->getPlainTextEdit()->setFocus(Qt::ActiveWindowFocusReason);
}
} else {
MainWindow::instance()->getUndoAction()->setEnabled(false);
MainWindow::instance()->getRedoAction()->setEnabled(false);
Expand Down

0 comments on commit 7aa92c1

Please sign in to comment.