Пример #1
0
void SnapshotCanvas::adjustMaximumSize()
{
    QRectF sr = sceneRect();

    int width = sr.width() + frameWidth() * 2;
    int height = sr.height() + frameWidth() * 2;

    if (minimumWidth() > width) {
        width = minimumWidth();
    }

    if (minimumHeight() > height) {
        height = minimumHeight();
    }

    int scrollBarExtent = style()->pixelMetric(QStyle::PM_ScrollBarExtent);

    if (verticalScrollBar()->isVisible()) {
        width += scrollBarExtent + frameWidth() * 2;
    }

    if (horizontalScrollBar()->isVisible()) {
        height += scrollBarExtent + frameWidth() * 2;
    }

    setMaximumSize(width, height);
}
int PandemicWindow::hoveredEdges(QMouseEvent *event)
{
    if(minimumSize() == maximumSize()) return NoEdge;

    int edges = NoEdge;

    //left edge
    if(minimumWidth() != maximumWidth() && event->localPos().x() >= 0 && event->localPos().x() <= 8 && event->localPos().y() > 0 && event->localPos().y() <= height())
    {
        edges |= LeftEdge;
    }

    //bottom edge
    if(minimumHeight() != maximumHeight() && event->localPos().x() > 0 && event->localPos().x() < width() && event->localPos().y() > height() - 8 && event->localPos().y() <= height())
    {
        edges |= BottomEdge;
    }

    //right edge
    if(minimumWidth() != maximumWidth() && event->localPos().x() >= width() - 8 && event->localPos().x() <= width() && event->localPos().y() > 0 && event->localPos().y() <= height())
    {
        edges |= RightEdge;
    }

    //top edge
    if(minimumHeight() != maximumHeight() && event->localPos().x() > 0 && event->localPos().x() < width() && event->localPos().y() >= 0 && event->localPos().y() <= 8)
    {
        edges |= TopEdge;
    }

    return edges;
}
Пример #3
0
bool Ui::AspectRatioResizebleWnd::_onWMSizing(RECT& rc, unsigned wParam) {
    const int cw = rc.right - rc.left;
    const int ch = rc.bottom - rc.top;

    if (!_use_aspect || _aspect_ratio < 0.001f) {
        return false;
    }

    switch(wParam) {
    case WMSZ_TOP:
    case WMSZ_BOTTOM:
        {
            int w = ch * _aspect_ratio;
            if (w >= minimumWidth()) {
                rc.right = rc.left + w;
            } else {
                rc.right = rc.left + minimumWidth();

                if (wParam == WMSZ_BOTTOM)
                    rc.bottom = rc.top + minimumWidth() / _aspect_ratio;
                else
                    rc.top = rc.bottom - minimumWidth() / _aspect_ratio;
            }
        }
        break;

    case WMSZ_LEFT:
    case WMSZ_RIGHT:
        {
            int h = cw / _aspect_ratio;
            rc.bottom = rc.top + h;
        }
        break;

    case WMSZ_TOPLEFT:
    case WMSZ_TOPRIGHT:
        {
            int h = cw / _aspect_ratio;
            rc.top = rc.bottom - h;
        }
        break;

    case WMSZ_BOTTOMLEFT:
    case WMSZ_BOTTOMRIGHT:
        {
            int h = cw / _aspect_ratio;
            rc.bottom = rc.top + h;
        }
        break;

    default: return false;
    }

    return true;
}
Пример #4
0
void
GraphicsScene::mouseMoveEvent(QMouseEvent* event)
{
  if (!m_move)
    return;

  if (event->x() < c_half_pad || event->x() > (c_half_pad + minimumWidth()))
    return;

  if (event->y() < c_half_pad || event->y() > (c_half_pad + minimumHeight()))
    return;

  unsigned x = event->x() - c_half_pad;
  unsigned y = event->y() - c_half_pad;
  unsigned hdiv = (minimumHeight() - c_pad) / 2;
  unsigned vdiv = (minimumWidth() - c_pad) / 2;

  if (m_rotate == 0 || m_rotate == 180)
  {
    if (x > vdiv)
      sendAction("Pan", m_rotate == 180 ? "-1" : "1");
    else if (x < vdiv)
      sendAction("Pan", m_rotate == 180 ? "1" : "-1");
    else
      sendAction("Pan", "0");

    if (y > hdiv)
      sendAction("Tilt", m_rotate == 180 ? "-1" : "1");
    else if (y < hdiv)
      sendAction("Tilt", m_rotate == 180 ? "1" : "-1");
    else
      sendAction("Tilt", "0");
  }
  else if (m_rotate == 90 || m_rotate == 270)
  {
    if (x > vdiv)
      sendAction("Tilt", m_rotate == 90 ? "-1" : "1");
    else if (x < vdiv)
      sendAction("Tilt", m_rotate == 90 ? "1" : "-1");
    else
      sendAction("Tilt", "0");

    if (y > hdiv)
      sendAction("Pan", m_rotate == 270 ? "-1" : "1");
    else if (y < hdiv)
      sendAction("Pan", m_rotate == 270 ? "1" : "-1");
    else
      sendAction("Pan", "0");
  }

  event->accept();
}
Пример #5
0
/**
 * \brief Handle the mouse move event
 * @param as the mouse event
 */
void UBDockPalette::mouseMoveEvent(QMouseEvent *event)
{
    QPoint p = event->pos();

    if(mCanResize && ((mMousePressPos - p).manhattanLength() > QApplication::startDragDistance()))
    {
	switch(mOrientation)
	{
	case eUBDockOrientation_Left:
            if(p.x() < collapseWidth() && p.x() >= minimumWidth())
            {
                resize(border(), height());
                mLastWidth = collapseWidth() + 1;
                mResized = true;
            }
            else if(p.x() <= maximumWidth() && p.x() >= minimumWidth())
	    {
		resize(p.x(), height());
                mResized = true;
	    }
	    break;
	case eUBDockOrientation_Right:
            if((this->x() + p.x() > parentWidget()->width() - collapseWidth()) && (this->x() + p.x() < parentWidget()->width()))
            {
                resize(border(), height());
                mLastWidth = collapseWidth() + 1;
                mResized = true;
            }
            else if((this->x() + p.x() >= parentWidget()->width() - maximumWidth()) && (this->x() + p.x() <= parentWidget()->width() - this->minimumWidth()))
	    {
		resize(parentWidget()->width() - (this->x() + p.x()), height());
                mResized = true;
	    }
	    break;
	case eUBDockOrientation_Top:
	case eUBDockOrientation_Bottom:
	    if(p.y() <= maximumHeight())
	    {
		resize(width(), p.y());
                mResized = true;
	    }
	    break;

	default:
	    break;
	}
    }
}
void AddNewTorrentDialog::showAdvancedSettings(bool show)
{
    const int minimumW = minimumWidth();
    setMinimumWidth(width());  // to remain the same width
    if (show) {
        ui->adv_button->setText(QString::fromUtf8(C_UP));
        ui->settings_group->setVisible(true);
        ui->infoGroup->setVisible(true);
        if (m_hasMetadata && (m_torrentInfo.filesCount() > 1)) {
            ui->content_tree->setVisible(true);
        }
        else {
            ui->content_tree->setVisible(false);
        }
        static_cast<QVBoxLayout*>(layout())->insertWidget(layout()->indexOf(ui->never_show_cb) + 1, ui->adv_button);
    }
    else {
        ui->adv_button->setText(QString::fromUtf8(C_DOWN));
        ui->settings_group->setVisible(false);
        ui->infoGroup->setVisible(false);
        ui->buttonsHLayout->insertWidget(0, layout()->takeAt(layout()->indexOf(ui->never_show_cb) + 1)->widget());
    }
    adjustSize();
    setMinimumWidth(minimumW);
}
Пример #7
0
void Dialog::showEvent(QShowEvent *e)
{
    if (!shown) {
        shown=true;
        AcceleratorManager::manage(this);
        if (defButton) {
            setDefaultButton((ButtonCode)defButton);
        }
        if (buttonBox && mw) {
            QSize mwSize=mw->minimumSize();
            if (mwSize.width()<16 || mwSize.height()<16) {
                mwSize=mw->minimumSizeHint();
            }
            if (mwSize.width()>15 && mwSize.height()>15) {
                setMinimumHeight(qMax(minimumHeight(), buttonBox->height()+layout()->spacing()+mwSize.height()+(2*layout()->margin())));
                setMinimumWidth(qMax(minimumWidth(), mwSize.width()+(2*layout()->margin())));
            }
        }
    }
    #ifdef Q_OS_MAC
    if (!isModal()) {
        OSXStyle::self()->addWindow(this);
    }
    #endif
    QDialog::showEvent(e);
}
Пример #8
0
void KisColorPatches::resizeEvent(QResizeEvent* event)
{
    if(size()==QSize(1, 1))
        return;

    QWheelEvent dummyWheelEvent(QPoint(), 0, Qt::NoButton, Qt::NoModifier);
    wheelEvent(&dummyWheelEvent);

    if(parentWidget()==0) {
        // this instance is a popup
        setMinimumWidth(m_patchWidth*(m_patchCount/4));
        setMaximumWidth(minimumWidth());
    }

    if(m_allowScrolling == false && event->oldSize() != event->size()) {
        if(m_direction == Horizontal) {
            setMaximumHeight(heightForWidth(width()));
            setMinimumHeight(heightForWidth(width()));
        }
        else {
            setMaximumWidth(widthForHeight(height()));
            setMinimumWidth(widthForHeight(height()));
        }
    }
}
Пример #9
0
PageWidgetItem * PageWidget::addPage(QWidget *widget, const QString &name, const QIcon &icon, const QString &header)
{
    PageWidgetItem *page=new PageWidgetItem(stack, header, icon, widget, showHeaders);
    QListWidgetItem *listItem=new QListWidgetItem(name, list);
    listItem->setIcon(icon);
    stack->addWidget(page);
    list->addItem(listItem);

    int rows = list->model()->rowCount();
    int width = 0;
    for (int i = 0; i < rows; ++i) {
        QSize rowSize=list->sizeHintForIndex(list->model()->index(i, 0));
        width = qMax(width, rowSize.width());
    }

    width+=static_cast<PageWidgetItemDelegate *>(list->itemDelegate())->standardList() ? 8 : 25;
    list->setFixedWidth(width);

    QSize stackSize = stack->size();
    for (int i = 0; i < stack->count(); ++i) {
        const QWidget *widget = stack->widget(i);
        if (widget) {
            stackSize = stackSize.expandedTo(widget->minimumSizeHint());
        }
    }
    setMinimumHeight(qMax(minimumHeight(), stackSize.height()));
    setMinimumWidth(qMax(minimumWidth(), stackSize.width()+width+layout()->spacing()));

    list->setCurrentRow(0);
    stack->setCurrentIndex(0);
    pages.insert(listItem, page);

    return page;
}
Пример #10
0
void Dialog::showEvent(QShowEvent *e)
{
    if (!shown) {
        shown=true;
        QSize mwSize=mainWidget()->minimumSize();

        if (mwSize.width()<16 || mwSize.height()<16) {
            mwSize=mainWidget()->minimumSizeHint();
        }

        if (mwSize.width()>15 && mwSize.height()>15) {
            QSize btnSize(24, 32);
            for (int i=0; i<15; ++i) {
                int code=1<<i;
                KPushButton *btn=KDialog::button((KDialog::ButtonCode)code);
                if (btn) {
                    btnSize=btn->sizeHint();
                    break;
                }
            }
            QLayout *lay=layout();
            int sp=lay ? layout()->spacing() : KDialog::spacingHint();
            int mar=lay ? layout()->margin() : KDialog::marginHint();
            setMinimumHeight(qMax(minimumHeight(), btnSize.height()+sp+mwSize.height()+(2*mar)));
            setMinimumWidth(qMax(minimumWidth(), mwSize.width()+(2*mar)));
        }
    }
    KDialog::showEvent(e);
}
Пример #11
0
//设置鼠标拖动的窗口位置信息
void MainFrame::SetDrayMove(int nXGlobal,int nYGlobal,enum_Direction direction)
{
    //计算偏差
    int ndX = nXGlobal - m_ptPressGlobal.x();
    int ndY = nYGlobal - m_ptPressGlobal.y();
    //获得主窗口位置信息
    QRect rectWindow = geometry();
    //判别方向
    if(direction & eTop)
    {
        rectWindow.setTop(rectWindow.top()+ndY);
    }
    if(direction & eRight)
    {
        rectWindow.setRight(rectWindow.right()+ndX);
    }
    if(direction & eBottom)
    {
        rectWindow.setBottom(rectWindow.bottom()+ndY);
    }
    if(direction & eLeft)
    {
        rectWindow.setLeft(rectWindow.left()+ndX);
    }
    if(rectWindow.width()< minimumWidth() || rectWindow.height()<minimumHeight())
    {
        return;
    }
    //重新设置窗口位置为新位置信息
    setGeometry(rectWindow);
}
Пример #12
0
void MyWindow::setWidth(int arg)
{
    if (m_width != arg&&arg<=maximumWidth ()&&arg>=minimumWidth ()) {
        m_width = arg;
        contentItem ()->setWidth (arg);
        emit widthChanged(arg);
    }
}
Пример #13
0
bool KWidget::widthToChild()
{
    qreal minwidth = minimumWidth();
    qreal maxwidth = maximumWidth();
    if(minwidth == -1.0 && maxwidth == -1.0)
        return true;
    return false;
}
Пример #14
0
void MainWindow::resizeEvent(QResizeEvent *)
{
    int extraWidth = width() - minimumWidth();
    int extraHeight = height() - minimumHeight();

    ui->query->setGeometry(10, 10, 620 + extraWidth, 24);
    ui->results->setGeometry(10, 40, 620 + extraWidth, 410 + extraHeight);
}
Пример #15
0
QSize
ComboBox::sizeForWidth(int w) const
{
    if (minimumWidth() > 0) {
        w = std::max( w, maximumWidth() );
    }
    QSize contentsMargin;
    {
        QMargins margins = contentsMargins();
        contentsMargin.setWidth( margins.left() + margins.right() );
        contentsMargin.setHeight( margins.bottom() + margins.top() );
    }
    QRect br;

    //Using this constructor of QFontMetrics will respect the DPI of the screen, see http://doc.qt.io/qt-4.8/qfontmetrics.html#QFontMetrics-2
    QFontMetrics fm(font(), 0);
    Qt::Alignment align = QStyle::visualAlignment( Qt::LeftToRight, QFlag(_align) );
    int hextra = DROP_DOWN_ICON_SIZE * 2, vextra = 0;

    ///Indent of 1 character
    int indent = fm.width( QLatin1Char('x') );

    if (indent > 0) {
        if ( (align & Qt::AlignLeft) || (align & Qt::AlignRight) ) {
            hextra += indent;
        }
        if ( (align & Qt::AlignTop) || (align & Qt::AlignBottom) ) {
            vextra += indent;
        }
    }
    // Turn off center alignment in order to avoid rounding errors for centering,
    // since centering involves a division by 2. At the end, all we want is the size.
    int flags = align & ~(Qt::AlignVCenter | Qt::AlignHCenter);
    bool tryWidth = (w < 0) && (align & Qt::TextWordWrap);

    if (tryWidth) {
        w = std::min( fm.averageCharWidth() * 80, maximumSize().width() );
    } else if (w < 0) {
        w = 2000;
    }

    w -= ( hextra + contentsMargin.width() );

    br = fm.boundingRect(0, 0, w, 2000, flags, _currentText);

    if ( tryWidth && ( br.height() < 4 * fm.lineSpacing() ) && (br.width() > w / 2) ) {
        br = fm.boundingRect(0, 0, w / 2, 2000, flags, _currentText);
    }

    if ( tryWidth && ( br.height() < 2 * fm.lineSpacing() ) && (br.width() > w / 4) ) {
        br = fm.boundingRect(0, 0, w / 4, 2000, flags, _currentText);
    }

    const QSize contentsSize(br.width() + hextra, br.height() + vextra);

    return (contentsSize + contentsMargin).expandedTo( minimumSize() );
} // ComboBox::sizeForWidth
Пример #16
0
void Player::viewPlaylist(bool show) {
	if (show) {
		playlist_widget->setVisible(true);
		statusBar()->setVisible(true);
	} else { //TODO: fix the geometry issue of it remembering the minimum space required to show the playlist
		playlist_widget->setVisible(false);
		statusBar()->setVisible(false);
		resize(minimumWidth(), minimumHeight());
	}
}
Пример #17
0
void PandemicWindow::mouseMoveEvent(QMouseEvent *event)
{

    if(_resizing == true)
    {
        if(_resizePoint & RightEdge)
        {
            resize(event->pos().x() + _resizePos.x(), height());
        }
        if(_resizePoint & BottomEdge)
        {
            resize(width(), event->pos().y() + _resizePos.y());
        }
        if(_resizePoint & LeftEdge)
        {
            QPoint offset = QPoint(event->pos().x() - _resizePos.x(), 0);\
            if(geometry().right() - (pos().x() + offset.x()) > minimumWidth() &&
               geometry().right() - (pos().x() + offset.x()) < maximumWidth()) move(pos() + offset);
            else if(geometry().right() - (pos().x() + offset.x()) > minimumWidth()) move(geometry().right() - (maximumWidth() - 1), pos().y());
            else move(geometry().right() - (minimumWidth() - 1), pos().y());
            resize(width() - offset.x(), height() - offset.y());
        }
        if(_resizePoint & TopEdge)
        {
            QPoint offset = QPoint(0, event->pos().y() - _resizePos.y());
            if(geometry().bottom() - (pos().y() + offset.y()) > minimumHeight() &&
               geometry().bottom() - (pos().y() + offset.y()) < maximumHeight()) move(pos() + offset);
            else if(geometry().bottom() - (pos().y() + offset.y()) > minimumHeight()) move(pos().x(), geometry().bottom() - (maximumHeight() - 1));
            else move(pos().x(), geometry().bottom() - (minimumHeight() - 1));
            resize(width() - offset.x(), height() - offset.y());
        }
    }

    int edges = hoveredEdges(event);
    if(edges == LeftEdge || edges == RightEdge) _cursor.setShape(Qt::SizeHorCursor);
    else if(edges == TopEdge || edges == BottomEdge) _cursor.setShape(Qt::SizeVerCursor);
    else if(edges == (TopEdge | LeftEdge) || edges == (BottomEdge | RightEdge)) _cursor.setShape(Qt::SizeFDiagCursor);
    else if(edges == (BottomEdge | LeftEdge) || edges == (TopEdge | RightEdge)) _cursor.setShape(Qt::SizeBDiagCursor);
    else _cursor.setShape(Qt::ArrowCursor);

    setCursor(_cursor);
}
Пример #18
0
StartupDialog::StartupDialog (QWidget *parent, StartupDialogResult *result, KRecentFilesAction *recent_files) : QDialog (parent, 0, true) {
	RK_TRACE (DIALOGS);
	StartupDialog::result = result;

	setCaption (i18n ("What would you like to do?"));

	QVBoxLayout *vbox = new QVBoxLayout (this);
	
	logo = new QPixmap (KGlobal::dirs ()->findResourceDir ("data", "rkward/phpfiles/common.php") + "rkward/icons/rkward_logo.png");
	QLabel *pic = new QLabel (this);
	pic->setPixmap (*logo);
	vbox->addWidget (pic);

	choser = new QButtonGroup (this);
	choser->setColumnLayout (0, Qt::Vertical);
	choser->layout()->setSpacing (6);
	choser->layout()->setMargin (11);
	QVBoxLayout *choser_layout = new QVBoxLayout(choser->layout());
	choser_layout->addWidget (empty_workspace_button = new QRadioButton (i18n ("Start with an empty workspace"), choser));
	choser_layout->addWidget (empty_table_button = new QRadioButton (i18n ("Start with an empty table"), choser));
	open_button = new QRadioButton (i18n ("Load an existing workspace:"), choser);
	connect (open_button, SIGNAL (stateChanged (int)), this, SLOT (openButtonSelected (int)));
	empty_table_button->setChecked (true);
	choser_layout->addWidget (open_button);

	file_list = new QListView (choser);
	file_list->addColumn (i18n ("Filename"));
	file_list->setSorting (-1);
	chose_file_item = new QListViewItem (file_list, i18n ("<<Open another file>>"));
	if (recent_files) {
		QStringList items = recent_files->items ();
		for (QStringList::iterator it = items.begin (); it != items.end (); ++it) {
			if (!(*it).isEmpty ()) new QListViewItem (file_list, (*it));
		}
	}
	connect (file_list, SIGNAL (selectionChanged (QListViewItem *)), this, SLOT (listClicked (QListViewItem*)));
	connect (file_list, SIGNAL (doubleClicked (QListViewItem *, const QPoint &, int)), this, SLOT (listDoubleClicked (QListViewItem*, const QPoint &, int)));
	choser_layout->addWidget (file_list);
	choser_layout->addWidget (remember_box = new QCheckBox (i18n ("Always do this on startup"), choser));
	
	vbox->addWidget (choser);
	
	QHBoxLayout *button_hbox = new QHBoxLayout (vbox);
	ok_button = new QPushButton (i18n ("Ok"), this);
	connect (ok_button, SIGNAL (clicked ()), this, SLOT (accept ()));
	button_hbox->addWidget (ok_button);
	button_hbox->addStretch ();
	
	cancel_button = new QPushButton (i18n ("Cancel"), this);
	connect (cancel_button, SIGNAL (clicked ()), this, SLOT (reject ()));
	button_hbox->addWidget (cancel_button);

	setFixedWidth (minimumWidth ());
}
Пример #19
0
void ThFrame::dragThFrame(int x, int y, DragDirection edirection)
{
    //计算偏差
    int dX = x - globalStartPosition.x();
    int dY = y - globalStartPosition.y();
    //获得主窗口位置信息
    QRect rectWindow = geometry();
    //判别方向
    if(edirection == eTop)
    {
        rectWindow.setTop(rectWindow.top()+dY);
    }
    else if(edirection == eBottom)
    {
        rectWindow.setBottom(rectWindow.bottom()+dY);
    }
    else if(edirection == eLeft)
    {
        rectWindow.setLeft(rectWindow.left()+dX);
    }
    else if(edirection == eRight)
    {
        rectWindow.setRight(rectWindow.right()+dX);
    }
    else if (edirection == eTopLeft)
    {
        rectWindow.setTop(rectWindow.top() + dY);
        rectWindow.setLeft(rectWindow.left() + dX);
    }
    else if (edirection == eBottomRight)
    {
        rectWindow.setBottom(rectWindow.bottom() + dY);
        rectWindow.setRight(rectWindow.right() + dX);
    }
    else if (edirection == eTopRight)
    {
        rectWindow.setTop(rectWindow.top() + dY);
        rectWindow.setRight(rectWindow.right() + dX);
    }
    else if (edirection == eBottomLeft)
    {
        rectWindow.setBottom(rectWindow.bottom() + dY);
        rectWindow.setLeft(rectWindow.left() + dX);
    }


    if(rectWindow.width()< minimumWidth() || rectWindow.height()<minimumHeight())
    {
        return;
    }

    // 重新设置窗口位置为新位置信息
    setGeometry(rectWindow);
}
Пример #20
0
tikz::Value Style::minimumWidth() const
{
    if (propertySet(s_minimumWidth)) {
        return d->minimumWidth;
    }

    auto style = parentStyle().entity<Style>();
    if (style) {
        return style->minimumWidth();
    }

    return 0.0_cm;
}
Пример #21
0
void
Unicorn::TabBar::paintEvent( QPaintEvent* e )
{
    QPainter p( this );
    
    p.setClipRect( e->rect());
    if( count() <= 0 )
        return;
        
    int w = (minimumWidth() - layout()->minimumSize().width() - m_leftMargin) / count();
    for (int i = 0; i < count(); ++i)
    {
        int const x = m_leftMargin + (i * ( w + m_spacing ));
        
        if (i == count() - 1)
            w += (minimumWidth() - layout()->minimumSize().width() - m_leftMargin + 10) % w;
        
        if (currentIndex() == i)
        {
            p.setBrush( palette().brush( QPalette::Button ) );
            p.drawPixmap( x, 7, 8, m_active.height(), m_active, 0, 0, 8, m_active.height() );
            p.drawPixmap( x + 8, 7, w -16, m_active.height(), palette().brush( QPalette::Button ).texture());
            p.drawPixmap( x + w - 8, 7, 9, m_active.height(), m_active, m_active.width() / 2, 0, 9, m_active.height() );
            p.setPen( palette().color( QPalette::Active, QPalette::Text ) );
        }
        else
        {
            p.setPen( palette().color( QPalette::Inactive, QPalette::Text ) );
        }
                
        p.drawText( x, -1, w, height(), Qt::AlignCenter, tabText( i ) );
    }
    
    const int h = height() - 1;
    p.setPen( QPen( Qt::black, 0 ) );
    p.setRenderHint( QPainter::Antialiasing, false );
    p.drawLine( 0, h, width(), h );   
}
Пример #22
0
	QSize ModeTabBar::tabSizeHint() const
	{
		QFont labelFont = font();
		labelFont.setBold(true);

		QFontMetrics fm(labelFont);

		int maxWidth = minimumWidth();
		for(int i = 0; i < count(); ++i) {
			maxWidth = qMax(maxWidth, fm.width(tabLabel(i)) + 3 * tabPadding);
		}

		return QSize(maxWidth, iconSize + fm.height() + (3 * tabPadding));
	}
Пример #23
0
void TDockWidget::setDockedAppearance() {
  // No layout margin is visible when docked
  layout()->setMargin(0);

  if (m_floating)  // was floating
  {
    // Removing margin from extremal sizes
    int addition = 2 * m_margin;
    setMinimumSize(
        QSize(minimumWidth() - addition, minimumHeight() - addition));
    setMaximumSize(
        QSize(maximumWidth() - addition, maximumHeight() - addition));
  }
}
Пример #24
0
void CoverArtLabel::showArtUpdate( const QString& url )
{
    QPixmap pix;
    if( !url.isEmpty() && pix.load( url ) )
    {
        pix = pix.scaled( minimumWidth(), minimumHeight(),
                          Qt::KeepAspectRatioByExpanding,
                          Qt::SmoothTransformation );
    }
    else
    {
        pix = QPixmap( ":/noart.png" );
    }
    setPixmap( pix );
}
Пример #25
0
MainWindow::MainWindow(files_control *files) : /*QMainWindow(parent) , */ui(new Ui::MainWindow)
{
	this->files = files;
	ui->setupUi(this);

	resize(minimumWidth(), minimumHeight());

	seznam_ = new seznam();
	PV = new long double(0);
	R = new double(0);
	T = new unsigned short int(0);
	popl = new double(0);
	popl_last = new double(0);
	vysledna_hodnota = new QString();

	ui->r_line->hide();
	ui->r_label_3->hide();

	ui->poplatek_line->hide();
	ui->skutecny_label->hide();
	ui->procento->hide();

	ui->poplatek_line->setText("0,00");

	//********** doplnovani comboboxu ************
	for(int i = 0; i < 13; i++)
	{
	   ui->r_combo->addItem(QString("MIX %1: %2 %3").arg(i+1).arg(files->PA(i),6, 'f', 2).arg("p.a.", 5));
	}
	ui->r_combo->addItem(QString::fromUtf8("Vlastní hodnota"));

	//********** dosazovani hodnot ************
	connect(this->ui->r_combo, SIGNAL(currentIndexChanged(int)), this , SLOT(rLineVlastniSelected(int)));
	connect(this->ui->pv_line, SIGNAL(textChanged(QString)), this , SLOT(setPV(QString)));
	connect(this->ui->t_line, SIGNAL(textChanged(QString)), this, SLOT(setT(QString)));
	connect(this->ui->r_line, SIGNAL(textChanged(QString)), this, SLOT(setR(QString)));
	connect(this, SIGNAL(anyValueChanged()), this, SLOT(calculate()));
	connect(this->ui->otaznik_button, SIGNAL(clicked()), this, SLOT(otaznikClick()));
	connect(this->ui->action_close_window, SIGNAL(triggered()), this, SLOT(close()));
	connect(this->ui->poplatek_check, SIGNAL(clicked()), this, SLOT(poplatekChecked()));
	connect(this->ui->poplatek_line, SIGNAL(textChanged(QString)), this, SLOT(setPopl(QString)));

	rLineVlastniSelected(1);

	this->setWindowTitle(APP_NAME);

	this->ui->otaznik_button->setIcon(QIcon(QPixmap(":/img/info.png")));
}
Пример #26
0
void PopupWidget::anchorTo(QWidget *widget)
{
    QPoint globalPos = widget->mapToGlobal(widget->mapFromParent(widget->pos()));
    QPoint myPos = mapFromGlobal(globalPos);

    if(m_arrowPosition == Bottom) {
        move(myPos.x() - minimumWidth() / 2 + widget->width() / 2,
             myPos.y() - minimumHeight() - widget->height() + 40);
    }
    else if(m_arrowPosition == Left) {
        move(myPos.x() + widget->width() - 25,
             myPos.y() - minimumHeight() / 2 + 8);
    }

    m_anchorWidget = widget;
}
Пример #27
0
void
Unicorn::TabBar::mousePressEvent( QMouseEvent* e )
{
    if (e->button() != Qt::LeftButton) {
        e->ignore();
        return;
    }
    
    m_mouseDownPos = e->pos();
    
    int w = (minimumWidth() - layout()->minimumSize().width() - m_leftMargin) / count();
    
    int index = ( (e->pos().x() - m_leftMargin ) / (w + m_spacing ));

    if( index < count() )
        setCurrentIndex( index );
}
Пример #28
0
void QExpandingLineEdit::resizeToContents()
{
    int oldWidth = width();
    if (originalWidth == -1)
        originalWidth = oldWidth;
    if (QWidget *parent = parentWidget()) {
        QPoint position = pos();
        int hintWidth = minimumWidth() + fontMetrics().width(displayText());
        int parentWidth = parent->width();
        int maxWidth = isRightToLeft() ? position.x() + oldWidth : parentWidth - position.x();
        int newWidth = qBound(originalWidth, hintWidth, maxWidth);
        if (widgetOwnsGeometry)
            setMaximumWidth(newWidth);
        if (isRightToLeft())
            move(position.x() - newWidth + oldWidth, position.y());
        resize(newWidth, height());
    }
}
Пример #29
0
void TDockWidget::setFloatingAppearance() {
  if (m_titlebar) {
    // If has a custom title bar, impose a margin to the layout
    // to provide a frame.
    layout()->setMargin(m_margin);

    if (!m_floating)  // was docked
    {
      // Adding margin to extremal sizes
      int addition = 2 * m_margin;
      setMinimumSize(
          QSize(minimumWidth() + addition, minimumHeight() + addition));
      setMaximumSize(
          QSize(maximumWidth() + addition, maximumHeight() + addition));
    }
  }
  // else
  //  setWindowFlags(Qt::Tool);
}
Пример #30
0
void EntryDlg::slotDockVertical()
{
  if (!docked) {
    oldMainPos = mainwin->pos();
    oldMainSize = mainwin->size();
    docked = true;
  }

  KWinModule info;
  QRect rect = info.workArea();

  int diff_x = frameGeometry().width()-width();
  int diff_y = frameGeometry().height()-height();
  resize(minimumWidth(), rect.height()-diff_y);
  mainwin->resize(rect.width()-frameGeometry().width()-diff_x,
                  rect.height()-diff_y);
  move (0, 0);
  mainwin->move(frameGeometry().width(), 0);
}