Esempio n. 1
1
/*!
    Resizes the top-level widget containing this widget. The event is
    in \a e.
*/
void QSizeGrip::mouseMoveEvent( QMouseEvent * e )
{
    if ( e->state() != LeftButton )
	return;

    QWidget* tlw = qt_sizegrip_topLevelWidget(this);
    if ( tlw->testWState(WState_ConfigPending) )
	return;

    QPoint np( e->globalPos() );

    QWidget* ws = qt_sizegrip_workspace( this );
    if ( ws ) {
	QPoint tmp( ws->mapFromGlobal( np ) );
	if ( tmp.x() > ws->width() )
	    tmp.setX( ws->width() );
	if ( tmp.y() > ws->height() )
	    tmp.setY( ws->height() );
	np = ws->mapToGlobal( tmp );
    }

    int w;
    int h = np.y() - p.y() + s.height();

    if ( QApplication::reverseLayout() )
	w = s.width() - ( np.x() - p.x() );
    else
	w = np.x() - p.x() + s.width();

    if ( w < 1 )
	w = 1;
    if ( h < 1 )
	h = 1;
    QSize ms( tlw->minimumSizeHint() );
    ms = ms.expandedTo( minimumSize() );
    if ( w < ms.width() )
	w = ms.width();
    if ( h < ms.height() )
	h = ms.height();

    if (QApplication::reverseLayout()) {
	tlw->resize( w, h );
	if (tlw->size() == QSize(w,h))
	    tlw->move( tlw->x() + ( np.x()-p.x() ), tlw->y() );
    } else {
	tlw->resize( w, h );
    }
#ifdef Q_WS_WIN
    MSG msg;
    while( PeekMessage( &msg, winId(), WM_MOUSEMOVE, WM_MOUSEMOVE, PM_REMOVE ) )
      ;
#endif
    QApplication::syncX();

    if ( QApplication::reverseLayout() && tlw->size() == QSize(w,h) ) {
	s.rwidth() = tlw->size().width();
	p.rx() = np.x();
    }
}
Esempio n. 2
0
bool QChildWidget::eventFilter(QObject *o, QEvent *e)
{
    if (e->type() == QEvent::Paint){
        QWidget *w = static_cast<QWidget*>(o);
        for (QWidget *p = parentWidget(); p; p = p->parentWidget()){
            const QPixmap bg = p->palette().brush(p->backgroundRole()).texture();
            if (!bg.isNull()){
                QPoint pos = w->mapToGlobal(QPoint(0, 0));
                pos = p->mapFromGlobal(pos);
                QRect rc(pos.x(), pos.y(), w->width(), w->height());
                if (rc != rcChild){
                    rcChild = rc;
                    QPixmap new_bg(w->width(), w->height());
                    QPainter pp(&new_bg);
                    pp.drawTiledPixmap(0, 0, w->width(), w->height(), bg, pos.x(), pos.y());
                    pp.end();
                    QPalette palette = w->palette();
                    palette.setBrush(w->backgroundRole(), QBrush(new_bg));
                    w->setPalette(palette);
                }
                if (!w->palette().brush(w->backgroundRole()).texture().isNull()){
                    QPainter pp(w);
                    pp.drawPixmap(0, 0, w->palette().brush(w->backgroundRole()).texture());
                }
                return true;
            }
        }
    }
    return false;
}
Esempio n. 3
0
bool QChildWidget::eventFilter(QObject *o, QEvent *e)
{
    if (e->type() == QEvent::Paint){
        QWidget *w = static_cast<QWidget*>(o);
        for (QWidget *p = parentWidget(); p; p = p->parentWidget()){
            const QPixmap *bg = p->backgroundPixmap();
            if (bg){
                QPoint pos = w->mapToGlobal(QPoint(0, 0));
                pos = p->mapFromGlobal(pos);
                QRect rc(pos.x(), pos.y(), w->width(), w->height());
                if (rc != rcChild){
                    rcChild = rc;
                    QPixmap new_bg(w->width(), w->height());
                    QPainter pp(&new_bg);
                    pp.drawTiledPixmap(0, 0, w->width(), w->height(), *bg, pos.x(), pos.y());
                    pp.end();
                    w->setBackgroundPixmap(new_bg);
                }
                if (w->backgroundPixmap()){
                    QPainter pp(w);
                    pp.drawPixmap(0, 0, *w->backgroundPixmap());
                }
                return true;
            }
        }
    }
    return false;
}
    bool eventFilter(QObject *pO, QEvent *event)
    {
        if ( event->type() == QEvent::Paint) {
            QWidget* pW = qobject_cast<QWidget*>(pO);
            QColor backColor = NotificationServerSettings::instance()->value("notification_backgroundColor").value<QColor>();
            float fOpacity = NotificationServerSettings::instance()->value("notification_opacity").value<float>();
            QPainter painter ( pW );
            painter.setRenderHint(QPainter::Antialiasing);
            painter.setRenderHint(QPainter::HighQualityAntialiasing);

            // corners
            const int kShadowCornerSize = scShadowSize + scRadiusSize;
            painter.drawPixmap(0, 0, shadowsCorners.at(0));
            painter.drawPixmap(pW->width() - kShadowCornerSize, 0, shadowsCorners.at(1));
            painter.drawPixmap(pW->width() - kShadowCornerSize, pW->height() - kShadowCornerSize, shadowsCorners.at(2));
            painter.drawPixmap(0, pW->height() - kShadowCornerSize, shadowsCorners.at(3));

            //edges
            painter.drawTiledPixmap(kShadowCornerSize, 0,pW->width() - kShadowCornerSize*2, scShadowSize,shadowsEdges.at(0));
            painter.drawTiledPixmap(pW->width() - scShadowSize, kShadowCornerSize,scShadowSize, pW->height() - kShadowCornerSize*2,shadowsEdges.at(1));
            painter.drawTiledPixmap(kShadowCornerSize, pW->height() - scShadowSize,pW->width() - kShadowCornerSize*2, scShadowSize,shadowsEdges.at(2));
            painter.drawTiledPixmap(0, kShadowCornerSize,scShadowSize, pW->height() - kShadowCornerSize*2,shadowsEdges.at(3));


            // rounded pixmap
            painter.setBrush(backColor);
            painter.setPen(backColor);
            painter.setOpacity(fOpacity);
            painter.drawRoundedRect(scShadowSize,scShadowSize,pW->width()-2*scShadowSize, pW->height()-2*scShadowSize,scRadiusSize,scRadiusSize);
        }
    }
Esempio n. 5
0
void
AnimatedSplitter::show( int index, bool animate )
{
    m_animateIndex = index;

    QWidget* w = widget( index );
    QSize size = w->sizeHint();

    if ( w->height() == size.height() )
        return;

    emit shown( w );
    w->setMaximumHeight( QWIDGETSIZE_MAX );
    qDebug() << "animating to:" << size.height() << "from" << w->height();

    m_animateForward = true;
    if ( animate )
    {
        if ( m_timeLine->state() == QTimeLine::Running )
            m_timeLine->stop();

        m_timeLine->setFrameRange( w->height(), size.height() );
        m_timeLine->setDirection( QTimeLine::Forward );
        m_timeLine->start();
    }
    else
    {
        onAnimationStep( size.height() );
        onAnimationFinished();
    }
}
Esempio n. 6
0
/*
 * resizeEvent is to resize mainWindow and put search box to center
 * */
void MainWindow::resizeEvent(QResizeEvent *event) {
    QMainWindow::resizeEvent(event);
    QWidget *central = centralWidget();
    QWidget *layoutContainer = central->findChild<QWidget *>("layoutContainer");
    layoutContainer->move(QPoint((central->width() - layoutContainer->width()) / 2,
                                 (central->height() - layoutContainer->height()) / 2));
}
Esempio n. 7
0
void
AnimatedSplitter::hide( int index, bool animate )
{
    m_animateIndex = index;

    QWidget* w = widget( index );
    int minHeight = m_sizes.at( index ).height();

    if ( w->height() == minHeight )
        return;

    emit hidden( w );
    w->setMinimumHeight( minHeight );
    qDebug() << "animating to:" << w->height() << "from" << minHeight;

    m_animateForward = false;
    if ( animate )
    {
        if ( m_timeLine->state() == QTimeLine::Running )
            m_timeLine->stop();

        m_timeLine->setFrameRange( minHeight, w->height() );
        m_timeLine->setDirection( QTimeLine::Backward );
        m_timeLine->start();
    }
    else
    {
        onAnimationStep( minHeight );
        onAnimationFinished();
    }
}
void NewsDetailViewModule::updateGeometry() {
    QWidget *playlistRegion = _shell->findRegion( "PlaylistRegion" )->widget();

    if( playlistRegion != NULL ) {
        int width = _fixedWidth;
        int height = _fixedHeight;
        int widthProportional = ( int ) playlistRegion->width() * Constants::NEWSDETAILVIEW_WIDTH_PROCENT_PLAYLISTREGION / 100;
        int heightProportional = ( int ) playlistRegion->height() * Constants::NEWSDETAILVIEW_HEIGHT_PROCENT_PLAYLISTREGION / 100;

        if( width < widthProportional )
            width = widthProportional;
        else if( width > playlistRegion->width() )
            width = playlistRegion->width();

        if( height < heightProportional )
            height = heightProportional;
        else if( height > playlistRegion->height() )
            height = playlistRegion->height();

        int left = ( playlistRegion->x() + playlistRegion->width() / 2 ) - ( width / 2 );
        int top = playlistRegion->y();
        _region->widget()->move( left, top );
        _region->widget()->resize( width, height );
    }
}
Esempio n. 9
0
void TaskMTRTableView::fillView()
{
	TaskMTRTable *g = (TaskMTRTable *)node();
	ui->tableWidget->setColumnCount(g->columns().count());
	int rowcount = 0;
	for(int i=0; i<g->columns().count(); ++i)
		if (g->columns().at(i).count()>rowcount)
			rowcount = g->columns().at(i).count();
	ui->tableWidget->setRowCount(rowcount);
	ui->tableWidget->setHorizontalHeaderLabels(g->columnTitles());
	for(int i=0; i<g->columns().count(); ++i)
	{
		for(int j=0; j<g->columns().at(i).count(); ++j)
		{
			QWidget *widget = cell(g->columns().at(i)[j]);
			widget->adjustSize();
			if (widget->width() > ui->tableWidget->columnWidth(i))
				ui->tableWidget->setColumnWidth(i, widget->width());
			if (widget->height() > ui->tableWidget->rowHeight(j))
				ui->tableWidget->setRowHeight(j, widget->height());
			ui->tableWidget->setItem(j,i, new QTableWidgetItem());
			ui->tableWidget->setCellWidget(j, i, widget);
		}
		for(int j=g->columns().at(i).count(); j<ui->tableWidget->rowCount(); ++j)
		{
			QTableWidgetItem *item = new QTableWidgetItem();
			item->setFlags(0);
			ui->tableWidget->setItem(j, i, item);
		}
	}
}
void NewsDetailViewModule::getFixedSize() {
    QSize minScreenSize = getSmallestMonitorScreenSize();
    _fixedWidth = ( int ) minScreenSize.width() * Constants::NEWSDETAILVIEW_WIDTH_PROCENT_PLAYLISTREGION / 100;
    QWidget *topRegion = _shell->findRegion( "TopRegion" )->widget();
    QWidget *searchRegion = _shell->findRegion( "SearchRegion" )->widget();
    _fixedHeight = ( int )( minScreenSize.height() - topRegion->height() - searchRegion->height() - topRegion->height() )
                   * Constants::NEWSDETAILVIEW_HEIGHT_PROCENT_PLAYLISTREGION / 100;
}
Esempio n. 11
0
static void resize_container(void *_object, QWidget *cont, int w, int h)
{
	QWidget *wid = ((CWIDGET *)_object)->widget;
	#if USE_CACHE
	resize_widget(_object, w + wid->width() - cont->width(), h + wid->height() - cont->height());
	#else
	CWIDGET_resize(_object, w + wid->width() - cont->width(), h + wid->height() - cont->height());
	#endif
}
void AssureView::resize()
{
    QWidget *wParent = dynamic_cast<QWidget *>(parent());
    if (wParent) {
        setFixedHeight(wParent->height()*0.7);
        move((wParent->width() - width())/2, (wParent->height() - height())/2);
    }

    m_vbox->setAlignment(m_assure, Qt::AlignHCenter);
    m_hbox->setSpacing(m_assure->width() - 2*m_yesBtn->width());
}
Esempio n. 13
0
void MainWindow::doResize()
{
  QWidget *w = centralWidget();
  if (w->layout()==0) return;

  if (w->width() > w->height()) {
    w->setContentsMargins((w->width()-w->height())/2,0,
                          (w->width()-w->height())/2,0);
  } else {
    w->setContentsMargins(0,(w->height()-w->width())/2,
                          0,(w->height()-w->width())/2);
  }
}
Esempio n. 14
0
void LXQtGroupPopup::dropEvent(QDropEvent *event)
{
    qlonglong temp;
    QDataStream stream(event->mimeData()->data(LXQtTaskButton::mimeDataFormat()));
    stream >> temp;
    WId window = (WId) temp;

    LXQtTaskButton *button = nullptr;
    int oldIndex(0);
    // get current position of the button being dragged
    for (int i = 0; i < layout()->count(); i++)
    {
        LXQtTaskButton *b = qobject_cast<LXQtTaskButton*>(layout()->itemAt(i)->widget());
        if (b && b->windowId() == window)
        {
            button = b;
            oldIndex = i;
            break;
        }
    }

    if (button == nullptr)
        return;

    int newIndex = -1;
    // find the new position to place it in
    for (int i = 0; i < oldIndex && newIndex == -1; i++)
    {
        QWidget *w = layout()->itemAt(i)->widget();
        if (w && w->pos().y() + w->height() / 2 > event->pos().y())
            newIndex = i;
    }
    const int size = layout()->count();
    for (int i = size - 1; i > oldIndex && newIndex == -1; i--)
    {
        QWidget *w = layout()->itemAt(i)->widget();
        if (w && w->pos().y() + w->height() / 2 < event->pos().y())
            newIndex = i;
    }

    if (newIndex == -1 || newIndex == oldIndex)
        return;

    QVBoxLayout * l = qobject_cast<QVBoxLayout *>(layout());
    l->takeAt(oldIndex);
    l->insertWidget(newIndex, button);
    l->invalidate();

}
Esempio n. 15
0
ZLQtWaitMessage::ZLQtWaitMessage(const std::string &message) : QWidget(0, 0, WType_Popup) {
	resize(1, 1);
	QHBoxLayout layout(this, 24);
	QLabel *label = new QLabel(::qtString(message), this);
	layout.add(label);

	qApp->processEvents();

	QWidget *root = QApplication::desktop();
	move(root->width() / 2 - width() / 2, root->height() / 2 - height() / 2);
	show();
	move(root->width() / 2 - width() / 2, root->height() / 2 - height() / 2);

	qApp->processEvents();
}
Esempio n. 16
0
QRectF SceneWidgetContainer::boundingRect() const
{
    if(!childproxy)
        return QRectF();
    QWidget *childwidget = childproxy->widget();
    return QRectF(-10, -50, childwidget->width()+20, childwidget->height()+60);
}
Esempio n. 17
0
  void
  TreeCanvas::zoomToFit(void) {
    QMutexLocker locker(&layoutMutex);
    if (root != NULL) {
      BoundingBox bb;
      bb = root->getBoundingBox();
      QWidget* p = parentWidget();
      if (p) {
        double newXScale =
          static_cast<double>(p->width()) / (bb.right - bb.left +
                                             Layout::extent);
        double newYScale =
          static_cast<double>(p->height()) / (root->getShape()->depth() * 
                                              Layout::dist_y +
                                              2*Layout::extent);
        int scale0 = static_cast<int>(std::min(newXScale, newYScale)*100);
        if (scale0<LayoutConfig::minScale)
          scale0 = LayoutConfig::minScale;
        if (scale0>LayoutConfig::maxAutoZoomScale)
          scale0 = LayoutConfig::maxAutoZoomScale;

        if (!smoothScrollAndZoom) {
          scaleTree(scale0);
        } else {
          zoomTimeLine.stop();
          int zoomCurrent = static_cast<int>(scale*100);
          int targetZoom = scale0;
          targetZoom = std::min(std::max(targetZoom, LayoutConfig::minScale),
                                LayoutConfig::maxAutoZoomScale);
          zoomTimeLine.setFrameRange(zoomCurrent,targetZoom);
          zoomTimeLine.start();
        }
      }
    }
  }
void
MainWindow::resizeEvent(QResizeEvent *event)
{
	QMainWindow::resizeEvent(event);
	QWidget *w = graphics_view;
	graphics_scene->setSceneRect(0.0, 0.0,w->width(),w->height());
}
Esempio n. 19
0
void UBFloatingPalette::moveInsideParent(const QPoint &position)
{
    QWidget *parent = parentWidget();

    if (parent)
    {
        int margin = UBSettings::boardMargin - border();
        qreal newX = qMax(margin, qMin(parent->width() - getParentRightOffset() - width() - margin, position.x()));
        qreal newY = qMax(margin, qMin(parent->height() - height() - margin, position.y()));

        if (!mCustomPosition && !mIsMoving)
        {
            if (mDefaultPosition == Qt::TopLeftCorner || mDefaultPosition == Qt::BottomLeftCorner)
            {
                newX = margin;
            }
            else
            {
                newX = qMax(margin, parent->width() - getParentRightOffset() - width() - margin);
            }
        }
        move(newX, newY);
        minimizePalette(QPoint(newX, newY));
    }
    else
    {
        move(position);
    }
}
Esempio n. 20
0
Splash::Splash()
{
    ::init(&data, Splash_Params);
    pSplash = this;
    wnd = NULL;
    string part;
    string file = buildFileName(SPLASH_CONF);
    QFile fs(QString::fromLocal8Bit(file.c_str()));
    if (fs.open(IO_ReadOnly))
        ::load(&data, Splash_Params, fs, part);
    if (isShow()){
        QPixmap pict(QString::fromLocal8Bit(app_file(getPicture())));
        if (!pict.isNull()){
            wnd = new QWidget(NULL, "splash",
                              QWidget::WType_TopLevel | QWidget::WStyle_Customize |
                              QWidget::WStyle_NoBorderEx | QWidget::WStyle_StaysOnTop);
            wnd->resize(pict.width(), pict.height());
            QWidget *desktop = QApplication::desktop();
            wnd->move((desktop->width() - pict.width()) / 2, (desktop->height() - pict.height()) / 2);
            wnd->setBackgroundPixmap(pict);
            const QBitmap *mask = pict.mask();
            if (mask) wnd->setMask(*mask);
            wnd->show();
        }
    }
    MainWindow::playSound(getStartupSound());
}
void
MainWindowGraphicsView::resizeEvent(QResizeEvent *event)
{
	QGraphicsView::resizeEvent(event);
	QWidget *w = this;		
	scene()->setSceneRect(0.0, 0.0,w->width(),w->height());
}
CaptureFilePropertiesDialog::CaptureFilePropertiesDialog(QWidget &parent, CaptureFile &capture_file) :
    WiresharkDialog(parent, capture_file),
    ui(new Ui::CaptureFilePropertiesDialog)
{
    ui->setupUi(this);
    loadGeometry(parent.width() * 2 / 3, parent.height());

    ui->detailsTextEdit->setAcceptRichText(true);

    QPushButton *button = ui->buttonBox->button(QDialogButtonBox::Reset);
    if (button) {
        button->setText(tr("Refresh"));
    }

    button = ui->buttonBox->button(QDialogButtonBox::Apply);
    if (button) {
        button->setText(tr("Copy To Clipboard"));
    }

    button = ui->buttonBox->button(QDialogButtonBox::Save);
    if (button) {
        button->setText(tr("Save Comments"));
    }

    setWindowSubtitle(tr("Capture File Properties"));
    QTimer::singleShot(0, this, SLOT(updateWidgets()));
}
Esempio n. 23
0
PasswdDialog::PasswdDialog()
        : QDialog(NULL, NULL, true)
{
    bLogin = false;
    oldPassword = QString::fromLocal8Bit(pClient->Password);
    QGridLayout *lay = new QGridLayout(this, 2, 2, 10, 5);
    lblPasswd = new QLabel(i18n("Password:"******"Close"), this);
    connect(btnClose, SIGNAL(clicked()), this, SLOT(close()));
    hLay->addWidget(btnClose);
    hLay->addStretch();
    btnLogin = new QPushButton(i18n("Login"), this);
    btnLogin->setDefault(true);
    connect(btnLogin, SIGNAL(clicked()), this, SLOT(login()));
    hLay->addWidget(btnLogin);
    hLay->addStretch();
    setCaption(i18n("Invalid password"));
    textChanged("");
    QSize s = sizeHint();
    QWidget *desktop = QApplication::desktop();
    move((desktop->width() - s.width()) / 2, (desktop->height() - s.height()) / 2);
};
Esempio n. 24
0
int main(int argc, char *argv[])
{

  KAboutData aboutData( "poof2", I18N_NOOP("Poof2"),
    "0.1", description, KAboutData::License_GPL,
    "(c) 2004, Augusto Beiro", 0, 0, "*****@*****.**");
  aboutData.addAuthor("Augusto Beiro",0, "*****@*****.**");
  KCmdLineArgs::init( argc, argv, &aboutData );
  KCmdLineArgs::addCmdLineOptions( options ); // Add our own options.

  KApplication a;

  pid_t tenedor;
 
  mainWin *poof2 = new mainWin();
  


  a.setMainWidget(poof2);
  
  int wxx=poof2->width();
  int hxx=poof2->height();

  

  QWidget* tmp = QApplication::desktop();
  poof2->setGeometry(tmp->width()/2-(wxx/2),tmp->height()/2-(hxx/2),wxx, hxx);

  //poof2->show();

 return a.exec();
 
}
ZLQtWaitMessage::ZLQtWaitMessage(const std::string &message) : QWidget(0, 0, WStyle_Splash), myLabelText(::qtString(message)) {
	QWidget *main = qApp->mainWidget();
	if (main != 0) {
		myCursorIsStored = true;
		myStoredCursor = main->cursor();
		main->setCursor(Qt::waitCursor);
	} else {
		myCursorIsStored = false;
	}
	setCursor(Qt::waitCursor);

	qApp->processEvents();

	if (main == 0) {
		main = QApplication::desktop();
	}
	QPoint position = main->mapToGlobal(main->pos());
	QFontMetrics metrics = fontMetrics();
	const int w = metrics.width(myLabelText) + 20;
	const int h = metrics.height() + 20;
	resize(1, 1);
	show();
	setGeometry(
		position.x() + (main->width() - w) / 2,
		position.y() + (main->height() - h) / 2,
		w, h
	);

	qApp->processEvents();
	for (int i = 0; i < 6; ++i) {
		usleep(5000);
		qApp->processEvents();
	}
}
MusicApplicationObject::MusicApplicationObject(QObject *parent)
    : QObject(parent), m_mobileDevices(nullptr)
{
    m_supperClass = MStatic_cast(QWidget*, parent);
    QWidget *widget = QApplication::desktop();
    m_supperClass->move( (widget->width() - m_supperClass->width())/2,
                         (widget->height() - m_supperClass->height())/2 );
    M_SETTING->setValue(MusicSettingManager::ScreenSize, widget->size());

    windowStartAnimationOpacity();
    m_musicTimerAutoObj = new MusicTimerAutoObject(this);
    connect(m_musicTimerAutoObj, SIGNAL(setPlaySong(int)), parent,
                                 SLOT(setPlaySongChanged(int)));
    connect(m_musicTimerAutoObj, SIGNAL(setStopSong()), parent,
                                 SLOT(setStopSongChanged()));
#ifdef Q_OS_UNIX
    m_mobileDevicesLinux = new MusicMobileDevicesThread(this);
    connect(m_mobileDevicesLinux, SIGNAL(devicesChanged(bool)), SLOT(musicDevicesLinuxChanged(bool)));
    m_mobileDevicesLinux->start();
#elif defined Q_OS_WIN
    m_mobileDevicesLinux = nullptr;
#endif

    m_setWindowToTop = false;
    M_CONNECTION->setValue("MusicApplicationObject", this);
    M_CONNECTION->poolConnect("MusicApplicationObject", "MusicApplication");
    M_CONNECTION->poolConnect("MusicApplicationObject", "MusicEnhancedWidget");

    musicToolSetsParameter();
}
Esempio n. 27
0
QPixmap QPixmap::grabWindow(WId window, int x, int y, int w, int h)
{
    QWidget *widget = QWidget::find(window);
    if (!widget)
        return QPixmap();

    QRect grabRect = widget->frameGeometry();
    if (!widget->isWindow())
        grabRect.translate(widget->parentWidget()->mapToGlobal(QPoint()));
    if (w < 0)
        w = widget->width() - x;
    if (h < 0)
        h = widget->height() - y;
    grabRect &= QRect(x, y, w, h).translated(widget->mapToGlobal(QPoint()));

    QScreen *screen = qt_screen;
    QDesktopWidget *desktop = QApplication::desktop();
    if (!desktop)
        return QPixmap();
    if (desktop->numScreens() > 1) {
        const int screenNo = desktop->screenNumber(widget);
        if (screenNo != -1)
            screen = qt_screen->subScreens().at(screenNo);
        grabRect = grabRect.translated(-screen->region().boundingRect().topLeft());
    }

    if (screen->pixelFormat() == QImage::Format_Invalid) {
        qWarning("QPixmap::grabWindow(): Unable to copy pixels from framebuffer");
        return QPixmap();
    }

    if (screen->isTransformed()) {
        const QSize screenSize(screen->width(), screen->height());
        grabRect = screen->mapToDevice(grabRect, screenSize);
    }

    QWSDisplay::grab(false);
    QPixmap pixmap;
    QImage img(screen->base(),
               screen->deviceWidth(), screen->deviceHeight(),
               screen->linestep(), screen->pixelFormat());
    img = img.copy(grabRect);
    QWSDisplay::ungrab();

    if (screen->isTransformed()) {
        QMatrix matrix;
        switch (screen->transformOrientation()) {
        case 1: matrix.rotate(90); break;
        case 2: matrix.rotate(180); break;
        case 3: matrix.rotate(270); break;
        default: break;
        }
        img = img.transformed(matrix);
    }

    if (screen->pixelType() == QScreen::BGRPixel)
        img = img.rgbSwapped();

    return QPixmap::fromImage(img);
}
ZLQtWaitMessage::ZLQtWaitMessage(const std::string &message) : QWidget(0, Qt::SplashScreen) {
	QWidget *main = qApp->activeWindow();
	if (main != 0) {
		myMainWidget = main;
		myStoredCursor = main->cursor();
		myMainWidget->setCursor(Qt::WaitCursor);
	} else {
		myMainWidget = 0;
	}
	setCursor(Qt::WaitCursor);

	qApp->processEvents();

	QBoxLayout layout(QBoxLayout::LeftToRight, this);
	QLabel *label = new QLabel(::qtString(message), this);
	layout.addWidget(label);

	if (main == 0) {
		main = QApplication::desktop();
	}
	move(
		main->x() + main->width() / 2 - label->width() / 2 - 10,
		main->y() + main->height() / 2 - label->height() / 2 - 10
	);
	show();

	qApp->processEvents();
	usleep(5000);
	qApp->processEvents();
}
CaptureFilePropertiesDialog::CaptureFilePropertiesDialog(QWidget &parent, CaptureFile &capture_file) :
    WiresharkDialog(parent, capture_file),
    ui(new Ui::CaptureFilePropertiesDialog)
{
    ui->setupUi(this);

    // XXX Use recent settings instead
    resize(parent.width() * 2 / 3, parent.height());

    QPushButton *button = ui->buttonBox->button(QDialogButtonBox::Reset);
    if (button) {
        button->setText(tr("Refresh"));
    }

    button = ui->buttonBox->button(QDialogButtonBox::Apply);
    if (button) {
        button->setText(tr("Copy To Clipboard"));
    }

    button = ui->buttonBox->button(QDialogButtonBox::Save);
    if (button) {
        button->setText(tr("Save Comments"));
    }

    setWindowSubtitle(tr("Capture File Properties"));
    updateWidgets();
}
Esempio n. 30
0
void OCompletionBox::show()
{
    resize( sizeHint() );

    if ( d->m_parent )
    {
        //QDesktopWidget *screen = QApplication::desktop();
        QWidget *screen = QApplication::desktop();

        QPoint orig = d->m_parent->mapToGlobal( QPoint(0, d->m_parent->height()) );
            int x = orig.x();
        int y = orig.y();

        if ( x + width() > screen->width() )
            x = screen->width() - width();
        if (y + height() > screen->height() )
            y = y - height() - d->m_parent->height();

            move( x, y);
            qApp->installEventFilter( this );
    }

    // ### we shouldn't need to call this, but without this, the scrollbars
    // are pretty b0rked.
    //triggerUpdate( true );

    OListBox::show();
}