void ThemesInstallWindow::resizeEvent(QResizeEvent* e)
{
    qDebug() << "[Themes]" << e;

    QPixmap p, q;
    QSize img;
    img.setHeight(ui.themePreview->height());
    img.setWidth(ui.themePreview->width());

    p.loadFromData(imgData);
    if(p.isNull()) return;
    q = p.scaled(img, Qt::KeepAspectRatio, Qt::SmoothTransformation);
    ui.themePreview->setScaledContents(false);
    ui.themePreview->setPixmap(p);
}
void WbDlg::setGeometry() {
    // TODO: make a proper dialog
    QSize size;

    bool ok;
    size.setWidth(QInputDialog::getInteger(this, tr("Set new width:"), tr("Width:"), static_cast<int>(wbWidget_->scene()->sceneRect().width()), 10, 100000, 10, &ok));
    if(!ok)
        return;

    size.setHeight(QInputDialog::getInteger(this, tr("Set new height:"), tr("Height:"), static_cast<int>(wbWidget_->scene()->sceneRect().height()), 10, 100000, 10, &ok));
    if(!ok)
        return;

    wbWidget_->setSize(size);
}
QSize
PlaylistItemDelegate::sizeHint( const QStyleOptionViewItem& option, const QModelIndex& index ) const
{
    QSize size = QStyledItemDelegate::sizeHint( option, index );

    {
        if ( m_model->style() != PlayableProxyModel::SingleColumn )
        {
            int rowHeight = option.fontMetrics.height() * 1.6;
            size.setHeight( rowHeight );
        }
    }

    return size;
}
Exemple #4
0
void SAQwtSymbolSetWidget::onSpinBoxSizeXValueChanged(int v)
{
    if(m_signalLock)
    {
        return;
    }
    QSize symbolSize;
    if(ui->toolButtonFixWidthHeight->isChecked())
    {
        symbolSize.setWidth(v);
        symbolSize.setHeight(v);
        m_signalLock = true;
        ui->spinBoxSizeY->setValue(v);
        m_signalLock = false;
    }
    else
    {
        symbolSize.setWidth(ui->spinBoxSizeX->value());
        symbolSize.setHeight(ui->spinBoxSizeY->value());
    }
    m_symbol.setSize(symbolSize);
    updateSymbol();
    emit symbolSetChanged(m_symbol);
}
Exemple #5
0
QSize userlayout::set_size()    // расчет размеров превьюшки
{
   QSize z;
   const float k = 1.4285714;   // отношение высоты к длине
   float h, w, h1, w1;
   w1=ui->label->width()/ul_hor;
   h1=ui->label->height()/ul_ver;
   h=h1;
   w=w1;
   if (w1*k>h1)   w=h1/k;
   else           h=w1*k;
   z.setWidth(w);
   z.setHeight(h);
   return z;
}
static inline QSize qwtScreenResolution()
{
    static QSize screenResolution;
    if ( !screenResolution.isValid() )
    {
        QDesktopWidget *desktop = QApplication::desktop();
        if ( desktop )
        {
            screenResolution.setWidth( desktop->logicalDpiX() );
            screenResolution.setHeight( desktop->logicalDpiY() );
        }
    }

    return screenResolution;
}
QSize LocationFilterDelegate::sizeHint(const QStyleOptionViewItem &option, const QModelIndex &index) const
{
	QFont fontBigger = qApp->font();
	fontBigger.setPointSize(fontBigger.pointSize() + 2);
	fontBigger.setBold(true);

	QFontMetrics fmBigger(fontBigger);

	QFont fontSmaller = qApp->font();
	QFontMetrics fmSmaller(fontSmaller);

	QSize retSize = QStyledItemDelegate::sizeHint(option, index);
	retSize.setHeight(fmBigger.boundingRect("Yellow House").height() + 5 /*spacing*/ + fmSmaller.boundingRect("Yellow House").height());
	return retSize;
}
Exemple #8
0
void KNHelper::restoreWindowSize(const QString &name, QWidget *d, const QSize &defaultSize)
{
    KConfig *c = knGlobals.config();
    c->setGroup("WINDOW_SIZES");

    QSize s = c->readSizeEntry(name, &defaultSize);

    if(s.isValid())
    {
        QRect max = KGlobalSettings::desktopGeometry(QCursor::pos());
        if(s.width() > max.width()) s.setWidth(max.width() - 5);
        if(s.height() > max.height()) s.setHeight(max.height() - 5);
        d->resize(s);
    }
}
QSize QToolBarAreaLayoutItem::sizeHint() const
{
    if (skip())
        return QSize(0, 0);

    QWidget *wid = widgetItem->widget();
    QSize s = wid->sizeHint().expandedTo(wid->minimumSizeHint());
    if (wid->sizePolicy().horizontalPolicy() == QSizePolicy::Ignored)
        s.setWidth(0);
    if (wid->sizePolicy().verticalPolicy() == QSizePolicy::Ignored)
        s.setHeight(0);
    s = s.boundedTo(wid->maximumSize())
        .expandedTo(wid->minimumSize());
    return s;
}
QSize KOTodoRichTextDelegate::sizeHint( const QStyleOptionViewItem &option,
                                        const QModelIndex &index ) const
{
  QSize ret = QStyledItemDelegate::sizeHint( option, index );
  if ( index.data( KOTodoModel::IsRichTextRole ).toBool() ) {
    m_textDoc->setHtml( index.data().toString() );
    ret = ret.expandedTo( m_textDoc->size().toSize() );
  }
  // limit height to max. 2 lines
  // TODO add graphical hint when truncating! make configurable height?
  if ( ret.height() > option.fontMetrics.height() * 2 ) {
    ret.setHeight( option.fontMetrics.height() * 2 );
  }
  return ret;
}
QSize TransferListDelegate::sizeHint(const QStyleOptionViewItem & option, const QModelIndex & index) const {
  QSize size = QItemDelegate::sizeHint(option, index);

  static int icon_height = -1;
  if (icon_height == -1) {
    QIcon icon(":/Icons/skin/downloading.png");
    QList<QSize> ic_sizes(icon.availableSizes());
    icon_height = ic_sizes[0].height();
  }

  if (size.height() < icon_height)
    size.setHeight(icon_height);

  return size;
}
Exemple #12
0
QSize TaskDelegate::sizeHint(const QStyleOptionViewItem &option, const QModelIndex &index) const
{
    QStyleOptionViewItemV4 opt = option;
    initStyleOption(&opt, index);


    QFontMetrics fm(option.font);
    QSize s;
    s.setWidth(option.rect.width());
    const QAbstractItemView * view = qobject_cast<const QAbstractItemView *>(opt.widget);
    TaskModel *model = static_cast<TaskModel *>(view->model());
    int width = opt.rect.width() - model->sizeOfFile() - model->sizeOfLineNumber() - 12 - 22;
    if (view->selectionModel()->currentIndex() == index) {
        QString description = index.data(TaskModel::Description).toString();
        // Layout the description
        int leading = fm.leading();
        int height = 0;
        QTextLayout tl(description);
        tl.beginLayout();
        while (true) {
            QTextLine line = tl.createLine();
            if (!line.isValid())
                break;
            line.setLineWidth(width);
            height += leading;
            line.setPosition(QPoint(0, height));
            height += static_cast<int>(line.height());
        }
        tl.endLayout();

        s.setHeight(height + leading + fm.height() + 3);
    } else {
        s.setHeight(fm.height() + 3);
    }
    return s;
}
Exemple #13
0
void TabPreview::showOnRect(const QRect &r)
{
    if (m_animation->state() == QPropertyAnimation::Running) {
        m_animation->stop();
    }

    QRect oldGeometry = geometry();
    bool wasVisible = isVisible();

    resize(QSize(250, 170));
    QFrame::show();

    QRect finishingGeometry;

    if (m_pixmap->isVisible()) {
        m_title->setWordWrap(false);
        m_title->setText(m_title->fontMetrics().elidedText(m_title->text(), Qt::ElideRight, 240));

        QSize previewSize(250, 170);
        finishingGeometry = QRect(calculatePosition(r, previewSize), previewSize);
    }
    else {
        m_title->setWordWrap(true);

        QSize previewSize = sizeHint();
        previewSize.setWidth(qMin(previewSize.width() + 2 * 5, 240));
        previewSize.setHeight(qMin(previewSize.height() + 2 * 5, 130));

        finishingGeometry = QRect(calculatePosition(r, previewSize), previewSize);
    }

    if (!m_animationsEnabled) {
        m_opacityEffect->setOpacity(1.0);
        QFrame::setGeometry(finishingGeometry);
        return;
    }
    else {
        showAnimated();
    }

    if (!wasVisible) {
        oldGeometry = finishingGeometry;
    }

    setFinishingGeometry(oldGeometry, finishingGeometry);
    m_animation->start();

}
Exemple #14
0
QSize TabBar::tabSizeHint(int index) const
{
    if (!isVisible()) {
        return QSize(-1, -1);
    }

    const int maxWidth = 250;
    const int minWidth = 100;
    const int minHeight = 27;

    TabBar* tabBar = const_cast<TabBar*>(this);

    QSize size = QTabBar::tabSizeHint(index);
    size.setHeight(qMax(size.height(), minHeight));

    int availableWidth = width() - (m_addTabButton->isVisible() ? m_addTabButton->width() : 0);
    int tabCount = count();
    int boundedWidthForTab = maxWidth;
    int activeTabWidth = boundedWidthForTab;

    if (tabCount > 0) {
        boundedWidthForTab = qBound(minWidth, availableWidth / tabCount, maxWidth);
        if (index == currentIndex()) {
            activeTabWidth = qBound(boundedWidthForTab, availableWidth - (tabCount - 1) * boundedWidthForTab, maxWidth);
            size.setWidth(activeTabWidth);
        }
        else {
            size.setWidth(boundedWidthForTab);
        }
    }

    if (index == tabCount - 1) {
        if (tabCount * boundedWidthForTab > availableWidth) {
            m_addTabButton->hide();
        }
        else {
            int addTabButtonX = (tabCount - 1) * boundedWidthForTab + activeTabWidth;

            if (isRightToLeft()) {
                addTabButtonX = width() - addTabButtonX;
            }

            tabBar->moveAddTabButton(addTabButtonX);
            m_addTabButton->show();
        }
    }
    return size;
}
Exemple #15
0
void MainWindow::updateGeometry()
{
    const Position position = m_settings->position();
    QSize size = m_settings->windowSize();

    m_mainPanel->setFixedSize(size);
    m_mainPanel->updateDockPosition(position);
    m_mainPanel->updateDockDisplayMode(m_settings->displayMode());

    if (m_settings->hideState() == Hide)
    {
        m_sizeChangeAni->stop();
        m_posChangeAni->stop();
        switch (position)
        {
        case Top:
        case Bottom:    size.setHeight(1);      break;
        case Left:
        case Right:     size.setWidth(1);       break;
        }
        QWidget::setFixedSize(size);
    }
    else
    {
        setFixedSize(size);
    }

    //    const QRect primaryRect = m_settings->primaryRect();
    //    const int offsetX = (primaryRect.width() - size.width()) / 2;
    //    const int offsetY = (primaryRect.height() - size.height()) / 2;

    //    switch (position)
    //    {
    //    case Top:
    //        move(primaryRect.topLeft().x() + offsetX, primaryRect.y());                   break;
    //    case Left:
    //        move(primaryRect.topLeft().x(), primaryRect.y() + offsetY);                   break;
    //    case Right:
    //        move(primaryRect.right() - size.width() + 1, primaryRect.y() + offsetY);      break;
    //    case Bottom:
    //        move(primaryRect.x() + offsetX, primaryRect.bottom() - size.height() + 1);    break;
    //    default:
    //        Q_ASSERT(false);
    //    }
    const QRect windowRect = m_settings->windowRect(position, m_settings->hideState() == Hide);
    move(windowRect.x(), windowRect.y());
    m_mainPanel->update();
}
Exemple #16
0
//------------------------------------------------------------------------------
// Name: BitButton
// Desc: constructor
//------------------------------------------------------------------------------
BitButton::BitButton(QWidget *parent) : QAbstractButton(parent), on_(false) {

	// too many bits for tab focus
	setFocusPolicy(Qt::ClickFocus);

	// size button by font
	QSize size = fontMetrics().size(0, QLatin1String("M"));
	
	if (size.width() < size.height()) {
		size.setHeight(size.width());
	} else {
		size.setWidth(size.height());
	}
	
	setFixedSize(size.expandedTo(QApplication::globalStrut()));
}
Exemple #17
0
QPixmap MainWindow::scalePixmap(QPixmap *pixmapOriginal, float scale)
{
    QSize   scaledsize = QSize(pixmapOriginal->size());
    scaledsize.setHeight(scaledsize.height()*scale);
    scaledsize.setWidth(scaledsize.width()*scale);
    QPixmap scaledPixmap(scaledsize);
    scaledPixmap.fill(Qt::transparent);
    QPainter p(&scaledPixmap);
    p.setRenderHint(QPainter::Antialiasing);
    p.setRenderHint(QPainter::SmoothPixmapTransform);
    p.setRenderHint(QPainter::HighQualityAntialiasing);
    p.scale(scale,scale);
    p.drawPixmap(0, 0, *pixmapOriginal);
    p.end();
    return scaledPixmap;
}
Exemple #18
0
QSize SizeFitter::getOrientedTargetSize(const QSize &size) const
{
    QSize result;

    if (isFitOptionEnabled(FitOption::RespectOrientation) &&
        size.width() < size.height() &&
        d->targetSize.width() > d->targetSize.height()) {
        // make 'size' and 'target' have the same orientation
        result.setWidth(d->targetSize.height());
        result.setHeight(d->targetSize.width());
    } else {
        result = d->targetSize;
    }

    return result;
}
Exemple #19
0
void PopupWindow::setWindowGeometry(const QRect &newRect)
{
    if (newRect.isValid()) {
        QRect oldRect = rect();
        move(newRect.topLeft());

        QSize newSize = newRect.size();
        int additionalHeight = height() - m_view->height();
        newSize.setHeight(newSize.height() + additionalHeight);
        resize(newSize);

        if (newRect.topLeft() == QPoint(0, 0) && oldRect.topLeft() == QPoint(0, 0)) {
            qz_centerWidgetOnScreen(this);
        }
    }
}
void MultipleChoiceWidget::addButton() {
    QSize newSize = this->size();
    QRadioButton * button = new QRadioButton(tr("Insert Text: New"), this);
    //QFont *font = new QFont("Arial", 100);
    //button->setFont(*font);
    correctButtonSize(button);
    questions->append(button);
    box->addButton(button);
    gridLayoutButtonGroup->addWidget(button);
    if (button->width() > this->width())
        newSize.setWidth(button->width());
    newSize.setHeight(questions->size() * button->height());
    this->resize(newSize);
    button->show();
    this->update();
}
Exemple #21
0
int main(int argc, char *argv[])
{
    QGuiApplication app(argc, argv);

    QtQuick2ApplicationViewer viewer;
    viewer.setMainQmlFile(QStringLiteral("qml/testCacheName/main.qml"));
    viewer.showExpanded();

    QSize requestSize;
    requestSize.setHeight(200);
    requestSize.setWidth(200);
    qDebug() << "++++aaaaaaaa" << cacheKey("/home/mengcong/Pictures/1.jpg", requestSize);
    qDebug() << "++++bbbbbbbb" << cacheKey("/home/mengcong/Pictures/1.jpg", requestSize);

    return app.exec();
}
Exemple #22
0
QString ImageBuilder::createImageFromClipboard()
{
    QSize sz = KisClipboard::instance()->clipSize();
    KisPaintDeviceSP clipDevice = KisClipboard::instance()->clip(QRect(0, 0, sz.width(), sz.height()), false);

    if (clipDevice) {
        connect(DocumentManager::instance(), SIGNAL(documentChanged()), SLOT(createImageFromClipboardDelayed()));
        DocumentManager::instance()->newDocument(sz.width(), sz.height(), 1.0);
    }
    else {
        sz.setWidth(qApp->desktop()->width());
        sz.setHeight(qApp->desktop()->height());
        DocumentManager::instance()->newDocument(sz.width(), sz.height(), 1.0f);
    }
    return QString("temp://%1x%2").arg(sz.width()).arg(sz.height());
}
Exemple #23
0
QSize PictButton::sizeHint() const
{
#if QT_VERSION > 300
    int wChar = QFontMetrics(font()).width('0');
    QSize p = QToolButton:: sizeHint();
    QToolBar *bar = static_cast<QToolBar*>(parent());
    if (bar->orientation() == Vertical){
        p.setHeight(p.height() + 2 * wChar + 16);
    }else{
        p.setWidth(p.width() + 2 * wChar + 16);
    }
    return p;
#else
    return  QToolButton:: minimumSizeHint();
#endif
}
void PrimeSieveGUI::initGUI() {
  this->setWindowTitle(APPLICATION_NAME + " " + PRIMESIEVE_VERSION);
  this->createMenu(primeText_);

  // fill sieveSizeComboBox with power of 2 values <= "4096 KiB"
  for (int i = MINIMUM_SIEVE_SIZE; i <= MAXIMUM_SIEVE_SIZE; i *= 2)
    ui->sieveSizeComboBox->addItem(QString::number(i) + " KiB");

  int sieveSize = get_sieve_size();
  this->setTo(ui->sieveSizeComboBox, QString::number(sieveSize) + " KiB");

  maxThreads_ = ParallelSieve::getMaxThreads();

  std::set<int> threads;
  threads.insert(maxThreads_);

  if (maxThreads_ >= 2)
    threads.insert(maxThreads_ / 2);

  for (int i = 1; i < maxThreads_; i *= 2)
    threads.insert(i);

  // fill ComboBox with thread values
  for (int n : threads)
    ui->threadsComboBox->addItem(QString::number(n));

  this->setTo(ui->threadsComboBox, "1");

  // set an ideal ComboBox width
  int width = ui->sieveSizeComboBox->minimumSizeHint().width();
  ui->sieveSizeComboBox->setFixedWidth(width);
  ui->threadsComboBox->setFixedWidth(width);

  // set a nice GUI size
  QSize size = this->sizeHint();
  size.setWidth(this->minimumSizeHint().width());
#if defined(Q_OS_WIN)
  size.setHeight(size.height() - (size.height() / 20));
#endif
  this->resize(size);

  // limit input for arithmetic expressions
  QRegExp rx("[0-9\\+\\-\\*\\/\\%\\^\\(\\)\\e\\E]*");
  validator_ = new QRegExpValidator(rx, this);
  ui->lowerBoundLineEdit->setValidator(validator_);
  ui->upperBoundLineEdit->setValidator(validator_);
}
Exemple #25
0
bool DkResizeBatch::prepareProperties(const QSize& imgSize, QSize& size, float& scaleFactor, QStringList& logStrings) const {

    float sf = 1.0f;
    QSize normalizedSize = imgSize;

    if (mMode == mode_default) {
        scaleFactor = this->mScaleFactor;
        return true;
    }
    else if (mMode == mode_long_side) {

        if (imgSize.width() < imgSize.height())
            normalizedSize.transpose();
    }
    else if (mMode == mode_short_side) {

        if (imgSize.width() > imgSize.height())
            normalizedSize.transpose();
    }
    else if (mMode == mode_height)
        normalizedSize.transpose();

    sf = this->mScaleFactor/normalizedSize.width();

    if (sf > 1.0 && this->mProperty == prop_decrease_only) {

        logStrings.append(QObject::tr("%1 I need to increase the image, but the option is set to decrease only -> skipping.").arg(name()));
        return false;
    }
    else if (sf < 1.0f && this->mProperty == prop_increase_only) {
        logStrings.append(QObject::tr("%1 I need to decrease the image, but the option is set to increase only -> skipping.").arg(name()));
        return false;
    }
    else if (sf == 1.0f) {
        logStrings.append(QObject::tr("%1 image size matches scale factor -> skipping.").arg(name()));
        return false;
    }

    size.setWidth(qRound(this->mScaleFactor));
    size.setHeight(qRound(sf*normalizedSize.height()));

    if (normalizedSize != imgSize)
        size.transpose();

    return true;
}
ImageWidget::ImageWidget(Graph *plot, const QImage& image):FrameWidget(plot),
d_save_xpm(true)
{
	d_pix = QPixmap::fromImage(image);

	QSize picSize = image.size();
	int w = plot->canvas()->width();
	if (picSize.width() > w)
		picSize.setWidth(w);

	int h = plot->canvas()->height();
	if (picSize.height() > h)
		picSize.setHeight(h);

	setSize(picSize);
	move(plot->mapToParent(plot->canvas()->pos()));
}
ImageWidget::ImageWidget(Graph *plot, const QString& fn):FrameWidget(plot),
d_save_xpm(false)
{
	if (load(fn, false)){
		QSize picSize = d_pix.size();
		int w = plot->canvas()->width();
		if (picSize.width() > w)
			picSize.setWidth(w);

		int h = plot->canvas()->height();
		if (picSize.height() > h)
			picSize.setHeight(h);

		setSize(picSize);
	}
	move(plot->mapToParent(plot->canvas()->pos()));
}
QSize TransferListDelegate::sizeHint(const QStyleOptionViewItem &option, const QModelIndex &index) const
{
    // Reimplementing sizeHint() because the 'name' column contains text+icon.
    // When that WHOLE column goes out of view(eg user scrolls horizontally)
    // the rows shrink if the text's height is smaller than the icon's height.
    // This happens because icon from the 'name' column is no longer drawn.

    static int nameColHeight = -1;
    if (nameColHeight == -1) {
        QModelIndex nameColumn = index.sibling(index.row(), TransferListModel::TR_NAME);
        nameColHeight = QItemDelegate::sizeHint(option, nameColumn).height();
    }

    QSize size = QItemDelegate::sizeHint(option, index);
    size.setHeight(std::max(nameColHeight, size.height()));
    return size;
}
Exemple #29
0
/**
 * @brief Executes the dialog and returns the result of QDialog::exec
 * @param type Type of the images (ImageDialogType)
 * @return Result of QDialog::exec
 */
int ImageDialog::exec(int type)
{
    qDebug() << "Entered, type=" << type;
    m_type = type;
    QSettings settings;
    ui->previewSizeSlider->setValue(settings.value(QString("ImageDialog/PreviewSize_%1").arg(m_type), 8).toInt());
    QSize newSize;
    newSize.setHeight(parentWidget()->size().height()-50);
    newSize.setWidth(qMin(1200, parentWidget()->size().width()-100));
    resize(newSize);

    int xMove = (parentWidget()->size().width()-size().width())/2;
    QPoint globalPos = parentWidget()->mapToGlobal(parentWidget()->pos());
    move(globalPos.x()+xMove, globalPos.y());

    return QDialog::exec();
}
Exemple #30
0
bool KPrTimeLineView::eventFilter(QObject *target, QEvent *event)
{
    if (QScrollArea *scrollArea = m_mainView->scrollArea()) {
        if (target == scrollArea && event->type() == QEvent::Resize) {
            if (QResizeEvent *resizeEvent = static_cast<QResizeEvent*>(event)) {
                const int ExtraWidth = 5;
                QSize size = resizeEvent->size();
                size.setHeight(sizeHint().height());
                int width = size.width() - (ExtraWidth +
                                            scrollArea->verticalScrollBar()->sizeHint().width());
                size.setWidth(width);
                resize(size);
            }
        }
    }
    return QWidget::eventFilter(target, event);
}