Bug 69070 - Autohide "pin" button should show the button state as pressed when the autohide is off
Summary: Autohide "pin" button should show the button state as pressed when the autohi...
Status: RESOLVED FIXED
Alias: None
Product: krdc
Classification: Applications
Component: general (show other bugs)
Version: unspecified
Platform: unspecified Linux
: NOR minor
Target Milestone: ---
Assignee: Urs Wolfer
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2003-11-26 14:07 UTC by Stino V.
Modified: 2007-08-03 21:53 UTC (History)
0 users

See Also:
Latest Commit:
Version Fixed In:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Stino V. 2003-11-26 14:07:04 UTC
Version:            (using KDE KDE 3.1.93)
OS:          Linux

Now the behavior is inverted, which is visually very confusing.
Comment 1 tim 2003-11-26 21:15:35 UTC
The option is called 'autohide'. Thus when the button is pressed the option is activated and the panel hides automatically. When it is not pressed it is deactivated. 

It would be different if the option would be called 'sticky', but I avoided that term because it is less self-explanatory and quite confusing for most people. The icon is not optimal for the name 'autohide', but on the other hand I couldn't imagine a better one and it is relatively well-known.
Comment 2 Stino V. 2003-11-27 09:40:02 UTC
I know this is just a minor issue - I am sure you have other things to worry about ;).
I checked Microsoft's implementation (just as a comparison), they have the same behavior as I suggested, but they do not have a name for the pin (so no 'autohide' or 'sticky' tooltip).
Even though I understand you reasoning, it just seems very illogical to have the pin "in" the screen, while the button is unpressed - and visa-versa. Maybe you can call it 'Always on top' or 'Always visible' or even remove the name - everybody knows or probably quickly figures out the meaning of the pin.
If you don't agree, just close the report again, and I will never bother you again with this ;)
Comment 3 Brad Hards 2006-08-13 13:07:11 UTC
I see this as a useability bug.

Planned to be fixed before KDE4 beta 1.
Comment 4 Urs Wolfer 2007-08-03 21:53:25 UTC
SVN commit 696092 by uwolfer:

* Toolbar has autohide / sticky feature back.
* Fix bug: changing config could lead in a removed start page.
* Forward port form okular floating toolbar: Port form KImageEffect to QLinearGradient. Thanks Pino!

BUGS: 69070, 108853

 M  +101 -11   floatingtoolbar.cpp  
 M  +4 -0      floatingtoolbar.h  
 M  +9 -1      mainwindow.cpp  


--- trunk/KDE/kdenetwork/krdc/floatingtoolbar.cpp #696091:696092
@@ -25,7 +25,7 @@
 
 #include "floatingtoolbar.h"
 
-#include <KImageEffect>
+#include <KDebug>
 
 #include <QApplication>
 #include <QBitmap>
@@ -43,6 +43,9 @@
 static const int buttonSize = 28;
 static const int toolBarGridSize = 28;
 static const int toolBarRBMargin = 2;
+static const qreal toolBarOpacity = 0.8;
+static const int visiblePixelWhenAutoHidden = 3;
+static const int autoHideTimeout = 2000;
 
 class FloatingToolBarPrivate
 {
@@ -65,10 +68,13 @@
     FloatingToolBar::Side anchorSide;
 
     QTimer *animTimer;
+    QTimer *autoHideTimer;
     QPoint currentPosition;
     QPoint endPosition;
     bool hiding;
+    bool toDelete;
     bool visible;
+    bool sticky;
     qreal opacity;
 
     QPixmap backgroundPixmap;
@@ -83,12 +89,18 @@
     d->anchorWidget = anchorWidget;
     d->anchorSide = Left;
     d->hiding = false;
+    d->toDelete = false;
     d->visible = false;
-    d->opacity = 0.8;
+    d->sticky = false;
+    d->opacity = toolBarOpacity;
 
     d->animTimer = new QTimer(this);
     connect(d->animTimer, SIGNAL(timeout()), this, SLOT(slotAnimate()));
 
+    d->autoHideTimer = new QTimer(this);
+    connect(d->autoHideTimer, SIGNAL(timeout()), this, SLOT(hide()));
+    d->autoHideTimer->start(autoHideTimeout);
+
     // apply a filter to get notified when anchor changes geometry
     d->anchorWidget->installEventFilter(this);
 }
@@ -109,6 +121,9 @@
 
     d->buttons.append(button);
 
+    button->setMouseTracking(true);
+    button->installEventFilter(this);
+
     // rebuild toolbar shape and contents
     d->reposition();
 }
@@ -120,9 +135,21 @@
     d->reposition();
 }
 
+void FloatingToolBar::setSticky(bool sticky)
+{
+    kDebug(5010) << "showAndAnimate: " << sticky;
+    d->sticky = sticky;
+
+    if (sticky)
+        d->autoHideTimer->stop();
+    else
+        d->autoHideTimer->start(autoHideTimeout);
+}
+
 void FloatingToolBar::showAndAnimate()
 {
-    // set parameters for sliding in
+    kDebug(5010) << "showAndAnimate";
+
     d->hiding = false;
 
     show();
@@ -135,23 +162,57 @@
 {
     // set parameters for sliding out
     d->hiding = true;
+    d->toDelete = true;
     d->endPosition = d->getOuterPoint();
 
     // start scrolling out
     d->animTimer->start(20);
 }
 
+void FloatingToolBar::hide()
+{
+    kDebug(5010) << "hide";
+    // set parameters for sliding out
+
+    if (d->visible) {
+        QPoint diff;
+        switch (d->anchorSide) {
+        case Left:
+            diff = QPoint(visiblePixelWhenAutoHidden, 0);
+            break;
+        case Right:
+            diff = QPoint(-visiblePixelWhenAutoHidden, 0);
+            break;
+        case Top:
+            diff = QPoint(0, visiblePixelWhenAutoHidden);
+            break;
+        case Bottom:
+            diff = QPoint(0, -visiblePixelWhenAutoHidden);
+            break;
+        }
+        d->hiding = true;
+        d->endPosition = d->getOuterPoint() + diff;
+    }
+
+    // start scrolling out
+    d->animTimer->start(20);
+}
+
 bool FloatingToolBar::eventFilter(QObject *obj, QEvent *e)
 {
     // if anchorWidget changed geometry reposition toolbar
     if (obj == d->anchorWidget && e->type() == QEvent::Resize) {
         d->animTimer->stop();
-        if (d->hiding)
+        if (d->hiding && d->toDelete)
             deleteLater();
         else
             d->reposition();
     }
 
+    // keep toolbar visible when mouse is on it
+    if (e->type() == QEvent::MouseMove && d->autoHideTimer->isActive())
+        d->autoHideTimer->start(autoHideTimeout);
+
     return false;
 }
 
@@ -171,6 +232,22 @@
 
 void FloatingToolBar::mouseMoveEvent(QMouseEvent *e)
 {
+    // keep toolbar visible when mouse is on it
+    if (d->autoHideTimer->isActive())
+        d->autoHideTimer->start(autoHideTimeout);
+
+    // show the toolbar again when it is auto-hidden
+    if (!d->visible && !d->animTimer->isActive()) {
+        d->hiding = false;
+        show();
+        d->endPosition = QPoint();
+        d->reposition();
+
+        d->animTimer->start(20);
+
+        return;
+    }
+
     if ((QApplication::mouseButtons() & Qt::LeftButton) != Qt::LeftButton)
         return;
 
@@ -277,12 +354,24 @@
     QPainter bufferPainter(&backgroundPixmap);
     QPalette pal = q->palette();
     // 5.1. draw horizontal/vertical gradient
-    QColor fromColor = topLeft ? pal.color(QPalette::Active, QPalette::Button) : pal.color(QPalette::Active, QPalette::Light);
-    QColor toColor = topLeft ? pal.color(QPalette::Active, QPalette::Light) : pal.color(QPalette::Active, QPalette::Button);
-    QImage gradientPattern = KImageEffect::gradient(
-            vertical ? QSize(myWidth + 1, 1) : QSize(1, myHeight + 1), fromColor, toColor,
-            vertical ? KImageEffect::HorizontalGradient : KImageEffect::VerticalGradient);
-    bufferPainter.drawTiledPixmap(0, 0, myWidth + 1, myHeight + 1, QPixmap::fromImage(gradientPattern));
+    QLinearGradient grad;
+    switch (anchorSide) {
+    case FloatingToolBar::Left:
+        grad = QLinearGradient(0, 1, myWidth + 1, 1);
+        break;
+    case FloatingToolBar::Right:
+        grad = QLinearGradient(myWidth + 1, 1, 0, 1);
+        break;
+    case FloatingToolBar::Top:
+        grad = QLinearGradient(1, 0, 1, myHeight + 1);
+        break;
+    case FloatingToolBar::Bottom:
+        grad = QLinearGradient(1, myHeight + 1, 0, 1);
+        break;
+    }
+    grad.setColorAt(0, pal.color(QPalette::Active, QPalette::Button));
+    grad.setColorAt(1, pal.color(QPalette::Active, QPalette::Light));
+    bufferPainter.fillRect(0, 0, myWidth + 1, myHeight + 1, grad);
     // 5.2. draw rounded border
     bufferPainter.setPen(pal.color(QPalette::Active, QPalette::Dark));
     bufferPainter.setRenderHints(QPainter::Antialiasing);
@@ -389,7 +478,8 @@
         d->animTimer->stop();
         if (d->hiding) {
             d->visible = false;
-            deleteLater();
+            if (d->toDelete)
+                deleteLater();
         }
         else
             d->visible = true;
--- trunk/KDE/kdenetwork/krdc/floatingtoolbar.h #696091:696092
@@ -54,6 +54,9 @@
 signals:
     void orientationChanged(int side);
 
+public slots:
+    void setSticky(bool sticky);
+
 protected:
     bool eventFilter(QObject *o, QEvent *e);
     void paintEvent(QPaintEvent *);
@@ -67,6 +70,7 @@
 
 private slots:
     void slotAnimate();
+    void hide();
 };
 
 #endif
--- trunk/KDE/kdenetwork/krdc/mainwindow.cpp #696091:696092
@@ -452,6 +452,14 @@
         m_toolBar->addAction(actionCollection()->action("view_only"));
         m_toolBar->addAction(actionCollection()->action("show_local_cursor"));
         m_toolBar->addAction(actionCollection()->action("logout"));
+
+        QAction *stickToolBarAction = new QAction(m_toolBar);
+        stickToolBarAction->setCheckable(true);
+        stickToolBarAction->setIcon(KIcon("note2"));
+        stickToolBarAction->setText(i18n("S&tick Toolbar"));
+        connect(stickToolBarAction, SIGNAL(triggered(bool)), m_toolBar, SLOT(setSticky(bool)));
+
+        m_toolBar->addAction(stickToolBarAction);
     }
 
     m_toolBar->showAndAnimate();
@@ -516,7 +524,7 @@
 
     if (Settings::showStartPage() && !m_showStartPage)
         createStartPage();
-    else if (m_showStartPage) {
+    else if (!Settings::showStartPage() && m_showStartPage) {
         m_tabWidget->removeTab(0);
         m_showStartPage = false;
     }