| Summary: | Autohide window does not come back once it's hidden | ||
|---|---|---|---|
| Product: | [Applications] krdc | Reporter: | Tom <darkvater> |
| Component: | general | Assignee: | Urs Wolfer <uwolfer> |
| Status: | RESOLVED FIXED | ||
| Severity: | normal | CC: | burdi, karaluh, me |
| Priority: | NOR | ||
| Version First Reported In: | unspecified | ||
| Target Milestone: | --- | ||
| Platform: | openSUSE | ||
| OS: | Linux | ||
| Latest Commit: | Version Fixed/Implemented In: | ||
| Sentry Crash Report: | |||
|
Description
Tom
2005-07-10 15:38:24 UTC
You can work around this bug for the time being. When you open a session, use a custom resolution. Make sure the Height property is 2 pixels lower than the actual pixel height of your screen. You don't have to decrease the Width property. *** Bug 123935 has been marked as a duplicate of this bug. *** 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;
}
|