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 reg::setUi() { setLayout(ui->regLayout); ui->regWrap->setObjectName("regWindow"); ui->regWrap->setStyleSheet("#regWindow{background: url(:/img/images/regBack.png);}"); ui->regWrap->setMaximumSize(maximumWidth(),maximumHeight()); ui->regWrap->setMinimumSize(maximumWidth(),maximumHeight()); connect(ui->loginField, SIGNAL(returnPressed()), ui->doReg, SLOT(click())); connect(ui->passField, SIGNAL(returnPressed()), ui->doReg, SLOT(click())); connect(ui->passField2, SIGNAL(returnPressed()), ui->doReg, SLOT(click())); }
void TransparentScrollButtonH::hoverOff() { setHovered(true); maxSizeAnimation_->stop(); maxSizeAnimation_->setDuration(L::thinTime); maxSizeAnimation_->setStartValue(maximumHeight()); maxSizeAnimation_->setEndValue(minScrollButtonHeight_); maxSizeAnimation_->start(); minSizeAnimation_->stop(); minSizeAnimation_->setDuration(L::thinTime); minSizeAnimation_->setStartValue(maximumHeight()); minSizeAnimation_->setEndValue(minScrollButtonHeight_); minSizeAnimation_->start(); update(); }
GameButton::GameButton(int width, QString nom, QString desc, QString path, bool pwd, bool steam, QString gameID, QWidget *parent) : QCommandLinkButton (parent), nom (nom), desc (desc), path (path), pwd (pwd), steam (steam), gameID (gameID), proc (new QProcess(this)) { //Définition de l'apparence du bouton setMaximumSize(width / 21.875f, (width / 21.875f)); setIconSize(QSize(maximumWidth()-16, maximumHeight()-16)); setIcon(QIcon("./icons/" + nom + ".png")); setCheckable(true); //On définit le working directory du jeu représenté proc->setWorkingDirectory(QFileInfo(path).absolutePath()); //connexion signaux/slots connect(this, SIGNAL(clicked()), this, SLOT(click())); connect(proc, SIGNAL(error(QProcess::ProcessError)), this, SLOT(error(QProcess::ProcessError))); connect(proc, SIGNAL(started()), this, SLOT(started())); connect(proc, SIGNAL(finished(int)), this, SLOT(finished(int))); }
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 BackgroundWidget::paintEvent( QPaintEvent *e ) { if ( !b_withart ) { /* we just want background autofill */ QWidget::paintEvent( e ); return; } int i_maxwidth, i_maxheight; QPixmap pixmap = QPixmap( pixmapUrl ); QPainter painter(this); QBitmap pMask; float f_alpha = 1.0; i_maxwidth = __MIN( maximumWidth(), width() ) - MARGIN * 2; i_maxheight = __MIN( maximumHeight(), height() ) - MARGIN * 2; painter.setOpacity( property( "opacity" ).toFloat() ); if ( height() > MARGIN * 2 ) { /* Scale down the pixmap if the widget is too small */ if( pixmap.width() > i_maxwidth || pixmap.height() > i_maxheight ) { pixmap = pixmap.scaled( i_maxwidth, i_maxheight, Qt::KeepAspectRatio, Qt::SmoothTransformation ); } else if ( b_expandPixmap && pixmap.width() < width() && pixmap.height() < height() ) { /* Scale up the pixmap to fill widget's size */ f_alpha = ( (float) pixmap.height() / (float) height() ); pixmap = pixmap.scaled( width() - MARGIN * 2, height() - MARGIN * 2, Qt::KeepAspectRatio, ( f_alpha < .2 )? /* Don't waste cpu when not visible */ Qt::SmoothTransformation: Qt::FastTransformation ); /* Non agressive alpha compositing when sizing up */ pMask = QBitmap( pixmap.width(), pixmap.height() ); pMask.fill( QColor::fromRgbF( 1.0, 1.0, 1.0, f_alpha ) ); pixmap.setMask( pMask ); } painter.drawPixmap( MARGIN + ( i_maxwidth - pixmap.width() ) /2, MARGIN + ( i_maxheight - pixmap.height() ) /2, pixmap); } QWidget::paintEvent( e ); }
void RocketTaskbar::OnDelayedResize() { if (isVisible() && framework_ && toolBarRight_ && ui_.frameRight) { ui_.frameRight->layout()->update(); ui_.frameLoader->layout()->update(); QRectF rect = framework_->Ui()->GraphicsScene()->sceneRect(); QMargins margins = ui_.frameRight->layout()->contentsMargins(); int horizontalMargins = margins.left() + margins.right(); int spacing = ui_.frameRight->layout()->spacing(); if (anchor_ == Bottom) { if (sizePolicy_ == QSizePolicy::Expanding) setGeometry(QRectF(0, rect.height() - maximumHeight(), rect.width(), maximumHeight())); else { int additionalWidth = horizontalMargins + spacing + (ui_.frameLoader->isVisible() ? ui_.frameLoader->width() + spacing : 0) + ui_.buttonDisconnect->width() + spacing; int width = toolBarRight_->width() + additionalWidth; if (width < minimumWidth_) width = minimumWidth_; setGeometry(QRectF(rect.width() - width, rect.height() - maximumHeight(), width, maximumHeight())); } } else if (anchor_ == Top) { if (sizePolicy_ == QSizePolicy::Expanding) setGeometry(QRectF(0, 0, rect.width(), maximumHeight())); else { int additionalWidth = horizontalMargins + spacing + (ui_.frameLoader->isVisible() ? ui_.frameLoader->width() + spacing : 0) + ui_.buttonDisconnect->width() + spacing; int width = toolBarRight_->width() + additionalWidth; if (width < minimumWidth_) width = minimumWidth_; setGeometry(QRectF(rect.width() - width, 0, width, maximumHeight())); } } } }
void EPGRuler::paintEvent( QPaintEvent *event ) { Q_UNUSED( event ); const QSize margin( 0, contentsMargins().top() ); const QSize header( 0, maximumHeight() - contentsMargins().top() ); const int spacing = m_scale * 3600; QPainter p( this ); QDateTime localStartTime; localStartTime = m_startTime.addSecs( m_offset / m_scale ); QDateTime diff( localStartTime ); diff.setTime( QTime( localStartTime.time().hour(), 0, 0, 0 ) ); int secondsToHour = localStartTime.secsTo( diff ); /* draw hour blocks, with right bound being hourmark */ QPoint here( secondsToHour * m_scale, margin.height() ); QPoint previous( -1, 0 ); QDateTime current( localStartTime.addSecs( secondsToHour ) ); current = current.addSecs( -3600 ); QColor fillColor; while ( here.rx() < width() + spacing ) { QRect area( QPoint( previous.x() + 1, margin.height() ), here ); area.adjust( 0, 0, 0, header.height() ); QString timeString = current.toString( "hh'h'" ); /* Show Day */ if ( current.time().hour() == 0 ) timeString += current.date().toString( " ddd dd" ); if ( m_startTime.date().daysTo( current.date() ) % 2 == 0 ) fillColor = palette().color( QPalette::Window ); else fillColor = palette().color( QPalette::Dark ); p.fillRect( area, fillColor ); p.drawLine( area.topRight(), area.bottomRight() ); p.drawText( area, Qt::AlignLeft, timeString ); previous = here; here.rx() += spacing; current = current.addSecs( 3600 ); } /* draw current time line */ here.rx() = localStartTime.secsTo( QDateTime::currentDateTime() ) * m_scale; if ( here.x() <= width() && here.x() >= 0 ) { p.setPen( QPen( QColor( 255, 0 , 0, 128 ) ) ); p.drawLine( here, QPoint( here.x(), here.y() + header.height() ) ); } }
void CoverArtLabel::showArtUpdate( const QString& url ) { QPixmap pix; if( !url.isEmpty() && pix.load( url ) ) { pix = pix.scaled( maximumWidth(), maximumHeight(), Qt::KeepAspectRatioByExpanding ); } else { pix = QPixmap( ":/noart.png" ); } setPixmap( pix ); }
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)); } }
/** * \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; } } }
/** * \brief Set the current orientation * @param orientation as the given orientation */ void UBDockPalette::setOrientation(eUBDockOrientation orientation) { // Set the size mOrientation = orientation; if(orientation == eUBDockOrientation_Left || orientation == eUBDockOrientation_Right) { setMaximumHeight(parentWidget()->height()); setMinimumHeight(maximumHeight()); } else if(orientation == eUBDockOrientation_Top || orientation == eUBDockOrientation_Bottom) { setMaximumWidth(parentWidget()->width()); setMinimumWidth(maximumWidth()); } }
void WDialog::render(WFlags<RenderFlag> flags) { if (flags & RenderFull) { WApplication *app = WApplication::instance(); bool centerX = offset(Left).isAuto() && offset(Right).isAuto(), centerY = offset(Top).isAuto() && offset(Bottom).isAuto(); /* * Make sure layout adjusts to contents preferred width, especially * important for IE workaround which uses static position scheme */ if (app->environment().ajax()) if (width().isAuto()) if (maximumWidth().unit() == WLength::Percentage || maximumWidth().toPixels() == 0) impl_->resolveWidget("layout")->setMaximumSize(999999, maximumHeight()); doJavaScript("new " WT_CLASS ".WDialog(" + app->javaScriptClass() + "," + jsRef() + "," + titleBar_->jsRef() + "," + (centerX ? "1" : "0") + "," + (centerY ? "1" : "0") + ");"); /* * When a dialog is shown immediately for a new session, the recentering * logic comes too late and causes a glitch. Thus we include directly in * the HTML a JavaScript block to mitigate that */ if (!app->environment().agentIsIElt(9)) { std::string js = WString::tr("Wt.WDialog.CenterJS").toUTF8(); Utils::replace(js, "$el", "'" + id() + "'"); Utils::replace(js, "$centerX", centerX ? "1" : "0"); Utils::replace(js, "$centerY", centerY ? "1" : "0"); impl_->bindString ("center-script", "<script>" + js + "</script>", XHTMLUnsafeText); } else impl_->bindEmpty("center-script"); } WCompositeWidget::render(flags); }
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); }
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 mapWidget::emitMoveActionEnabled() { int w, h; w = p_zoomW; h = p_zoomH; if (p_scrollBarsVisible) { w += p_scrollBarWidth; h += p_scrollBarHeight; } if (w < maximumWidth() * p_lastFactorX || h < maximumHeight() * p_lastFactorY) { p_scrollBarsVisible = true; emit setMoveActionEnabled(true); } else { p_scrollBarsVisible = false; emit setMoveActionChecked(false); emit setMoveActionEnabled(false); } }
qreal RocketTaskbar::Height() { return maximumHeight(); }
int QWidget::qt_metacall(QMetaObject::Call _c, int _id, void **_a) { _id = QObject::qt_metacall(_c, _id, _a); if (_id < 0) return _id; if (_c == QMetaObject::InvokeMetaMethod) { if (_id < 23) qt_static_metacall(this, _c, _id, _a); _id -= 23; } #ifndef QT_NO_PROPERTIES else if (_c == QMetaObject::ReadProperty) { void *_v = _a[0]; switch (_id) { case 0: *reinterpret_cast< bool*>(_v) = isModal(); break; case 1: *reinterpret_cast< Qt::WindowModality*>(_v) = windowModality(); break; case 2: *reinterpret_cast< bool*>(_v) = isEnabled(); break; case 3: *reinterpret_cast< QRect*>(_v) = geometry(); break; case 4: *reinterpret_cast< QRect*>(_v) = frameGeometry(); break; case 5: *reinterpret_cast< QRect*>(_v) = normalGeometry(); break; case 6: *reinterpret_cast< int*>(_v) = x(); break; case 7: *reinterpret_cast< int*>(_v) = y(); break; case 8: *reinterpret_cast< QPoint*>(_v) = pos(); break; case 9: *reinterpret_cast< QSize*>(_v) = frameSize(); break; case 10: *reinterpret_cast< QSize*>(_v) = size(); break; case 11: *reinterpret_cast< int*>(_v) = width(); break; case 12: *reinterpret_cast< int*>(_v) = height(); break; case 13: *reinterpret_cast< QRect*>(_v) = rect(); break; case 14: *reinterpret_cast< QRect*>(_v) = childrenRect(); break; case 15: *reinterpret_cast< QRegion*>(_v) = childrenRegion(); break; case 16: *reinterpret_cast< QSizePolicy*>(_v) = sizePolicy(); break; case 17: *reinterpret_cast< QSize*>(_v) = minimumSize(); break; case 18: *reinterpret_cast< QSize*>(_v) = maximumSize(); break; case 19: *reinterpret_cast< int*>(_v) = minimumWidth(); break; case 20: *reinterpret_cast< int*>(_v) = minimumHeight(); break; case 21: *reinterpret_cast< int*>(_v) = maximumWidth(); break; case 22: *reinterpret_cast< int*>(_v) = maximumHeight(); break; case 23: *reinterpret_cast< QSize*>(_v) = sizeIncrement(); break; case 24: *reinterpret_cast< QSize*>(_v) = baseSize(); break; case 25: *reinterpret_cast< QPalette*>(_v) = palette(); break; case 26: *reinterpret_cast< QFont*>(_v) = font(); break; case 27: *reinterpret_cast< QCursor*>(_v) = cursor(); break; case 28: *reinterpret_cast< bool*>(_v) = hasMouseTracking(); break; case 29: *reinterpret_cast< bool*>(_v) = isActiveWindow(); break; case 30: *reinterpret_cast< Qt::FocusPolicy*>(_v) = focusPolicy(); break; case 31: *reinterpret_cast< bool*>(_v) = hasFocus(); break; case 32: *reinterpret_cast< Qt::ContextMenuPolicy*>(_v) = contextMenuPolicy(); break; case 33: *reinterpret_cast< bool*>(_v) = updatesEnabled(); break; case 34: *reinterpret_cast< bool*>(_v) = isVisible(); break; case 35: *reinterpret_cast< bool*>(_v) = isMinimized(); break; case 36: *reinterpret_cast< bool*>(_v) = isMaximized(); break; case 37: *reinterpret_cast< bool*>(_v) = isFullScreen(); break; case 38: *reinterpret_cast< QSize*>(_v) = sizeHint(); break; case 39: *reinterpret_cast< QSize*>(_v) = minimumSizeHint(); break; case 40: *reinterpret_cast< bool*>(_v) = acceptDrops(); break; case 41: *reinterpret_cast< QString*>(_v) = windowTitle(); break; case 42: *reinterpret_cast< QIcon*>(_v) = windowIcon(); break; case 43: *reinterpret_cast< QString*>(_v) = windowIconText(); break; case 44: *reinterpret_cast< double*>(_v) = windowOpacity(); break; case 45: *reinterpret_cast< bool*>(_v) = isWindowModified(); break; case 46: *reinterpret_cast< QString*>(_v) = toolTip(); break; case 47: *reinterpret_cast< QString*>(_v) = statusTip(); break; case 48: *reinterpret_cast< QString*>(_v) = whatsThis(); break; case 49: *reinterpret_cast< QString*>(_v) = accessibleName(); break; case 50: *reinterpret_cast< QString*>(_v) = accessibleDescription(); break; case 51: *reinterpret_cast< Qt::LayoutDirection*>(_v) = layoutDirection(); break; case 52: *reinterpret_cast< bool*>(_v) = autoFillBackground(); break; case 53: *reinterpret_cast< QString*>(_v) = styleSheet(); break; case 54: *reinterpret_cast< QLocale*>(_v) = locale(); break; case 55: *reinterpret_cast< QString*>(_v) = windowFilePath(); break; case 56: *reinterpret_cast< Qt::InputMethodHints*>(_v) = inputMethodHints(); break; } _id -= 57; } else if (_c == QMetaObject::WriteProperty) { void *_v = _a[0]; switch (_id) { case 1: setWindowModality(*reinterpret_cast< Qt::WindowModality*>(_v)); break; case 2: setEnabled(*reinterpret_cast< bool*>(_v)); break; case 3: setGeometry(*reinterpret_cast< QRect*>(_v)); break; case 8: move(*reinterpret_cast< QPoint*>(_v)); break; case 10: resize(*reinterpret_cast< QSize*>(_v)); break; case 16: setSizePolicy(*reinterpret_cast< QSizePolicy*>(_v)); break; case 17: setMinimumSize(*reinterpret_cast< QSize*>(_v)); break; case 18: setMaximumSize(*reinterpret_cast< QSize*>(_v)); break; case 19: setMinimumWidth(*reinterpret_cast< int*>(_v)); break; case 20: setMinimumHeight(*reinterpret_cast< int*>(_v)); break; case 21: setMaximumWidth(*reinterpret_cast< int*>(_v)); break; case 22: setMaximumHeight(*reinterpret_cast< int*>(_v)); break; case 23: setSizeIncrement(*reinterpret_cast< QSize*>(_v)); break; case 24: setBaseSize(*reinterpret_cast< QSize*>(_v)); break; case 25: setPalette(*reinterpret_cast< QPalette*>(_v)); break; case 26: setFont(*reinterpret_cast< QFont*>(_v)); break; case 27: setCursor(*reinterpret_cast< QCursor*>(_v)); break; case 28: setMouseTracking(*reinterpret_cast< bool*>(_v)); break; case 30: setFocusPolicy(*reinterpret_cast< Qt::FocusPolicy*>(_v)); break; case 32: setContextMenuPolicy(*reinterpret_cast< Qt::ContextMenuPolicy*>(_v)); break; case 33: setUpdatesEnabled(*reinterpret_cast< bool*>(_v)); break; case 34: setVisible(*reinterpret_cast< bool*>(_v)); break; case 40: setAcceptDrops(*reinterpret_cast< bool*>(_v)); break; case 41: setWindowTitle(*reinterpret_cast< QString*>(_v)); break; case 42: setWindowIcon(*reinterpret_cast< QIcon*>(_v)); break; case 43: setWindowIconText(*reinterpret_cast< QString*>(_v)); break; case 44: setWindowOpacity(*reinterpret_cast< double*>(_v)); break; case 45: setWindowModified(*reinterpret_cast< bool*>(_v)); break; case 46: setToolTip(*reinterpret_cast< QString*>(_v)); break; case 47: setStatusTip(*reinterpret_cast< QString*>(_v)); break; case 48: setWhatsThis(*reinterpret_cast< QString*>(_v)); break; case 49: setAccessibleName(*reinterpret_cast< QString*>(_v)); break; case 50: setAccessibleDescription(*reinterpret_cast< QString*>(_v)); break; case 51: setLayoutDirection(*reinterpret_cast< Qt::LayoutDirection*>(_v)); break; case 52: setAutoFillBackground(*reinterpret_cast< bool*>(_v)); break; case 53: setStyleSheet(*reinterpret_cast< QString*>(_v)); break; case 54: setLocale(*reinterpret_cast< QLocale*>(_v)); break; case 55: setWindowFilePath(*reinterpret_cast< QString*>(_v)); break; case 56: setInputMethodHints(*reinterpret_cast< Qt::InputMethodHints*>(_v)); break; } _id -= 57; } else if (_c == QMetaObject::ResetProperty) { switch (_id) { case 27: unsetCursor(); break; case 51: unsetLayoutDirection(); break; case 54: unsetLocale(); break; } _id -= 57; } else if (_c == QMetaObject::QueryPropertyDesignable) { bool *_b = reinterpret_cast<bool*>(_a[0]); switch (_id) { case 41: *_b = isWindow(); break; case 42: *_b = isWindow(); break; case 43: *_b = isWindow(); break; case 44: *_b = isWindow(); break; case 45: *_b = isWindow(); break; case 55: *_b = isWindow(); break; } _id -= 57; } else if (_c == QMetaObject::QueryPropertyScriptable) { _id -= 57; } else if (_c == QMetaObject::QueryPropertyStored) { _id -= 57; } else if (_c == QMetaObject::QueryPropertyEditable) { _id -= 57; } else if (_c == QMetaObject::QueryPropertyUser) { _id -= 57; } #endif // QT_NO_PROPERTIES return _id; }
void Widget::onClipboardUpdated() { QClipboard *clip = qApp->clipboard(); if (clip->mimeData()->hasImage()) { QImage image = clip->image(); QSize origSize = image.size(); const int minWidth = minimumWidth() - 20; const int minHeight = minimumHeight() - 20; if (image.width() <= image.height() && image.height() < minimumHeight() - 20) { image = image.scaledToHeight(minHeight); } else if (image.width() < minWidth) { image = image.scaledToWidth(minWidth); } if (image.width() > maximumWidth() - 10) { image = image.scaledToWidth(maximumWidth() - 10); } if (image.height() > maximumHeight() - 10) { image = image.scaledToHeight(maximumHeight() - 10); } { QPainter p(&image); QFont font; font.setPixelSize(15); p.setFont(font); QFontMetrics metrics(font); QString text = QString::number(origSize.width()) + "x" + QString::number(origSize.height()); QRect rect = metrics.boundingRect(text).marginsAdded(QMargins(5, 5, 5, 5)); rect.moveTopLeft(QPoint(0, 0)); p.fillRect(rect, QColor(0, 0, 0, 128)); p.setPen(Qt::white); p.drawText(rect, Qt::AlignCenter, text); } m_label->setPixmap(QPixmap::fromImage(image)); resize(image.size()); updateGeometry(); m_hasTrimmed = false; return; } QString text = clip->text(); const QStringList formats = clip->mimeData()->formats(); bool onlyTextPlain = formats.contains("text/plain"); if (onlyTextPlain) { for (const QString &format : formats) { // "Special" fake mimetypes to indicate multiselections etc. if (!format.contains('/') || format.toUpper() == format) { continue; } if (format == "text/plain" || format == "text/html") { continue; } onlyTextPlain = false; break; } QString trimmed = text.trimmed(); if (onlyTextPlain && trimmed != text && !m_hasTrimmed) { clip->setText(trimmed); m_hasTrimmed = true; return; } } m_hasTrimmed = false; QFontMetrics metrics(font()); QString filteredText; for (const QChar &c : text) { if ((c.isPrint() || c == '\n' || c == '\t') && (c.script() == QChar::Script_Latin || c.script() == QChar::Script_Common)) { filteredText += c; continue; } qDebug() << c << c.script() << c.category(); filteredText += "0x" + QString::number(c.unicode(), 16); } text = filteredText; QRect boundingRect = QRect(0, 0, maximumWidth(), maximumHeight()); boundingRect = metrics.boundingRect(boundingRect, Qt::TextWordWrap, text); boundingRect = boundingRect.marginsAdded(QMargins(20, 20, 20, 20)); if (boundingRect.height() > maximumHeight()) { m_label->setWordWrap(false); QString newText; int h = metrics.height() * 2; for (const QString &line : text.split('\n')) { newText.append(metrics.elidedText(line, Qt::ElideRight, m_label->width() - 20) + '\n'); h += metrics.height(); } text = newText; boundingRect.setHeight(h); } else { m_label->setWordWrap(true); } resize(boundingRect.size()); m_label->setText(text); m_label->setSelection(0, text.length()); updateGeometry(); }
RepairerDialog::RepairerDialog(qReal::Repairer *repairer, QString const savePath) { mRepairer = repairer; mSavePath = savePath; layout = new QGridLayout(); mPatchSaveDialog = new PatchSaveDialog(savePath, "", mRepairer); mPatchSaveDialog->setMaximumSize(0,0); mPatchSaveDialog->setMaximumSize(maximumWidth(),maximumHeight()); mAutorepairDialog = new QWidget(); mAutorepairLayout = new QGridLayout(); mAutorepairText = new QLabel(tr("QReal will use logs maded during working with editor.")); //todo: autodetect mAutorepairLayout->addWidget(mAutorepairText,0,0,1,-1,Qt::AlignCenter); mAutorepairDialog->setLayout(mAutorepairLayout); mGenerateEditorDialog = new QWidget(); mGenerateEditorLayout = new QGridLayout(); mGenerateEditorText = new QLabel(tr("Choose path to editor XML")); mGenerateEditorPath = new QLineEdit(); mGenerateEditorPathError = new QLabel(tr("Path is incorrect")); mGenerateEditorPathCaption = new QLabel(tr("Path to XML: ")); mGenerateEditorPathBrowse = new QPushButton(tr("Browse")); mGenerateEditorLayout->addWidget(mGenerateEditorText,0,0,1,-1,Qt::AlignLeft); mGenerateEditorLayout->addWidget(mGenerateEditorPathCaption,1,0); mGenerateEditorLayout->addWidget(mGenerateEditorPath,1,1); mGenerateEditorLayout->addWidget(mGenerateEditorPathBrowse,1,2); mGenerateEditorLayout->addWidget(mGenerateEditorPathError,2,1,1,-1,Qt::AlignLeft); mGenerateEditorPathError->setStyleSheet("QLabel {color : red; }"); mGenerateEditorPathError->hide(); mGenerateEditorDialog->setLayout(mGenerateEditorLayout); mPatchSaveSwitcher = new QCheckBox(tr("Patch save")); mAutorepairSwitcher = new QCheckBox(tr("Try to repair save automatically")); mGenerateEditorSwitcher = new QCheckBox(tr("Generate new editor from file")); mCommonText = new QLabel(tr("Current save cannot be loaded.\nChoose ways to fix it:")); mRunButton = new QPushButton(tr("Run")); layout->addWidget(mCommonText,0,0,1,-1,Qt::AlignLeft); layout->addWidget(mPatchSaveSwitcher,1,0,1,-1,Qt::AlignLeft); layout->addWidget(mPatchSaveDialog,2,0); layout->addWidget(mAutorepairSwitcher,3,0,1,-1,Qt::AlignLeft); layout->addWidget(mAutorepairDialog,4,0); layout->addWidget(mGenerateEditorSwitcher,5,0,1,-1,Qt::AlignLeft); layout->addWidget(mGenerateEditorDialog,6,0); layout->addWidget(mRunButton,7,0,1,-1,Qt::AlignCenter); setLayout(layout); mPatchSaveDialog->hide(); mAutorepairDialog->hide(); mGenerateEditorDialog->hide(); QPushButton* patchSaveRunButton = mPatchSaveDialog->getRunButton(); patchSaveRunButton->hide(); connect(mRunButton, SIGNAL(clicked()),this,SLOT(run())); connect(mGenerateEditorPathBrowse, SIGNAL(clicked()),this,SLOT(openEditorXML())); connect(mGenerateEditorPath, SIGNAL(editingFinished()), this, SLOT(checkEditorPath())); connectSwitchers(); int width = this->width() + 20; setFixedSize(width,heightForWidth(width)); mAutorepairSwitcher->toggle(); }
bool CFramelessWindow::nativeEvent(const QByteArray &eventType, void *message, long *result) { MSG* msg = (MSG *)message; switch (msg->message) { case WM_NCCALCSIZE: { //this kills the window frame and title bar we added with WS_THICKFRAME and WS_CAPTION *result = 0; return true; } case WM_NCHITTEST: { *result = 0; const LONG border_width = m_borderWidth; RECT winrect; GetWindowRect(HWND(winId()), &winrect); long x = GET_X_LPARAM(msg->lParam); long y = GET_Y_LPARAM(msg->lParam); if(m_bResizeable) { bool resizeWidth = minimumWidth() != maximumWidth(); bool resizeHeight = minimumHeight() != maximumHeight(); if(resizeWidth) { //left border if (x >= winrect.left && x < winrect.left + border_width) { *result = HTLEFT; } //right border if (x < winrect.right && x >= winrect.right - border_width) { *result = HTRIGHT; } } if(resizeHeight) { //bottom border if (y < winrect.bottom && y >= winrect.bottom - border_width) { *result = HTBOTTOM; } //top border if (y >= winrect.top && y < winrect.top + border_width) { *result = HTTOP; } } if(resizeWidth && resizeHeight) { //bottom left corner if (x >= winrect.left && x < winrect.left + border_width && y < winrect.bottom && y >= winrect.bottom - border_width) { *result = HTBOTTOMLEFT; } //bottom right corner if (x < winrect.right && x >= winrect.right - border_width && y < winrect.bottom && y >= winrect.bottom - border_width) { *result = HTBOTTOMRIGHT; } //top left corner if (x >= winrect.left && x < winrect.left + border_width && y >= winrect.top && y < winrect.top + border_width) { *result = HTTOPLEFT; } //top right corner if (x < winrect.right && x >= winrect.right - border_width && y >= winrect.top && y < winrect.top + border_width) { *result = HTTOPRIGHT; } } } if (0!=*result) return true; //*result still equals 0, that means the cursor locate OUTSIDE the frame area //but it may locate in titlebar area if (!m_titlebar) return false; //support highdpi double dpr = this->devicePixelRatioF(); QPoint pos = m_titlebar->mapFromGlobal(QPoint(x/dpr,y/dpr)); if (!m_titlebar->rect().contains(pos)) return false; QWidget* child = m_titlebar->childAt(pos); if (!child) { *result = HTCAPTION; return true; }else{ if (m_whiteList.contains(child)) { *result = HTCAPTION; return true; } } return false; } //end case WM_NCHITTEST case WM_GETMINMAXINFO: { if (::IsZoomed(msg->hwnd)) { RECT frame = { 0, 0, 0, 0 }; AdjustWindowRectEx(&frame, WS_OVERLAPPEDWINDOW, FALSE, 0); //record frame area data double dpr = this->devicePixelRatioF(); m_frames.setLeft(abs(frame.left)/dpr+0.5); m_frames.setTop(abs(frame.bottom)/dpr+0.5); m_frames.setRight(abs(frame.right)/dpr+0.5); m_frames.setBottom(abs(frame.bottom)/dpr+0.5); QMainWindow::setContentsMargins(m_frames.left()+m_margins.left(), \ m_frames.top()+m_margins.top(), \ m_frames.right()+m_margins.right(), \ m_frames.bottom()+m_margins.bottom()); m_bJustMaximized = true; }else { if (m_bJustMaximized) { QMainWindow::setContentsMargins(m_margins); //after window back to normal size from maximized state //a twinkle will happen, to avoid this twinkle //repaint() is important used just before the window back to normal repaint(); m_frames = QMargins(); m_bJustMaximized = false; } } return false; } default: return QMainWindow::nativeEvent(eventType, message, result); } }