QRect WPiano::viewport() const { QWidget *w = qobject_cast<QWidget *>(parent()); if (w == NULL) w = const_cast<WPiano *>(this); QRect geom = w->geometry(); return QRect(mapFrom(w, geom.topLeft()), mapFrom(w, geom.bottomRight())); }
void GfxMenu::select() { GfxMenuItem *mi = menuItem()->item(list()->current()); if(mi->count()) { GfxCanvasList *l = listForItem(mi, mapFrom(list()->currentItem(), static_cast<MenuListItem *>(list()->currentItem())->rect().topLeft())); tl.move(list()->x(), -240, 300); list()->setActive(false); tl.move(l->x(), 0, 300); _listStack << l; list()->setActive(true); _miStack << mi; } else { itemactivated(); } }
/*! rgb picking */ void ImageViewer::pickColor(QMouseEvent *event, bool putValueToStyleEditor) { if (!m_isHistogramEnable) return; if (!m_histogramPopup->isVisible()) return; QPoint curPos = event->pos() * getDevPixRatio(); // avoid to pick outside of the flip if ((!m_image) || !rect().contains(curPos)) { // throw transparent color m_histogramPopup->updateInfo(TPixel32::Transparent, TPointD(-1, -1)); return; } StylePicker picker(m_image); TPoint mousePos = TPoint(curPos.x(), height() - 1 - curPos.y()); TRectD area = TRectD(mousePos.x, mousePos.y, mousePos.x, mousePos.y); if (m_lutCalibrator && m_lutCalibrator->isValid()) m_fbo->bind(); const TPixel32 pix = picker.pickColor(area); if (m_lutCalibrator && m_lutCalibrator->isValid()) m_fbo->release(); QPoint viewP = mapFrom(this, curPos); TPointD pos = getViewAff().inv() * TPointD(viewP.x() - width() / 2, -viewP.y() + height() / 2); TPointD imagePos = TPointD(0.5 * m_image->getBBox().getLx() + pos.x, 0.5 * m_image->getBBox().getLy() + pos.y); if (m_image->getBBox().contains(imagePos)) { // throw the picked color to the histogram m_histogramPopup->updateInfo(pix, imagePos); // throw it to the style editor as well if (putValueToStyleEditor) setPickedColorToStyleEditor(pix); } else { // throw transparent color if picking outside of the image m_histogramPopup->updateInfo(TPixel32::Transparent, TPointD(-1, -1)); } }
void QSideBar::paintEvent(QPaintEvent *event) { QPainter p(this); QFont fontText(p.font()); fontText.setFamily("Comic Sans MS"); //Helvetica Neue p.setFont(fontText); QImage texture(":/GUI/SideBarTexture"); p.fillRect(event->rect(), QBrush(texture)); p.setPen(Qt::black); p.drawLine(event->rect().topRight(), event->rect().bottomRight()); int action_y = 0; int action_x = 0; switch (paintMode_) { case 0: action_y = 0; break; case 1: action_y = event->rect().height()/2-actions_.size()*actionHeight_/2; break; } foreach(QAction *action, actions_) { QRect actionRect; if (style_ == 0) { actionRect = QRect(action_x, action_y, event->rect().width(), actionHeight_); } else { actionRect = QRect(action_x, action_y, event->rect().height(), actionWidth_); } int curActionResize = 0; if (action == clickedAction_) { curActionResize = clickedActionSize_; } QRect actionIconRect(action_x+actionSpace_/2+curActionResize/2, action_y+actionSpace_/2+curActionResize/2, event->rect().width()-actionSpace_-curActionResize, actionHeight_-actionSpace_-curActionResize); QIcon actionIcon(action->icon()); actionIcon.paint(&p, actionIconRect); if((action == actionUnderMouse_) && (action != clickedAction_)) { p.setOpacity(0.3); p.fillRect(actionRect, *colorUnderMouseAction_); p.setPen(QColor(9, 9, 9)); p.drawLine(actionRect.topLeft(), actionRect.topRight()); p.setOpacity(1); QToolTip::showText(mapFrom(this, QCursor::pos()), action->toolTip()); } if (action == clickedAction_) { p.setOpacity(clickedActionSize_ / 10.0); p.fillRect(actionRect, *colorClickedAction_); p.setPen(QColor(9, 9, 9)); p.drawLine(actionRect.topLeft(), actionRect.topRight()); p.setOpacity(1); } if(action == actions_.last()) { p.setPen(QColor(15, 15, 15)); p.drawLine(QPoint(action_x, actionRect.bottomLeft().y()-1), QPoint(actionRect.width(), actionRect.bottomRight().y()-1)); p.setPen(QColor(55, 55, 55)); p.drawLine(actionRect.bottomLeft(), actionRect.bottomRight()); } p.setPen(QColor(15, 15, 15)); p.drawLine(actionRect.topLeft(), actionRect.topRight()); p.setPen(QColor(55, 55, 55)); p.drawLine(QPoint(action_x, actionRect.topLeft().y()+1), QPoint(actionRect.width(), actionRect.topRight().y()+1)); if (isDrawText_) { p.setPen(QColor(217, 217, 217)); if(action->isChecked()) p.setPen(QColor(255, 255, 255)); QRect actionTextRect(action_x, action_y+actionRect.height()-20, event->rect().width(), 15); p.drawText(actionTextRect, Qt::AlignCenter, action->text()); } if (style_ == 0) { action_y += actionRect.height(); } else { action_x += actionRect.width(); } }
void QueueLabel::mousePressEvent( QMouseEvent* mouseEvent ) { hideToolTip(); if( m_timer.isActive() ) // if the user clicks again when (right after) the menu is open, { // (s)he probably wants to close it m_timer.stop(); return; } Playlist *pl = Playlist::instance(); PLItemList &queue = pl->m_nextTracks; if( queue.isEmpty() ) return; int length = 0; for( QPtrListIterator<PlaylistItem> it( queue ); *it; ++it ) { const int s = (*it)->length(); if( s > 0 ) length += s; } QPtrList<KPopupMenu> menus; menus.setAutoDelete( true ); KPopupMenu *menu = new KPopupMenu; menus.append( menu ); const uint count = queue.count(); if( length ) menu->insertTitle( i18n( "1 Queued Track (%1)", "%n Queued Tracks (%1)", count ) .arg( MetaBundle::prettyLength( length, true ) ) ); else menu->insertTitle( i18n( "1 Queued Track", "%n Queued Tracks", count ) ); Pana::actionCollection()->action( "queue_manager" )->plug( menu ); menu->insertItem( SmallIconSet( Pana::icon( "rewind" ) ), count > 1 ? i18n( "&Dequeue All Tracks" ) : i18n( "&Dequeue Track" ), 0 ); menu->insertSeparator(); uint i = 1; QPtrListIterator<PlaylistItem> it( queue ); it.toFirst(); while( i <= count ) { for( uint n = kMin( i + MAX_TO_SHOW - 1, count ); i <= n; ++i, ++it ) menu->insertItem( KStringHandler::rsqueeze( i18n( "%1. %2" ).arg( i ).arg( veryNiceTitle( *it ) ), 50 ), i ); if( i < count ) { menus.append( new KPopupMenu ); menu->insertSeparator(); menu->insertItem( i18n( "1 More Track", "%n More Tracks", count - i + 1 ), menus.getLast() ); menu = menus.getLast(); } } menu = menus.getFirst(); int mx, my; const int mw = menu->sizeHint().width(), mh = menu->sizeHint().height(), sy = mapFrom( Pana::StatusBar::instance(), QPoint( 0, 0 ) ).y(), sheight = Pana::StatusBar::instance()->height(); const QRect dr = QApplication::desktop()->availableGeometry( this ); if( mapYToGlobal( sy ) - mh > dr.y() ) my = mapYToGlobal( sy ) - mh; else if( mapYToGlobal( sy + sheight ) + mh < dr.y() + dr.height() ) my = mapYToGlobal( sy + sheight ); else my = mapToGlobal( mouseEvent->pos() ).y(); mx = mapXToGlobal( 0 ) - ( mw - width() ) / 2; int id = menu->exec( QPoint( mx, my ) ); if( id < 0 ) m_timer.start( 50, true ); else if( id == 0 ) //dequeue { const PLItemList dequeued = queue; while( !queue.isEmpty() ) pl->queue( queue.getLast(), true ); emit queueChanged( PLItemList(), dequeued ); } else { PlaylistItem *selected = queue.at( id - 1 ); if( selected ) pl->ensureItemCentered( selected ); } }