Skip to content

Commit

Permalink
Do not automatically enlarge Message Browser setting (#11970)
Browse files Browse the repository at this point in the history
Related to #9889
The setting is disabled by default. If enabled, the message browser will not open on new messages.
Instead the small messages tab bar shown will start blinking indicating that a new message is available.
  • Loading branch information
adeas31 committed Feb 8, 2024
1 parent 997609b commit e971726
Show file tree
Hide file tree
Showing 8 changed files with 122 additions and 6 deletions.
80 changes: 79 additions & 1 deletion OMEdit/OMEditLIB/MainWindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -426,7 +426,11 @@ void MainWindow::setUpMainWindow(threadData_t *threadData)
mpLocalsWidget->getLocalsTreeView()->header()->restoreState(pSettings->value("localsTreeState").toByteArray());
pSettings->endGroup();
if (restoreMessagesWidget) {
showMessageBrowser();
if (!OptionsDialog::instance()->getMessagesPage()->getEnlargeMessageBrowserCheckBox()->isChecked()) {
showMessageBrowser();
} else {
animateMessagesTabWidgetForNewMessage(StringHandler::NoOMError);
}
}
}
switchToWelcomePerspective();
Expand Down Expand Up @@ -1815,6 +1819,39 @@ void MainWindow::writeNewApiProfiling(const QString &str)
}
}

/*!
* \brief MainWindow::animateMessagesTabWidgetForNewMessage
* Start the animation of MessageTab.
* \param errorType
*/
void MainWindow::animateMessagesTabWidgetForNewMessage(StringHandler::OpenModelicaErrors errorType)
{
MessageTab *pMessageTab = 0;
switch (errorType) {
case StringHandler::Notification:
pMessageTab = qobject_cast<MessageTab*>(mpMessagesTabWidget->widget(1));
break;
case StringHandler::Warning:
pMessageTab = qobject_cast<MessageTab*>(mpMessagesTabWidget->widget(2));
break;
case StringHandler::Internal:
case StringHandler::OMError:
pMessageTab = qobject_cast<MessageTab*>(mpMessagesTabWidget->widget(3));
break;
default:
break;
}

if (pMessageTab) {
pMessageTab->startAnimation();
}

MessageTab *pAllMessageTab = qobject_cast<MessageTab*>(mpMessagesTabWidget->widget(0));
if (pAllMessageTab) {
pAllMessageTab->startAnimation();
}
}

/*!
* \brief MainWindow::showMessageBrowser
* Slot activated when MessagesWidget::messageAdded signal is raised.\n
Expand Down Expand Up @@ -3614,6 +3651,7 @@ void MainWindow::threeDViewerDockWidgetVisibilityChanged(bool visible)
void MainWindow::messagesTabBarClicked(int index)
{
showMessageBrowser();
emit stopMessagesTabWidgetAnimation();
MessagesWidget::instance()->getMessagesTabWidget()->setCurrentIndex(index);
}

Expand Down Expand Up @@ -5118,8 +5156,10 @@ MessageTab *MainWindow::createMessageTab(const QString &name, bool fixedTab)
MessageTab *pMessageTab = new MessageTab(fixedTab);
int index = mpMessagesTabWidget->addTab(pMessageTab, name);
pMessageTab->setIndex(index);
pMessageTab->setColor(mpMessagesTabWidget->tabBar()->tabTextColor(index));
mpMessagesTabWidget->setCurrentIndex(index);
connect(pMessageTab, SIGNAL(clicked(int)), mpMessagesTabWidget, SIGNAL(tabBarClicked(int)));
connect(this, SIGNAL(stopMessagesTabWidgetAnimation()), pMessageTab, SLOT(stopAnimation()));
return pMessageTab;
}

Expand Down Expand Up @@ -5333,6 +5373,9 @@ MessageTab::MessageTab(bool fixedTab)
mpProgressBar = new QProgressBar;
mpProgressBar->setAlignment(Qt::AlignHCenter);
mpProgressBar->installEventFilter(this);
// timer to change tab color
mTimer.setInterval(500); // 0.5 sec
connect(&mTimer, SIGNAL(timeout()), SLOT(updateTabTextColor()));
// layout
QGridLayout *pMainLayout = new QGridLayout;
pMainLayout->setContentsMargins(5, 5, 5, 5);
Expand All @@ -5343,6 +5386,15 @@ MessageTab::MessageTab(bool fixedTab)
setLayout(pMainLayout);
}

/*!
* \brief MessageTab::startAnimation
* Starts the timer.
*/
void MessageTab::startAnimation()
{
mTimer.start();
}

/*!
* \brief MessageTab::updateText
* Updates the text label.
Expand All @@ -5365,6 +5417,32 @@ void MessageTab::updateProgress(QProgressBar *pProgressBar)
mpProgressBar->setTextVisible(pProgressBar->isTextVisible());
}

/*!
* \brief MessageTab::stopAnimation
* Stops the timer.
* Sets the animation counter to 0 and resets the tab text color.
*/
void MessageTab::stopAnimation()
{
mTimer.stop();
mAnimationCounter = 0;
MainWindow::instance()->getMessagesTabWidget()->tabBar()->setTabTextColor(mIndex, mColor);
}

/*!
* \brief MessageTab::updateTabTextColor
* Updates the tab text color.
*/
void MessageTab::updateTabTextColor()
{
mAnimationCounter++;
// We can stop the animation after certain number of times. But for now we use MainWindow::stopMessagesTabWidgetAnimation() signal.
// if (mCount > 10) {
// return;
// }
MainWindow::instance()->getMessagesTabWidget()->tabBar()->setTabTextColor(mIndex, (mAnimationCounter % 2 == 0) ? mColor : Qt::transparent);
}

/*!
* \brief MessageTab::eventFilter
* Emits the clicked signal on left mouse press.
Expand Down
15 changes: 14 additions & 1 deletion OMEdit/OMEditLIB/MainWindow.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@ extern "C" {
#include "meta/meta_modelica.h"
}

#include "Util/StringHandler.h"

#include <QtGlobal>
#if (QT_VERSION < QT_VERSION_CHECK(5, 0, 0))
#error "OMEdit requires Qt 5.0.0 or newer"
Expand All @@ -58,6 +60,7 @@ extern "C" {
#include <QMdiArea>
#include <QShortcut>
#include <QRadioButton>
#include <QTimer>

class OMCProxy;
class TransformationsWidget;
Expand Down Expand Up @@ -132,7 +135,6 @@ class MainWindow : public QMainWindow
VariablesWidget* getVariablesWidget() {return mpVariablesWidget;}
QDockWidget* getVariablesDockWidget() {return mpVariablesDockWidget;}
SearchWidget* getSearchWidget() {return mpSearchWidget;}

#if !defined(WITHOUT_OSG)
bool isThreeDViewerInitialized();
ThreeDViewer* getThreeDViewer();
Expand All @@ -146,6 +148,7 @@ class MainWindow : public QMainWindow
GitCommands* getGitCommands() {return mpGitCommands;}
CommitChangesDialog* getCommitChangesDialog() {return mpCommitChangesDialog;}
TraceabilityInformationURI* getTraceabilityInformationURI() {return mpTraceabilityInformationURI;}
QTabWidget* getMessagesTabWidget() {return mpMessagesTabWidget;}
StatusBar* getStatusBar() {return mpStatusBar;}
QProgressBar* getProgressBar() {return mpProgressBar;}
void showProgressBar() {mpProgressBar->setVisible(true);}
Expand Down Expand Up @@ -267,6 +270,7 @@ class MainWindow : public QMainWindow
void addSystemLibraries();
QString getLibraryIndexFilePath() const;
void writeNewApiProfiling(const QString &str);
void animateMessagesTabWidgetForNewMessage(StringHandler::OpenModelicaErrors errorType);

QList<QString> mFMUDirectoriesList;
QList<QString> mMOLDirectoriesList;
Expand Down Expand Up @@ -487,6 +491,8 @@ class MainWindow : public QMainWindow
QToolBar *mpTLMSimulationToolbar;
QToolBar *mpOMSimulatorToolbar;
QHash<QString, TransformationsWidget*> mTransformationsWidgetHash;
signals:
void stopMessagesTabWidgetAnimation();
public slots:
void showMessageBrowser();
void switchToWelcomePerspectiveSlot();
Expand Down Expand Up @@ -648,13 +654,20 @@ class MessageTab : public QWidget
public:
MessageTab(bool fixedTab);
void setIndex(int index) {mIndex = index;}
void setColor(const QColor &color) {mColor = color;}
void startAnimation();
private:
int mIndex = -1;
QColor mColor;
Label *mpProgressLabel;
QProgressBar *mpProgressBar;
QTimer mTimer;
int mAnimationCounter = 0;
public slots:
void updateText(const QString &text);
void updateProgress(QProgressBar *pProgressBar);
void stopAnimation();
void updateTabTextColor();
signals:
void clicked(int index);
// QObject interface
Expand Down
6 changes: 5 additions & 1 deletion OMEdit/OMEditLIB/Modeling/MessagesWidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -621,7 +621,11 @@ void MessagesWidget::addGUIMessage(MessageItem messageItem)
break;
}
mpMessagesTabWidget->setCurrentWidget(mpAllMessageWidget);
emit messageAdded();
if (!OptionsDialog::instance()->getMessagesPage()->getEnlargeMessageBrowserCheckBox()->isChecked()) {
emit messageAdded();
} else {
MainWindow::instance()->animateMessagesTabWidgetForNewMessage(messageItem.getErrorType());
}
}

/*!
Expand Down
1 change: 0 additions & 1 deletion OMEdit/OMEditLIB/Modeling/MessagesWidget.h
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,6 @@ class MessagesWidget : public QWidget
MessageWidget *mpNotificationMessageWidget;
MessageWidget *mpWarningMessageWidget;
MessageWidget *mpErrorMessageWidget;
QVector<QWidget*> mSimulationWidgetsVector;

QStringList mSuppressMessagesList;
QQueue<MessageItem> mPendingMessagesQueue;
Expand Down
1 change: 1 addition & 0 deletions OMEdit/OMEditLIB/Options/OptionsDefaults.h
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,7 @@ namespace OptionsDefaults
int outputSize = 0;
bool resetMessagesNumberBeforeSimulation = true;
bool clearMessagesBrowserBeforeSimulation = false;
bool enlargeMessageBrowserCheckBox = false;
QColor notificationColor = Qt::black;
QColor warningColor = QColor(255, 170, 0);
QColor errorColor = Qt::red;
Expand Down
16 changes: 16 additions & 0 deletions OMEdit/OMEditLIB/Options/OptionsDialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1019,6 +1019,12 @@ void OptionsDialog::readMessagesSettings()
} else {
mpMessagesPage->getClearMessagesBrowserBeforeSimulationCheckBox()->setChecked(OptionsDefaults::Messages::clearMessagesBrowserBeforeSimulation);
}
// read enlarge message browser
if (mpSettings->contains("messages/enlargeMessagesBrowser")) {
mpMessagesPage->getEnlargeMessageBrowserCheckBox()->setChecked(mpSettings->value("messages/enlargeMessagesBrowser").toBool());
} else {
mpMessagesPage->getEnlargeMessageBrowserCheckBox()->setChecked(OptionsDefaults::Messages::enlargeMessageBrowserCheckBox);
}
// read font family
QTextBrowser textBrowser;
if (mpSettings->contains("messages/fontFamily")) {
Expand Down Expand Up @@ -2565,6 +2571,13 @@ void OptionsDialog::saveMessagesSettings()
} else {
mpSettings->setValue("messages/clearMessagesBrowser", clearMessagesBrowserBeforeSimulation);
}
// save enlarge message browser
bool enlargeMessagesBrowserBeforeSimulation = mpMessagesPage->getEnlargeMessageBrowserCheckBox()->isChecked();
if (enlargeMessagesBrowserBeforeSimulation == OptionsDefaults::Messages::enlargeMessageBrowserCheckBox) {
mpSettings->remove("messages/enlargeMessagesBrowser");
} else {
mpSettings->setValue("messages/enlargeMessagesBrowser", enlargeMessagesBrowserBeforeSimulation);
}
// save font
QTextBrowser textBrowser;
QString fontFamily = mpMessagesPage->getFontFamilyComboBox()->currentFont().family();
Expand Down Expand Up @@ -5738,13 +5751,16 @@ MessagesPage::MessagesPage(OptionsDialog *pOptionsDialog)
mpResetMessagesNumberBeforeSimulationCheckBox->setChecked(OptionsDefaults::Messages::resetMessagesNumberBeforeSimulation);
// clear message browser before simulation
mpClearMessagesBrowserBeforeSimulationCheckBox = new QCheckBox(tr("Clear message browser before checking, instantiation, and simulation"));
// enlarge message browser on a new message
mpEnlargeMessageBrowserCheckBox = new QCheckBox(tr("Do not automatically enlarge message browser when a new message is available"));
// set general groupbox layout
QGridLayout *pGeneralGroupBoxLayout = new QGridLayout;
pGeneralGroupBoxLayout->setColumnStretch(1, 1);
pGeneralGroupBoxLayout->addWidget(mpOutputSizeLabel, 0, 0);
pGeneralGroupBoxLayout->addWidget(mpOutputSizeSpinBox, 0, 1);
pGeneralGroupBoxLayout->addWidget(mpResetMessagesNumberBeforeSimulationCheckBox, 1, 0, 1, 2);
pGeneralGroupBoxLayout->addWidget(mpClearMessagesBrowserBeforeSimulationCheckBox, 2, 0, 1, 2);
pGeneralGroupBoxLayout->addWidget(mpEnlargeMessageBrowserCheckBox, 3, 0, 1, 2);
mpGeneralGroupBox->setLayout(pGeneralGroupBoxLayout);
// Font and Colors
mpFontColorsGroupBox = new QGroupBox(Helper::Colors);
Expand Down
2 changes: 2 additions & 0 deletions OMEdit/OMEditLIB/Options/OptionsDialog.h
Original file line number Diff line number Diff line change
Expand Up @@ -717,6 +717,7 @@ class MessagesPage : public QWidget
QSpinBox* getOutputSizeSpinBox() {return mpOutputSizeSpinBox;}
QCheckBox* getResetMessagesNumberBeforeSimulationCheckBox() {return mpResetMessagesNumberBeforeSimulationCheckBox;}
QCheckBox* getClearMessagesBrowserBeforeSimulationCheckBox() {return mpClearMessagesBrowserBeforeSimulationCheckBox;}
QCheckBox* getEnlargeMessageBrowserCheckBox() {return mpEnlargeMessageBrowserCheckBox;}
QFontComboBox* getFontFamilyComboBox() {return mpFontFamilyComboBox;}
DoubleSpinBox* getFontSizeSpinBox() {return mpFontSizeSpinBox;}
void setNotificationColor(QColor color) {mNotificaitonColor = color;}
Expand All @@ -736,6 +737,7 @@ class MessagesPage : public QWidget
QSpinBox *mpOutputSizeSpinBox;
QCheckBox *mpResetMessagesNumberBeforeSimulationCheckBox;
QCheckBox *mpClearMessagesBrowserBeforeSimulationCheckBox;
QCheckBox *mpEnlargeMessageBrowserCheckBox;
QGroupBox *mpFontColorsGroupBox;
Label *mpFontFamilyLabel;
QFontComboBox *mpFontFamilyComboBox;
Expand Down
7 changes: 5 additions & 2 deletions doc/UsersGuide/source/omedit.rst
Original file line number Diff line number Diff line change
Expand Up @@ -1737,15 +1737,18 @@ Messages Options

- General

- *Output Size* - Specifies the maximum number of rows the Messages
- *Output Size* - Specifies the maximum number of rows the Message
Browser may have. If there are more rows then the rows are removed
from the beginning.

- *Reset messages number before simulation* - Resets the messages
counter before starting the simulation.

- *Clear messages browser before checking, instantiation & simulation* - If enabled then the
messages browser is cleared before checking, instantiation & simulation of model.
message browser is cleared before checking, instantiation & simulation of model.

- *Do not automatically enlarge message browser when a new message is available* - If enabled then the
message browser will not be enlarged instead the tabbar shown will start blinking indicating that a new message is available.

- Font and Colors

Expand Down

0 comments on commit e971726

Please sign in to comment.