Example #1
0
void QElidingLabel::paintEvent( QPaintEvent * )
{
    QPainter p( this );
    int space = frameWidth() + margin();
    QRect r = rect().adjusted( space, space, -space, -space );
    p.drawText( r, fontMetrics().elidedText( text(), elideMode, r.width() ), alignment() );
}
Example #2
0
QRect SourceEdit::lineRect()
{
    QRect rect = cursorRect();
    rect.setLeft(0);
    rect.setWidth(viewport()->width());
    return rect;
}
Example #3
0
    void updatePosition()
    {
        int x, y;
        QRect widgetRect = mWidget->geometry();
        int splitterWidth = mSplitter->width();
        int handleWidth = mSplitter->handleWidth();
        int width = q->width();

        if (!isVertical()) {
            // FIXME: Make this configurable
            y = 30;
            if (mDirection == LTR) {
                if (isVisible()) {
                    x = widgetRect.right() + handleWidth;
                } else {
                    x = 0;
                }
            } else { // RTL
                if (isVisible()) {
                    x = widgetRect.left() - handleWidth - width;
                } else {
                    x = splitterWidth - handleWidth - width;
                }
            }
        } else {
            // FIXME
            x = 0;
            y = 0;
        }
        q->move(x, y);
    }
void CurvesDialog::contextMenuEvent(QContextMenuEvent *e)
{
	QPoint pos = available->viewport()->mapFromGlobal(QCursor::pos());
	QRect rect = available->visualItemRect(available->currentItem());
	if (rect.contains(pos))
	{
       QList<QTreeWidgetItem *> lst = available->selectedItems();
       int count = 0;
	   foreach (QTreeWidgetItem *item, lst){
			if (item->type() == FolderItem)
				continue;

			count++;
	   }

	   if (!count)
		return;

	   QMenu contextMenu(this);
       if (count > 1)
	       contextMenu.insertItem(tr("&Plot Selection"), this, SLOT(addCurves()));
       else if (count == 1)
	       contextMenu.insertItem(tr("&Plot"), this, SLOT(addCurves()));
	   contextMenu.exec(QCursor::pos());
    }
Example #5
0
/**
 * 处理内容:最大化/还原按钮信号
 * @param void
 * @return void
 */
void MainWnd::showMax()
{
    //首先判断是最大化还是还原
    if(!m_bMax)
    {
        m_rectRestore = geometry();
#if defined(Q_OS_UNIX) || defined(Q_OS_LINUX)
        QRect size = QApplication::desktop()->availableGeometry();
        setGeometry(0,0,size.width(),size.height());
        setMinimumSize(size.width(),size.height());
        setMaximumSize(size.width(),size.height());
#else
        setGeometry(QApplication::desktop()->availableGeometry());
#endif
    }
    else
    {
#if defined(Q_OS_UNIX) || defined(Q_OS_LINUX)
        this->move(m_rectRestore.x(),m_rectRestore.y());
        setMinimumSize(m_rectRestore.width(),m_rectRestore.height());
        setMaximumSize(m_rectRestore.width(),m_rectRestore.height());
#else
        setGeometry(m_rectRestore);
#endif
    }
    m_bMax = !m_bMax;
}
Example #6
0
/*!
    \fn TitleBar::mouseMoveEvent ( QMouseEvent * event )
 */
void TitleBar::mouseMoveEvent ( QMouseEvent * event )
{
	QPoint pos = event->pos();

	QRect rect = this->rect();
	const int buttonRight = 15;
	const int buttonWidth = 15;
	int right = rect.right() - pos.x();
	int button1 = (right - buttonRight)/buttonWidth;
	
	const int buttonhi = 10;
	int h = rect.height() - pos.y();
	int button2 = (h-10)/buttonhi;
	
	int button = button1 | button2;
	
	if((button != 0) && (but_press))
	{
		bpress = false;
		event->ignore();
	}
	else if((button == 0) && (but_press))
	{
	   bpress = true;
	   event->accept();
	}
	else
		event->ignore();
	
	repaint();
}
Example #7
0
void pTabBar::paintEvent( QPaintEvent* event )
{
    // draw tabs
    QTabBar::paintEvent( event );
    
    // update button close
    if ( !aToggleTabsHaveCloseButton->isChecked() )
        return;
    
    // get tab
    int i = tabAt( mapFromGlobal( QCursor::pos() ) );
    if ( i != -1 )
    {
        // get close button rect
        QRect ir = iconRectForTab( i );
        
        // if mouse in close button rect
        if ( ir.contains( mapFromGlobal( QCursor::pos() ) ) )
        {
            // draw button
            QPainter p( this );
            p.drawPixmap( ir.topLeft(), QIcon( ":/file/icons/file/closeall.png" ).pixmap( iconSize(), QIcon::Active, isTabEnabled( i ) ? QIcon::On : QIcon::Off ) );
        }
    }
}
Example #8
0
void QgsComposerPicture::loadPicture( const QString &path )
{
  if ( path.startsWith( "http" ) )
  {
    //remote location
    loadRemotePicture( path );
  }
  else
  {
    //local location
    loadLocalPicture( path );
  }
  if ( mMode != Unknown ) //make sure we start with a new QImage
  {
    recalculateSize();
  }
  else if ( mHasExpressionError || !( path.isEmpty() ) )
  {
    //trying to load an invalid file or bad expression, show cross picture
    mMode = SVG;
    QString badFile = QString( ":/images/composer/missing_image.svg" );
    mSVG.load( badFile );
    if ( mSVG.isValid() )
    {
      mMode = SVG;
      QRect viewBox = mSVG.viewBox(); //take width/height ratio from view box instead of default size
      mDefaultSvgSize.setWidth( viewBox.width() );
      mDefaultSvgSize.setHeight( viewBox.height() );
      recalculateSize();
    }
  }

  emit itemChanged();
}
Example #9
0
    virtual void draw(QPainter *painter,
		      const QwtScaleMap &xMap, const QwtScaleMap &,
		      const QRect &rect) const
    {
	RideItem *rideItem = parent->rideItem;

	if (! rideItem)
	    return;

	const Zones *zones       = rideItem->zones;
	int zone_range     = rideItem->zoneRange();

	if (parent->shadeZones() && (zone_range >= 0)) {
	    QList <int> zone_lows = zones->getZoneLows(zone_range);
	    int num_zones = zone_lows.size();
	    if (num_zones > 0) {
		for (int z = 0; z < num_zones; z ++) {
		    QRect r = rect;

		    QColor shading_color =
			zoneColor(z, num_zones);
		    shading_color.setHsv(
					 shading_color.hue(),
					 shading_color.saturation() / 4,
					 shading_color.value()
					 );
		    r.setLeft(xMap.transform(zone_lows[z]));
		    if (z + 1 < num_zones)
			r.setRight(xMap.transform(zone_lows[z + 1]));
		    if (r.right() >= r.left())
			painter->fillRect(r, shading_color);
		}
	    }
	}
    }
void QGstreamerVideoOverlay::setScaledDisplayRect()
{
    QRect formatViewport = m_surface->surfaceFormat().viewport();

    switch (m_aspectRatioMode) {
    case Qt::KeepAspectRatio:
        {
            QSize size = m_surface->surfaceFormat().sizeHint();
            size.scale(m_displayRect.size(), Qt::KeepAspectRatio);

            QRect rect(QPoint(0, 0), size);
            rect.moveCenter(m_displayRect.center());

            m_surface->setDisplayRect(rect);
            m_surface->setViewport(formatViewport);
        }
        break;
    case Qt::IgnoreAspectRatio:
        m_surface->setDisplayRect(m_displayRect);
        m_surface->setViewport(formatViewport);
        break;
    case Qt::KeepAspectRatioByExpanding:
        {
            QSize size = m_displayRect.size();
            size.scale(m_surface->surfaceFormat().sizeHint(), Qt::KeepAspectRatio);

            QRect viewport(QPoint(0, 0), size);
            viewport.moveCenter(formatViewport.center());
            m_surface->setDisplayRect(m_displayRect);
            m_surface->setViewport(viewport);
        }
        break;
    };
}
Example #11
0
/**
 * Returns a new stamp where all variations have been rotated in the given
 * \a direction.
 */
TileStamp TileStamp::rotated(RotateDirection direction) const
{
    TileStamp rotated(*this);
    rotated.d.detach();

    for (const TileStampVariation &variation : rotated.variations()) {
        const QRect mapRect(QPoint(), variation.map->size());
        QSize rotatedSize;

        for (auto layer : variation.map->tileLayers()) {
            TileLayer *tileLayer = static_cast<TileLayer*>(layer);

            // Synchronize tile layer size to map size (assumes map contains all layers)
            if (tileLayer->rect() != mapRect) {
                tileLayer->resize(mapRect.size(), tileLayer->position());
                tileLayer->setPosition(0, 0);
            }

            if (variation.map->orientation() == Map::Hexagonal)
                tileLayer->rotateHexagonal(direction, variation.map);
            else
                tileLayer->rotate(direction);

            rotatedSize = tileLayer->size();
        }

        variation.map->setWidth(rotatedSize.width());
        variation.map->setHeight(rotatedSize.height());
    }

    return rotated;
}
Example #12
0
void Slider::setOrientation(Qt::Orientation o)
{
	d_orient = o;
	ScaleDraw::OrientationX so = ScaleDraw::Bottom;
	switch (d_orient)
	{
		case Qt::Vertical:
			if (d_scalePos == Right)
				so = ScaleDraw::Right;
			else
				so = ScaleDraw::Left;
			break;
		case Qt::Horizontal:
			if (d_scalePos == Bottom)
				so = ScaleDraw::Bottom;
			else
				so = ScaleDraw::Top;
			break;
	}

	d_scale.setGeometry(0, 0, 40, so);
	if (d_orient == Qt::Vertical)
		setMinimumSize(10, 20);
	else
		setMinimumSize(20, 10);
	QRect r = geometry();
	setGeometry(r.x(), r.y(), r.height(), r.width());
	update();
}
void ApplyFilterCommand::redo()
{
    m_undoData.clear();
    Database database = m_database;

    Sheet* const sheet = database.range().lastSheet();
    const QRect range = database.range().lastRange();
    const int start = database.orientation() == Qt::Vertical ? range.top() : range.left();
    const int end = database.orientation() == Qt::Vertical ? range.bottom() : range.right();
    for (int i = start + 1; i <= end; ++i) {
        const bool isFiltered = !database.filter().evaluate(database, i);
//         kDebug() <<"Filtering column/row" << i <<"?" << isFiltered;
        if (database.orientation() == Qt::Vertical) {
            m_undoData[i] = sheet->rowFormats()->isFiltered(i);
            sheet->rowFormats()->setFiltered(i, i, isFiltered);
        } else { // database.orientation() == Qt::Horizontal
            m_undoData[i] = sheet->columnFormat(i)->isFiltered();
            sheet->nonDefaultColumnFormat(i)->setFiltered(isFiltered);
        }
    }
    if (database.orientation() == Qt::Vertical)
        sheet->map()->addDamage(new SheetDamage(sheet, SheetDamage::RowsChanged));
    else // database.orientation() == Qt::Horizontal
        sheet->map()->addDamage(new SheetDamage(sheet, SheetDamage::ColumnsChanged));

    m_sheet->cellStorage()->setDatabase(*this, Database());
    m_sheet->cellStorage()->setDatabase(*this, database);
    m_sheet->map()->addDamage(new CellDamage(m_sheet, *this, CellDamage::Appearance));
}
Example #14
0
QString GwtCallback::promptForText(QString title,
                                   QString caption,
                                   QString defaultValue,
                                   bool usePasswordMask,
                                   QString extraOptionPrompt,
                                   bool extraOptionByDefault,
                                   bool numbersOnly,
                                   int selectionStart,
                                   int selectionLength)
{
   InputDialog dialog(pOwner_->asWidget());
   dialog.setWindowTitle(title);
   dialog.setCaption(caption);

   if (usePasswordMask)
      dialog.setEchoMode(QLineEdit::Password);

   if (!extraOptionPrompt.isEmpty())
   {
      dialog.setExtraOptionPrompt(extraOptionPrompt);
      dialog.setExtraOption(extraOptionByDefault);
   }

   if (usePasswordMask)
   {
      // password prompts are shown higher up (because they relate to
      // console progress dialogs which are at the top of the screen)
      QRect parentGeom = pOwner_->asWidget()->geometry();
      int x = parentGeom.left() + (parentGeom.width() / 2) - (dialog.width() / 2);
      dialog.move(x, parentGeom.top() + 75);
   }

   if (numbersOnly)
      dialog.setNumbersOnly(true);
   if (!defaultValue.isEmpty())
   {
      dialog.setTextValue(defaultValue);
      if (selectionStart >= 0 && selectionLength >= 0)
      {
         dialog.setSelection(selectionStart, selectionLength);
      }
      else
      {
         dialog.setSelection(0, defaultValue.size());
      }
   }

   if (dialog.exec() == QDialog::Accepted)
   {
      QString value = dialog.textValue();
      bool extraOption = dialog.extraOption();
      QString values;
      values += value;
      values += QString::fromUtf8("\n");
      values += extraOption ? QString::fromUtf8("1") : QString::fromUtf8("0");
      return values;
   }
   else
      return QString();
}
//! Wrapper for QPainter::drawPoints()
void QwtPainter::drawPoints( QPainter *painter, 
    const QPoint *points, int pointCount )
{
    QRectF clipRect;
    const bool deviceClipping = qwtIsClippingNeeded( painter, clipRect );

    if ( deviceClipping )
    {
        const int minX = qCeil( clipRect.left() );
        const int maxX = qFloor( clipRect.right() );
        const int minY = qCeil( clipRect.top() );
        const int maxY = qFloor( clipRect.bottom() );

        const QRect r( minX, minY, maxX - minX, maxY - minY );

        QPolygon clippedPolygon( pointCount );
        QPoint *clippedData = clippedPolygon.data();

        int numClippedPoints = 0;
        for ( int i = 0; i < pointCount; i++ )
        {
            if ( r.contains( points[i] ) )
                clippedData[ numClippedPoints++ ] = points[i];
        }
        painter->drawPoints( clippedData, numClippedPoints );
    }
    else
    {
        painter->drawPoints( points, pointCount );
    }
}
Example #16
0
void FileTransferWidget::showPreview(const QString &filename)
{
    static const QStringList previewExtensions = { "png", "jpeg", "jpg", "gif", "svg",
                                                   "PNG", "JPEG", "JPG", "GIF", "SVG" };

    if (previewExtensions.contains(QFileInfo(filename).suffix()))
    {
        const int size = qMax(ui->previewLabel->width(), ui->previewLabel->height());

        QPixmap pmap = QPixmap(filename).scaled(QSize(size, size),
                                                Qt::KeepAspectRatioByExpanding, Qt::SmoothTransformation);
        ui->previewLabel->setPixmap(pmap);
        ui->previewLabel->show();
        ui->previewLabel->setCursor(Qt::PointingHandCursor);
        // Show mouseover preview, but make sure it's not larger than 50% of the screen width/height
        QRect desktopSize = QApplication::desktop()->screenGeometry();
        QImage image = QImage(filename).scaled(0.5 * desktopSize.width(),
                                               0.5 * desktopSize.height(),
                                               Qt::KeepAspectRatio, Qt::SmoothTransformation);
        QByteArray imageData;
        QBuffer buffer(&imageData);
        buffer.open(QIODevice::WriteOnly);
        image.save(&buffer, "PNG");
        buffer.close();
        ui->previewLabel->setToolTip("<img src=data:image/png;base64," + imageData.toBase64() + "/>");
    }
}
Example #17
0
//-----------------------------------------------------------------------------
//!
//-----------------------------------------------------------------------------
void tWindPlotGraph::DrawTimeLabelAndGridLine(QPainter& painter, QPen& gridPen, int timeIncrement)
{
    // Work out the Y position for the label and grid line
    int samplePosition;

    // Calculate the samplePosition
    samplePosition = timeIncrement * 60000;
    samplePosition /= tDigitalTimePlotDataManager::Instance()->GetSamplePeriod(m_TimePlotRange);

    qreal y = m_GraphConfig.originY + (samplePosition * m_GraphConfig.pixPerTime);

    QFontMetrics fm = QFontMetrics(painter.font());

    // Draw the label
    QString label = QString("%1").arg(timeIncrement);
    QRect boundingRect = fm.boundingRect( label );

    int w = contentsRect().width();

    QRectF textRect = QRectF((w - m_GraphConfig.centreMarginWidth) / 2, y - (boundingRect.height() / 2), m_GraphConfig.centreMarginWidth, boundingRect.height() );
    painter.drawText(textRect, Qt::AlignCenter, label );

    QPen savedPen = painter.pen();

    // draw grid lines
    if ( (samplePosition != 0) && (samplePosition != m_TimePlotData[0].GetMaxNumberOfSamples()) )
    {
        painter.setPen( gridPen );
        painter.drawLine( m_GraphConfig.originX[0], static_cast<int>(y), m_GraphConfig.originX[0] + m_GraphConfig.extentX[0], static_cast<int>(y) );
        painter.drawLine( m_GraphConfig.originX[1], static_cast<int>(y), m_GraphConfig.originX[1] + m_GraphConfig.extentX[1], static_cast<int>(y) );
    }

    painter.setPen(savedPen);
}
Example #18
0
int CHikVision::PlayVideo(HANDLE hChannel, HWND hWnd, QRect &rect, int nFrameRate)
{
    RECT winRect;
    POINT point;
    point.x = rect.left( );
    point.y = rect.top( );

    //BOOL bRet = ClientToScreen( hWnd, &point );

    winRect.left   = point.x;
    winRect.top    = point.y;
    winRect.right  = point.x + rect.right( );
    winRect.bottom = point.y + rect.bottom( );

    qDebug( ) << "left = "
              << winRect.left
              << "top = "
              << winRect.top
              << "right = "
              << winRect.right
              << "bottom = "
              << winRect.bottom
              << endl;

    //int nRet = SetPreviewOverlayMode( TRUE );
    int nRet = StartVideoPreview( hChannel, hWnd, &winRect, true, 0, nFrameRate );
    return nRet;
}
Example #19
0
void TitleBar::mouseReleaseEvent(QMouseEvent *event)
{
	if(!bpress)
	{
		event->ignore();
		return;
	}
	
	but_press = false;
	
	QDockWidget *dw = qobject_cast<QDockWidget*>(parentWidget());
	Q_ASSERT(dw != 0);
	
	QPoint pos = event->pos();

	QRect rect = this->rect();

	const int buttonRight = 7;
	const int buttonWidth = 20;
	int right = rect.right() - pos.x();
	int button = (right - buttonRight)/buttonWidth;
	if(!button){
		event->accept();
		dw->close();
	}
	else
		event->ignore();
	
	bpress = false;
	
	repaint();
}
Example #20
0
void LineCbBox::paintEvent (QPaintEvent *event)
{
	QStyleOption opt;
	opt.initFrom(this);
	QPainter painter(this);
	style()->drawPrimitive(QStyle::PE_Widget, &opt, &painter, this);

	painter.save();

//	painter.setRenderHint(QPainter::Antialiasing);

	QColor ContourColor = Qt::gray;

	if(!isEnabled()) ContourColor = Qt::lightGray;

	QRect r = event->rect();
//	QRect g = rect();
	painter.setBrush(Qt::NoBrush);
	painter.setBackgroundMode(Qt::TransparentMode);

	QPen LinePen(m_Color);
	LinePen.setStyle(getStyle(m_Style));
	LinePen.setWidth(m_Width);
	painter.setPen(LinePen);
	painter.drawLine(r.left()+5, r.height()/2, r.width()-10, r.height()/2);

//	QPen ContourPen(ContourColor);
//	painter.setPen(ContourPen);
//	r.adjust(0,2,-1,-3);
//	painter.drawRoundRect(r,5,40);

	painter.restore();
}
Example #21
0
void SoundViewerWidget::paintEvent(QPaintEvent *event) {
	(void)event;
	
	QPainter painter(this);
	
	painter.fillRect(rect(), Qt::transparent);
	
	QRect temp = rect();
	temp.moveTop(METER_HEIGHT);
	painter.drawTiledPixmap(temp, pixmap);
	
	// draw note
	if (this->note >= 0 && this->note < 12 * NUM_OCTAVES) {
		int octave = this->note / 12;
		int nn = this->note % 12;
		
		int adjust = 7 * KEY_WIDTH * octave;
		QRect noteRect = keyRect[nn].adjusted(adjust, METER_HEIGHT, adjust, METER_HEIGHT);
		painter.fillRect(noteRect, colors[this->channel]);
	}
	
	// draw volume
	int meterLength = rect().width() / 2;
	int left = (this->volume * this->panL) * meterLength;
	int right = (this->volume * this->panR) * meterLength;
	painter.fillRect(QRect(meterLength, 0, -left, METER_HEIGHT - METER_MARGIN), colors[this->channel]);
	painter.fillRect(QRect(meterLength, 0, right, METER_HEIGHT - METER_MARGIN), colors[this->channel]);
}
Example #22
0
void SortManipulator::sort(Element *element)
{
    // we'll use insert-sort to sort
    QRect range = element->rect();
    int max = m_rows ? range.bottom() : range.right();
    int min = m_rows ? range.top() : range.left();
    int count = max - min + 1;
    // initially, all values are at their original positions
    sorted.clear();
    for (int i = 0; i < count; ++i) sorted[i] = i;

    // for each position, find the lowest value and move it there
    int start = m_skipfirst ? 1 : 0;
    for (int i = start; i < count - 1; ++i) {
        int lowest = i;
        for (int j = i + 1; j < count; ++j)
            if (shouldReorder(element, sorted[lowest], sorted[j]))
                lowest = j;
        // move lowest to start
        int tmp = sorted[i];
        sorted[i] = sorted[lowest];
        sorted[lowest] = tmp;
    }

    // that's all - process will take care of the rest, together with our
    // newValue/newFormat
}
Example #23
0
MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWindow)
{
    ui->setupUi(this);

    this->model = new SailSizeModel(parent, 80);
    this->windSizeTableModel = new WindSizeTableModel(this, this->model);
    // connect the weightslider to the model
    QObject::connect(ui->weightSlider,SIGNAL(valueChanged(int)), this->model, SLOT(setWeight(int)));

    // connect the fromWindSlider to the model
    QObject::connect(ui->windSlider1,SIGNAL(valueChanged(int)),
                     this, SLOT(setWindSpeed(int)));

    // connect the fromWindSlider to the model
    QObject::connect(ui->windSlider2,SIGNAL(valueChanged(int)),
                     this, SLOT(setWindSpeed(int)));

    // connect the model update signal to the main window
    QObject::connect(this->model,SIGNAL(updated()), this, SLOT(modelUpdated()));

    ui->weightSlider->setValue(this->model->weight());

    ui->weightLabel->setMinimumWidth(90);
    ui->windRangeLabel->setMinimumWidth(90);

    this->updateWeightLabel();
    this->updateWindRangeLabel();

    ui->sailSizeTable->setModel(this->windSizeTableModel);
    ui->sailSizeTable->horizontalHeader()->setResizeMode(QHeaderView::Stretch);
    // center window on screen
    QRect frect = frameGeometry();
    frect.moveCenter(QDesktopWidget().availableGeometry().center());
    move(frect.topLeft());
}
Example #24
0
void BrushItem::updateBoundingRect()
{
    prepareGeometryChange();

    if (!mMapDocument) {
        mBoundingRect = QRectF();
        return;
    }

    QRect bounds = mRegion.boundingRect();
    if (mTileLayer) {
        bounds.setSize(QSize(mTileLayer->width(), mTileLayer->height()));
        mTileLayer->setX(bounds.x());
        mTileLayer->setY(bounds.y());
    }

    mBoundingRect = mMapDocument->renderer()->boundingRect(bounds);

    // Adjust for amount of pixels tiles extend above the brush
    if (mTileLayer) {
        const int tileHeight = mMapDocument->map()->tileHeight();
        const int extra = qMax(0, mTileLayer->maxTileHeight() - tileHeight);
        mBoundingRect.adjust(0, -extra, 0, 0);
    }
}
void QSystemTrayIconPrivate::showMessage_sys(const QString &title, const QString &message, QSystemTrayIcon::MessageIcon type, int timeOut)
{
    if (!sys || !sys->allowsMessages())
        return;

    uint uSecs = 0;
    if ( timeOut < 0)
        uSecs = 10000; //10 sec default
    else uSecs = (int)timeOut;

    //message is limited to 255 chars + NULL
    QString messageString;
    if (message.isEmpty() && !title.isEmpty())
        messageString = QLatin1Char(' '); //ensures that the message shows when only title is set
    else
        messageString = message.left(255) + QChar();

    //title is limited to 63 chars + NULL
    QString titleString = title.left(63) + QChar();

    if (sys->supportsMessages()) {
        sys->showMessage(titleString, messageString, type, (unsigned int)uSecs);
    } else {
        //use fallback
        QRect iconPos = sys->findIconGeometry(q_uNOTIFYICONID);
        if (iconPos.isValid()) {
            QBalloonTip::showBalloon(type, title, message, sys->q, iconPos.center(), uSecs, true);
        }
    }
}
Example #26
0
void CodeEditor::resizeEvent(QResizeEvent *e)
{
    QPlainTextEdit::resizeEvent(e);

    QRect cr = contentsRect();
    lineNumberArea->setGeometry(QRect(cr.left(), cr.top(), lineNumberAreaWidth(), cr.height()));
}
Example #27
0
void FrontPanel::displayImageGL(Image const &img)
{
    m_GlWidget->setWindowTitle("Front Panel");    

    Image cpyImg(img);
    m_GlWidget->loadImage(cpyImg);
    m_GlWidget->loadShaders(HDR_DIR"/shaders/frontPanel.vert", HDR_DIR"/shaders/frontPanel.frag");

    QDesktopWidget *backDesktop = QApplication::desktop();
    QRect screenGeo = backDesktop->availableGeometry(m_DisplayId);
    if (m_CurrentMode == FULLSCREEN)
        m_GlWidget->showFullScreen();
    else
    {
        m_GlWidget->resize(screenGeo.size());
        m_GlWidget->show();
    }
    //Move the window to the target device.
    m_GlWidget->move(screenGeo.topLeft());

    if (m_ToneMapped)
        m_GlWidget->toggleToneMapping();
    else
        m_GlWidget->toggleHDRDisplay();

    //Compute and set tone-mapping parameters.
    computeShaderParameters(cpyImg);
    m_GlWidget->setToneMappingParameters(m_Parameters);
}
Example #28
0
void mainwidget::animHideChannelWidget(bool immediately) {
    if (!_isChannelWidgetShowing && !immediately) return;

    QParallelAnimationGroup *animgroup = new QParallelAnimationGroup(this);
    QPropertyAnimation *control_anim = new QPropertyAnimation(ui->controlWidget, "pos");
    control_anim->setDuration(400);
    control_anim->setStartValue(ui->controlWidget->pos());
    QPoint endpos = ui->controlWidget->pos();
    endpos.setY(0);
    control_anim->setEndValue(endpos);
    control_anim->setEasingCurve(QEasingCurve::OutCubic);

    animgroup->addAnimation(control_anim);

    QPropertyAnimation *main_anim = new QPropertyAnimation(this, "geometry");
    main_anim->setDuration(400);
    main_anim->setStartValue(this->geometry());
    QRect endval2 = this->geometry();
    endval2.setHeight(ui->controlWidget->geometry().height());
    main_anim->setEndValue(endval2);
    main_anim->setEasingCurve(QEasingCurve::OutCubic);

    animgroup->addAnimation(main_anim);

    connect(animgroup, &QParallelAnimationGroup::finished, [this] () {
        _isChannelWidgetShowing = false;
        QRect pauseGeo = ui->pauseWidget->geometry();
        pauseGeo.setHeight(this->geometry().height());
        ui->pauseWidget->setGeometry(pauseGeo);
        this->setMaximumHeight(pauseGeo.height());
    });
    animgroup->start(QAbstractAnimation::DeleteWhenStopped);
}
Example #29
0
/** This seems to be called when the user has selected a rectangle
* using the mouse.
*
* @param dets :: returns a list of detector IDs selected.
*/
void Projection3D::getSelectedDetectors(QList<int> &dets) {
  dets.clear();
  if (!hasSelection())
    return;
  double xmin, xmax, ymin, ymax, zmin, zmax;
  m_viewport.getInstantProjection(xmin, xmax, ymin, ymax, zmin, zmax);
  QRect rect = selectionRect();
  int w, h;
  m_viewport.getViewport(w, h);

  double xLeft = xmin + (xmax - xmin) * rect.left() / w;
  double xRight = xmin + (xmax - xmin) * rect.right() / w;
  double yBottom = ymin + (ymax - ymin) * (h - rect.bottom()) / h;
  double yTop = ymin + (ymax - ymin) * (h - rect.top()) / h;
  size_t ndet = m_instrActor->ndetectors();

  // Cache all the detector positions if needed. This is slow, but just once.
  m_instrActor->cacheDetPos();

  for (size_t i = 0; i < ndet; ++i) {
    detid_t detId = m_instrActor->getDetID(i);
    V3D pos = m_instrActor->getDetPos(i);
    m_viewport.transform(pos);
    if (pos.X() >= xLeft && pos.X() <= xRight && pos.Y() >= yBottom &&
        pos.Y() <= yTop) {
      dets.push_back(detId);
    }
  }
}
loginDialog::loginDialog()
{
    // Create the login widget
    QELogin* login = new QELogin();
    login->setCompactStyle( false );
    login->setFrameStyle( QFrame::NoFrame );
    QObject::connect(login, SIGNAL(login()), this, SLOT(accept()));

    // Create the cancel button
    QPushButton* cancelButton = new QPushButton( this );
    cancelButton->setText( "Cancel" );
    QObject::connect(cancelButton, SIGNAL(clicked()), this, SLOT(reject()));

    // Add the login widget to the the dialog
    QVBoxLayout* layout = new QVBoxLayout(this);
    layout->addWidget( login );
    layout->addWidget( cancelButton );

    // Give the QELogin widget the focus so an enter pressed after entering the password will change the user level
    login->setFocus();

    // Set the dialog title
    setWindowTitle( "Change User Level" );

    // Explicity set the desired size. If we don't and then apply scaling, the sensible
    // default sizing "goes out the window"..
    //
    QRect g = geometry();
    g.setWidth( 200 );
    g.setHeight( 280 );
    setGeometry( g );
}