void KKbdAccessExtensions::resizePanel(int dx, int dy, int state) { int adj = dx + dy; if (adj == 0) return; // kdDebug() << "KKbdAccessExtensions::resizePanel: panel = " << d->panel->name() << endl; if (::qt_cast<QSplitter*>( d->panel )) { QSplitter* splitter = dynamic_cast<QSplitter *>(d->panel); int handleNdx = d->handleNdx - 1; QValueList<int> sizes = splitter->sizes(); // kdDebug() << "KKbdAccessExtensions::resizePanel: before sizes = " << sizes << endl; sizes[handleNdx] = sizes[handleNdx] + adj; // kdDebug() << "KKbdAccessExtensions::resizePanel: setSizes = " << sizes << endl; splitter->setSizes(sizes); QApplication::postEvent(splitter, new QEvent(QEvent::LayoutHint)); } else { // TODO: How to get the handle width? QDockWindow* dockWindow = dynamic_cast<QDockWindow *>(d->panel); if (dockWindow->area()) { // kdDebug() << "KKbdAccessExtensions::resizePanel: fixedExtent = " << dockWindow->fixedExtent() << endl; QSize fe = dockWindow->fixedExtent(); if (d->handleNdx == 1) { // When vertically oriented and dock area is on right side of screen, pressing // left arrow increases size. if (dockWindow->area()->orientation() == Qt::Vertical && dockWindow->area()->handlePosition() == QDockArea::Reverse) adj = -adj; int w = fe.width(); if (w < 0) w = dockWindow->width(); w = w + adj; if (w > 0 ) dockWindow->setFixedExtentWidth(w); } else { // When horizontally oriented and dock area is at bottom of screen, // pressing up arrow increases size. if (dockWindow->area()->orientation() == Qt::Horizontal && dockWindow->area()->handlePosition() == QDockArea::Reverse) adj = -adj; int h = fe.height(); if (h < 0) h = dockWindow->height(); h = h + adj; if (h > 0) dockWindow->setFixedExtentHeight(h); } dockWindow->updateGeometry(); QApplication::postEvent(dockWindow->area(), new QEvent(QEvent::LayoutHint)); // kdDebug() << "KKbdAccessExtensions::resizePanel: fixedExtent = " << dockWindow->fixedExtent() << endl; } else { if (state == Qt::ShiftButton) { QSize s = dockWindow->size(); s.setWidth(s.width() + dx); s.setHeight(s.height() + dy); dockWindow->resize(s); } else { QPoint p = dockWindow->pos(); p.setX(p.x() + dx); p.setY(p.y() + dy); dockWindow->move(p); } } } }
void KKbdAccessExtensions::showIcon() { if (!d->panel) return; QPoint p; // kdDebug() << "KKbdAccessExtensions::showIcon: topLevelWidget = " << d->panel->topLevelWidget()->name() << endl; if (::qt_cast<QSplitter*>( d->panel )) { QSplitter* splitter = dynamic_cast<QSplitter *>(d->panel); int handleNdx = d->handleNdx - 1; QValueList<int> sizes = splitter->sizes(); // kdDebug() << "KKbdAccessExtensions::showIcon: sizes = " << sizes << endl; if (splitter->orientation() == Qt::Horizontal) { d->icon->setShape(Qt::SizeHorCursor); p.setX(sizes[handleNdx] + (splitter->handleWidth() / 2)); p.setY(splitter->height() / 2); } else { d->icon->setShape(Qt::SizeVerCursor); p.setX(splitter->width() / 2); p.setY(sizes[handleNdx] + (splitter->handleWidth() / 2)); } // kdDebug() << "KKbdAccessExtensions::showIcon: p = " << p << endl; p = splitter->mapToGlobal(p); // kdDebug() << "KKbdAccessExtensions::showIcon: mapToGlobal = " << p << endl; } else { QDockWindow* dockWindow = dynamic_cast<QDockWindow *>(d->panel); p = dockWindow->pos(); if (dockWindow->area()) { // kdDebug() << "KKbdAccessExtensions::showIcon: pos = " << p << " of window = " << dockWindow->parentWidget()->name() << endl; p = dockWindow->parentWidget()->mapTo(dockWindow->topLevelWidget(), p); // kdDebug() << "KKbdAccessExtensions::showIcon: mapTo = " << p << " of window = " << dockWindow->topLevelWidget()->name() << endl; // TODO: How to get the handle width? if (d->handleNdx == 1) { d->icon->setShape(Qt::SizeHorCursor); if (dockWindow->area()->orientation() == Qt::Vertical) { if (dockWindow->area()->handlePosition() == QDockArea::Normal) // Handle is to the right of the dock window. p.setX(p.x() + dockWindow->width()); // else Handle is to the left of the dock window. } else // Handle is to the right of the dock window. p.setX(p.x() + dockWindow->width()); p.setY(p.y() + (dockWindow->height() / 2)); } else { d->icon->setShape(Qt::SizeVerCursor); p.setX(p.x() + (dockWindow->width() / 2)); if (dockWindow->area()->orientation() == Qt::Vertical) // Handle is below the dock window. p.setY(p.y() + dockWindow->height()); else { if (dockWindow->area()->handlePosition() == QDockArea::Normal) // Handle is below the dock window. p.setY(p.y() + dockWindow->height()); // else Handle is above the dock window. } } p = dockWindow->topLevelWidget()->mapToGlobal(p); } else { d->icon->setShape(Qt::SizeAllCursor); p = QPoint(dockWindow->width() / 2, dockWindow->height() / 2); p = dockWindow->mapToGlobal(p); // Undocked. Position in center of window. } } // kdDebug() << "KKbdAccessExtensions::showIcon: show(p) = " << p << endl; d->icon->show(p); }