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; }
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(); }
//设置鼠标拖动的窗口位置信息 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); }
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); }
void QTFAbstractPanel::toggleHide() { m_isHidden = !m_isHidden; if(m_isHidden) { m_showButton->setIcon(m_checked); m_origHeight = height(); m_origMinimumHeight = minimumHeight(); if(m_widgets && !m_widgets->empty()) { for(int i = 0; i < m_widgets->size();i++) { m_origHeight += (*m_widgets)[i]->height(); m_origMinimumHeight += (*m_widgets)[i]->minimumHeight(); (*m_widgets)[i]->hide(); } } minSize = minimumSize(); maxSize = maximumSize(); //m_pTFEditor->setMinimumHeight(0); setFixedHeight(20); m_pTFEditor->setMinimumHeight(m_pTFEditor->minimumHeight() - (m_origMinimumHeight - 20)); m_pTFEditor->resize(m_pTFEditor->width(), m_pTFEditor->height() + 20 - m_origHeight); } else { m_showButton->setIcon(m_unchecked); if(m_widgets && !m_widgets->empty()) { for(int i = 0; i < m_widgets->size(); i++) { (*m_widgets)[i]->show(); } } setMinimumSize(minSize); setMaximumSize(maxSize); m_pTFEditor->resize(m_pTFEditor->width(), m_pTFEditor->height() + m_origHeight - 20); m_pTFEditor->setMinimumHeight(m_pTFEditor->minimumHeight() + (m_origMinimumHeight - 20)); //m_pTFEditor->setMinimumHeight(m_pTFEditor->minimumHeight() + (m_origHeight - 20)); } repaint(); }
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); }
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; }
OpenRecent::OpenRecent(QWidget *parent) : QDialog(parent), ui(new Ui::OpenRecent), itemModel(0), exitEarly(false) { ui->setupUi(this); connect(ui->browseBtn, SIGNAL(clicked()), this, SLOT(browseForFile())); connect(this, SIGNAL(accepted()), this, SLOT(processAccepted())); connect(this, SIGNAL(rejected()), this, SLOT(processRejected())); connect(ui->fileLineEdit, SIGNAL(textChanged(QString)), this, SLOT(processFileNameChanged(QString))); recentFiles = RecentFile::recentFilesList(); // Use the last used directory for opening an image file or the user's // home as base path. recentPath = QSettings().value("recentPath", QDir::homePath()).toString(); // Don't show recent files list if there aren't any. if (recentFiles.size() == 0) { ui->recentFilesListView->hide(); ui->recentFilesListViewLabel->hide(); this->resize(sizeHint().width(), minimumHeight()); // trigger update ui->fileLineEdit->setText(QString()); } else { initRecentFilesUi(); } }
void OnyxSearchDialog::adjustSizeAndPosition() { // Change size at first. int x = 0, y = 0; QWidget *parent = safeParentWidget(parentWidget()); QRect parent_rect = parent->rect(); if (mode() == MODE_FULL) { setFixedSize(parent_rect.width(), minimumHeight()); } else if (mode() == MODE_NEXT_PREV) { setFixedSize(parent_rect.width(), defaultItemHeight() * 2 + 2 *SPACING); } else if (mode() == MODE_SEARCHING) { setFixedSize(parent_rect.width(), defaultItemHeight() * 2 + 2 *SPACING); } y = parent->height() - height(); if (sys::isIRTouch()) { y -= ui::statusBarHeight(); } move(x, y); }
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; }
TranscoderOptionsDialog::TranscoderOptionsDialog(Song::FileType type, QWidget* parent) : QDialog(parent), ui_(new Ui_TranscoderOptionsDialog), options_(NULL) { ui_->setupUi(this); switch (type) { case Song::Type_Flac: case Song::Type_OggFlac: options_ = new TranscoderOptionsFlac(this); break; case Song::Type_Mp4: options_ = new TranscoderOptionsAAC(this); break; case Song::Type_Mpeg: options_ = new TranscoderOptionsMP3(this); break; case Song::Type_OggVorbis: options_ = new TranscoderOptionsVorbis(this); break; case Song::Type_OggOpus: options_ = new TranscoderOptionsOpus(this); break; case Song::Type_OggSpeex: options_ = new TranscoderOptionsSpeex(this); break; case Song::Type_Asf: options_ = new TranscoderOptionsWma(this); break; default: break; } if (options_) { setWindowTitle(windowTitle() + " - " + Song::TextForFiletype(type)); options_->layout()->setContentsMargins(0, 0, 0, 0); ui_->verticalLayout->insertWidget(0, options_); resize(width(), minimumHeight()); } }
QSize MsgView::sizeHint() const { QSize s = QListView::sizeHint(); s.setHeight(minimumHeight()); return s; }
int JItem::j_getPreferredHeight() { QSize hint = sizeHint(); if (hint.isValid()) return hint.height(); else return minimumHeight(); }
bool KWidget::heightToChild() { qreal minwidth = minimumHeight(); qreal maxwidth = maximumHeight(); if(minwidth == -1.0 && maxwidth == -1.0) return true; return false; }
void MyWindow::setHeight(int arg) { if (m_height != arg&&arg<=maximumHeight ()&&arg>=minimumHeight ()) { m_height = arg; contentItem ()->setHeight (arg); emit heightChanged(arg); } }
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); }
HostDialog::HostDialog(QWidget *parent) : QDialog(parent) { setupUi(this); my.nssGuiStarted = false; my.advancedState = false; my.advancedString = advancedPushButton->text(); my.originalHeight = geometry().height(); my.minimalHeight = minimumHeight(); changedAdvancedState(); }
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()); } }
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); }
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); }
KexiDBCheckBox::KexiDBCheckBox(const QString &text, QWidget *parent) : QCheckBox(text, parent), KexiFormDataItemInterface() , m_invalidState(false) , m_tristateChanged(false) , m_tristate(TristateDefault) { setFocusPolicy(Qt::StrongFocus); setMinimumHeight(sizeHint().height()); setMinimumWidth(minimumHeight()); updateTristate(); connect(this, SIGNAL(stateChanged(int)), this, SLOT(slotStateChanged(int))); }
tikz::Value Style::minimumHeight() const { if (propertySet(s_minimumHeight)) { return d->minimumHeight; } auto style = parentStyle().entity<Style>(); if (style) { return style->minimumHeight(); } return 0.0_cm; }
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)); } }
// uses sizeHint->minimumHeight int JItem::j_getPreferredHeight() { if (MidpFormInSingleItemMode(form->toMidpDisplayable())) { qDebug("MidpFormInSingleItemMode"); return form->viewportHeight(); } QSize hint = sizeHint(); if (hint.isValid()) return hint.height(); else return minimumHeight(); }
void BookmarkDialog::toolButtonClicked() { bool visible = !ui.treeView->isVisible(); ui.treeView->setVisible(visible); ui.newFolderButton->setVisible(visible); if (visible) { resize(QSize(width(), 400)); ui.toolButton->setText(QLatin1String("-")); } else { resize(width(), minimumHeight()); ui.toolButton->setText(QLatin1String("+")); } }
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 ); }
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"))); }
void KateMailDialog::slotShowButton() { if ( list->isVisible() ) { setButtonText( User1, i18n("&Show All Documents >>") ); list->hide(); } else { list->show(); setButtonText( User1, i18n("&Hide Document List <<") ); lInfo->setText( i18n("Press <strong>Mail...</strong> to send selected documents") ); } mw->setMinimumSize( TQSize( lInfo->sizeHint().width(), mw->sizeHint().height()) ); setMinimumSize( calculateSize( mw->minimumSize().width(), mw->sizeHint().height() ) ); resize( width(), minimumHeight() ); }
InboxButtonView::InboxButtonView(QWidget* parent) : QGraphicsView(parent), m_usedWidth(0) { setMinimumHeight( 24 ); setMaximumHeight( minimumHeight() ); setFrameShape(QFrame::NoFrame); setFrameShadow(QFrame::Plain); setLineWidth(0); setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff); setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff); setInteractive(true); setAttribute(Qt::WA_Hover, true); setAlignment(Qt::AlignLeft | Qt::AlignTop); m_scene = new QGraphicsScene(this); setScene( m_scene ); }