Beispiel #1
0
void NextClient::init()
{
    createMainWidget(WResizeNoErase | WStaticContents);
    widget()->installEventFilter(this);

    widget()->setBackgroundMode( NoBackground );

    QVBoxLayout *mainLayout = new QVBoxLayout(widget());
    QBoxLayout  *titleLayout = new QBoxLayout(0, QBoxLayout::LeftToRight, 0, 0, 0);
    QHBoxLayout *windowLayout = new QHBoxLayout();
    mainLayout->addLayout(titleLayout);
    mainLayout->addLayout(windowLayout, 1);
    mainLayout->addSpacing(mustDrawHandle() ? handleSize : 1);

    windowLayout->addSpacing(1);
    if (isPreview())
        windowLayout->addWidget(new QLabel(i18n(
			"<center><b>KStep preview</b></center>"), widget()));
    else
        windowLayout->addItem(new QSpacerItem( 0, 0 ));

    windowLayout->addSpacing(1);

    initializeButtonsAndTitlebar(titleLayout);
}
Beispiel #2
0
void TguitarView::paintEvent(QPaintEvent* event) {
  if (isPreview() && horizontalScrollBar()->value() >= m_guitar->fbRect().x() + m_guitar->fbRect().width()) {
    QPainter painter(viewport());
//     if (!m_guitar->isRightHanded()) {
//       painter.translate(width(), 0);
//       painter.scale(-1, 1);
//     }
    if (m_guitar->guitarTypeId() == 1) { // No need to check for non guitar - in such a case it never goes here
      QPixmap guitarPixmap = QPixmap(Tpath::img("body")).scaled(
                  (m_parent->width() / 2) * transform().m11(), height() * 2.445714285714286, Qt::IgnoreAspectRatio);
      painter.drawPixmap((m_guitar->posX12fret() + 7) * transform().m11() - horizontalScrollBar()->value(),
                         height() - guitarPixmap.height(), guitarPixmap);
    } else {
      QPixmap guitarPixmap;
      if (m_guitar->guitarTypeId() == 2)
          guitarPixmap = QPixmap(Tpath::img("body-electro")).scaled(644 * ((height() * 2.9) / 614), height() * 2.9);
      else
          guitarPixmap = QPixmap(Tpath::img("body-bass")).scaled(640 * ((height() * 2.9) / 535), height() * 2.9);
      painter.drawPixmap((m_guitar->fbRect().right() - m_guitar->height() * 1.449532710280374) * transform().m11() - horizontalScrollBar()->value(),
                         height() - guitarPixmap.height() , guitarPixmap);
//       if (!gl->GisRightHanded)
//         painter.resetTransform();
      qreal pickCoef = (((height() * 2.9) / 614.0) * 0.5);
      QPixmap rosettePixmap = QPixmap(Tpath::img("pickup")).scaled(291 * pickCoef, 468 * pickCoef, Qt::KeepAspectRatio);
      painter.drawPixmap(m_guitar->pickRect()->x() * transform().m11() - horizontalScrollBar()->value(),
                         6 * transform().m11(), rosettePixmap);
    }
  }
  QGraphicsView::paintEvent(event);
}
Beispiel #3
0
bool TguitarView::checkIsPreview() {
#if defined (Q_OS_ANDROID)
  m_isPreview = Tmtr::fingerPixels() * 4 > m_guitar->height() * 1.1;
  if (isPreview()) { // as long as it is called only under Android where re-sizing doesn't occur
    if (!m_proxy) { // it is sufficient to call this once - only when proxy is created
      m_proxy = m_parent->scene()->addWidget(this);
      m_proxy->setZValue(50);
      m_proxy->hide();
      m_proxy->setGraphicsEffect(new TdropShadowEffect());
      setFixedSize(m_guitar->averFretWidth() * 2.5, qMax<int>(Tmtr::fingerPixels() * 4, m_guitar->viewport()->height() * 1.1)); // also size of preview
      qreal factor = (qreal)height() / (qreal)m_guitar->viewport()->height(); // and its scale
      scale(factor, factor); // will not change
      QColor fretHi = m_guitar->selectedColor();
      fretHi.setAlpha(50);
      m_mark = m_guitar->scene()->addRect(QRectF(), Qt::NoPen, QBrush(fretHi));
      m_mark->setZValue(0);
      m_mark->hide();
    }
  }
#else
  m_isPreview = false;
#endif
  return m_isPreview;
}
Beispiel #4
0
void KCommonDecoration::resetLayout()
{
    for (int n=0; n<NumButtons; n++) {
        if (m_button[n]) {
            delete m_button[n];
            m_button[n] = 0;
        }
    }
    m_buttonsLeft.clear();
    m_buttonsRight.clear();

    delete m_previewWidget;
    m_previewWidget = 0;

    // shown instead of the window contents in decoration previews
    if(isPreview() ) {
        m_previewWidget = new QLabel(i18n("%1 is the name of window decoration style", "<center><b>%1 preview</b></center>").arg(visibleName() ), widget());
        m_previewWidget->show();
    }

    addButtons(m_buttonsLeft,
               options()->customButtonPositions() ? options()->titleButtonsLeft() : defaultButtonsLeft(),
               true);
    addButtons(m_buttonsRight,
               options()->customButtonPositions() ? options()->titleButtonsRight() : defaultButtonsRight(),
               false);

    updateLayout();

    const int minTitleBarWidth = 35;
    btnHideMinWidth = buttonContainerWidth(m_buttonsLeft,true) + buttonContainerWidth(m_buttonsRight,true) +
            layoutMetric(LM_TitleEdgeLeft,false) + layoutMetric(LM_TitleEdgeRight,false) +
            layoutMetric(LM_TitleBorderLeft,false) + layoutMetric(LM_TitleBorderRight,false) +
            minTitleBarWidth;
    btnHideLastWidth = 0;
}
Beispiel #5
0
bool TguitarView::mapTouchEvent(QTouchEvent* te) {
#if defined (Q_OS_ANDROID)
  if (isPreview()) { // PREVIEW MODE
      if (!TtouchParams::i()->guitarWasTouched) { // display hint how to use fret preview
          tMessage->setMessage(TtouchProxy::touchGuitarHelp(), 0);
          TtouchParams::i()->guitarWasTouched = true;
      }
      switch (te->type()) {
        case QEvent::TouchBegin: {
          if (proxy()->isVisible()) // already displayed - can be scrolled or selected
            m_couldBeTouch = true;
          break;
        }
        case QEvent::TouchUpdate: {
          if (isVisible() && m_touchStartedHere &&
              QLineF(te->touchPoints().first().pos(), te->touchPoints().first().startPos()).length() > Tmtr::fingerPixels() / 2)
          { // scrolling - so not selected
              horizontalScrollBar()->setValue(horizontalScrollBar()->value() +
                                              (te->touchPoints()[0].pos().x() - te->touchPoints()[0].lastPos().x()));
              quint8 currFret = m_guitar->pointToFinger(QPoint(horizontalScrollBar()->value() / transform().m11(),
                                                               m_guitar->height() / 2)).fret();
              if ((m_fret == 1 && currFret > 1) || (m_fret != 1 && currFret != m_fret)) {
                m_fret = currFret;
                updateMarkPosition();
                proxy()->setPos(m_fret ? m_guitar->fretPositionX(m_fret) + 9.0 :
                                         m_parent->width() - width(), m_parent->height() - height() - 4);
              }
              m_couldBeTouch = false;
          }
          break;
        }
        case QEvent::TouchEnd: {
          if (isVisible()) {
            if (m_touchStartedHere) { // preview was touched so it might be scrolled or touched
              if (m_couldBeTouch) { // it was touched - fake press the guitar
                if (m_parent->itemAt(te->touchPoints().first().startPos().toPoint()) == proxy()) {
                  QPointF mtgv = proxy()->mapFromScene(te->touchPoints().first().pos()); // mapped from global scene to guitar view
                  m_guitar->fakePress(QPointF((mtgv.x() + horizontalScrollBar()->value()) / transform().m11(),
                                              mtgv.y() / transform().m11()).toPoint());
                }
              } else // touched but scrolled - update displayed fret
                  updateContextPosition();
            } else // guitar (parent widget) was touched, so hide the preview
                hide();
          } else // not visible -display it at touch position
              displayAt(te->touchPoints().first().pos());
          m_touchStartedHere = false;
          m_couldBeTouch = false;
          break;
        }
        default:
          break;
      }
  } else
#endif
  { // NO PREVIEW - only convert touch in guitar into mouse press
      if (te->type() == QEvent::TouchEnd)
          m_guitar->fakePress(QPoint(te->touchPoints().first().pos().x() - m_guitar->x(),
                                     te->touchPoints().first().pos().y() - m_guitar->y()));
  }
  return true;
}