本文整理汇总了C++中QSize::width方法的典型用法代码示例。如果您正苦于以下问题:C++ QSize::width方法的具体用法?C++ QSize::width怎么用?C++ QSize::width使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QSize
的用法示例。
在下文中一共展示了QSize::width方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: fitToSize
int RichTextRenderer::fitToSize(const QSize& size, int minimumFontSize, int maximumFontSize)
{
int width = size.width();
int height = size.height();
const QString sizeKey = QString("%1:%2:%3:%4").arg(html()).arg(width).arg(height).arg(minimumFontSize);
// for centering
qreal boxHeight = -1;
double ptSize = -1;
if(static_autoTextSizeCache.contains(sizeKey))
{
ptSize = *(static_autoTextSizeCache[sizeKey]);
//qDebug()<<"RichTextRenderer::fitToSize(): size search: CACHE HIT: loaded size:"<<ptSize;
// We go thru the much-more-verbose method of creating
// the document and setting the html, width, merge cursor,
// etc, just so we can get the document height after
// setting the font size inorder to use it to center the textbox.
// If we didnt nead the height, we could just use autoText->setFontSize()
QTextDocument doc;
doc.setTextWidth(width);
if (Qt::mightBeRichText(html()))
doc.setHtml(html());
else
doc.setPlainText(html());
QTextCursor cursor(&doc);
cursor.select(QTextCursor::Document);
QTextCharFormat format;
format.setFontPointSize(ptSize);
cursor.mergeCharFormat(format);
boxHeight = doc.documentLayout()->documentSize().height();
setHtml(doc.toHtml());
}
else
{
double ptSize = minimumFontSize > 0 ? minimumFontSize : findFontSize();
double sizeInc = 1; // how big of a jump to add to the ptSize each iteration
int count = 0; // current loop iteration
int maxCount = 100; // max iterations of the search loop
bool done = false;
double lastGoodSize = ptSize;
QString lastGoodHtml = html();
QTextDocument doc;
qreal heightTmp;
doc.setTextWidth(width);
if (Qt::mightBeRichText(html()))
doc.setHtml(html());
else
doc.setPlainText(html());
QTextCursor cursor(&doc);
cursor.select(QTextCursor::Document);
QTextCharFormat format;
while(!done && count++ < maxCount)
{
format.setFontPointSize(ptSize);
cursor.mergeCharFormat(format);
heightTmp = doc.documentLayout()->documentSize().height();
if(heightTmp < height &&
ptSize < maximumFontSize)
{
lastGoodSize = ptSize;
//lastGoodHtml = html();
boxHeight = heightTmp;
sizeInc *= 1.1;
// qDebug()<<"size search: "<<ptSize<<"pt was good, trying higher, inc:"<<sizeInc<<"pt";
ptSize += sizeInc;
}
else
{
// qDebug()<<"fitToSize: size search: last good ptsize:"<<lastGoodSize<<", stopping search";
done = true;
}
}
if(boxHeight < 0 && minimumFontSize <= 0) // didnt find a size
{
ptSize = 100;
count = 0;
//.........这里部分代码省略.........
示例2: smartMaxSize
void tst_QLayout::smartMaxSize()
{
QVector<int> expectedWidths;
QFile f(QLatin1String(SRCDIR "/baseline/smartmaxsize"));
QCOMPARE(f.open(QIODevice::ReadOnly | QIODevice::Text), true);
QTextStream stream(&f);
while(!stream.atEnd()) {
QString line = stream.readLine(200);
expectedWidths.append(line.section(QLatin1Char(' '), 6, -1, QString::SectionSkipEmpty).toInt());
}
f.close();
int sizeCombinations[] = { 0, 10, 20, QWIDGETSIZE_MAX};
QSizePolicy::Policy policies[] = { QSizePolicy::Fixed,
QSizePolicy::Minimum,
QSizePolicy::Maximum,
QSizePolicy::Preferred,
QSizePolicy::Expanding,
QSizePolicy::MinimumExpanding,
QSizePolicy::Ignored
};
Qt::Alignment alignments[] = { 0,
Qt::AlignLeft,
Qt::AlignRight,
Qt::AlignHCenter
};
int expectedIndex = 0;
int regressionCount = 0;
for (int p = 0; p < sizeof(policies)/sizeof(QSizePolicy::Policy); ++p) {
QSizePolicy sizePolicy;
sizePolicy.setHorizontalPolicy(policies[p]);
for (int min = 0; min < sizeof(sizeCombinations)/sizeof(int); ++min) {
int minSize = sizeCombinations[min];
for (int max = 0; max < sizeof(sizeCombinations)/sizeof(int); ++max) {
int maxSize = sizeCombinations[max];
for (int sh = 0; sh < sizeof(sizeCombinations)/sizeof(int); ++sh) {
int sizeHint = sizeCombinations[sh];
for (int a = 0; a < sizeof(alignments)/sizeof(int); ++a) {
Qt::Alignment align = alignments[a];
QSize sz = qSmartMaxSize(QSize(sizeHint, 1), QSize(minSize, 1), QSize(maxSize, 1), sizePolicy, align);
int width = sz.width();
#if 0
qDebug() << expectedIndex << sizePolicy.horizontalPolicy() << align << minSize << sizeHint << maxSize << width;
#else
int expectedWidth = expectedWidths[expectedIndex];
if (width != expectedWidth) {
qDebug() << "error at index" << expectedIndex << ":" << sizePolicy.horizontalPolicy() << align << minSize << sizeHint << maxSize << width;
++regressionCount;
}
#endif
++expectedIndex;
}
}
}
}
}
QCOMPARE(regressionCount, 0);
}
示例3: return
bool operator<(const QSize &firstSize, const QSize &secondSize)
{
return (firstSize.height() + (QUACKLE_MAXIMUM_BOARD_SIZE + 1) * firstSize.width()) < (secondSize.height() + (QUACKLE_MAXIMUM_BOARD_SIZE + 1) * secondSize.width());
}
示例4: qwtBorderMask
static QBitmap qwtBorderMask( const QWidget *canvas, const QSize &size )
{
const QRect r( 0, 0, size.width(), size.height() );
QPainterPath borderPath;
( void )QMetaObject::invokeMethod(
const_cast< QWidget *>( canvas ), "borderPath", Qt::DirectConnection,
Q_RETURN_ARG( QPainterPath, borderPath ), Q_ARG( QRect, r ) );
if ( borderPath.isEmpty() )
{
if ( canvas->contentsRect() == canvas->rect() )
return QBitmap();
QBitmap mask( size );
mask.fill( Qt::color0 );
QPainter painter( &mask );
painter.fillRect( canvas->contentsRect(), Qt::color1 );
return mask;
}
QImage image( size, QImage::Format_ARGB32_Premultiplied );
image.fill( Qt::color0 );
QPainter painter( &image );
painter.setClipPath( borderPath );
painter.fillRect( r, Qt::color1 );
// now erase the frame
painter.setCompositionMode( QPainter::CompositionMode_DestinationOut );
if ( canvas->testAttribute(Qt::WA_StyledBackground ) )
{
QStyleOptionFrame opt;
opt.initFrom(canvas);
opt.rect = r;
canvas->style()->drawPrimitive( QStyle::PE_Frame, &opt, &painter, canvas );
}
else
{
const QVariant borderRadius = canvas->property( "borderRadius" );
const QVariant frameWidth = canvas->property( "frameWidth" );
if ( borderRadius.type() == QVariant::Double
&& frameWidth.type() == QVariant::Int )
{
const double br = borderRadius.toDouble();
const int fw = frameWidth.toInt();
if ( br > 0.0 && fw > 0 )
{
painter.setPen( QPen( Qt::color1, fw ) );
painter.setBrush( Qt::NoBrush );
painter.setRenderHint( QPainter::Antialiasing, true );
painter.drawPath( borderPath );
}
}
}
painter.end();
const QImage mask = image.createMaskFromColor(
QColor( Qt::color1 ).rgb(), Qt::MaskOutColor );
return QBitmap::fromImage( mask );
}
示例5: setLocation
void GBAKeyEditor::setLocation(QWidget* widget, qreal x, qreal y) {
QSize s = size();
QSize hint = widget->sizeHint();
widget->setGeometry(s.width() * x - hint.width() / 2.0, s.height() * y - hint.height() / 2.0, hint.width(), hint.height());
}
示例6: setPixmap
void PixmapLabel::setPixmap(QPixmap const& p) {
m_pixmap = p;
if (m_mode == Mode::FixedSize) {
QSize size = m_pixmap.size() * m_scalingFactor;
this->resize(size);
QLabel::setPixmap(m_pixmap.scaled(size, Qt::KeepAspectRatio, Qt::SmoothTransformation));
LOGGER_DEBUG("Setting pixmap in FixedSize mode with Size {} x {} (Pixmap size = {} x {}, Scaling Factor = {})", size.width(), size.height(), m_pixmap.width(), m_pixmap.height(), m_scalingFactor);
} else if (m_mode == Mode::HeightForWidth) {
QSize size = this->size();
QLabel::setPixmap(m_pixmap.scaled(size, Qt::KeepAspectRatio, Qt::SmoothTransformation));
LOGGER_DEBUG("Setting pixmap in HeightForWidth mode with Size {} x {} (Pixmap size = {} x {})", size.width(), size.height(), m_pixmap.width(), m_pixmap.height());
} else if (m_mode == Mode::TouchFromInside) {
QSize size = this->size();
QLabel::setPixmap(m_pixmap.scaled(size, Qt::KeepAspectRatio, Qt::SmoothTransformation));
LOGGER_DEBUG("Setting pixmap in TouchFromInside mode with Size {} x {} (Pixmap size = {} x {})", size.width(), size.height(), m_pixmap.width(), m_pixmap.height());
}
}
示例7: p
void OpenGL2Common::paintGL()
{
if (videoFrameArr.isEmpty() && !hasImage)
return;
const QSize winSize = widget()->size();
bool resetDone = false;
if (!videoFrameArr.isEmpty())
{
const VideoFrame *videoFrame = VideoFrame::fromData(videoFrameArr);
if (doReset)
{
/* Prepare textures */
glBindTexture(GL_TEXTURE_2D, 2);
glTexImage2D(GL_TEXTURE_2D, 0, GL_LUMINANCE, videoFrame->linesize[0], outH, 0, GL_LUMINANCE, GL_UNSIGNED_BYTE, NULL);
glBindTexture(GL_TEXTURE_2D, 3);
glTexImage2D(GL_TEXTURE_2D, 0, GL_LUMINANCE, videoFrame->linesize[1], outH >> 1, 0, GL_LUMINANCE, GL_UNSIGNED_BYTE, NULL);
glBindTexture(GL_TEXTURE_2D, 4);
glTexImage2D(GL_TEXTURE_2D, 0, GL_LUMINANCE, videoFrame->linesize[2], outH >> 1, 0, GL_LUMINANCE, GL_UNSIGNED_BYTE, NULL);
/* Prepare texture coordinates */
texCoordYCbCr[2] = texCoordYCbCr[6] = (videoFrame->linesize[0] == outW) ? 1.0f : (outW / (videoFrame->linesize[0] + 1.0f));
resetDone = true;
}
glActiveTexture(GL_TEXTURE0);
glBindTexture(GL_TEXTURE_2D, 2);
glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, videoFrame->linesize[0], outH, GL_LUMINANCE, GL_UNSIGNED_BYTE, videoFrame->data[0]);
glActiveTexture(GL_TEXTURE1);
glBindTexture(GL_TEXTURE_2D, 3);
glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, videoFrame->linesize[1], outH >> 1, GL_LUMINANCE, GL_UNSIGNED_BYTE, videoFrame->data[1]);
glActiveTexture(GL_TEXTURE2);
glBindTexture(GL_TEXTURE_2D, 4);
glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, videoFrame->linesize[2], outH >> 1, GL_LUMINANCE, GL_UNSIGNED_BYTE, videoFrame->data[2]);
VideoFrame::unref(videoFrameArr);
hasImage = true;
}
shaderProgramYCbCr->setAttributeArray(positionYCbCrLoc, verticesYCbCr[flip], 2);
shaderProgramYCbCr->setAttributeArray(texCoordYCbCrLoc, texCoordYCbCr, 2);
shaderProgramYCbCr->enableAttributeArray(positionYCbCrLoc);
shaderProgramYCbCr->enableAttributeArray(texCoordYCbCrLoc);
shaderProgramYCbCr->bind();
if (doReset)
{
shaderProgramYCbCr->setUniformValue("scale", W / (float)winSize.width(), H / (float)winSize.height());
shaderProgramYCbCr->setUniformValue("videoEq", Brightness, Contrast, Saturation, Hue);
doReset = !resetDone;
}
glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
shaderProgramYCbCr->release();
shaderProgramYCbCr->disableAttributeArray(texCoordYCbCrLoc);
shaderProgramYCbCr->disableAttributeArray(positionYCbCrLoc);
glActiveTexture(GL_TEXTURE3);
/* OSD */
osdMutex.lock();
if (!osdList.isEmpty())
{
glBindTexture(GL_TEXTURE_2D, 1);
QRect bounds;
const qreal scaleW = (qreal)W / outW, scaleH = (qreal)H / outH;
bool mustRepaint = Functions::mustRepaintOSD(osdList, osdChecksums, &scaleW, &scaleH, &bounds);
if (!mustRepaint)
mustRepaint = osdImg.size() != bounds.size();
if (mustRepaint)
{
if (osdImg.size() != bounds.size())
osdImg = QImage(bounds.size(), QImage::Format_ARGB32);
osdImg.fill(0);
QPainter p(&osdImg);
p.translate(-bounds.topLeft());
Functions::paintOSD(false, osdList, scaleW, scaleH, p, &osdChecksums);
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, bounds.width(), bounds.height(), 0, GL_RGBA, GL_UNSIGNED_BYTE, osdImg.bits());
}
const float left = (bounds.left() + X) * 2.0f / winSize.width();
const float right = (bounds.right() + X + 1) * 2.0f / winSize.width();
const float top = (bounds.top() + Y) * 2.0f / winSize.height();
const float bottom = (bounds.bottom() + Y + 1) * 2.0f / winSize.height();
const float verticesOSD[8] = {
left - 1.0f, -bottom + 1.0f,
right - 1.0f, -bottom + 1.0f,
left - 1.0f, -top + 1.0f,
right - 1.0f, -top + 1.0f,
};
//.........这里部分代码省略.........
示例8: ApplyLetterboxing
// Code should take into account the aspect ratios of both the video as
// well as the actual screen to allow proper letterboxing to take place.
void VideoOutWindow::ApplyLetterboxing(void)
{
float disp_aspect = fix_aspect(GetDisplayAspect());
float aspect_diff = disp_aspect - overriden_video_aspect;
bool aspects_match = abs(aspect_diff / disp_aspect) <= 0.02f;
bool nomatch_with_fill =
!aspects_match && ((kAdjustFill_HorizontalStretch == adjustfill) ||
(kAdjustFill_VerticalStretch == adjustfill));
bool nomatch_without_fill = (!aspects_match) && !nomatch_with_fill;
// Adjust for video/display aspect ratio mismatch
if (nomatch_with_fill && (disp_aspect > overriden_video_aspect))
{
float pixNeeded = ((disp_aspect / overriden_video_aspect)
* (float) display_video_rect.height()) + 0.5f;
display_video_rect.moveTop(
display_video_rect.top() +
(display_video_rect.height() - (int) pixNeeded) / 2);
display_video_rect.setHeight((int) pixNeeded);
}
else if (nomatch_with_fill)
{
float pixNeeded =
((overriden_video_aspect / disp_aspect) *
(float) display_video_rect.width()) + 0.5f;
display_video_rect.moveLeft(
display_video_rect.left() +
(display_video_rect.width() - (int) pixNeeded) / 2);
display_video_rect.setWidth((int) pixNeeded);
}
else if (nomatch_without_fill && (disp_aspect > overriden_video_aspect))
{
float pixNeeded =
((overriden_video_aspect / disp_aspect) *
(float) display_video_rect.width()) + 0.5f;
display_video_rect.moveLeft(
display_video_rect.left() +
(display_video_rect.width() - (int) pixNeeded) / 2);
display_video_rect.setWidth((int) pixNeeded);
}
else if (nomatch_without_fill)
{
float pixNeeded = ((disp_aspect / overriden_video_aspect) *
(float) display_video_rect.height()) + 0.5f;
display_video_rect.moveTop(
display_video_rect.top() +
(display_video_rect.height() - (int) pixNeeded) / 2);
display_video_rect.setHeight((int) pixNeeded);
}
// Process letterbox zoom modes
if (adjustfill == kAdjustFill_Full)
{
// Zoom mode -- Expand by 4/3 and overscan.
// 1/6 of original is 1/8 of new
display_video_rect = QRect(
display_video_rect.left() - (display_video_rect.width() / 6),
display_video_rect.top() - (display_video_rect.height() / 6),
display_video_rect.width() * 4 / 3,
display_video_rect.height() * 4 / 3);
}
else if (adjustfill == kAdjustFill_Half)
{
// Zoom mode -- Expand by 7/6 and overscan.
// Intended for eliminating the top bars on 14:9 material.
// Also good compromise for 4:3 material on 16:9 screen.
// Expanding by 7/6, so remove 1/6 of original from overscan;
// take half from each side, so remove 1/12.
display_video_rect = QRect(
display_video_rect.left() - (display_video_rect.width() / 12),
display_video_rect.top() - (display_video_rect.height() / 12),
display_video_rect.width() * 7 / 6,
display_video_rect.height() * 7 / 6);
}
else if (adjustfill == kAdjustFill_HorizontalStretch)
{
// Horizontal Stretch mode -- 1/6 of original is 1/8 of new
// Intended to be used to eliminate side bars on 4:3 material
// encoded to 16:9.
display_video_rect.moveLeft(
display_video_rect.left() - (display_video_rect.width() / 6));
display_video_rect.setWidth(display_video_rect.width() * 4 / 3);
}
else if (adjustfill == kAdjustFill_VerticalStretch)
{
// Vertical Stretch mode -- 1/6 of original is 1/8 of new
// Intended to be used to eliminate top/bottom bars on 16:9
// material encoded to 4:3.
display_video_rect.moveTop(
//.........这里部分代码省略.........
示例9: scaled
QSize
DpiScaler::scaled( const QPaintDevice* pd, const QSize& size )
{
return scaled( pd, size.width(), size.height() );
}
示例10: init
bool QGLPixelBufferPrivate::init(const QSize &size, const QGLFormat &f, QGLWidget *shareWidget)
{
QGLWidget dmy;
dmy.makeCurrent(); // needed for wglGetProcAddress() to succeed
PFNWGLCREATEPBUFFERARBPROC wglCreatePbufferARB =
(PFNWGLCREATEPBUFFERARBPROC) wglGetProcAddress("wglCreatePbufferARB");
PFNWGLGETPBUFFERDCARBPROC wglGetPbufferDCARB =
(PFNWGLGETPBUFFERDCARBPROC) wglGetProcAddress("wglGetPbufferDCARB");
PFNWGLQUERYPBUFFERARBPROC wglQueryPbufferARB =
(PFNWGLQUERYPBUFFERARBPROC) wglGetProcAddress("wglQueryPbufferARB");
PFNWGLCHOOSEPIXELFORMATARBPROC wglChoosePixelFormatARB =
(PFNWGLCHOOSEPIXELFORMATARBPROC) wglGetProcAddress("wglChoosePixelFormatARB");
if (!wglCreatePbufferARB) // assumes that if one can be resolved, all of them can
return false;
dc = GetDC(dmy.winId());
Q_ASSERT(dc);
PFNWGLGETEXTENSIONSSTRINGARBPROC wglGetExtensionsStringARB =
(PFNWGLGETEXTENSIONSSTRINGARBPROC) wglGetProcAddress("wglGetExtensionsStringARB");
if (wglGetExtensionsStringARB) {
QString extensions(QLatin1String(wglGetExtensionsStringARB(dc)));
has_render_texture = extensions.contains(QLatin1String("WGL_ARB_render_texture"));
}
int attribs[40];
qt_format_to_attrib_list(has_render_texture, f, attribs);
// Find pbuffer capable pixel format.
unsigned int num_formats = 0;
int pixel_format;
wglChoosePixelFormatARB(dc, attribs, 0, 1, &pixel_format, &num_formats);
// some GL implementations don't support pbuffers with accum
// buffers, so try that before we give up
if (num_formats == 0 && f.accum()) {
QGLFormat tmp = f;
tmp.setAccum(false);
qt_format_to_attrib_list(has_render_texture, tmp, attribs);
wglChoosePixelFormatARB(dc, attribs, 0, 1, &pixel_format, &num_formats);
}
if (num_formats == 0) {
qWarning("QGLPixelBuffer: Unable to find a pixel format with pbuffer - giving up.");
ReleaseDC(dmy.winId(), dc);
return false;
}
format = pfiToQGLFormat(dc, pixel_format);
// NB! The below ONLY works if the width/height are powers of 2.
// Set some pBuffer attributes so that we can use this pBuffer as
// a 2D RGBA texture target.
int pb_attribs[] = {WGL_TEXTURE_FORMAT_ARB, WGL_TEXTURE_RGBA_ARB,
WGL_TEXTURE_TARGET_ARB, WGL_TEXTURE_2D_ARB, 0};
pbuf = wglCreatePbufferARB(dc, pixel_format, size.width(), size.height(),
has_render_texture ? pb_attribs : 0);
if(!pbuf) {
// try again without the render_texture extension
pbuf = wglCreatePbufferARB(dc, pixel_format, size.width(), size.height(), 0);
has_render_texture = false;
if (!pbuf) {
qWarning("QGLPixelBuffer: Unable to create pbuffer [w=%d, h=%d] - giving up.", size.width(), size.height());
ReleaseDC(dmy.winId(), dc);
return false;
}
}
ReleaseDC(dmy.winId(), dc);
dc = wglGetPbufferDCARB(pbuf);
ctx = wglCreateContext(dc);
if (!dc || !ctx) {
qWarning("QGLPixelBuffer: Unable to create pbuffer context - giving up.");
return false;
}
HGLRC share_ctx = shareWidget ? shareWidget->d_func()->glcx->d_func()->rc : 0;
if (share_ctx && !wglShareLists(share_ctx, ctx))
qWarning("QGLPixelBuffer: Unable to share display lists - with share widget.");
int width, height;
wglQueryPbufferARB(pbuf, WGL_PBUFFER_WIDTH_ARB, &width);
wglQueryPbufferARB(pbuf, WGL_PBUFFER_HEIGHT_ARB, &height);
return true;
}
示例11: p
KSSH::KSSH(QWidget *parent)
: QDialog(parent)
{
setupUi(this);
QLayout *lay;
lay = layout();
if (lay)
lay->setSizeConstraint(QLayout::SetFixedSize);
opt = false;
mopt = false;
editorF->hide();
QSize s = size();
QPoint p(s.width(), s.height());
QPoint po = pos();
QDesktopWidget *d = QApplication::desktop();
int w = d->width(); // returns desktop width
int h = d->height (); // returns desktop height
int x = 0, y = 0;
if ((p + po).x()>w)
po.setX(x = w-p.x());
if ((p + po).y()>h)
po.setY(y = h-p.y());
if (x<0)
po.setX(0);
if (y<0)
po.setY(0);
move(po);
optionsGB->hide();
moreF->hide();
adjustSize();
compUser = new KCompletion();
userCB->setCompletionObject(compUser);
compHost = new KCompletion();
hostCB->setCompletionObject(compHost);
hostCB->setFocus();
connect(hostCB, SIGNAL(editTextChanged(const QString&)), this, SLOT(userFor(const QString&)));
connect(compHost, SIGNAL(match(const QString&)), this, SLOT(userFor(const QString&)));
userCB->insertItem(1, "");
hostCB->insertItem(2, "");
loadHosts();
loadOptions("DefaultConfig");
connect(aboutPB, SIGNAL(clicked()), this, SLOT(about()));
connect(optionsPB, SIGNAL(clicked()), this, SLOT(options()));
connect(morePB, SIGNAL(clicked()), this, SLOT(moreOptions()));
connect(hostTB, SIGNAL(clicked()), this, SLOT(hostEditor()));
connect(userTB, SIGNAL(clicked()), this, SLOT(userEditor()));
connect(cancelPB, SIGNAL(clicked()), this, SLOT(cancelEditor()));
connect(okPB, SIGNAL(clicked()), this, SLOT(okEditor()));
connect(connectPB, SIGNAL(clicked()), this, SLOT(ssh()));
connect(savePB, SIGNAL(clicked()), this, SLOT(saveAsDefault()));
connect(quitPB, SIGNAL(clicked()), this, SLOT(exitHandler()));
KConfigGroup general_group = KGlobal::config()->group("General");
int fi = hostCB->findText(general_group.readEntry("LastHost"));
if (fi)
hostCB->setCurrentIndex(fi);
int def = KGlobalSettings::completionMode();
int mode = general_group.readEntry("HostCompletionMode", def);
hostCB->setCompletionMode((KGlobalSettings::Completion) mode);
mode = general_group.readEntry("UserCompletionMode", def);
userCB->setCompletionMode((KGlobalSettings::Completion)mode);
setWindowIcon(KIcon("kssh.png"));
}
示例12: maxSize
static QSize maxSize(const QSize &a,
const QSize &b)
{
return QSize(qMax(a.width(), b.width()),
qMax(a.height(), b.height()));
}
示例13: setSize
void QTermWidget::setSize(const QSize &size)
{
if (!m_impl->m_terminalDisplay)
return;
m_impl->m_terminalDisplay->setSize(size.width(), size.height());
}
示例14: fix_alignment
/// Correct for underalignment
static QSize fix_alignment(QSize raw)
{
return QSize((raw.width() + 15) & (~0xf), (raw.height() + 15) & (~0xf));
}
示例15: QObject
ScaleDlg::ScaleDlg( const QSize & origsize, QVBox * parent, const char * name )
: QObject( parent, name )
, m_origsize( origsize )
, m_newsizeunit( 0 )
, m_newsizeunit2( 0 )
, m_resolutionunit( 0 )
, m_newwidth( origsize.width() )
, m_newheight( origsize.height() )
, m_resx( 72 )
, m_resy( 72 )
{
QGroupBox * pixelgroup = new QGroupBox( i18n( "Pixel Dimensions" ), parent );
QGroupBox * printgroup = new QGroupBox( i18n( "Print Size && Display Units" ), parent );
QGridLayout * pixelgroupgrid = new QGridLayout( pixelgroup, 1, 1,
KDialog::marginHint(), KDialog::spacingHint() );
QGridLayout * printgroupgrid = new QGridLayout( printgroup, 1, 1,
KDialog::marginHint(), KDialog::spacingHint() );
QLabel * label;
pixelgroupgrid->addRowSpacing( 0, KDialog::spacingHint() );
label = new QLabel( i18n( "Original width:" ), pixelgroup );
label->setAlignment( int( QLabel::AlignVCenter | QLabel::AlignRight ) );
pixelgroupgrid->addWidget( label, 1, 0 );
label = new QLabel( i18n( "Height:" ), pixelgroup );
label->setAlignment( int( QLabel::AlignVCenter | QLabel::AlignRight ) );
pixelgroupgrid->addWidget( label, 2, 0 );
pixelgroupgrid->addRowSpacing( 3, KDialog::spacingHint() );
label = new QLabel( i18n( "New width:" ), pixelgroup );
label->setAlignment( int( QLabel::AlignVCenter | QLabel::AlignRight ) );
pixelgroupgrid->addWidget( label, 4, 0 );
label = new QLabel( i18n( "Height:" ), pixelgroup );
label->setAlignment( int( QLabel::AlignVCenter | QLabel::AlignRight ) );
pixelgroupgrid->addWidget( label, 5, 0 );
pixelgroupgrid->addRowSpacing( 6, KDialog::spacingHint() );
label = new QLabel( i18n( "Ratio X:" ), pixelgroup );
label->setAlignment( int( QLabel::AlignVCenter | QLabel::AlignRight ) );
pixelgroupgrid->addWidget( label, 7, 0 );
label = new QLabel( i18n( "Y:" ), pixelgroup );
label->setAlignment( int( QLabel::AlignVCenter | QLabel::AlignRight ) );
pixelgroupgrid->addWidget( label, 8, 0 );
printgroupgrid->addRowSpacing( 0, KDialog::spacingHint() );
label = new QLabel( i18n( "New width:" ), printgroup );
label->setAlignment( int( QLabel::AlignVCenter | QLabel::AlignRight ) );
printgroupgrid->addWidget( label, 1, 0 );
label = new QLabel( i18n( "Height:" ), printgroup );
label->setAlignment( int( QLabel::AlignVCenter | QLabel::AlignRight ) );
printgroupgrid->addWidget( label, 2, 0 );
printgroupgrid->addRowSpacing( 3, KDialog::spacingHint() );
label = new QLabel( i18n( "Resolution X:" ), printgroup );
label->setAlignment( int( QLabel::AlignVCenter | QLabel::AlignRight ) );
printgroupgrid->addWidget( label, 4, 0 );
label = new QLabel( i18n( "Y:" ), printgroup );
label->setAlignment( int( QLabel::AlignVCenter | QLabel::AlignRight ) );
printgroupgrid->addWidget( label, 5, 0 );
m_pOldWidth = new QLabel( QString::number( origsize.width() ), pixelgroup );
m_pOldWidth->setAlignment( int( QLabel::AlignVCenter | QLabel::AlignRight ) );
pixelgroupgrid->addWidget( m_pOldWidth, 1, 1 );
m_pOldHeight = new QLabel( QString::number( origsize.height() ), pixelgroup );
m_pOldHeight->setAlignment( int( QLabel::AlignVCenter | QLabel::AlignRight ) );
pixelgroupgrid->addWidget( m_pOldHeight, 2, 1 );
m_pNewWidth = new KFloatSpinBox( 1.0, 100000.0, 10.0, 0, pixelgroup );
pixelgroupgrid->addWidget( m_pNewWidth, 4, 1 );
m_pNewHeight = new KFloatSpinBox( 1.0, 100000.0, 10.0, 0, pixelgroup );
pixelgroupgrid->addWidget( m_pNewHeight, 5, 1 );
m_pNewSizeUnit = new KComboBox( pixelgroup );
m_pNewSizeUnit->insertItem( i18n( "px" ) );
m_pNewSizeUnit->insertItem( i18n( "%" ) );
pixelgroupgrid->addMultiCellWidget( m_pNewSizeUnit, 4, 5, 2, 2, Qt::AlignVCenter );
m_pRatioX = new KFloatSpinBox( 0.0001, 10000.0, 0.1, 4, pixelgroup );
pixelgroupgrid->addWidget( m_pRatioX, 7, 1 );
m_pRatioY = new KFloatSpinBox( 0.0001, 10000.0, 0.1, 4, pixelgroup );
pixelgroupgrid->addWidget( m_pRatioY, 8, 1 );
m_pLinkRatio = new QCheckBox( i18n( "Link" ), pixelgroup );
pixelgroupgrid->addMultiCellWidget( m_pLinkRatio, 7, 8, 2, 2, Qt::AlignVCenter );
m_pNewWidth2 = new KFloatSpinBox( 0.0001, 10000.0, 0.1, 4, printgroup );
printgroupgrid->addWidget( m_pNewWidth2, 1, 1 );
m_pNewHeight2 = new KFloatSpinBox( 0.0001, 10000.0, 0.1, 4, printgroup );
printgroupgrid->addWidget( m_pNewHeight2, 2, 1 );
m_pNewSizeUnit2 = new KComboBox( printgroup );
m_pNewSizeUnit2->insertItem( i18n( "in" ) );
m_pNewSizeUnit2->insertItem( i18n( "mm" ) );
printgroupgrid->addMultiCellWidget( m_pNewSizeUnit2, 1, 2, 2, 2, Qt::AlignVCenter );
//.........这里部分代码省略.........