Gui: Only measure with Quick Measure if showing in status bar

This commit is contained in:
Benjamin Nauck
2025-09-02 23:15:57 +02:00
parent 1b38c6bb00
commit 2e850f0611
3 changed files with 21 additions and 10 deletions

View File

@@ -2315,6 +2315,11 @@ void MainWindow::setRightSideMessage(const QString& message)
d->rightSideLabel->setText(message.simplified());
}
bool MainWindow::isRightSideMessageVisible() const
{
return d->rightSideLabel->isVisible();
}
void MainWindow::showStatus(int type, const QString& message)
{
if(QApplication::instance()->thread() != QThread::currentThread()) {

View File

@@ -266,6 +266,7 @@ public Q_SLOTS:
void showMessage (const QString & message, int timeout = 0);
void setRightSideMessage(const QString & message);
bool isRightSideMessageVisible() const;
// Set main window title
void setWindowTitle(const QString& string);

View File

@@ -114,18 +114,23 @@ void QuickMeasure::tryMeasureSelection()
bool QuickMeasure::shouldMeasure(const Gui::SelectionChanges& msg) const
{
if (!Gui::getMainWindow()->isRightSideMessageVisible()) {
// don't measure if there's no where to show the result
return false;
}
// measure only IF
Gui::Document* doc = Gui::Application::Instance->activeDocument();
if (doc) {
// we have a document
if (msg.Type == Gui::SelectionChanges::AddSelection
|| msg.Type == Gui::SelectionChanges::RmvSelection
|| msg.Type == Gui::SelectionChanges::SetSelection
|| msg.Type == Gui::SelectionChanges::ClrSelection) {
// the event is about a change in selected objects
return true;
}
if (!doc) {
// no active document
return false;
}
if (msg.Type == Gui::SelectionChanges::AddSelection
|| msg.Type == Gui::SelectionChanges::RmvSelection
|| msg.Type == Gui::SelectionChanges::SetSelection
|| msg.Type == Gui::SelectionChanges::ClrSelection) {
// the event is about a change in selected objects
return true;
}
return false;
}