ui: Fixed zoom issues
* Show font size change as number not percent * Show current graph zoom in label next to zoom buttons * Fixed search blocks not properly updated when fonts size changes
This commit is contained in:
@@ -166,7 +166,9 @@ void ActivationController::handleMessage(MessageResetZoom* message)
|
||||
MessageRefresh().refreshUiOnly().dispatch();
|
||||
}
|
||||
|
||||
MessageStatus("Zoom: 100%").dispatch();
|
||||
std::stringstream text;
|
||||
text << "Font size: " << fontSizeStd;
|
||||
MessageStatus(text.str()).dispatch();
|
||||
}
|
||||
|
||||
void ActivationController::handleMessage(MessageZoom* message)
|
||||
@@ -176,7 +178,6 @@ void ActivationController::handleMessage(MessageZoom* message)
|
||||
ApplicationSettings* settings = ApplicationSettings::getInstance().get();
|
||||
|
||||
int fontSize = settings->getFontSize();
|
||||
int standardSize = settings->getFontSizeStd();
|
||||
int maxSize = settings->getFontSizeMax();
|
||||
int minSize = settings->getFontSizeMin();
|
||||
|
||||
@@ -189,11 +190,8 @@ void ActivationController::handleMessage(MessageZoom* message)
|
||||
settings->setFontSize(fontSize + (message->zoomIn ? 1 : -1));
|
||||
settings->save();
|
||||
|
||||
fontSize = settings->getFontSize();
|
||||
int zoom = (fontSize * 100) / standardSize;
|
||||
|
||||
std::stringstream text;
|
||||
text << "Zoom: " << zoom << "%";
|
||||
text << "Font size: " << settings->getFontSize();
|
||||
MessageStatus(text.str()).dispatch();
|
||||
|
||||
MessageRefresh().refreshUiOnly().dispatch();
|
||||
|
||||
@@ -49,6 +49,11 @@ void StatusBarController::handleMessage(MessagePingReceived* message)
|
||||
|
||||
void StatusBarController::handleMessage(MessageRefresh* message)
|
||||
{
|
||||
if (message->uiOnly)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
getView()->setErrorCount(m_storageAccess->getErrorCount());
|
||||
}
|
||||
|
||||
|
||||
@@ -110,6 +110,8 @@ void QtSearchBar::refreshStyle()
|
||||
ResourcePaths::getGuiPath().str() + "search_view/images/home.png",
|
||||
"search/button"
|
||||
));
|
||||
|
||||
m_searchBox->refreshStyle();
|
||||
}
|
||||
|
||||
void QtSearchBar::homeButtonClicked()
|
||||
|
||||
@@ -172,6 +172,11 @@ void QtSmartSearchBox::findFulltext()
|
||||
setEditText(QChar(SearchMatch::FULLTEXT_SEARCH_CHARACTER));
|
||||
}
|
||||
|
||||
void QtSmartSearchBox::refreshStyle()
|
||||
{
|
||||
updateElements();
|
||||
}
|
||||
|
||||
bool QtSmartSearchBox::event(QEvent *event)
|
||||
{
|
||||
if (event->type() == QEvent::KeyPress)
|
||||
|
||||
@@ -46,6 +46,8 @@ public:
|
||||
void setFocus();
|
||||
void findFulltext();
|
||||
|
||||
void refreshStyle();
|
||||
|
||||
protected:
|
||||
virtual bool event(QEvent *event);
|
||||
virtual void resizeEvent(QResizeEvent* event);
|
||||
|
||||
@@ -43,6 +43,9 @@ QtGraphicsView::QtGraphicsView(QWidget* parent)
|
||||
m_timerStopper->setSingleShot(true);
|
||||
connect(m_timerStopper.get(), SIGNAL(timeout()), this, SLOT(stopTimer()));
|
||||
|
||||
m_zoomLabelTimer = std::make_shared<QTimer>(this);
|
||||
connect(m_zoomLabelTimer.get(), SIGNAL(timeout()), this, SLOT(hideZoomLabel()));
|
||||
|
||||
m_exportGraphAction = new QAction(tr("Save as Image"), this);
|
||||
m_exportGraphAction->setStatusTip(tr("Save this graph as image file"));
|
||||
m_exportGraphAction->setToolTip(tr("Save this graph as image file"));
|
||||
@@ -58,6 +61,10 @@ QtGraphicsView::QtGraphicsView(QWidget* parent)
|
||||
m_bookmarkNodeAction->setToolTip(tr("Create a bookmark for this node"));
|
||||
connect(m_bookmarkNodeAction, SIGNAL(triggered()), this, SLOT(bookmarkNode()));
|
||||
|
||||
m_zoomState = new QPushButton(this);
|
||||
m_zoomState->setObjectName("zoom_state");
|
||||
m_zoomState->hide();
|
||||
|
||||
m_zoomInButton = new QPushButton(this);
|
||||
m_zoomInButton->setObjectName("zoom_in_button");
|
||||
m_zoomInButton->setAutoRepeat(true);
|
||||
@@ -143,9 +150,7 @@ void QtGraphicsView::updateZoom(float delta)
|
||||
}
|
||||
|
||||
double newZoom = m_zoomFactor * factor;
|
||||
m_zoomFactor = qBound(0.1, newZoom, 100.0);
|
||||
|
||||
updateTransform();
|
||||
setZoomFactor(qBound(0.1, newZoom, 100.0));
|
||||
}
|
||||
|
||||
void QtGraphicsView::refreshStyle()
|
||||
@@ -163,6 +168,7 @@ void QtGraphicsView::refreshStyle()
|
||||
|
||||
void QtGraphicsView::resizeEvent(QResizeEvent* event)
|
||||
{
|
||||
m_zoomState->setGeometry(QRect(31, event->size().height() - 27, 65, 19));
|
||||
m_zoomInButton->setGeometry(QRect(8, event->size().height() - 50, 19, 19));
|
||||
m_zoomOutButton->setGeometry(QRect(8, event->size().height() - 27, 19, 19));
|
||||
|
||||
@@ -218,7 +224,7 @@ void QtGraphicsView::keyPressEvent(QKeyEvent* event)
|
||||
m_right = true;
|
||||
break;
|
||||
case Qt::Key_0:
|
||||
m_zoomFactor = 1.0f;
|
||||
setZoomFactor(1.0f);
|
||||
updateTransform();
|
||||
break;
|
||||
case Qt::Key_Shift:
|
||||
@@ -489,11 +495,28 @@ void QtGraphicsView::zoomOutPressed()
|
||||
updateZoom(m_zoomOutButtonSpeed);
|
||||
}
|
||||
|
||||
void QtGraphicsView::hideZoomLabel()
|
||||
{
|
||||
m_zoomState->hide();
|
||||
}
|
||||
|
||||
bool QtGraphicsView::moves() const
|
||||
{
|
||||
return m_up || m_down || m_left || m_right;
|
||||
}
|
||||
|
||||
void QtGraphicsView::setZoomFactor(float zoomFactor)
|
||||
{
|
||||
m_zoomFactor = zoomFactor;
|
||||
|
||||
m_zoomState->setText(QString::number(int(m_zoomFactor * 100)) + "%");
|
||||
updateTransform();
|
||||
|
||||
m_zoomState->show();
|
||||
m_zoomLabelTimer->stop();
|
||||
m_zoomLabelTimer->start(1000);
|
||||
}
|
||||
|
||||
void QtGraphicsView::updateTransform()
|
||||
{
|
||||
float zoomFactor = m_appZoomFactor * m_zoomFactor;
|
||||
|
||||
@@ -59,9 +59,12 @@ private slots:
|
||||
void zoomInPressed();
|
||||
void zoomOutPressed();
|
||||
|
||||
void hideZoomLabel();
|
||||
|
||||
private:
|
||||
bool moves() const;
|
||||
|
||||
void setZoomFactor(float zoomFactor);
|
||||
void updateTransform();
|
||||
|
||||
QPoint m_last;
|
||||
@@ -80,11 +83,13 @@ private:
|
||||
|
||||
std::shared_ptr<QTimer> m_timer;
|
||||
std::shared_ptr<QTimer> m_timerStopper;
|
||||
std::shared_ptr<QTimer> m_zoomLabelTimer;
|
||||
|
||||
QAction* m_exportGraphAction;
|
||||
QAction* m_copyNodeNameAction;
|
||||
QAction* m_bookmarkNodeAction;
|
||||
|
||||
QPushButton* m_zoomState;
|
||||
QPushButton* m_zoomInButton;
|
||||
QPushButton* m_zoomOutButton;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user