Commit 3f392080 authored by Malte Jürgens's avatar Malte Jürgens Committed by Albert Astals Cid
Browse files

Improve the Isotope Table

- Zoom to mouse instead of to the center
- Make the zoom slider logarithmic
- Use the actual zoom scroll delta value (Previously zooming broke on a laptop touchpad without that)
- Make the rectangle in the top right preview more visible
- Show Isotope dialog on double click

BUGS: 415736
parent 5040d9a2
Pipeline #145226 passed with stage
in 53 seconds
......@@ -50,13 +50,13 @@
</sizepolicy>
</property>
<property name="minimum">
<number>1</number>
<number>-12</number>
</property>
<property name="maximum">
<number>20</number>
<number>23</number>
</property>
<property name="value">
<number>1</number>
<number>10</number>
</property>
<property name="orientation">
<enum>Qt::Horizontal</enum>
......
......@@ -40,8 +40,10 @@ void IsotopeGuideView::setVisibleSceneRect(const QPolygonF& sceneRect)
void IsotopeGuideView::drawForeground(QPainter *painter, const QRectF &rect)
{
if (m_guidedView && m_visibleSceneRect.boundingRect().intersects(rect)) {
painter->setPen(QPen(Qt::red));
painter->drawRect(m_visibleSceneRect.boundingRect().adjusted(0, 0, -1, -1));
QRectF drawRect = m_visibleSceneRect.boundingRect().adjusted(0, 0, -1, -1);
painter->setPen(QPen(Qt::yellow, 10.0));
painter->fillRect(drawRect, QBrush(QColor(0, 0 , 0 , 100)));
painter->drawRect(drawRect);
}
}
......
......@@ -134,3 +134,14 @@ void IsotopeItem::mousePressEvent(QGraphicsSceneMouseEvent *event)
IsotopeScene *scene2 = static_cast<IsotopeScene*>(scene());
scene2->updateContextHelp(this);
}
void IsotopeItem::mouseDoubleClickEvent(QGraphicsSceneMouseEvent *event)
{
if (event->button() != Qt::LeftButton) {
event->ignore();
return;
}
IsotopeScene *scene2 = static_cast<IsotopeScene*>(scene());
scene2->updateContextHelp(this);
}
......@@ -66,6 +66,7 @@ private:
protected:
void mousePressEvent(QGraphicsSceneMouseEvent *event) override;
void mouseDoubleClickEvent(QGraphicsSceneMouseEvent *event) override;
};
#endif // ISOTOPEITEM_H
......@@ -17,6 +17,7 @@
#include <QDialogButtonBox>
#include <QPushButton>
#include <QVBoxLayout>
#include <QtMath>
#include <KConfigGroup>
......@@ -63,7 +64,7 @@ IsotopeTableDialog::IsotopeTableDialog(QWidget* parent) : QDialog(parent)
void IsotopeTableDialog::zoom (int level)
{
double zoom = level / 2.0;
double zoom = qPow(M_E, level / 10.0);
(ui.gv)->setZoom(zoom);
}
......@@ -98,7 +99,7 @@ void IsotopeTableDialog::updateDockWidget(IsotopeItem * item)
void IsotopeTableDialog::slotZoomLevelChanged(double value)
{
const bool b = ui.Slider->blockSignals(true);
ui.Slider->setValue(qreal(value * 2));
ui.Slider->setValue(qLn(value) * 10.0);
ui.Slider->blockSignals(b);
}
......@@ -14,7 +14,12 @@ IsotopeView::IsotopeView(QWidget *parent) : QGraphicsView(parent)
m_zoomLevel = 1.0;
setScene(m_scene);
setSceneRect(m_scene->itemsBoundingRect());
ensureVisible(m_scene->sceneRect());
// Center the bottom left at the beginning
// centerOn(0, sceneRect().height());
// Zoom in a bit
// setZoom(3);
// Makes sure that you always zoom to the mouse if you use the scroll wheel
setTransformationAnchor(QGraphicsView::AnchorUnderMouse);
}
IsotopeView::~IsotopeView()
......@@ -41,18 +46,11 @@ void IsotopeView::mouseMoveEvent(QMouseEvent *event)
void IsotopeView::wheelEvent(QWheelEvent *event)
{
double oldZoomLevel = m_zoomLevel;
double factor;
if (event->angleDelta().y() > 0) {
factor = event->angleDelta().y() / 100.0;
m_zoomLevel *= factor;
} else {
factor = 1.0 / (-event->angleDelta().y() / 100.0);
m_zoomLevel *= factor;
}
double factor = event->angleDelta().y() / 1000.0;
m_zoomLevel = oldZoomLevel + oldZoomLevel * factor;
if (m_zoomLevel < 0.5) {
m_zoomLevel = 0.5;
if (m_zoomLevel < 0.3) {
m_zoomLevel = 0.3;
} else if (m_zoomLevel > 10.0) {
m_zoomLevel = 10.0;
}
......@@ -75,8 +73,8 @@ void IsotopeView::setZoom(double zoom)
m_zoomLevel = zoom;
if (m_zoomLevel < 0.5) {
m_zoomLevel = 0.5;
if (m_zoomLevel < 0.3) {
m_zoomLevel = 0.3;
} else if (m_zoomLevel > 10.0) {
m_zoomLevel = 10.0;
}
......@@ -87,4 +85,3 @@ void IsotopeView::setZoom(double zoom)
QPolygonF visibleSceneRect = mapToScene(viewport()->rect());
Q_EMIT visibleSceneRectChanged(visibleSceneRect);
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment