Index: kicker/taskbar/taskcontainer.cpp =================================================================== --- kicker/taskbar/taskcontainer.cpp (revision 850417) +++ kicker/taskbar/taskcontainer.cpp (working copy) @@ -202,6 +202,8 @@ } return; } + + KickerTip::Client::updateKickerTip(); QToolButton::update(); } @@ -1524,89 +1526,93 @@ } QPixmap pixmap; - if (TaskBarSettings::showThumbnails() && - m_filteredTasks.count() == 1) + QString name; + QString details; + + if (m_filteredTasks.count() > 0) { - Task::Ptr t = m_filteredTasks.first(); - - pixmap = t->thumbnail(TaskBarSettings::thumbnailMaxDimension()); - } - - if (pixmap.isNull() && tasks.last()) - { - // try to load icon via net_wm - pixmap = KWin::icon(tasks.last()->window(), - KIcon::SizeMedium, - KIcon::SizeMedium, - true); - } - - // Collect all desktops the tasks are on. Sort naturally. - QMap desktopMap; - bool demandsAttention = false; - bool modified = false; - bool allDesktops = false; - Task::List::const_iterator itEnd = m_filteredTasks.constEnd(); - for (Task::List::const_iterator it = m_filteredTasks.constBegin(); it != itEnd; ++it) - { - Task::Ptr t = *it; - if (t->demandsAttention()) + if (TaskBarSettings::showThumbnails() && + m_filteredTasks.count() == 1) { - demandsAttention = true; + Task::Ptr t = m_filteredTasks.first(); + + pixmap = t->thumbnail(TaskBarSettings::thumbnailMaxDimension()); } - - if (t->isModified()) + + if (pixmap.isNull() && tasks.count()) { - modified = true; + // try to load icon via net_wm + pixmap = KWin::icon(tasks.last()->window(), + KIcon::SizeMedium, + KIcon::SizeMedium, + true); } - - if (t->isOnAllDesktops()) + + // Collect all desktops the tasks are on. Sort naturally. + QMap desktopMap; + bool demandsAttention = false; + bool modified = false; + bool allDesktops = false; + Task::List::const_iterator itEnd = m_filteredTasks.constEnd(); + for (Task::List::const_iterator it = m_filteredTasks.constBegin(); it != itEnd; ++it) { - allDesktops = true; - desktopMap.clear(); + Task::Ptr t = *it; + if (t->demandsAttention()) + { + demandsAttention = true; + } + + if (t->isModified()) + { + modified = true; + } + + if (t->isOnAllDesktops()) + { + allDesktops = true; + desktopMap.clear(); + } + else if (!allDesktops) + { + desktopMap.insert(t->desktop(), + TaskManager::the()->desktopName(t->desktop())); + } } - else if (!allDesktops) + + if (TaskBarSettings::showAllWindows() && KWin::numberOfDesktops() > 1) { - desktopMap.insert(t->desktop(), - TaskManager::the()->desktopName(t->desktop())); + if (desktopMap.isEmpty()) + { + details.append(i18n("On all desktops")); + } + else + { + QStringList desktopNames = desktopMap.values(); + details.append(i18n("On %1").arg(QStyleSheet::escape(desktopNames.join(", "))) + "
"); + } } - } - - QString details; - - if (TaskBarSettings::showAllWindows() && KWin::numberOfDesktops() > 1) - { - if (desktopMap.isEmpty()) + + if (demandsAttention) { - details.append(i18n("On all desktops")); + details.append(i18n("Requesting attention") + "
"); } - else + + name = this->name(); + if (modified) { - QStringList desktopNames = desktopMap.values(); - details.append(i18n("On %1").arg(QStyleSheet::escape(desktopNames.join(", "))) + "
"); + details.append(i18n("Has unsaved changes")); + + static QString modStr = "[" + i18n( "modified" ) + "]"; + int modStrPos = name.find(modStr); + + if (modStrPos >= 0) + { + // +1 because we include a space after the closing brace. + name.remove(modStrPos, modStr.length() + 1); + } } } - if (demandsAttention) - { - details.append(i18n("Requesting attention") + "
"); - } - - QString name = this->name(); - if (modified) - { - details.append(i18n("Has unsaved changes")); - - static QString modStr = "[" + i18n( "modified" ) + "]"; - int modStrPos = name.find(modStr); - - if (modStrPos >= 0) - { - // +1 because we include a space after the closing brace. - name.remove(modStrPos, modStr.length() + 1); - } - } - data.message = QStyleSheet::escape(name); data.subtext = details; data.icon = pixmap; Index: kicker/taskbar/taskbar.cpp =================================================================== --- kicker/taskbar/taskbar.cpp (revision 850417) +++ kicker/taskbar/taskbar.cpp (working copy) @@ -61,8 +61,6 @@ m_textShadowEngine(0), m_ignoreUpdates(false) { - setFrameStyle( NoFrame ); - arrowType = LeftArrow; blocklayout = true; @@ -81,6 +79,8 @@ connect(&m_relayoutTimer, SIGNAL(timeout()), this, SLOT(reLayout())); + connect(this, SIGNAL(contentsMoving(int, int)), SLOT(setBackground())); + // connect manager connect(TaskManager::the(), SIGNAL(taskAdded(Task::Ptr)), this, SLOT(add(Task::Ptr))); @@ -647,7 +647,7 @@ if (!blocklayout && !m_ignoreUpdates) { - m_relayoutTimer.start(100, true); + m_relayoutTimer.start(25, true); } } @@ -814,24 +814,16 @@ QTimer::singleShot(100, this, SLOT(publishIconGeometry())); } -void TaskBar::viewportResizeEvent( QResizeEvent* e ) -{ - Panner::viewportResizeEvent(e); - setViewportBackground(); -} - void TaskBar::setViewportBackground() { const QPixmap *bg = parentWidget()->backgroundPixmap(); - viewport()->unsetPalette(); - if (bg) { QPixmap pm(parentWidget()->size()); pm.fill(parentWidget(), pos() + viewport()->pos()); viewport()->setPaletteBackgroundPixmap(pm); - viewport()->setBackgroundOrigin( WidgetOrigin ); + viewport()->setBackgroundOrigin(WidgetOrigin); } else viewport()->setPaletteBackgroundColor(paletteBackgroundColor()); Index: kicker/taskbar/taskbar.h =================================================================== --- kicker/taskbar/taskbar.h (revision 850417) +++ kicker/taskbar/taskbar.h (working copy) @@ -63,12 +63,11 @@ QImage* blendGradient(const QSize& size); - void setBackground(); - KTextShadowEngine *textShadowEngine(); public slots: void configure(); + void setBackground(); signals: void containerCountChanged(); @@ -98,7 +97,6 @@ void viewportMouseReleaseEvent( QMouseEvent* ); void viewportMouseDoubleClickEvent( QMouseEvent* ); void viewportMouseMoveEvent( QMouseEvent* ); - void viewportResizeEvent( QResizeEvent * ); void wheelEvent(QWheelEvent*); void propagateMouseEvent( QMouseEvent* ); void resizeEvent( QResizeEvent* ); Index: kicker/libkicker/panner.cpp =================================================================== --- kicker/libkicker/panner.cpp (revision 850417) +++ kicker/libkicker/panner.cpp (working copy) @@ -35,28 +35,28 @@ #include "panner.h" #include "panner.moc" - Panner::Panner( QWidget* parent, const char* name ) - : QScrollView( parent, name ), + : QWidget( parent, name ), _luSB(0), - _rdSB(0) + _rdSB(0), + _cwidth(0), _cheight(0), + _cx(0), _cy(0) { KGlobal::locale()->insertCatalogue("libkicker"); setBackgroundOrigin( AncestorOrigin ); _updateScrollButtonsTimer = new QTimer(this); connect(_updateScrollButtonsTimer, SIGNAL(timeout()), this, SLOT(reallyUpdateScrollButtons())); + + _clipper = new QWidget(this); + _clipper->setBackgroundOrigin(AncestorOrigin); + _clipper->installEventFilter( this ); + _viewport = new QWidget(_clipper); + _viewport->setBackgroundOrigin(AncestorOrigin); - setResizePolicy(Manual); - setVScrollBarMode( QScrollView::AlwaysOff ); - setHScrollBarMode( QScrollView::AlwaysOff ); - - viewport()->setBackgroundMode( PaletteBackground ); - viewport()->setBackgroundOrigin( AncestorOrigin ); - // layout _layout = new QBoxLayout(this, QBoxLayout::LeftToRight); - _layout->addWidget(viewport(), 1); + _layout->addWidget(_clipper, 1); setOrientation(Horizontal); } @@ -64,6 +64,37 @@ { } +void Panner::createScrollButtons() +{ + if (_luSB) + { + return; + } + + // left/up scroll button + _luSB = new SimpleArrowButton(this); + _luSB->installEventFilter(this); + //_luSB->setAutoRepeat(true); + _luSB->setMinimumSize(12, 12); + _luSB->hide(); + _layout->addWidget(_luSB); + connect(_luSB, SIGNAL(pressed()), SLOT(startScrollLeftUp())); + connect(_luSB, SIGNAL(released()), SLOT(stopScroll())); + + // right/down scroll button + _rdSB = new SimpleArrowButton(this); + _rdSB->installEventFilter(this); + //_rdSB->setAutoRepeat(true); + _rdSB->setMinimumSize(12, 12); + _rdSB->hide(); + _layout->addWidget(_rdSB); + connect(_rdSB, SIGNAL(pressed()), SLOT(startScrollRightDown())); + connect(_rdSB, SIGNAL(released()), SLOT(stopScroll())); + + // set up the buttons + setupButtons(); +} + void Panner::setupButtons() { if (orientation() == Horizontal) @@ -110,55 +141,54 @@ reallyUpdateScrollButtons(); } -void Panner::resizeEvent( QResizeEvent* e ) +void Panner::resizeEvent( QResizeEvent* ) { - QScrollView::resizeEvent( e ); - updateScrollButtons(); + //QScrollView::resizeEvent( e ); + //updateScrollButtons(); } void Panner::scrollRightDown() { if(orientation() == Horizontal) // scroll right - scrollBy( 40, 0 ); + scrollBy( _step, 0 ); else // scroll down - scrollBy( 0, 40 ); + scrollBy( 0, _step ); + if (_step < 64) + _step++; } void Panner::scrollLeftUp() { if(orientation() == Horizontal) // scroll left - scrollBy( -40, 0 ); + scrollBy( -_step, 0 ); else // scroll up - scrollBy( 0, -40 ); + scrollBy( 0, -_step ); + if (_step < 64) + _step++; } -void Panner::createScrollButtons() +void Panner::startScrollRightDown() { - if (_luSB) - { - return; - } + _scrollTimer = new QTimer(this); + connect(_scrollTimer, SIGNAL(timeout()), SLOT(scrollRightDown())); + _scrollTimer->start(50); + _step = 8; + scrollRightDown(); +} - // left/up scroll button - _luSB = new SimpleArrowButton(this); - _luSB->installEventFilter(this); - _luSB->setAutoRepeat(true); - _luSB->setMinimumSize(12, 12); - _luSB->hide(); - _layout->addWidget(_luSB); - connect(_luSB, SIGNAL(clicked()), SLOT(scrollLeftUp())); +void Panner::startScrollLeftUp() +{ + _scrollTimer = new QTimer(this); + connect(_scrollTimer, SIGNAL(timeout()), SLOT(scrollLeftUp())); + _scrollTimer->start(50); + _step = 8; + scrollLeftUp(); +} - // right/down scroll button - _rdSB = new SimpleArrowButton(this); - _rdSB->installEventFilter(this); - _rdSB->setAutoRepeat(true); - _rdSB->setMinimumSize(12, 12); - _rdSB->hide(); - _layout->addWidget(_rdSB); - connect(_rdSB, SIGNAL(clicked()), SLOT(scrollRightDown())); - - // set up the buttons - setupButtons(); +void Panner::stopScroll() +{ + delete _scrollTimer; + _scrollTimer = 0; } void Panner::reallyUpdateScrollButtons() @@ -176,7 +206,7 @@ delta = contentsHeight() - height(); } - if (delta > 1) + if (delta >= 1) { createScrollButtons(); @@ -184,21 +214,11 @@ // we need to do this every single time _luSB->show(); _rdSB->show(); - - if (orientation() == Horizontal) - { - setMargins(0, 0, _luSB->width() + _rdSB->width(), 0); - } - else - { - setMargins(0, 0, 0, _luSB->height() + _rdSB->height()); - } } else if (_luSB && _luSB->isVisibleTo(this)) { _luSB->hide(); _rdSB->hide(); - setMargins(0, 0, 0, 0); } } @@ -207,8 +227,170 @@ _updateScrollButtonsTimer->start(200, true); } +void Panner::setContentsPos(int x, int y) +{ + if (x < 0) + x = 0; + else if (x > (contentsWidth() - visibleWidth())) + x = contentsWidth() - visibleWidth(); + + if (y < 0) + y = 0; + else if (y > (contentsHeight() - visibleHeight())) + y = contentsHeight() - visibleHeight(); + + if (x == contentsX() && y == contentsY()) + return; + + _viewport->move(-x, -y); + emit contentsMoving(x, y); +} + +void Panner::scrollBy(int dx, int dy) +{ + setContentsPos(contentsX() + dx, contentsY() + dy); +} + void Panner::resizeContents( int w, int h ) { - QScrollView::resizeContents( w, h ); + _viewport->resize(w, h); + setContentsPos(contentsX(), contentsY()); updateScrollButtons(); } + +QPoint Panner::contentsToViewport( const QPoint& p ) const +{ + return QPoint(p.x() - contentsX() - _clipper->x(), p.y() - contentsY() - _clipper->y()); +} + +QPoint Panner::viewportToContents( const QPoint& vp ) const +{ + return QPoint(vp.x() + contentsX() + _clipper->x(), vp.y() + contentsY() + _clipper->y()); +} + +void Panner::contentsToViewport( int x, int y, int& vx, int& vy ) const +{ + const QPoint v = contentsToViewport(QPoint(x,y)); + vx = v.x(); + vy = v.y(); +} + +void Panner::viewportToContents( int vx, int vy, int& x, int& y ) const +{ + const QPoint c = viewportToContents(QPoint(vx,vy)); + x = c.x(); + y = c.y(); +} + +void Panner::ensureVisible( int x, int y ) +{ + ensureVisible(x, y, 50, 50); +} + +void Panner::ensureVisible( int x, int y, int xmargin, int ymargin ) +{ + int pw=visibleWidth(); + int ph=visibleHeight(); + + int cx=-contentsX(); + int cy=-contentsY(); + int cw=contentsWidth(); + int ch=contentsHeight(); + + if ( pw < xmargin*2 ) + xmargin=pw/2; + if ( ph < ymargin*2 ) + ymargin=ph/2; + + if ( cw <= pw ) { + xmargin=0; + cx=0; + } + if ( ch <= ph ) { + ymargin=0; + cy=0; + } + + if ( x < -cx+xmargin ) + cx = -x+xmargin; + else if ( x >= -cx+pw-xmargin ) + cx = -x+pw-xmargin; + + if ( y < -cy+ymargin ) + cy = -y+ymargin; + else if ( y >= -cy+ph-ymargin ) + cy = -y+ph-ymargin; + + if ( cx > 0 ) + cx=0; + else if ( cx < pw-cw && cw>pw ) + cx=pw-cw; + + if ( cy > 0 ) + cy=0; + else if ( cy < ph-ch && ch>ph ) + cy=ph-ch; + + setContentsPos( -cx, -cy ); +} + +bool Panner::eventFilter( QObject *obj, QEvent *e ) +{ + if ( obj == _viewport || obj == _clipper ) + { + switch ( e->type() ) + { + case QEvent::Resize: + viewportResizeEvent((QResizeEvent *)e); + break; + case QEvent::MouseButtonPress: + viewportMousePressEvent( (QMouseEvent*)e ); + if ( ((QMouseEvent*)e)->isAccepted() ) + return true; + break; + case QEvent::MouseButtonRelease: + viewportMouseReleaseEvent( (QMouseEvent*)e ); + if ( ((QMouseEvent*)e)->isAccepted() ) + return true; + break; + case QEvent::MouseButtonDblClick: + viewportMouseDoubleClickEvent( (QMouseEvent*)e ); + if ( ((QMouseEvent*)e)->isAccepted() ) + return true; + break; + case QEvent::MouseMove: + viewportMouseMoveEvent( (QMouseEvent*)e ); + if ( ((QMouseEvent*)e)->isAccepted() ) + return true; + break; + default: + break; + } + } + + return QWidget::eventFilter( obj, e ); // always continue with standard event processing +} + +void Panner::viewportResizeEvent( QResizeEvent* ) +{ +} + +void Panner::viewportMousePressEvent( QMouseEvent* e) +{ + e->ignore(); +} + +void Panner::viewportMouseReleaseEvent( QMouseEvent* e ) +{ + e->ignore(); +} + +void Panner::viewportMouseDoubleClickEvent( QMouseEvent* e ) +{ + e->ignore(); +} + +void Panner::viewportMouseMoveEvent( QMouseEvent* e ) +{ + e->ignore(); +} Index: kicker/libkicker/kickertip.cpp =================================================================== --- kicker/libkicker/kickertip.cpp (revision 850417) +++ kicker/libkicker/kickertip.cpp (working copy) @@ -128,8 +128,10 @@ // Tickle the information out of the bastard. client->updateKickerTip(data); + // Hide the tip if there is nothing to show if (data.message.isEmpty() && data.subtext.isEmpty() && data.icon.isNull()) { + hide(); return; } @@ -137,7 +139,7 @@ m_richText = new QSimpleRichText("

" + data.message + "

" + data.subtext + "

", font(), QString::null, 0, m_mimeFactory); - m_richText->setWidth(400); + m_richText->setWidth(640); m_direction = data.direction; if (KickerSettings::mouseOversShowIcon()) @@ -193,11 +195,81 @@ void KickerTip::mousePressEvent(QMouseEvent * /*e*/) { QToolTip::setGloballyEnabled(m_toolTipsEnabled); - m_timer.stop(); - m_frameTimer.stop(); hide(); } +static void drawRoundRect(QPainter &p, const QRect &r) +{ + static int line[8] = { 1, 3, 4, 5, 6, 7, 7, 8 }; + static int border[8] = { 1, 2, 1, 1, 1, 1, 1, 1 }; + int xl, xr, y1, y2; + QPen pen = p.pen(); + bool drawBorder = pen.style() != QPen::NoPen; + + if (r.width() < 16 || r.height() < 16) + { + p.drawRect(r); + return; + } + + p.fillRect(r.x(), r.y() + 8, r.width(), r.height() - 16, p.brush()); + p.fillRect(r.x() + 8, r.y(), r.width() - 16, r.height(), p.brush()); + + p.setPen(p.brush().color()); + + for (int i = 0; i < 8; i++) + { + xl = i; + xr = r.width() - i - 1; + y1 = 7; + y2 = 7 - (line[i] - 1); + + p.drawLine(xl, y1, xl, y2); + p.drawLine(xr, y1, xr, y2); + + y1 = r.height() - y1 - 1; + y2 = r.height() - y2 - 1; + + p.drawLine(xl, y1, xl, y2); + p.drawLine(xr, y1, xr, y2); + + } + + if (drawBorder) + { + p.setPen(pen); + + if (r.height() > 16) + { + p.drawLine(r.x(), r.y() + 8, r.x(), r.y() + r.height() - 9); + p.drawLine(r.x() + r.width() - 1, r.y() + 8, r.x() + r.width() - 1, r.y() + r.height() - 9); + } + if (r.width() > 16) + { + p.drawLine(r.x() + 8, r.y(), r.x() + r.width() - 9, r.y()); + p.drawLine(r.x() + 8, r.y() + r.height() - 1, r.x() + r.width() - 9, r.y() + r.height() - 1); + } + + for (int i = 0; i < 8; i++) + { + xl = i; + xr = r.width() - i - 1; + y2 = 7 - (line[i] - 1); + y1 = y2 + (border[i] - 1); + + p.drawLine(xl, y1, xl, y2); + p.drawLine(xr, y1, xr, y2); + + y1 = r.height() - y1 - 1; + y2 = r.height() - y2 - 1; + + p.drawLine(xl, y1, xl, y2); + p.drawLine(xr, y1, xr, y2); + + } + } +} + void KickerTip::plainMask() { QPainter maskPainter(&m_mask); @@ -205,9 +277,9 @@ m_mask.fill(Qt::black); maskPainter.setBrush(Qt::white); - maskPainter.setPen(Qt::white); - maskPainter.drawRoundRect(m_mask.rect(), 1600 / m_mask.rect().width(), - 1600 / m_mask.rect().height()); + maskPainter.setPen(Qt::NoPen); + //maskPainter.drawRoundRect(m_mask.rect(), 1600 / m_mask.rect().width(), 1600 / m_mask.rect().height()); + drawRoundRect(maskPainter, m_mask.rect()); setMask(m_mask); m_frameTimer.stop(); } @@ -219,9 +291,9 @@ m_mask.fill(Qt::black); maskPainter.setBrush(Qt::white); - maskPainter.setPen(Qt::white); - maskPainter.drawRoundRect(m_mask.rect(), 1600 / m_mask.rect().width(), - 1600 / m_mask.rect().height()); + maskPainter.setPen(Qt::NoPen); + //maskPainter.drawRoundRect(m_mask.rect(), 1600 / m_mask.rect().width(), 1600 / m_mask.rect().height()); + drawRoundRect(maskPainter, m_mask.rect()); m_dissolveSize += m_dissolveDelta; @@ -235,7 +307,7 @@ for (y = 0; y < height() + size; y += size) { x = width(); - s = m_dissolveSize * x / 128; + s = 4 * m_dissolveSize * x / 128; for (; x > -size; x -= size, s -= 2) { if (s < 0) @@ -311,10 +383,10 @@ // draw background QPainter bufferPainter(&m_pixmap); - bufferPainter.setPen(Qt::black); + bufferPainter.setPen(colorGroup().foreground()); bufferPainter.setBrush(colorGroup().background()); - bufferPainter.drawRoundRect(0, 0, width, height, - 1600 / width, 1600 / height); + //bufferPainter.drawRoundRect(0, 0, width, height, 1600 / width, 1600 / height); + drawRoundRect(bufferPainter, QRect(0, 0, width, height)); // draw icon if present if (!m_icon.isNull()) @@ -331,11 +403,11 @@ QColorGroup cg = colorGroup(); cg.setColor(QColorGroup::Text, cg.background().dark(115)); int shadowOffset = QApplication::reverseLayout() ? -1 : 1; - m_richText->draw(&bufferPainter, 5 + textX + shadowOffset, textY + 1, QRect(), cg); + m_richText->draw(&bufferPainter, textX + shadowOffset, textY + 1, QRect(), cg); // draw text cg = colorGroup(); - m_richText->draw(&bufferPainter, 5 + textX, textY, rect(), cg); + m_richText->draw(&bufferPainter, textX, textY, rect(), cg); } } @@ -359,11 +431,7 @@ void KickerTip::untipFor(const QWidget* w) { if (isTippingFor(w)) - { - tipFor(0); - m_timer.stop(); hide(); - } } bool KickerTip::isTippingFor(const QWidget* w) const @@ -408,7 +476,8 @@ void KickerTip::hide() { - m_tippingFor = 0; + tipFor(0); + m_timer.stop(); m_frameTimer.stop(); QWidget::hide(); } @@ -476,8 +545,6 @@ break; case QEvent::MouseButtonPress: QToolTip::setGloballyEnabled(m_toolTipsEnabled); - m_timer.stop(); - m_frameTimer.stop(); hide(); default: break; Index: kicker/libkicker/simplebutton.cpp =================================================================== --- kicker/libkicker/simplebutton.cpp (revision 850417) +++ kicker/libkicker/simplebutton.cpp (working copy) @@ -32,6 +32,8 @@ #include #include +#define BUTTON_MARGIN KDialog::spacingHint() + SimpleButton::SimpleButton(QWidget *parent, const char *name) : QButton(parent, name), m_highlight(false), @@ -70,7 +72,7 @@ if (!pm) return QButton::sizeHint(); else - return QSize(pm->width() + KDialog::spacingHint(), pm->height() + KDialog::spacingHint()); + return QSize(pm->width() + BUTTON_MARGIN, pm->height() + BUTTON_MARGIN); } QSize SimpleButton::minimumSizeHint() const @@ -107,7 +109,7 @@ int w = width(); int ph = pix.height(); int pw = pix.width(); - int margin = KDialog::spacingHint(); + int margin = BUTTON_MARGIN; QPoint origin(margin / 2, margin / 2); if (ph < (h - margin)) Index: kicker/libkicker/panner.h =================================================================== --- kicker/libkicker/panner.h (revision 850417) +++ kicker/libkicker/panner.h (working copy) @@ -24,14 +24,14 @@ #ifndef __panner_h__ #define __panner_h__ -#include +#include #include "simplebutton.h" class QBoxLayout; class QTimer; -class KDE_EXPORT Panner : public QScrollView +class KDE_EXPORT Panner : public QWidget { Q_OBJECT @@ -43,17 +43,55 @@ Qt::Orientation orientation() const { return _orient; } virtual void setOrientation(Orientation orientation); + + QWidget *viewport() const { return _viewport; } + + QRect contentsRect() const { return QRect(0, 0, width(), height()); } + + int contentsX() const { return _viewport ? -_viewport->x() : 0; } + int contentsY() const { return _viewport ? -_viewport->y() : 0; } + int contentsWidth() const { return _viewport ? _viewport->width() : 0; } + int contentsHeight() const { return _viewport ? _viewport->height() : 0; } + void setContentsPos(int x, int y); + + int visibleWidth() const { return _clipper->width(); } + int visibleHeight() const { return _clipper->height(); } + + void contentsToViewport( int x, int y, int& vx, int& vy ) const; + void viewportToContents( int vx, int vy, int& x, int& y ) const; + QPoint contentsToViewport( const QPoint& ) const; + QPoint viewportToContents( const QPoint& ) const; + + void addChild(QWidget *child) { child->show(); } + void removeChild(QWidget *child) { child->hide(); } + int childX(QWidget *child) const { return child->x(); } + int childY(QWidget *child) const { return child->y(); } + void moveChild(QWidget *child, int x, int y) { child->move(x, y); } + void ensureVisible( int x, int y ); + void ensureVisible( int x, int y, int xmargin, int ymargin ); + public slots: virtual void resizeContents( int w, int h ); + void startScrollRightDown(); + void startScrollLeftUp(); + void stopScroll(); void scrollRightDown(); void scrollLeftUp(); void reallyUpdateScrollButtons(); + void scrollBy(int dx, int dy); +signals: + void contentsMoving(int x, int y); + protected: - void resizeEvent(QResizeEvent *ev); - void contentsWheelEvent(QWheelEvent *){;} - void viewportWheelEvent(QWheelEvent *){;} + virtual bool eventFilter( QObject *obj, QEvent *e ); + virtual void resizeEvent(QResizeEvent *ev); + virtual void viewportResizeEvent( QResizeEvent* ); + virtual void viewportMousePressEvent( QMouseEvent* ); + virtual void viewportMouseReleaseEvent( QMouseEvent* ); + virtual void viewportMouseDoubleClickEvent( QMouseEvent* ); + virtual void viewportMouseMoveEvent( QMouseEvent* ); private: void setupButtons(); @@ -65,6 +103,13 @@ SimpleArrowButton *_luSB; // Left Scroll Button SimpleArrowButton *_rdSB; // Right Scroll Button QTimer *_updateScrollButtonsTimer; + QTimer *_scrollTimer; + + QWidget *_clipper; + QWidget *_viewport; + int _cwidth, _cheight; + int _cx, _cy; + int _step; }; #endif Index: kicker/kicker/core/container_extension.cpp =================================================================== --- kicker/kicker/core/container_extension.cpp (revision 850417) +++ kicker/kicker/core/container_extension.cpp (working copy) @@ -126,6 +126,7 @@ connect(Kicker::the()->kwinModule(), SIGNAL(currentDesktopChanged(int)), this, SLOT( currentDesktopChanged(int))); + setBackgroundOrigin(AncestorOrigin); setFrameStyle(NoFrame); setLineWidth(0); setMargin(0); @@ -163,7 +164,7 @@ { _userHidden = static_cast(tmp); } - + if (m_extension) { // if we have an extension, we need to grab the extension-specific Index: kicker/kicker/core/containerarea.cpp =================================================================== --- kicker/kicker/core/containerarea.cpp (revision 850417) +++ kicker/kicker/core/containerarea.cpp (working copy) @@ -90,15 +90,12 @@ m_addAppletDialog(0) { setBackgroundOrigin( WidgetOrigin ); - viewport()->setBackgroundOrigin( AncestorOrigin ); - m_contents = new QWidget(viewport()); - m_contents->setBackgroundOrigin(AncestorOrigin); + m_contents = viewport(); m_layout = new ContainerAreaLayout(m_contents); - // Install an event filter to propagate layout hints coming from - // m_contents. + // Install an event filter to propagate layout hints coming from m_contents. m_contents->installEventFilter(this); setBackground(); Index: kicker/kicker/core/panelextension.cpp =================================================================== --- kicker/kicker/core/panelextension.cpp (revision 850417) +++ kicker/kicker/core/panelextension.cpp (working copy) @@ -74,7 +74,6 @@ connect(_containerArea, SIGNAL(maintainFocus(bool)), this, SIGNAL(maintainFocus(bool))); _layout->addWidget(_containerArea); - _containerArea->setFrameStyle(QFrame::NoFrame); _containerArea->viewport()->installEventFilter(this); _containerArea->configure(); Index: kicker/applets/systemtray/systemtrayapplet.h =================================================================== --- kicker/applets/systemtray/systemtrayapplet.h (revision 850417) +++ kicker/applets/systemtray/systemtrayapplet.h (working copy) @@ -118,6 +118,7 @@ TrayEmbed( bool kdeTray, QWidget* parent = NULL ); bool kdeTray() const { return kde_tray; } void setBackground(); + void getIconSize(int defaultIconSize); private: bool kde_tray; }; Index: kicker/applets/systemtray/systemtrayapplet.cpp =================================================================== --- kicker/applets/systemtray/systemtrayapplet.cpp (revision 850417) +++ kicker/applets/systemtray/systemtrayapplet.cpp (working copy) @@ -54,6 +54,8 @@ #include +#define ICON_MARGIN 1 + extern "C" { KDE_EXPORT KPanelApplet* init(QWidget *parent, const QString& configFile) @@ -459,9 +461,9 @@ delete emb; return; } - + connect(emb, SIGNAL(embeddedWindowDestroyed()), SLOT(updateTrayWindows())); - emb->setMinimumSize(m_iconSize, m_iconSize); + emb->getIconSize(m_iconSize); if (shouldHide(w)) { @@ -471,7 +473,7 @@ } else { - emb->hide(); + //emb->hide(); emb->setBackground(); emb->show(); m_shownWins.append(emb); @@ -515,7 +517,7 @@ { for (; emb != lastEmb; ++emb) { - (*emb)->hide(); + //(*emb)->hide(); (*emb)->setBackground(); (*emb)->show(); } @@ -744,8 +746,7 @@ } int currentHeight = height(); - int minHeight = m_iconSize + 4; - if (currentHeight != h && currentHeight != minHeight) + if (currentHeight != h) { SystemTrayApplet* me = const_cast(this); me->setMinimumSize(0, 0); @@ -764,8 +765,7 @@ } int currentWidth = width(); - int minSize = m_iconSize + 4; - if (currentWidth != w && currentWidth != minSize) + if (currentWidth != w) { SystemTrayApplet* me = const_cast(this); me->setMinimumSize(0, 0); @@ -782,10 +782,8 @@ } -void SystemTrayApplet::resizeEvent( QResizeEvent* e ) +void SystemTrayApplet::resizeEvent( QResizeEvent* ) { - KPanelApplet::resizeEvent(e); - layoutTray(); // we need to give ourselves a chance to adjust our size before calling this QTimer::singleShot(0, this, SIGNAL(updateLayout())); @@ -808,7 +806,7 @@ int i = 0, line, nbrOfLines, heightWidth; bool showExpandButton = m_expandButton && m_expandButton->isVisibleTo(this); delete m_layout; - m_layout = new QGridLayout(this, 1, 1, 2, 2); + m_layout = new QGridLayout(this, 1, 1, ICON_MARGIN, ICON_MARGIN); if (m_expandButton) { @@ -828,18 +826,18 @@ // // The margin and spacing specified in the layout implies that: - // [-- 2 pixels --] [-- first icon --] [-- 2 pixels --] ... [-- 2 pixels --] [-- last icon --] [-- 2 pixels --] + // [-- ICON_MARGIN pixels --] [-- first icon --] [-- ICON_MARGIN pixels --] ... [-- ICON_MARGIN pixels --] [-- last icon --] [-- ICON_MARGIN pixels --] // - // So, if we say that iconWidth is the icon width plus the 2 pixels spacing, then the available width for the icons - // is the widget width minus 2 pixels margin. Forgetting these 2 pixels broke the layout algorithm in KDE <= 3.5.9. + // So, if we say that iconWidth is the icon width plus the ICON_MARGIN pixels spacing, then the available width for the icons + // is the widget width minus ICON_MARGIN pixels margin. Forgetting these ICON_MARGIN pixels broke the layout algorithm in KDE <= 3.5.9. // - // This fix makes the workaround in the heightForWidth() and widthForHeight() methods unneeded. + // This fix makes the workarounds in the heightForWidth() and widthForHeight() methods unneeded. // if (orientation() == Vertical) { - int iconWidth = maxIconWidth() + 2; // +2 for the margins that implied by the layout - heightWidth = width() - 2; + int iconWidth = maxIconWidth() + ICON_MARGIN; // +2 for the margins that implied by the layout + heightWidth = width() - ICON_MARGIN; // to avoid nbrOfLines=0 we ensure heightWidth >= iconWidth! heightWidth = heightWidth < iconWidth ? iconWidth : heightWidth; nbrOfLines = heightWidth / iconWidth; @@ -860,12 +858,12 @@ emb != lastEmb; ++emb) { line = i % nbrOfLines; - (*emb)->hide(); + //(*emb)->hide(); (*emb)->show(); m_layout->addWidget(*emb, col, line, Qt::AlignHCenter | Qt::AlignVCenter); - if (line + 1 == nbrOfLines) + if ((line + 1) == nbrOfLines) { ++col; } @@ -879,12 +877,12 @@ emb != lastEmb; ++emb) { line = i % nbrOfLines; - (*emb)->hide(); + //(*emb)->hide(); (*emb)->show(); m_layout->addWidget(*emb, col, line, Qt::AlignHCenter | Qt::AlignVCenter); - if (line + 1 == nbrOfLines) + if ((line + 1) == nbrOfLines) { ++col; } @@ -894,8 +892,8 @@ } else // horizontal { - int iconHeight = maxIconHeight() + 2; // +2 for the margins that implied by the layout - heightWidth = height() - 2; + int iconHeight = maxIconHeight() + ICON_MARGIN; // +2 for the margins that implied by the layout + heightWidth = height() - ICON_MARGIN; heightWidth = heightWidth < iconHeight ? iconHeight : heightWidth; // to avoid nbrOfLines=0 nbrOfLines = heightWidth / iconHeight; @@ -914,12 +912,12 @@ for (TrayEmbedList::const_iterator emb = m_hiddenWins.begin(); emb != lastEmb; ++emb) { line = i % nbrOfLines; - (*emb)->hide(); + //(*emb)->hide(); (*emb)->show(); m_layout->addWidget(*emb, line, col, Qt::AlignHCenter | Qt::AlignVCenter); - if (line + 1 == nbrOfLines) + if ((line + 1) == nbrOfLines) { ++col; } @@ -933,12 +931,12 @@ emb != lastEmb; ++emb) { line = i % nbrOfLines; - (*emb)->hide(); + //(*emb)->hide(); (*emb)->show(); m_layout->addWidget(*emb, line, col, Qt::AlignHCenter | Qt::AlignVCenter); - if (line + 1 == nbrOfLines) + if ((line + 1) == nbrOfLines) { ++col; } @@ -975,6 +973,21 @@ : QXEmbed( parent ), kde_tray( kdeTray ) { hide(); +} + +void TrayEmbed::getIconSize(int defaultIconSize) +{ + QSize minSize = minimumSizeHint(); + + int width = minSize.width(); + int height = minSize.height(); + + if (width < 1 || width > defaultIconSize) + width = defaultIconSize; + if (height < 1 || height > defaultIconSize) + height = defaultIconSize; + + setFixedSize(width, height); setBackground(); } @@ -994,9 +1007,7 @@ if (!isHidden()) { - hide(); - show(); + XClearArea(x11Display(), embeddedWinId(), 0, 0, 0, 0, True); } - //XClearArea(x11Display(), embeddedWinId(), 0, 0, 0, 0, True); } Index: kicker/applets/clock/clock.h =================================================================== --- kicker/applets/clock/clock.h (revision 850417) +++ kicker/applets/clock/clock.h (working copy) @@ -41,6 +41,7 @@ #include #include "settings.h" +#include "kshadowengine.h" class QTimer; class QBoxLayout; @@ -152,6 +153,9 @@ bool showDayOfWeek(); protected: + void paintEvent(QPaintEvent *e); + void drawContents(QPainter *p); + QString _timeStr; }; @@ -279,6 +283,8 @@ QDate clockGetDate(); virtual void updateKickerTip(KickerTip::Data&); + + KTextShadowEngine *shadowEngine(); k_dcop: void reconfigure(); @@ -335,6 +341,7 @@ QStringList _remotezonelist; KPopupMenu* menu; ClockAppletToolTip m_tooltip; + KTextShadowEngine *m_shadowEngine; }; Index: kicker/applets/clock/Makefile.am =================================================================== --- kicker/applets/clock/Makefile.am (revision 850417) +++ kicker/applets/clock/Makefile.am (working copy) @@ -1,7 +1,7 @@ pic_DATA = lcd.png picdir = $(kde_datadir)/clockapplet/pics -INCLUDES = -I$(top_srcdir)/kicker/libkicker $(all_includes) +INCLUDES = -I$(top_srcdir)/kicker/libkicker -I../../libkicker $(all_includes) kde_module_LTLIBRARIES = clock_panelapplet.la Index: kicker/applets/clock/clock.cpp =================================================================== --- kicker/applets/clock/clock.cpp (revision 850417) +++ kicker/applets/clock/clock.cpp (working copy) @@ -57,6 +57,7 @@ #include // libkickermain +#include "kickerSettings.h" #include "clock.h" #include "datepicker.h" #include "zone.h" @@ -219,6 +220,7 @@ PlainClock::PlainClock(ClockApplet *applet, Prefs *prefs, QWidget *parent, const char *name) : QLabel(parent, name), ClockWidget(applet, prefs) { + setWFlags(WNoAutoErase); setBackgroundOrigin(AncestorOrigin); loadSettings(); updateClock(); @@ -228,7 +230,7 @@ int PlainClock::preferedWidthForHeight(int ) const { QString maxLengthTime = KGlobal::locale()->formatTime( QTime( 23, 59 ), _prefs->plainShowSeconds()); - return fontMetrics().width( maxLengthTime+2 ); + return fontMetrics().width( maxLengthTime ) + 8; } @@ -244,7 +246,7 @@ if (_force || newStr != _timeStr) { _timeStr = newStr; - setText(_timeStr); + update(); } } @@ -266,6 +268,32 @@ return _prefs->plainShowDayOfWeek(); } +void PlainClock::paintEvent(QPaintEvent *) +{ + QPainter p; + QPixmap buf(size()); + buf.fill(this, 0, 0); + p.begin(&buf); + p.setFont(font()); + p.setPen(paletteForegroundColor()); + drawContents(&p); + drawFrame(&p); + p.end(); + p.begin(this); + p.drawPixmap(0, 0, buf); + p.end(); +} + +void PlainClock::drawContents(QPainter *p) +{ + QRect tr(0, 0, width(), height()); + + if (!KickerSettings::transparent()) + p->drawText(tr, AlignCenter, _timeStr); + else + _applet->shadowEngine()->drawText(*p, tr, AlignCenter, _timeStr, size()); +} + //************************************************************ @@ -834,12 +862,22 @@ p->setFont(_prefs->fuzzyFont()); p->setPen(_prefs->fuzzyForegroundColor()); - if (_applet->getOrientation() == Vertical) { + + QRect tr; + + if (_applet->getOrientation() == Vertical) + { p->rotate(90); - p->drawText(4, -2, height() - 8, -(width()) + 2, AlignCenter, _timeStr); - } else { - p->drawText(4, 2, width() - 8, height() - 4, AlignCenter, _timeStr); + tr = QRect(4, -2, height() - 8, -(width()) + 2); } + else + tr = QRect(4, 2, width() - 8, height() - 4); + + if (!KickerSettings::transparent()) + p->drawText(tr, AlignCenter, _timeStr); + else + _applet->shadowEngine()->drawText(*p, tr, AlignCenter, _timeStr, size()); + alreadyDrawing = false; } @@ -872,7 +910,8 @@ _prefs(new Prefs(sharedConfig())), zone(new Zone(config())), menu(0), - m_tooltip(this) + m_tooltip(this), + m_shadowEngine(0) { DCOPObject::setObjId("ClockApplet"); _prefs->readConfig(); @@ -910,6 +949,7 @@ ClockApplet::~ClockApplet() { + delete m_shadowEngine; //reverse for the moment KGlobal::locale()->removeCatalogue("clockapplet"); KGlobal::locale()->removeCatalogue("timezones"); // For time zone translations @@ -929,6 +969,16 @@ config()->sync(); } + +KTextShadowEngine *ClockApplet::shadowEngine() +{ + if (!m_shadowEngine) + m_shadowEngine = new KTextShadowEngine(); + + return m_shadowEngine; +} + + int ClockApplet::widthForHeight(int h) const { if (orientation() == Qt::Vertical)