/// Correct for underalignment static QSize fix_alignment(QSize raw) { return QSize((raw.width() + 15) & (~0xf), (raw.height() + 15) & (~0xf)); }
SearchWidget::SearchWidget(MainWindow *mainWindow) : QWidget(mainWindow) , m_ui(new Ui::SearchWidget()) , m_tabStatusChangedMapper(new QSignalMapper(this)) , m_mainWindow(mainWindow) , m_isNewQueryString(false) { m_ui->setupUi(this); QString searchPatternHint; QTextStream stream(&searchPatternHint, QIODevice::WriteOnly); stream << "<html><head/><body><p>" << tr("A phrase to search for.") << "<br>" << tr("Spaces in a search term may be protected by double quotes.") << "</p><p>" << tr("Example:", "Search phrase example") << "<br>" << tr("<b>foo bar</b>: search for <b>foo</b> and <b>bar</b>", "Search phrase example, illustrates quotes usage, a pair of " "space delimited words, individal words are highlighted") << "<br>" << tr("<b>"foo bar"</b>: search for <b>foo bar</b>", "Search phrase example, illustrates quotes usage, double quoted" "pair of space delimited words, the whole pair is highlighted") << "</p></body></html>" << flush; m_ui->m_searchPattern->setToolTip(searchPatternHint); #ifndef Q_OS_MAC // Icons m_ui->searchButton->setIcon(GuiIconProvider::instance()->getIcon("edit-find")); m_ui->downloadButton->setIcon(GuiIconProvider::instance()->getIcon("download")); m_ui->goToDescBtn->setIcon(GuiIconProvider::instance()->getIcon("application-x-mswinurl")); m_ui->pluginsButton->setIcon(GuiIconProvider::instance()->getIcon("preferences-system-network")); m_ui->copyURLBtn->setIcon(GuiIconProvider::instance()->getIcon("edit-copy")); #else // On macOS the icons overlap the text otherwise QSize iconSize = m_ui->tabWidget->iconSize(); iconSize.setWidth(iconSize.width() + 16); m_ui->tabWidget->setIconSize(iconSize); #endif connect(m_ui->tabWidget, &QTabWidget::tabCloseRequested, this, &SearchWidget::closeTab); connect(m_ui->tabWidget, &QTabWidget::currentChanged, this, &SearchWidget::tabChanged); connect(m_tabStatusChangedMapper, static_cast<void (QSignalMapper::*)(QWidget *)>(&QSignalMapper::mapped) , this, &SearchWidget::tabStatusChanged); // NOTE: Although SearchManager is Application-wide component now, we still create it the legacy way. auto *searchManager = new SearchPluginManager; const auto onPluginChanged = [this]() { fillPluginComboBox(); fillCatCombobox(); selectActivePage(); }; connect(searchManager, &SearchPluginManager::pluginInstalled, this, onPluginChanged); connect(searchManager, &SearchPluginManager::pluginUninstalled, this, onPluginChanged); connect(searchManager, &SearchPluginManager::pluginUpdated, this, onPluginChanged); connect(searchManager, &SearchPluginManager::pluginEnabled, this, onPluginChanged); // Fill in category combobox onPluginChanged(); connect(m_ui->m_searchPattern, &LineEdit::returnPressed, m_ui->searchButton, &QPushButton::click); connect(m_ui->m_searchPattern, &LineEdit::textEdited, this, &SearchWidget::searchTextEdited); connect(m_ui->selectPlugin, static_cast<void (QComboBox::*)(int)>(&QComboBox::currentIndexChanged) , this, &SearchWidget::selectMultipleBox); connect(m_ui->selectPlugin, static_cast<void (QComboBox::*)(int)>(&QComboBox::currentIndexChanged) , this, &SearchWidget::fillCatCombobox); }
QImage VectorscopeGenerator::calculateVectorscope(const QSize &vectorscopeSize, const QImage &image, const float &gain, const VectorscopeGenerator::PaintMode &paintMode, const VectorscopeGenerator::ColorSpace &colorSpace, const bool &, const uint &accelFactor) const { if (vectorscopeSize.width() <= 0 || vectorscopeSize.height() <= 0 || image.width() <= 0 || image.height() <= 0) { // Invalid size return QImage(); } // Prepare the vectorscope data const int cw = (vectorscopeSize.width() < vectorscopeSize.height()) ? vectorscopeSize.width() : vectorscopeSize.height(); QImage scope = QImage(cw, cw, QImage::Format_ARGB32); scope.fill(qRgba(0,0,0,0)); const uchar *bits = image.bits(); int r,g,b; double dy, dr, dg, db, dmax; double /*y,*/ u, v; QPoint pt; QRgb px; const int stepsize = 4 * accelFactor; // Just an average for the number of image pixels per scope pixel. // NOTE: byteCount() has to be replaced by (img.bytesPerLine()*img.height()) for Qt 4.5 to compile, see: http://doc.trolltech.org/4.6/qimage.html#bytesPerLine double avgPxPerPx = (double) 4*(image.bytesPerLine()*image.height())/scope.size().width()/scope.size().height()/accelFactor; for (int i = 0; i < (image.bytesPerLine()*image.height()); i+= stepsize) { QRgb *col = (QRgb *) bits; r = qRed(*col); g = qGreen(*col); b = qBlue(*col); switch (colorSpace) { case VectorscopeGenerator::ColorSpace_YUV: // y = (double) 0.001173 * r +0.002302 * g +0.0004471* b; u = (double) -0.0005781* r -0.001135 * g +0.001713 * b; v = (double) 0.002411 * r -0.002019 * g -0.0003921* b; break; case VectorscopeGenerator::ColorSpace_YPbPr: default: // y = (double) 0.001173 * r +0.002302 * g +0.0004471* b; u = (double) -0.0006671* r -0.001299 * g +0.0019608* b; v = (double) 0.001961 * r -0.001642 * g -0.0003189* b; break; } pt = mapToCircle(vectorscopeSize, QPointF(SCALING*gain*u, SCALING*gain*v)); if (pt.x() >= scope.width() || pt.x() < 0 || pt.y() >= scope.height() || pt.y() < 0) { // Point lies outside (because of scaling), don't plot it } else { // Draw the pixel using the chosen draw mode. switch (paintMode) { case PaintMode_YUV: // see yuvColorWheel dy = 128; // Default Y value. Lower = darker. // Calculate the RGB values from YUV/YPbPr switch (colorSpace) { case VectorscopeGenerator::ColorSpace_YUV: dr = dy + 290.8*v; dg = dy - 100.6*u - 148*v; db = dy + 517.2*u; break; case VectorscopeGenerator::ColorSpace_YPbPr: default: dr = dy + 357.5*v; dg = dy - 87.75*u - 182*v; db = dy + 451.9*u; break; } if (dr < 0) dr = 0; if (dg < 0) dg = 0; if (db < 0) db = 0; if (dr > 255) dr = 255; if (dg > 255) dg = 255; if (db > 255) db = 255; scope.setPixel(pt, qRgba(dr, dg, db, 255)); break; case PaintMode_Chroma: dy = 200; // Default Y value. Lower = darker. // Calculate the RGB values from YUV/YPbPr switch (colorSpace) { case VectorscopeGenerator::ColorSpace_YUV: dr = dy + 290.8*v; dg = dy - 100.6*u - 148*v; db = dy + 517.2*u; break; case VectorscopeGenerator::ColorSpace_YPbPr: default: dr = dy + 357.5*v; dg = dy - 87.75*u - 182*v; db = dy + 451.9*u; break; } // Scale the RGB values back to max 255 dmax = dr; if (dg > dmax) dmax = dg; if (db > dmax) dmax = db; dmax = 255/dmax; dr *= dmax; dg *= dmax; db *= dmax; scope.setPixel(pt, qRgba(dr, dg, db, 255)); break; case PaintMode_Original: scope.setPixel(pt, *col); break; case PaintMode_Green: px = scope.pixel(pt); scope.setPixel(pt, qRgba(qRed(px)+(255-qRed(px))/(3*avgPxPerPx), qGreen(px)+20*(255-qGreen(px))/(avgPxPerPx), qBlue(px)+(255-qBlue(px))/(avgPxPerPx), qAlpha(px)+(255-qAlpha(px))/(avgPxPerPx))); break; case PaintMode_Green2: px = scope.pixel(pt); scope.setPixel(pt, qRgba(qRed(px)+ceil((255-(float)qRed(px))/(4*avgPxPerPx)), 255, qBlue(px)+ceil((255-(float)qBlue(px))/(avgPxPerPx)), qAlpha(px)+ceil((255-(float)qAlpha(px))/(avgPxPerPx)))); break; case PaintMode_Black: px = scope.pixel(pt); scope.setPixel(pt, qRgba(0,0,0, qAlpha(px)+(255-qAlpha(px))/20)); break; } } bits += stepsize; } return scope; }
QSize QwtPlotLayout::minimumSizeHint(const QwtPlot *plot) const { class ScaleData { public: ScaleData() { w = h = minLeft = minRight = tickOffset = 0; } int w; int h; int minLeft; int minRight; int tickOffset; } scaleData[QwtPlot::axisCnt]; int canvasBorder[QwtPlot::axisCnt]; int axis; for ( axis = 0; axis < QwtPlot::axisCnt; axis++ ) { if ( plot->axisEnabled(axis) ) { const QwtScaleWidget *scl = plot->axisWidget(axis); ScaleData &sd = scaleData[axis]; const QSize hint = scl->minimumSizeHint(); sd.w = hint.width(); sd.h = hint.height(); scl->getBorderDistHint(sd.minLeft, sd.minRight); sd.tickOffset = scl->margin(); if ( scl->scaleDraw()->hasComponent(QwtAbstractScaleDraw::Ticks) ) sd.tickOffset += scl->scaleDraw()->majTickLength(); } canvasBorder[axis] = plot->canvas()->frameWidth() + d_data->canvasMargin[axis] + 1; } for ( axis = 0; axis < QwtPlot::axisCnt; axis++ ) { ScaleData &sd = scaleData[axis]; if ( sd.w && (axis == QwtPlot::xBottom || axis == QwtPlot::xTop) ) { if ( (sd.minLeft > canvasBorder[QwtPlot::yLeft]) && scaleData[QwtPlot::yLeft].w ) { int shiftLeft = sd.minLeft - canvasBorder[QwtPlot::yLeft]; if ( shiftLeft > scaleData[QwtPlot::yLeft].w ) shiftLeft = scaleData[QwtPlot::yLeft].w; sd.w -= shiftLeft; } if ( (sd.minRight > canvasBorder[QwtPlot::yRight]) && scaleData[QwtPlot::yRight].w ) { int shiftRight = sd.minRight - canvasBorder[QwtPlot::yRight]; if ( shiftRight > scaleData[QwtPlot::yRight].w ) shiftRight = scaleData[QwtPlot::yRight].w; sd.w -= shiftRight; } } if ( sd.h && (axis == QwtPlot::yLeft || axis == QwtPlot::yRight) ) { if ( (sd.minLeft > canvasBorder[QwtPlot::xBottom]) && scaleData[QwtPlot::xBottom].h ) { int shiftBottom = sd.minLeft - canvasBorder[QwtPlot::xBottom]; if ( shiftBottom > scaleData[QwtPlot::xBottom].tickOffset ) shiftBottom = scaleData[QwtPlot::xBottom].tickOffset; sd.h -= shiftBottom; } if ( (sd.minLeft > canvasBorder[QwtPlot::xTop]) && scaleData[QwtPlot::xTop].h ) { int shiftTop = sd.minRight - canvasBorder[QwtPlot::xTop]; if ( shiftTop > scaleData[QwtPlot::xTop].tickOffset ) shiftTop = scaleData[QwtPlot::xTop].tickOffset; sd.h -= shiftTop; } } } const QwtPlotCanvas *canvas = plot->canvas(); const QSize minCanvasSize = canvas->minimumSize(); int w = scaleData[QwtPlot::yLeft].w + scaleData[QwtPlot::yRight].w; int cw = qwtMax(scaleData[QwtPlot::xBottom].w, scaleData[QwtPlot::xTop].w) + 2 * (canvas->frameWidth() + 1); w += qwtMax(cw, minCanvasSize.width()); int h = scaleData[QwtPlot::xBottom].h + scaleData[QwtPlot::xTop].h; int ch = qwtMax(scaleData[QwtPlot::yLeft].h, scaleData[QwtPlot::yRight].h) + 2 * (canvas->frameWidth() + 1); h += qwtMax(ch, minCanvasSize.height()); const QwtTextLabel *title = plot->titleLabel(); if (title && !title->text().isEmpty()) { // If only QwtPlot::yLeft or QwtPlot::yRight is showing, // we center on the plot canvas. const bool centerOnCanvas = !(plot->axisEnabled(QwtPlot::yLeft) && plot->axisEnabled(QwtPlot::yRight)); int titleW = w; if ( centerOnCanvas ) { titleW -= scaleData[QwtPlot::yLeft].w + scaleData[QwtPlot::yRight].w; } int titleH = title->heightForWidth(titleW); if ( titleH > titleW ) // Compensate for a long title { w = titleW = titleH; if ( centerOnCanvas ) { w += scaleData[QwtPlot::yLeft].w + scaleData[QwtPlot::yRight].w; } titleH = title->heightForWidth(titleW); } h += titleH + d_data->spacing; } // Compute the legend contribution const QwtLegend *legend = plot->legend(); if ( d_data->legendPos != QwtPlot::ExternalLegend && legend && !legend->isEmpty() ) { if ( d_data->legendPos == QwtPlot::LeftLegend || d_data->legendPos == QwtPlot::RightLegend ) { int legendW = legend->sizeHint().width(); int legendH = legend->heightForWidth(legendW); if ( legend->frameWidth() > 0 ) w += d_data->spacing; if ( legendH > h ) legendW += legend->verticalScrollBar()->sizeHint().height(); if ( d_data->legendRatio < 1.0 ) legendW = qwtMin(legendW, int(w / (1.0 - d_data->legendRatio))); w += legendW; } else // QwtPlot::Top, QwtPlot::Bottom { int legendW = qwtMin(legend->sizeHint().width(), w); int legendH = legend->heightForWidth(legendW); if ( legend->frameWidth() > 0 ) h += d_data->spacing; if ( d_data->legendRatio < 1.0 ) legendH = qwtMin(legendH, int(h / (1.0 - d_data->legendRatio))); h += legendH; } } w += 2 * d_data->margin; h += 2 * d_data->margin; return QSize( w, h ); }
/*! Draw symbols \param painter Painter \param symbol Curve symbol \param xMap x map \param yMap y map \param canvasRect Contents rect of the canvas \param from Index of the first point to be painted \param to Index of the last point to be painted \sa setSymbol(), drawSeries(), drawCurve() */ void QwtPlotCurve::drawSymbols( QPainter *painter, const QwtSymbol &symbol, const QwtScaleMap &xMap, const QwtScaleMap &yMap, const QRectF &canvasRect, int from, int to ) const { const bool doAlign = QwtPainter::roundingAlignment( painter ); bool usePixmap = testPaintAttribute( CacheSymbols ); if ( usePixmap && !doAlign ) { // Don't use the pixmap, when the paint device // could generate scalable vectors usePixmap = false; } if ( usePixmap ) { const QSize sz = ( 2 * symbol.boundingSize() + QSize( 1, 1 ) ) / 2; const int w2 = sz.width() / 2; const int h2 = sz.height() / 2; QPixmap pm( sz ); pm.fill( Qt::transparent ); QPainter p( &pm ); p.setRenderHints( painter->renderHints() ); symbol.drawSymbol( &p, QPointF( w2, h2 ) ); p.end(); for ( int i = from; i <= to; i++ ) { const QPointF sample = d_series->sample( i ); const double xi = xMap.transform( sample.x() ); const double yi = yMap.transform( sample.y() ); if ( canvasRect.contains( xi, yi ) ) { const int left = qRound( xi ) - w2; const int top = qRound( yi ) - h2; painter->drawPixmap( left, top, pm ); } } } else { const int chunkSize = 500; for ( int i = from; i <= to; i += chunkSize ) { const int n = qMin( chunkSize, to - i + 1 ); QPolygonF points; for ( int j = 0; j < n; j++ ) { const QPointF sample = d_series->sample( i + j ); const double xi = xMap.transform( sample.x() ); const double yi = yMap.transform( sample.y() ); if ( canvasRect.contains( xi, yi ) ) points += QPointF( xi, yi ); } if ( points.size() > 0 ) symbol.drawSymbols( painter, points ); } } }
STDMETHODIMP CThumbnailProvider::GetThumbnail(UINT cx, HBITMAP *phbmp, WTS_ALPHATYPE *pdwAlpha) { *phbmp = NULL; *pdwAlpha = WTSAT_ARGB; int width, height; QSize size = renderer.defaultSize(); if(size.width() == size.height()){ width = cx; height = cx; } else if (size.width() > size.height()){ width = cx; height = size.height() * ((double)cx / (double)size.width()); } else { width = size.width() * ((double)cx / (double)size.height()); height = cx; } QFile * f = new QFile("C:\\dev\\svg.log"); f->open(QFile::Append); f->write(QString("Size: %1 \n.").arg(cx).toAscii()); f->flush(); f->close(); QImage * device = new QImage(width, height, QImage::Format_ARGB32); device->fill(Qt::transparent); QPainter * painter = new QPainter(); QFont font; QColor color_font = QColor(255, 0, 0); painter->begin(device); painter->setRenderHints(QPainter::Antialiasing | QPainter::SmoothPixmapTransform | QPainter::TextAntialiasing); assert(device->paintingActive() && painter->isActive()); if(loaded){ renderer.render(painter); } else { int font_size = cx / 10; font.setStyleHint(QFont::Monospace); font.setPixelSize(font_size); painter->setPen(color_font); painter->setFont(font); painter->drawText(font_size, (cx - font_size) / 2, "Invalid SVG file."); } painter->end(); assert(!device->isNull()); #ifndef NDEBUG device->save(QString("C:\\dev\\%1.png").arg(QDateTime::currentMSecsSinceEpoch()), "PNG"); #endif *phbmp = QPixmap::fromImage(*device).toWinHBITMAP(QPixmap::Alpha); assert(*phbmp != NULL); delete painter; delete device; if( *phbmp != NULL ) return NOERROR; return E_NOTIMPL; }
KoFilter::ConversionStatus ImageExport::convert(const QCString& from, const QCString& to) { if(from != "application/x-kivio") { return KoFilter::BadMimeType; } QString format; if(to == "image/png") { format = "PNG"; } else if(to == "image/jpeg") { format = "JPEG"; } else if(to == "image/x-bmp") { format = "BMP"; } else if(to == "image/x-eps") { format = "EPS"; } else if(to == "image/x-portable-bitmap") { format = "PBM"; } else if(to == "image/x-pcx") { format = "PCX"; } else if(to == "image/x-portable-pixmap") { format = "PPM"; } else if(to == "image/x-rgb") { format = "RGB"; } else if(to == "image/x-xpm") { format = "XPM"; } else if(to == "image/jp2") { format = "JP2"; } else { return KoFilter::BadMimeType; } KoStoreDevice* storeIn = m_chain->storageFile("root", KoStore::Read); if (!storeIn) { KMessageBox::error(0, i18n("Failed to read data."), i18n( "Export Error" )); return KoFilter::FileNotFound; } // Get the XML tree. QDomDocument domIn; domIn.setContent(storeIn); KivioDoc doc; if(!doc.loadXML(0, domIn)) { KMessageBox::error(0, i18n("Malformed XML data."), i18n("Export Error")); return KoFilter::WrongFormat; } ImageExportDialog dlg; QStringList pageNames; QPtrList<KivioPage> pageList = doc.map()->pageList(); QPtrListIterator<KivioPage> it(pageList); for(; it.current() != 0; ++it) { pageNames.append(it.current()->pageName()); } dlg.setPageList(pageNames); dlg.setInitialDPI(300); dlg.setInitialmargin(10); if(dlg.exec() != QDialog::Accepted) { return KoFilter::UserCancelled; } KivioPage* page = doc.map()->findPage(dlg.selectedPage()); if(!page) { kdDebug() << "The page named " << dlg.selectedPage() << " wasn't found!!" << endl; return KoFilter::InternalError; } float z = (float)dlg.imageDPI()/(float)KoGlobal::dpiX(); KoZoomHandler zoom; zoom.setZoomAndResolution(qRound(z * 100), KoGlobal::dpiX(), KoGlobal::dpiY()); QSize size; if(dlg.usePageBorders()) { size = QSize(zoom.zoomItX(page->paperLayout().ptWidth), zoom.zoomItY(page->paperLayout().ptHeight)); } else { size = zoom.zoomSize(page->getRectForAllStencils().size()); } kdDebug() << "KoGlobal::dpiX() " << KoGlobal::dpiX() << " KoGlobal::dpiY() " << KoGlobal::dpiY() << endl; int border = dlg.margin(); size.setWidth(size.width() + (border * 2)); size.setHeight(size.height() + (border * 2)); QPixmap pixmap = QPixmap(size); pixmap.fill(Qt::white); KivioScreenPainter kpainter; kpainter.start(&pixmap); float translationX = border; float translationY = border; if(!dlg.usePageBorders()) { QPoint point = zoom.zoomPoint(page->getRectForAllStencils().topLeft()); translationX -= point.x(); translationY -= point.y(); } kpainter.setTranslation(translationX, translationY); page->printContent(kpainter, &zoom); if(!pixmap.save(m_chain->outputFile(), format.local8Bit())) { return KoFilter::CreationError; } return KoFilter::OK; }
/*! \reimp */ QSize QToolButton::sizeHint() const { Q_D(const QToolButton); if (d->sizeHint.isValid()) return d->sizeHint; ensurePolished(); int w = 0, h = 0; QStyleOptionToolButton opt; initStyleOption(&opt); QFontMetrics fm = fontMetrics(); if (opt.toolButtonStyle != Qt::ToolButtonTextOnly) { QSize icon = opt.iconSize; w = icon.width(); h = icon.height(); } if (opt.toolButtonStyle != Qt::ToolButtonIconOnly) { QSize textSize = fm.size(Qt::TextShowMnemonic, text()); textSize.setWidth(textSize.width() + fm.width(QLatin1Char(' '))*2); if (opt.toolButtonStyle == Qt::ToolButtonTextUnderIcon) { h += 4 + textSize.height(); if (textSize.width() > w) w = textSize.width(); } else if (opt.toolButtonStyle == Qt::ToolButtonTextBesideIcon) { w += 4 + textSize.width(); if (textSize.height() > h) h = textSize.height(); } else { // TextOnly w = textSize.width(); h = textSize.height(); } } opt.rect.setSize(QSize(w, h)); // PM_MenuButtonIndicator depends on the height if (d->popupMode == MenuButtonPopup) w += style()->pixelMetric(QStyle::PM_MenuButtonIndicator, &opt, this); d->sizeHint = style()->sizeFromContents(QStyle::CT_ToolButton, &opt, QSize(w, h), this). expandedTo(QApplication::globalStrut()); return d->sizeHint; }
void QToolButtonPrivate::popupTimerDone() { Q_Q(QToolButton); popupTimer.stop(); if (!menuButtonDown && !down) return; menuButtonDown = true; QPointer<QMenu> actualMenu; bool mustDeleteActualMenu = false; if(menuAction) { actualMenu = menuAction->menu(); } else if (defaultAction && defaultAction->menu()) { actualMenu = defaultAction->menu(); } else { actualMenu = new QMenu(q); mustDeleteActualMenu = true; for(int i = 0; i < actions.size(); i++) actualMenu->addAction(actions.at(i)); } repeat = q->autoRepeat(); q->setAutoRepeat(false); bool horizontal = true; #if !defined(QT_NO_TOOLBAR) QToolBar *tb = qobject_cast<QToolBar*>(parent); if (tb && tb->orientation() == Qt::Vertical) horizontal = false; #endif QPoint p; QRect screen = QApplication::desktop()->availableGeometry(q); QSize sh = ((QToolButton*)(QMenu*)actualMenu)->receivers(SIGNAL(aboutToShow()))? QSize() : actualMenu->sizeHint(); QRect rect = q->rect(); if (horizontal) { if (q->isRightToLeft()) { if (q->mapToGlobal(QPoint(0, rect.bottom())).y() + sh.height() <= screen.height()) { p = q->mapToGlobal(rect.bottomRight()); } else { p = q->mapToGlobal(rect.topRight() - QPoint(0, sh.height())); } p.rx() -= sh.width(); } else { if (q->mapToGlobal(QPoint(0, rect.bottom())).y() + sh.height() <= screen.height()) { p = q->mapToGlobal(rect.bottomLeft()); } else { p = q->mapToGlobal(rect.topLeft() - QPoint(0, sh.height())); } } } else { if (q->isRightToLeft()) { if (q->mapToGlobal(QPoint(rect.left(), 0)).x() - sh.width() <= screen.x()) { p = q->mapToGlobal(rect.topRight()); } else { p = q->mapToGlobal(rect.topLeft()); p.rx() -= sh.width(); } } else { if (q->mapToGlobal(QPoint(rect.right(), 0)).x() + sh.width() <= screen.right()) { p = q->mapToGlobal(rect.topRight()); } else { p = q->mapToGlobal(rect.topLeft() - QPoint(sh.width(), 0)); } } } p.rx() = qMax(screen.left(), qMin(p.x(), screen.right() - sh.width())); p.ry() += 1; QPointer<QToolButton> that = q; actualMenu->setNoReplayFor(q); if (!mustDeleteActualMenu) //only if action are not in this widget QObject::connect(actualMenu, SIGNAL(triggered(QAction*)), q, SLOT(_q_menuTriggered(QAction*))); QObject::connect(actualMenu, SIGNAL(aboutToHide()), q, SLOT(_q_updateButtonDown())); actualMenu->d_func()->causedPopup.widget = q; actualMenu->d_func()->causedPopup.action = defaultAction; actionsCopy = q->actions(); //(the list of action may be modified in slots) actualMenu->exec(p); QObject::disconnect(actualMenu, SIGNAL(aboutToHide()), q, SLOT(_q_updateButtonDown())); if (mustDeleteActualMenu) delete actualMenu; else QObject::disconnect(actualMenu, SIGNAL(triggered(QAction*)), q, SLOT(_q_menuTriggered(QAction*))); if (!that) return; actionsCopy.clear(); if (repeat) q->setAutoRepeat(true); }
static QSize maxSize(const QSize &a, const QSize &b) { return QSize(qMax(a.width(), b.width()), qMax(a.height(), b.height())); }
//! \internal void XmlPreferencesPrivate::writeSection(XmlWriter& out, const QString& name, const Section& section) { QHash<QString,QString> attrs; attrs.insert("name", name); out.writeOpenTag("section", attrs); attrs.clear(); for (Section::ConstIterator sectionIterator = section.constBegin(); sectionIterator != section.constEnd(); ++sectionIterator) { const EncVariant& v = sectionIterator.value(); attrs.insert("name", sectionIterator.key()); switch (v.data.type()) { case QVariant::String : attrs.insert("type", "string"); out.writeTaggedString("setting", v.data.toString(), attrs); break; case QVariant::StringList : { attrs.insert("type", "stringlist"); out.writeOpenTag("setting", attrs); attrs.clear(); QStringList list = v.data.toStringList(); for (int i = 0; i < list.size(); ++i) out.writeTaggedString("value", list.at(i), attrs); out.writeCloseTag("setting"); } break; case QVariant::Bool : attrs.insert("type", "bool"); out.writeTaggedString("setting", v.data.toBool() ? "true" : "false", attrs); break; case QVariant::Int : attrs.insert("type", "int"); out.writeTaggedString("setting", QString::number(v.data.toInt()), attrs); break; case QVariant::LongLong : attrs.insert("type", "int64"); out.writeTaggedString("setting", QString::number(v.data.toLongLong()), attrs); break; case QVariant::Rect : { attrs.insert("type", "rect"); QRect rect = v.data.toRect(); QString s = QString("%1;%2;%3;%4").arg(rect.x()).arg(rect.y()).arg(rect.width()).arg(rect.height()); out.writeTaggedString("setting", s, attrs); } break; case QVariant::Point : { attrs.insert("type", "point"); QPoint point = v.data.toPoint(); QString s = QString("%1;%2").arg(point.x()).arg(point.y()); out.writeTaggedString("setting", s, attrs); } break; case QVariant::Size : { attrs.insert("type", "size"); QSize size = v.data.toSize(); QString s = QString("%1;%2").arg(size.width()).arg(size.height()); out.writeTaggedString("setting", s, attrs); } break; case QVariant::ByteArray : { attrs.insert("type", "bytearray"); const QByteArray ba = v.data.toByteArray(); switch (v.encoding) { case XmlPreferences::Base64: attrs.insert("encoding", "base64"); out.writeTaggedString("setting", Base64::encode(ba), attrs); break; default: attrs.insert("encoding", "csv"); QString s; for (uint i = 0; i < (uint) ba.size(); ++i) (i != 0) ? s += "," + QString::number((uint)ba.at(i), 16) : s += QString::number((uint)ba.at(i), 16); out.writeTaggedString("setting", s, attrs); } attrs.clear(); } break; case QVariant::BitArray : { attrs.insert("type", "bitarray"); const QBitArray ba = v.data.toBitArray(); attrs.insert("size", QString::number(ba.size())); switch (v.encoding) { case XmlPreferences::Base64: attrs.insert("encoding", "base64"); out.writeTaggedString("setting", Base64::encode(ba), attrs); break; default: attrs.insert("encoding", "csv"); QString s; for (uint i = 0; i < (uint) ba.size(); ++i) (i != 0) ? s += ba.testBit(i) ? ",1" : ",0" : s += ba.testBit(i) ? "1" : "0"; out.writeTaggedString("setting", s, attrs); } attrs.clear(); } break; #ifndef QT_CORE_ONLY case QVariant::Color : attrs.insert("type", "color"); out.writeTaggedString("setting", v.data.value<QColor>().name(), attrs); break; #endif // QT_CORE_ONLY default: ; } } out.writeCloseTag("section"); }
void GLC_Viewport::setWinGLSize(const QSize &size, bool updateOpenGL) { setWinGLSize(size.width(), size.height(), updateOpenGL); }
QSize adjustSize(PrintOptionsPage* optionsPage, Document::Ptr doc, int printerResolution, const QSize & viewportSize) { QSize size = doc->size(); PrintOptionsPage::ScaleMode scaleMode = optionsPage->scaleMode(); if (scaleMode == PrintOptionsPage::ScaleToPage) { bool imageBiggerThanPaper = size.width() > viewportSize.width() || size.height() > viewportSize.height(); if (imageBiggerThanPaper || optionsPage->enlargeSmallerImages()) { size.scale(viewportSize, Qt::KeepAspectRatio); } } else if (scaleMode == PrintOptionsPage::ScaleToCustomSize) { double wImg = optionsPage->scaleWidth(); double hImg = optionsPage->scaleHeight(); size.setWidth(int(wImg * printerResolution)); size.setHeight(int(hImg * printerResolution)); } else { // No scale const double INCHES_PER_METER = 100. / 2.54; int dpmX = doc->image().dotsPerMeterX(); int dpmY = doc->image().dotsPerMeterY(); if (dpmX > 0 && dpmY > 0) { double wImg = double(size.width()) / double(dpmX) * INCHES_PER_METER; double hImg = double(size.height()) / double(dpmY) * INCHES_PER_METER; size.setWidth(int(wImg * printerResolution)); size.setHeight(int(hImg * printerResolution)); } } return size; }
QSize TickSlider::sizeHint() const { QSize size = QSlider::sizeHint(); bool using_labels = tickLabelPosition() != NoTicks; QSize label = using_labels ? biggestLabel() : QSize(); bool using_ticks = tickPosition() != NoTicks; int n_potential_labels = (maximum() - minimum()) / tickInterval(); if (orientation() == Qt::Horizontal) { // Horizontal if (using_labels) { size.rheight() += 2 * label.height(); size = size.expandedTo(QSize( n_potential_labels * label.width() + (n_potential_labels - 1) * m_min_interlabel_gap, 0)); } if (using_ticks) { size.rheight() += 2 * m_tick_length; } if (using_labels && using_ticks) { size.rheight() += 2 * m_tick_label_gap; } if (using_labels || using_ticks) { size.rheight() += 2 * m_gap_to_slider; } } else { // Vertical if (using_labels) { size.rwidth() += 2 * label.width(); size = size.expandedTo(QSize( 0, n_potential_labels * label.height() + (n_potential_labels - 1) * m_min_interlabel_gap)); } if (using_ticks) { size.rwidth() += 2 * m_tick_length; } if (using_labels && using_ticks) { size.rwidth() += 2 * m_tick_label_gap; } if (using_labels || using_ticks) { size.rwidth() += 2 * m_gap_to_slider; } } return size; }
QSize QToolBarAreaLayout::minimumSize(const QSize ¢erMin) const { if (!visible) return centerMin; QSize result = centerMin; QSize left_min = docks[QInternal::LeftDock].minimumSize(); QSize right_min = docks[QInternal::RightDock].minimumSize(); QSize top_min = docks[QInternal::TopDock].minimumSize(); QSize bottom_min = docks[QInternal::BottomDock].minimumSize(); result.setWidth(qMax(top_min.width(), result.width())); result.setWidth(qMax(bottom_min.width(), result.width())); result.setHeight(qMax(left_min.height(), result.height())); result.setHeight(qMax(right_min.height(), result.height())); result.rwidth() += left_min.width() + right_min.width(); result.rheight() += top_min.height() + bottom_min.height(); return result; }
QSize PropertyListFrame::minimumSizeHint() const { QSize size = layout()->minimumSize(); size.setWidth(parentWidget()->width()); return size; }
QSize QToolBarAreaLayout::sizeHint(const QSize ¢erHint) const { if (!visible) return centerHint; QSize result = centerHint; QSize left_hint = docks[QInternal::LeftDock].sizeHint(); QSize right_hint = docks[QInternal::RightDock].sizeHint(); QSize top_hint = docks[QInternal::TopDock].sizeHint(); QSize bottom_hint = docks[QInternal::BottomDock].sizeHint(); result.setWidth(qMax(top_hint.width(), result.width())); result.setWidth(qMax(bottom_hint.width(), result.width())); result.setHeight(qMax(left_hint.height(), result.height())); result.setHeight(qMax(right_hint.height(), result.height())); result.rwidth() += left_hint.width() + right_hint.width(); result.rheight() += top_hint.height() + bottom_hint.height(); return result; }
Preferences::Preferences(QupZilla* mainClass, QWidget* parent) : QDialog(parent) , ui(new Ui::Preferences) , p_QupZilla(mainClass) , m_autoFillManager(0) , m_pluginsList(0) , m_autoFillEnabled(false) { setAttribute(Qt::WA_DeleteOnClose); ui->setupUi(this); ui->languages->setLayoutDirection(Qt::LeftToRight); m_themesManager = new ThemeManager(ui->themesWidget, this); m_pluginsList = new PluginsManager(this); ui->pluginsFrame->addWidget(m_pluginsList); if (QIcon::themeName().toLower() == QLatin1String("oxygen")) { ui->listWidget->item(0)->setIcon(QIcon::fromTheme("preferences-desktop", QIcon(":/icons/preferences/preferences-desktop.png"))); ui->listWidget->item(1)->setIcon(QIcon::fromTheme("format-stroke-color", QIcon(":/icons/preferences/application-x-theme.png"))); ui->listWidget->item(2)->setIcon(QIcon::fromTheme("tab-new-background", QIcon(":/icons/preferences/applications-internet.png"))); ui->listWidget->item(3)->setIcon(QIcon::fromTheme("preferences-system-network", QIcon(":/icons/preferences/applications-webbrowsers.png"))); ui->listWidget->item(4)->setIcon(QIcon::fromTheme("preferences-desktop-font", QIcon(":/icons/preferences/applications-fonts.png"))); ui->listWidget->item(5)->setIcon(QIcon::fromTheme("configure-shortcuts", QIcon(":/icons/preferences/preferences-desktop-keyboard-shortcuts.png"))); ui->listWidget->item(6)->setIcon(QIcon::fromTheme("download", QIcon(":/icons/preferences/mail-inbox.png"))); ui->listWidget->item(7)->setIcon(QIcon::fromTheme("user-identity", QIcon(":/icons/preferences/dialog-password.png"))); ui->listWidget->item(8)->setIcon(QIcon::fromTheme("preferences-system-firewall", QIcon(":/icons/preferences/preferences-system-firewall.png"))); ui->listWidget->item(9)->setIcon(QIcon::fromTheme("preferences-desktop-notification", QIcon(":/icons/preferences/dialog-question.png"))); ui->listWidget->item(10)->setIcon(QIcon::fromTheme("preferences-plugin", QIcon(":/icons/preferences/extension.png"))); ui->listWidget->item(11)->setIcon(QIcon::fromTheme("applications-system", QIcon(":/icons/preferences/applications-system.png"))); } else { ui->listWidget->item(0)->setIcon(QIcon::fromTheme("preferences-desktop", QIcon(":/icons/preferences/preferences-desktop.png"))); ui->listWidget->item(1)->setIcon(QIcon::fromTheme("application-x-theme", QIcon(":/icons/preferences/application-x-theme.png"))); ui->listWidget->item(2)->setIcon(QIcon::fromTheme("applications-internet", QIcon(":/icons/preferences/applications-internet.png"))); ui->listWidget->item(3)->setIcon(QIcon::fromTheme("applications-webbrowsers", QIcon(":/icons/preferences/applications-webbrowsers.png"))); ui->listWidget->item(4)->setIcon(QIcon::fromTheme("applications-fonts", QIcon(":/icons/preferences/applications-fonts.png"))); ui->listWidget->item(5)->setIcon(QIcon::fromTheme("preferences-desktop-keyboard-shortcuts", QIcon(":/icons/preferences/preferences-desktop-keyboard-shortcuts.png"))); ui->listWidget->item(6)->setIcon(QIcon::fromTheme("mail-inbox", QIcon(":/icons/preferences/mail-inbox.png"))); ui->listWidget->item(7)->setIcon(QIcon::fromTheme("dialog-password", QIcon(":/icons/preferences/dialog-password.png"))); ui->listWidget->item(8)->setIcon(QIcon::fromTheme("preferences-system-firewall", QIcon(":/icons/preferences/preferences-system-firewall.png"))); ui->listWidget->item(9)->setIcon(QIcon::fromTheme("dialog-question", QIcon(":/icons/preferences/dialog-question.png"))); ui->listWidget->item(10)->setIcon(QIcon::fromTheme("extension", QIcon(":/icons/preferences/extension.png"))); ui->listWidget->item(11)->setIcon(QIcon::fromTheme("applications-system", QIcon(":/icons/preferences/applications-system.png"))); } Settings settings; //GENERAL URLs settings.beginGroup("Web-URL-Settings"); m_homepage = settings.value("homepage", "qupzilla:start").toString(); m_newTabUrl = settings.value("newTabUrl", "qupzilla:speeddial").toString(); ui->homepage->setText(m_homepage); ui->newTabUrl->setText(m_newTabUrl); int afterLaunch = settings.value("afterLaunch", 1).toInt(); settings.endGroup(); ui->afterLaunch->setCurrentIndex(afterLaunch); ui->checkUpdates->setChecked(settings.value("Web-Browser-Settings/CheckUpdates", DEFAULT_CHECK_UPDATES).toBool()); ui->dontLoadTabsUntilSelected->setChecked(settings.value("Web-Browser-Settings/LoadTabsOnActivation", false).toBool()); #if defined(Q_OS_WIN) && !defined(Q_OS_OS2) ui->checkDefaultBrowser->setChecked(settings.value("Web-Browser-Settings/CheckDefaultBrowser", DEFAULT_CHECK_DEFAULTBROWSER).toBool()); if (mApp->associationManager()->isDefaultForAllCapabilities()) { ui->checkNowDefaultBrowser->setText(tr("Default")); ui->checkNowDefaultBrowser->setEnabled(false); } else { ui->checkNowDefaultBrowser->setText(tr("Set as default")); ui->checkNowDefaultBrowser->setEnabled(true); connect(ui->checkNowDefaultBrowser, SIGNAL(clicked()), this, SLOT(makeQupZillaDefault())); } #else // No Default Browser settings on non-Windows platform ui->hSpacerDefaultBrowser->changeSize(0, 0, QSizePolicy::Fixed, QSizePolicy::Fixed); ui->hLayoutDefaultBrowser->invalidate(); delete ui->hLayoutDefaultBrowser; delete ui->checkDefaultBrowser; delete ui->checkNowDefaultBrowser; #endif ui->newTabFrame->setVisible(false); if (m_newTabUrl.isEmpty()) { ui->newTab->setCurrentIndex(0); } else if (m_newTabUrl == m_homepage) { ui->newTab->setCurrentIndex(1); } else if (m_newTabUrl == QLatin1String("qupzilla:speeddial")) { ui->newTab->setCurrentIndex(2); } else { ui->newTab->setCurrentIndex(3); ui->newTabFrame->setVisible(true); } afterLaunchChanged(ui->afterLaunch->currentIndex()); connect(ui->afterLaunch, SIGNAL(currentIndexChanged(int)), this, SLOT(afterLaunchChanged(int))); connect(ui->newTab, SIGNAL(currentIndexChanged(int)), this, SLOT(newTabChanged(int))); if (p_QupZilla) { connect(ui->useCurrentBut, SIGNAL(clicked()), this, SLOT(useActualHomepage())); connect(ui->newTabUseCurrent, SIGNAL(clicked()), this, SLOT(useActualNewTab())); } else { ui->useCurrentBut->setEnabled(false); ui->newTabUseCurrent->setEnabled(false); } //PROFILES m_actProfileName = mApp->currentProfilePath(); m_actProfileName = m_actProfileName.left(m_actProfileName.length() - 1); m_actProfileName = m_actProfileName.mid(m_actProfileName.lastIndexOf(QLatin1Char('/'))); m_actProfileName.remove(QLatin1Char('/')); ui->activeProfile->setText("<b>" + m_actProfileName + "</b>"); QSettings profileSettings(mApp->PROFILEDIR + "profiles/profiles.ini", QSettings::IniFormat); QString actProfileName = profileSettings.value("Profiles/startProfile", "default").toString(); ui->startProfile->addItem(actProfileName); QDir profilesDir(mApp->PROFILEDIR + "profiles/"); QStringList list_ = profilesDir.entryList(QDir::Dirs | QDir::NoDotAndDotDot); foreach (const QString &name, list_) { if (actProfileName == name) { continue; } ui->startProfile->addItem(name); } connect(ui->createProfile, SIGNAL(clicked()), this, SLOT(createProfile())); connect(ui->deleteProfile, SIGNAL(clicked()), this, SLOT(deleteProfile())); connect(ui->startProfile, SIGNAL(currentIndexChanged(QString)), this, SLOT(startProfileIndexChanged(QString))); startProfileIndexChanged(ui->startProfile->currentText()); //APPEREANCE settings.beginGroup("Browser-View-Settings"); ui->showStatusbar->setChecked(settings.value("showStatusBar", true).toBool()); if (p_QupZilla) { ui->showBookmarksToolbar->setChecked(p_QupZilla->bookmarksToolbar()->isVisible()); ui->showNavigationToolbar->setChecked(p_QupZilla->navigationBar()->isVisible()); } else { ui->showBookmarksToolbar->setChecked(settings.value("showBookmarksToolbar", true).toBool()); ui->showNavigationToolbar->setChecked(settings.value("showNavigationToolbar", true).toBool()); } ui->showHome->setChecked(settings.value("showHomeButton", true).toBool()); ui->showBackForward->setChecked(settings.value("showBackForwardButtons", true).toBool()); ui->showAddTabButton->setChecked(settings.value("showAddTabButton", false).toBool()); ui->showReloadStopButtons->setChecked(settings.value("showReloadButton", true).toBool()); ui->showWebSearchBar->setChecked(settings.value("showWebSearchBar", true).toBool()); ui->useTransparentBg->setChecked(settings.value("useTransparentBackground", false).toBool()); int currentSettingsPage = settings.value("settingsDialogPage", 0).toInt(0); settings.endGroup(); #ifdef Q_OS_WIN ui->useTransparentBg->setEnabled(QtWin::isCompositionEnabled()); #endif //TABS settings.beginGroup("Browser-Tabs-Settings"); ui->hideTabsOnTab->setChecked(settings.value("hideTabsWithOneTab", false).toBool()); ui->activateLastTab->setChecked(settings.value("ActivateLastTabWhenClosingActual", false).toBool()); ui->openNewTabAfterActive->setChecked(settings.value("newTabAfterActive", true).toBool()); ui->openNewEmptyTabAfterActive->setChecked(settings.value("newEmptyTabAfterActive", false).toBool()); ui->alwaysSwitchTabsWithWheel->setChecked(settings.value("AlwaysSwitchTabsWithWheel", false).toBool()); ui->switchToNewTabs->setChecked(settings.value("OpenNewTabsSelected", false).toBool()); ui->dontQuitOnTab->setChecked(settings.value("dontQuitWithOneTab", false).toBool()); ui->askWhenClosingMultipleTabs->setChecked(settings.value("AskOnClosing", false).toBool()); ui->closedInsteadOpened->setChecked(settings.value("closedInsteadOpenedTabs", false).toBool()); ui->showTabPreviews->setChecked(settings.value("showTabPreviews", true).toBool()); ui->animatedTabPreviews->setChecked(settings.value("tabPreviewAnimationsEnabled", true).toBool()); settings.endGroup(); connect(ui->showTabPreviews, SIGNAL(toggled(bool)), this, SLOT(showTabPreviewsChanged(bool))); showTabPreviewsChanged(ui->showTabPreviews->isChecked()); //AddressBar settings.beginGroup("AddressBar"); ui->addressbarCompletion->setCurrentIndex(settings.value("showSuggestions", 0).toInt()); ui->useInlineCompletion->setChecked(settings.value("useInlineCompletion", true).toBool()); ui->completionShowSwitchTab->setChecked(settings.value("showSwitchTab", true).toBool()); ui->alwaysShowGoIcon->setChecked(settings.value("alwaysShowGoIcon", false).toBool()); ui->selectAllOnFocus->setChecked(settings.value("SelectAllTextOnDoubleClick", true).toBool()); ui->selectAllOnClick->setChecked(settings.value("SelectAllTextOnClick", false).toBool()); ui->addCountryWithAlt->setChecked(settings.value("AddCountryDomainWithAltKey", true).toBool()); bool showPBinAB = settings.value("ShowLoadingProgress", false).toBool(); ui->showLoadingInAddressBar->setChecked(showPBinAB); ui->adressProgressSettings->setEnabled(showPBinAB); ui->progressStyleSelector->setCurrentIndex(settings.value("ProgressStyle", 0).toInt()); bool pbInABuseCC = settings.value("UseCustomProgressColor", false).toBool(); ui->checkBoxCustomProgressColor->setChecked(pbInABuseCC); ui->progressBarColorSelector->setEnabled(pbInABuseCC); QColor pbColor = settings.value("CustomProgressColor", p_QupZilla->palette().color(QPalette::Highlight)).value<QColor>(); setProgressBarColorIcon(pbColor); connect(ui->customColorToolButton, SIGNAL(clicked(bool)), SLOT(selectCustomProgressBarColor())); connect(ui->resetProgressBarcolor, SIGNAL(clicked()), SLOT(setProgressBarColorIcon())); settings.endGroup(); settings.beginGroup("SearchEngines"); ui->searchWithDefaultEngine->setChecked(settings.value("SearchWithDefaultEngine", false).toBool()); settings.endGroup(); //BROWSING settings.beginGroup("Web-Browser-Settings"); ui->allowPlugins->setChecked(settings.value("allowFlash", true).toBool()); ui->allowJavaScript->setChecked(settings.value("allowJavaScript", true).toBool()); ui->allowJava->setChecked(settings.value("allowJava", true).toBool()); ui->allowDNSPrefetch->setChecked(settings.value("DNS-Prefetch", false).toBool()); ui->linksInFocusChain->setChecked(settings.value("IncludeLinkInFocusChain", false).toBool()); ui->zoomTextOnly->setChecked(settings.value("zoomTextOnly", false).toBool()); ui->spatialNavigation->setChecked(settings.value("SpatialNavigation", false).toBool()); ui->caretBrowsing->setChecked(settings.value("CaretBrowsing", false).toBool()); ui->animateScrolling->setChecked(settings.value("AnimateScrolling", true).toBool()); ui->printEBackground->setChecked(settings.value("PrintElementBackground", true).toBool()); ui->wheelScroll->setValue(settings.value("wheelScrollLines", qApp->wheelScrollLines()).toInt()); ui->defaultZoom->setValue(settings.value("DefaultZoom", 100).toInt()); ui->xssAuditing->setChecked(settings.value("XSSAuditing", false).toBool()); ui->formsUndoRedo->setChecked(settings.value("enableFormsUndoRedo", false).toBool()); //Cache ui->pagesInCache->setValue(settings.value("maximumCachedPages", 3).toInt()); connect(ui->pagesInCache, SIGNAL(valueChanged(int)), this, SLOT(pageCacheValueChanged(int))); ui->pageCacheLabel->setText(QString::number(ui->pagesInCache->value())); ui->allowCache->setChecked(settings.value("AllowLocalCache", true).toBool()); ui->cacheMB->setValue(settings.value("LocalCacheSize", 50).toInt()); ui->MBlabel->setText(settings.value("LocalCacheSize", 50).toString() + " MB"); ui->cachePath->setText(settings.value("CachePath", QString("%1networkcache/").arg(mApp->currentProfilePath())).toString()); connect(ui->allowCache, SIGNAL(clicked(bool)), this, SLOT(allowCacheChanged(bool))); connect(ui->cacheMB, SIGNAL(valueChanged(int)), this, SLOT(cacheValueChanged(int))); connect(ui->changeCachePath, SIGNAL(clicked()), this, SLOT(changeCachePathClicked())); allowCacheChanged(ui->allowCache->isChecked()); //PASSWORD MANAGER ui->allowPassManager->setChecked(settings.value("SavePasswordsOnSites", true).toBool()); connect(ui->allowPassManager, SIGNAL(toggled(bool)), this, SLOT(showPassManager(bool))); showPassManager(ui->allowPassManager->isChecked()); //PRIVACY //Web storage ui->saveHistory->setChecked(settings.value("allowHistory", true).toBool()); ui->deleteHistoryOnClose->setChecked(settings.value("deleteHistoryOnClose", false).toBool()); if (!ui->saveHistory->isChecked()) { ui->deleteHistoryOnClose->setEnabled(false); } connect(ui->saveHistory, SIGNAL(toggled(bool)), this, SLOT(saveHistoryChanged(bool))); // Html5Storage ui->html5storage->setChecked(settings.value("HTML5StorageEnabled", true).toBool()); ui->deleteHtml5storageOnClose->setChecked(settings.value("deleteHTML5StorageOnClose", false).toBool()); connect(ui->html5storage, SIGNAL(toggled(bool)), this, SLOT(allowHtml5storageChanged(bool))); // Other ui->doNotTrack->setChecked(settings.value("DoNotTrack", false).toBool()); ui->sendReferer->setChecked(settings.value("SendReferer", true).toBool()); //CSS Style ui->userStyleSheet->setText(settings.value("userStyleSheet", "").toString()); connect(ui->chooseUserStylesheet, SIGNAL(clicked()), this, SLOT(chooseUserStyleClicked())); settings.endGroup(); //DOWNLOADS settings.beginGroup("DownloadManager"); ui->downLoc->setText(settings.value("defaultDownloadPath", "").toString()); ui->closeDownManOnFinish->setChecked(settings.value("CloseManagerOnFinish", false).toBool()); ui->downlaodNativeSystemDialog->setChecked(settings.value("useNativeDialog", DEFAULT_DOWNLOAD_USE_NATIVE_DIALOG).toBool()); if (ui->downLoc->text().isEmpty()) { ui->askEverytime->setChecked(true); } else { ui->useDefined->setChecked(true); } ui->useExternalDownManager->setChecked(settings.value("UseExternalManager", false).toBool()); ui->externalDownExecutable->setText(settings.value("ExternalManagerExecutable", "").toString()); ui->externalDownArguments->setText(settings.value("ExternalManagerArguments", "").toString()); connect(ui->useExternalDownManager, SIGNAL(toggled(bool)), this, SLOT(useExternalDownManagerChanged(bool))); connect(ui->useDefined, SIGNAL(toggled(bool)), this, SLOT(downLocChanged(bool))); connect(ui->downButt, SIGNAL(clicked()), this, SLOT(chooseDownPath())); connect(ui->chooseExternalDown, SIGNAL(clicked()), this, SLOT(chooseExternalDownloadManager())); downLocChanged(ui->useDefined->isChecked()); useExternalDownManagerChanged(ui->useExternalDownManager->isChecked()); settings.endGroup(); //FONTS settings.beginGroup("Browser-Fonts"); ui->fontStandard->setCurrentFont(QFont(settings.value("StandardFont", mApp->webSettings()->fontFamily(QWebSettings::StandardFont)).toString())); ui->fontCursive->setCurrentFont(QFont(settings.value("CursiveFont", mApp->webSettings()->fontFamily(QWebSettings::CursiveFont)).toString())); ui->fontFantasy->setCurrentFont(QFont(settings.value("FantasyFont", mApp->webSettings()->fontFamily(QWebSettings::FantasyFont)).toString())); ui->fontFixed->setCurrentFont(QFont(settings.value("FixedFont", mApp->webSettings()->fontFamily(QWebSettings::FixedFont)).toString())); ui->fontSansSerif->setCurrentFont(QFont(settings.value("SansSerifFont", mApp->webSettings()->fontFamily(QWebSettings::SansSerifFont)).toString())); ui->fontSerif->setCurrentFont(QFont(settings.value("SerifFont", mApp->webSettings()->fontFamily(QWebSettings::SerifFont)).toString())); ui->sizeDefault->setValue(settings.value("DefaultFontSize", mApp->webSettings()->fontSize(QWebSettings::DefaultFontSize)).toInt()); ui->sizeFixed->setValue(settings.value("FixedFontSize", mApp->webSettings()->fontSize(QWebSettings::DefaultFixedFontSize)).toInt()); ui->sizeMinimum->setValue(settings.value("MinimumFontSize", mApp->webSettings()->fontSize(QWebSettings::MinimumFontSize)).toInt()); ui->sizeMinimumLogical->setValue(settings.value("MinimumLogicalFontSize", mApp->webSettings()->fontSize(QWebSettings::MinimumLogicalFontSize)).toInt()); settings.endGroup(); //KEYBOARD SHORTCUTS settings.beginGroup("Shortcuts"); ui->switchTabsAlt->setChecked(settings.value("useTabNumberShortcuts", true).toBool()); ui->loadSpeedDialsCtrl->setChecked(settings.value("useSpeedDialNumberShortcuts", true).toBool()); settings.endGroup(); //NOTIFICATIONS ui->useNativeSystemNotifications->setEnabled(mApp->desktopNotifications()->supportsNativeNotifications()); DesktopNotificationsFactory::Type notifyType; settings.beginGroup("Notifications"); ui->notificationTimeout->setValue(settings.value("Timeout", 6000).toInt() / 1000); #ifdef QZ_WS_X11 notifyType = settings.value("UseNativeDesktop", true).toBool() ? DesktopNotificationsFactory::DesktopNative : DesktopNotificationsFactory::PopupWidget; #else notifyType = DesktopNotificationsFactory::PopupWidget; #endif if (ui->useNativeSystemNotifications->isEnabled() && notifyType == DesktopNotificationsFactory::DesktopNative) { ui->useNativeSystemNotifications->setChecked(true); } else { ui->useOSDNotifications->setChecked(true); } connect(ui->useNativeSystemNotifications, SIGNAL(toggled(bool)), this, SLOT(setNotificationPreviewVisible(bool))); connect(ui->useOSDNotifications, SIGNAL(toggled(bool)), this, SLOT(setNotificationPreviewVisible(bool))); ui->doNotUseNotifications->setChecked(!settings.value("Enabled", true).toBool()); m_notifPosition = settings.value("Position", QPoint(10, 10)).toPoint(); settings.endGroup(); //OTHER //Languages QString activeLanguage = mApp->currentLanguage(); if (!activeLanguage.isEmpty() && activeLanguage != QLatin1String("en_US")) { ui->languages->addItem(createLanguageItem(activeLanguage), activeLanguage); } ui->languages->addItem("English (en_US)"); QDir lanDir(mApp->TRANSLATIONSDIR); QStringList list = lanDir.entryList(QStringList("*.qm")); foreach (const QString &name, list) { if (name.startsWith(QLatin1String("qt_"))) { continue; } QString loc = name; loc.remove(QLatin1String(".qm")); if (loc == activeLanguage) { continue; } ui->languages->addItem(createLanguageItem(loc), loc); } // Proxy Configuration settings.beginGroup("Web-Proxy"); NetworkProxyFactory::ProxyPreference proxyPreference = NetworkProxyFactory::ProxyPreference(settings.value("UseProxy", NetworkProxyFactory::SystemProxy).toInt()); QNetworkProxy::ProxyType proxyType = QNetworkProxy::ProxyType(settings.value("ProxyType", QNetworkProxy::HttpProxy).toInt()); ui->systemProxy->setChecked(proxyPreference == NetworkProxyFactory::SystemProxy); ui->noProxy->setChecked(proxyPreference == NetworkProxyFactory::NoProxy); ui->manualProxy->setChecked(proxyPreference == NetworkProxyFactory::DefinedProxy); ui->pacProxy->setChecked(proxyPreference == NetworkProxyFactory::ProxyAutoConfig); if (proxyType == QNetworkProxy::HttpProxy) { ui->proxyType->setCurrentIndex(0); } else { ui->proxyType->setCurrentIndex(1); } ui->proxyServer->setText(settings.value("HostName", "").toString()); ui->proxyPort->setText(settings.value("Port", 8080).toString()); ui->proxyUsername->setText(settings.value("Username", "").toString()); ui->proxyPassword->setText(settings.value("Password", "").toString()); ui->useHttpsProxy->setChecked(settings.value("UseDifferentProxyForHttps", false).toBool()); ui->httpsProxyServer->setText(settings.value("HttpsHostName", "").toString()); ui->httpsProxyPort->setText(settings.value("HttpsPort", 8080).toString()); ui->httpsProxyUsername->setText(settings.value("HttpsUsername", "").toString()); ui->httpsProxyPassword->setText(settings.value("HttpsPassword", "").toString()); ui->pacUrl->setText(settings.value("PacUrl", QUrl()).toUrl().toString()); ui->proxyExceptions->setText(settings.value("ProxyExceptions", QStringList() << "localhost" << "127.0.0.1").toStringList().join(",")); settings.endGroup(); useDifferentProxyForHttpsChanged(ui->useHttpsProxy->isChecked()); setManualProxyConfigurationEnabled(proxyPreference == NetworkProxyFactory::DefinedProxy); setProxyAutoConfigEnabled(proxyPreference == NetworkProxyFactory::ProxyAutoConfig); connect(ui->manualProxy, SIGNAL(toggled(bool)), this, SLOT(setManualProxyConfigurationEnabled(bool))); connect(ui->pacProxy, SIGNAL(toggled(bool)), this, SLOT(setProxyAutoConfigEnabled(bool))); connect(ui->useHttpsProxy, SIGNAL(toggled(bool)), this, SLOT(useDifferentProxyForHttpsChanged(bool))); connect(ui->reloadPac, SIGNAL(clicked()), this, SLOT(reloadPacFileClicked())); //CONNECTS connect(ui->buttonBox, SIGNAL(clicked(QAbstractButton*)), this, SLOT(buttonClicked(QAbstractButton*))); connect(ui->cookieManagerBut, SIGNAL(clicked()), this, SLOT(showCookieManager())); connect(ui->html5permissions, SIGNAL(clicked()), this, SLOT(showHtml5Permissions())); connect(ui->sslManagerButton, SIGNAL(clicked()), this, SLOT(openSslManager())); connect(ui->preferredLanguages, SIGNAL(clicked()), this, SLOT(showAcceptLanguage())); connect(ui->deleteHtml5storage, SIGNAL(clicked()), this, SLOT(deleteHtml5storage())); connect(ui->uaManager, SIGNAL(clicked()), this, SLOT(openUserAgentManager())); connect(ui->jsOptionsButton, SIGNAL(clicked()), this, SLOT(openJsOptions())); connect(ui->listWidget, SIGNAL(currentItemChanged(QListWidgetItem*,QListWidgetItem*)), this, SLOT(showStackedPage(QListWidgetItem*))); ui->listWidget->setItemSelected(ui->listWidget->itemAt(5, 5), true); ui->version->setText(" QupZilla v" + QupZilla::VERSION); ui->listWidget->setCurrentRow(currentSettingsPage); QDesktopWidget* desktop = QApplication::desktop(); QSize s = size(); if (desktop->availableGeometry(this).size().width() < s.width()) { s.setWidth(desktop->availableGeometry(this).size().width() - 50); } if (desktop->availableGeometry(this).size().height() < s.height()) { s.setHeight(desktop->availableGeometry(this).size().height() - 50); } resize(s); #if QTWEBKIT_TO_2_3 ui->caretBrowsing->setHidden(true); ui->animateScrolling->setHidden(true); #endif #if QTWEBKIT_TO_2_2 ui->html5permissions->setDisabled(true); #endif QzTools::setWmClass("Preferences", this); }
void StateActionCanvas::compute_size() { double zoom = the_canvas()->zoom(); const StateActionData * data = (const StateActionData *) browser_node->get_data(); const QPixmap * px = ProfiledStereotypes::diagramPixmap(data->get_stereotype(), zoom); if (px != 0) { // force odd width and height for line alignment min_width = px->width() | 1; min_height = px->height() | 1; DiagramCanvas::resize(min_width, min_height); } else { QFontMetrics fm(the_canvas()->get_font(UmlNormalFont)); s = data->get_action((language == DefaultDrawingLanguage) ? ((BrowserStateDiagram *) the_canvas()->browser_diagram())->get_language() : language); s = toUnicode(s); QSize sz = fm.size(0, s); min_height = fm.height() + sz.height(); min_width = sz.width(); const char * st = data->get_short_stereotype(); int mn = (int) (STATE_ACTION_CANVAS_MIN_SIZE*zoom); if (!strcmp(st, "receive-signal") || !strcmp(st, "send-signal")) { if (min_height < mn) min_height = mn; min_width += ((height() > min_height) ? height() : min_height) / 2; } else if (st[0] != 0) { int w = fm.width(QString("<<") + toUnicode(st) + ">>"); if (min_width < w) min_width = w; min_height += 2*fm.height(); if (min_height < mn) min_height = mn; } min_width += (int) (8 * zoom); if (min_width < mn) min_width = mn; min_width += 2; used_color = (itscolor == UmlDefaultColor) ? the_canvas()->browser_diagram()->get_color(UmlStateAction) : itscolor; if (used_color != UmlTransparent) { const char * st = data->get_short_stereotype(); if (strcmp(st, "send-signal") && strcmp(st, "receive-signal")) { const int shadow = the_canvas()->shadow(); min_width += shadow; min_height += shadow; } } DiagramCanvas::resize((width() > min_width) ? width() : min_width, (height() > min_height) ? height() : min_height); } }
bool macosxSetScreenResolution(QSize resolution, QPoint screenPoint) { CGDirectDisplayID display = displayAtPoint(screenPoint); if (display == kCGNullDirectDisplay) { return false; } #if __MAC_OS_X_VERSION_MAX_ALLOWED >= 1060 if (CGDisplayCopyAllDisplayModes != NULL) { bool ok = false; CGDisplayModeRef currentMainDisplayMode = CGDisplayCopyDisplayMode(display); CFStringRef currentPixelEncoding = CGDisplayModeCopyPixelEncoding(currentMainDisplayMode); CFArrayRef displayModes = CGDisplayCopyAllDisplayModes(display, NULL); for (CFIndex i = 0, c = CFArrayGetCount(displayModes); i < c; i++) { bool isEqual = false; CGDisplayModeRef mode = (CGDisplayModeRef)CFArrayGetValueAtIndex(displayModes, i); CFStringRef pixelEncoding = CGDisplayModeCopyPixelEncoding(mode); if (CFStringCompare(pixelEncoding, currentPixelEncoding, 0) == kCFCompareEqualTo && CGDisplayModeGetWidth(mode) == (size_t)resolution.width() && CGDisplayModeGetHeight(mode) == (size_t)resolution.height()) { isEqual = true; } CFRelease(pixelEncoding); if (isEqual) { CGDisplaySetDisplayMode(display, mode, NULL); ok = true; break; } } CFRelease(currentPixelEncoding); CFRelease(displayModes); return ok; } else #endif { CFDictionaryRef currentMainDisplayMode = CGDisplayCurrentMode(display); int bpp; dictget(currentMainDisplayMode, Int, kCGDisplayBitsPerPixel, &bpp); boolean_t exactMatch = false; CFDictionaryRef bestMode = CGDisplayBestModeForParameters(display, bpp, resolution.width(), resolution.height(), &exactMatch); if (bestMode != NULL) { if (!exactMatch) { qWarning("No optimal display mode for requested parameters."); } CGDisplaySwitchToMode(display, bestMode); return true; } else { qWarning("Bad resolution change: Invalid display."); return false; } } }
/** * Resize the shell */ void gui_mch_set_shellsize(int width, int height, int min_width, int min_height, int base_width, int base_height, int direction) { // We actually resize the window, not the shell, i.e. we resize the window // to the new dimensions plus the difference between the window and the shell. // This does not ensure the final size is what Vim requested. // // The actual resize size must take into consideration // - The new shell widget size // - The toolbar/menubar/etc size // // New size <= shell size - window size + new size // QDesktopWidget *dw = QApplication::desktop(); QSize desktopSize = dw->availableGeometry(window).size(); if ( !window->isVisible() ) { // We can't resize properly if the window is not // visible just resize the window to the intended size if ( width > desktopSize.width() ) { width = desktopSize.width(); } if ( height > desktopSize.height() ) { height = desktopSize.height(); } window->resize(width, height); return; } int decoWidth = (window->frameGeometry().width() - window->width()); int decoHeight = (window->frameGeometry().height() - window->height()); int frameWidth = (window->size().width() - vimshell->size().width()); int frameHeight = (window->size().height() - vimshell->size().height()); int new_width = frameWidth + width; int new_height = frameHeight + height; // If the given dimenstions are too large, // cap them at available desktop dimensions minus the window decorations if ( new_width + decoWidth > desktopSize.width() ) { new_width = desktopSize.width() - decoWidth; } if ( new_height + decoWidth > desktopSize.height() ) { new_height = desktopSize.height() - decoHeight; } if (window->windowState() & Qt::WindowFullScreen ) { // In fullscreen mode, resize the widget vimshell->setMaximumSize(width, height); } else if ( window->isMaximized() ) { // Nothing to do here - the windows is maximized } else { window->resize( new_width, new_height ); } // // Spin the loop to handle the resize event. This will // cause gui_resize_shell() to be called gui_mch_update(); // Seems redundant but there are cases were the shell might not // call this - because its size is unchanged gui_resize_shell(vimshell->width(), vimshell->height()); // SHOCKING: it seems gui_get_shellsize() updates the proper values for // the columns and rows, after a resize. gui_get_shellsize(); }
bool macosxAppendAvailableScreenResolutions(QList<QSize> &resolutions, QSize minSize, QPoint screenPoint) { CGDirectDisplayID display = displayAtPoint(screenPoint); if (display == kCGNullDirectDisplay) { return false; } #if __MAC_OS_X_VERSION_MAX_ALLOWED >= 1060 bool modern = (CGDisplayCopyAllDisplayModes != NULL); // where 'modern' means >= 10.6 #endif CFArrayRef displayModes; #if __MAC_OS_X_VERSION_MAX_ALLOWED >= 1060 if (modern) { displayModes = CGDisplayCopyAllDisplayModes(display, NULL); } else #endif { displayModes = CGDisplayAvailableModes(display); } #if __MAC_OS_X_VERSION_MAX_ALLOWED >= 1060 CFStringRef currentPixelEncoding = NULL; #endif double currentRefreshRate; int curBPP, curBPS, curSPP; #if __MAC_OS_X_VERSION_MAX_ALLOWED >= 1060 if (modern) { CGDisplayModeRef currentDisplayMode = CGDisplayCopyDisplayMode(display); currentRefreshRate = CGDisplayModeGetRefreshRate(currentDisplayMode); currentPixelEncoding = CGDisplayModeCopyPixelEncoding(currentDisplayMode); CFRelease(currentDisplayMode); } else #endif { CFDictionaryRef currentDisplayMode = CGDisplayCurrentMode(display); dictget(currentDisplayMode, Double, kCGDisplayRefreshRate, ¤tRefreshRate); dictget(currentDisplayMode, Int, kCGDisplayBitsPerPixel, &curBPP); dictget(currentDisplayMode, Int, kCGDisplayBitsPerSample, &curBPS); dictget(currentDisplayMode, Int, kCGDisplaySamplesPerPixel, &curSPP); } for (CFIndex j = 0, c = CFArrayGetCount(displayModes); j < c; j++) { int width, height; double refreshRate; bool pixelEncodingsEqual; #if __MAC_OS_X_VERSION_MAX_ALLOWED >= 1060 if (modern) { CGDisplayModeRef displayMode = (CGDisplayModeRef)CFArrayGetValueAtIndex(displayModes, j); width = (int)CGDisplayModeGetWidth(displayMode); height = (int)CGDisplayModeGetHeight(displayMode); refreshRate = CGDisplayModeGetRefreshRate(displayMode); CFStringRef pixelEncoding = CGDisplayModeCopyPixelEncoding(displayMode); pixelEncodingsEqual = (CFStringCompare(pixelEncoding, currentPixelEncoding, 0) == kCFCompareEqualTo); CFRelease(pixelEncoding); } else #endif { CFDictionaryRef displayMode = (CFDictionaryRef)CFArrayGetValueAtIndex(displayModes, j); dictget(displayMode, Int, kCGDisplayWidth, &width); dictget(displayMode, Int, kCGDisplayHeight, &height); dictget(displayMode, Double, kCGDisplayRefreshRate, &refreshRate); int bpp, bps, spp; dictget(displayMode, Int, kCGDisplayBitsPerPixel, &bpp); dictget(displayMode, Int, kCGDisplayBitsPerSample, &bps); dictget(displayMode, Int, kCGDisplaySamplesPerPixel, &spp); pixelEncodingsEqual = (bpp == curBPP && bps == curBPS && spp == curSPP); } QSize res(width, height); if (!resolutions.contains(res) && width >= minSize.width() && height >= minSize.height() && refreshRate == currentRefreshRate && pixelEncodingsEqual) { resolutions += res; } } #if __MAC_OS_X_VERSION_MAX_ALLOWED >= 1060 if (modern) { CFRelease(currentPixelEncoding); CFRelease(displayModes); } #endif return true; }
void QwtPlotLayout::LayoutData::init(const QwtPlot *plot, const QRect &rect) { // legend if ( plot->plotLayout()->legendPosition() != QwtPlot::ExternalLegend && plot->legend() ) { legend.frameWidth = plot->legend()->frameWidth(); legend.vScrollBarWidth = plot->legend()->verticalScrollBar()->sizeHint().width(); legend.hScrollBarHeight = plot->legend()->horizontalScrollBar()->sizeHint().height(); const QSize hint = plot->legend()->sizeHint(); int w = qwtMin(hint.width(), rect.width()); int h = plot->legend()->heightForWidth(w); if ( h == 0 ) h = hint.height(); if ( h > rect.height() ) w += legend.vScrollBarWidth; legend.hint = QSize(w, h); } // title title.frameWidth = 0; title.text = QwtText(); if (plot->titleLabel() ) { const QwtTextLabel *label = plot->titleLabel(); title.text = label->text(); if ( !(title.text.testPaintAttribute(QwtText::PaintUsingTextFont)) ) title.text.setFont(label->font()); title.frameWidth = plot->titleLabel()->frameWidth(); } // scales for (int axis = 0; axis < QwtPlot::axisCnt; axis++ ) { if ( plot->axisEnabled(axis) ) { const QwtScaleWidget *scaleWidget = plot->axisWidget(axis); scale[axis].isEnabled = true; scale[axis].scaleWidget = scaleWidget; scale[axis].scaleFont = scaleWidget->font(); scale[axis].start = scaleWidget->startBorderDist(); scale[axis].end = scaleWidget->endBorderDist(); scale[axis].baseLineOffset = scaleWidget->margin(); scale[axis].tickOffset = scaleWidget->margin(); if ( scaleWidget->scaleDraw()->hasComponent( QwtAbstractScaleDraw::Ticks) ) { scale[axis].tickOffset += (int)scaleWidget->scaleDraw()->majTickLength(); } scale[axis].dimWithoutTitle = scaleWidget->dimForLength( QWIDGETSIZE_MAX, scale[axis].scaleFont); if ( !scaleWidget->title().isEmpty() ) { scale[axis].dimWithoutTitle -= scaleWidget->titleHeightForWidth(QWIDGETSIZE_MAX); } } else { scale[axis].isEnabled = false; scale[axis].start = 0; scale[axis].end = 0; scale[axis].baseLineOffset = 0; scale[axis].tickOffset = 0; scale[axis].dimWithoutTitle = 0; } } // canvas canvas.frameWidth = plot->canvas()->frameWidth(); }
QStringList res; foreach(const QByteArray& ext,src) res.push_back(ext.data()); return res; } bool SCgExportImage::doExport(SCgScene *scene, const QString &fileName) { QList<QGraphicsItem*> allItems = scene->items(); foreach (QGraphicsItem *item, allItems) { item->setSelected(false); item->clearFocus(); } QSize sz = scene->itemsBoundingRect().size().toSize(); QSize imgSize(sz.width() + 10, sz.height() + 10); QImage img(imgSize, QImage::Format_ARGB32_Premultiplied); img.fill(Qt::transparent); if (!img.isNull()) { QPainter painter(&img); painter.setRenderHint(QPainter::Antialiasing, true); painter.eraseRect(0, 0, imgSize.width(), imgSize.height()); scene->renderToImage(&painter, QRect(5, 5, sz.width(), sz.height()), scene->itemsBoundingRect()); return img.save(fileName); } return false; }
/*! \brief Draw the identifier representing the curve on the legend \param painter Painter \param rect Bounding rectangle for the identifier \sa setLegendAttribute(), QwtPlotItem::Legend */ void QwtPlotCurve::drawLegendIdentifier( QPainter *painter, const QRectF &rect ) const { if ( rect.isEmpty() ) return; const double dim = qMin( rect.width(), rect.height() ); QSizeF size( dim, dim ); QRectF r( 0, 0, size.width(), size.height() ); r.moveCenter( rect.center() ); if ( d_data->legendAttributes == 0 ) { QBrush brush = d_data->brush; if ( brush.style() == Qt::NoBrush ) { if ( style() != QwtPlotCurve::NoCurve ) brush = QBrush( pen().color() ); else if ( d_data->symbol && ( d_data->symbol->style() != QwtSymbol::NoSymbol ) ) { brush = QBrush( d_data->symbol->pen().color() ); } } if ( brush.style() != Qt::NoBrush ) painter->fillRect( r, brush ); } if ( d_data->legendAttributes & QwtPlotCurve::LegendShowBrush ) { if ( d_data->brush.style() != Qt::NoBrush ) painter->fillRect( r, d_data->brush ); } if ( d_data->legendAttributes & QwtPlotCurve::LegendShowLine ) { if ( pen() != Qt::NoPen ) { painter->setPen( pen() ); QwtPainter::drawLine( painter, rect.left(), rect.center().y(), rect.right() - 1.0, rect.center().y() ); } } if ( d_data->legendAttributes & QwtPlotCurve::LegendShowSymbol ) { if ( d_data->symbol && ( d_data->symbol->style() != QwtSymbol::NoSymbol ) ) { QSize symbolSize = d_data->symbol->boundingSize(); symbolSize -= QSize( 2, 2 ); // scale the symbol size down if it doesn't fit into rect. double xRatio = 1.0; if ( rect.width() < symbolSize.width() ) xRatio = rect.width() / symbolSize.width(); double yRatio = 1.0; if ( rect.height() < symbolSize.height() ) yRatio = rect.height() / symbolSize.height(); const double ratio = qMin( xRatio, yRatio ); painter->save(); painter->scale( ratio, ratio ); d_data->symbol->drawSymbol( painter, rect.center() / ratio ); painter->restore(); } } }
void OSDWidget::showOSD(const QString &str, OSDUserData *data) { if (isScreenSaverActive()){ hide(); return; } setFont(FontEdit::str2font(data->Font.str(), baseFont)); QPainter p(this); p.setFont(font()); unsigned nScreen = data->Screen.toULong(); unsigned nScreens = screens(); if (nScreen >= nScreens) nScreen = 0; int SHADOW_OFFS = SHADOW_DEF; QRect rcScreen = screenGeometry(nScreen); rcScreen = QRect(0, 0, rcScreen.width() - SHADOW_OFFS - XOSD_MARGIN * 2 - data->Offset.toULong(), rcScreen.height() - SHADOW_OFFS - XOSD_MARGIN * 2 - data->Offset.toULong()); QRect rc = p.boundingRect(rcScreen, AlignLeft | AlignTop | WordBreak, str); if (rc.height() >= rcScreen.height() / 2){ rcScreen = QRect(0, 0, rcScreen.width() - SHADOW_OFFS - XOSD_MARGIN * 2 - data->Offset.toULong(), rcScreen.height() - SHADOW_OFFS - XOSD_MARGIN * 2 - data->Offset.toULong()); rc = p.boundingRect(rcScreen, AlignLeft | AlignTop | WordBreak, str); } p.end(); if (data->EnableMessageShowContent.toBool() && data->ContentLines.toULong()){ QFontMetrics fm(font()); int maxHeight = fm.height() * (data->ContentLines.toULong() + 1); if (rc.height() > maxHeight) rc.setHeight(maxHeight); } int x = rcScreen.left(); int y = rcScreen.top(); int w = rc.width() + 1; int h = rc.height() + 1; int text_y = 0; if (data->Background.toBool()){ w += XOSD_MARGIN * 2; h += XOSD_MARGIN * 2; if (m_button == NULL){ m_button = new QPushButton("", this); m_button->setPixmap(QPixmap((const char **)close_h_xpm)); connect(m_button, SIGNAL(clicked()), this, SLOT(slotCloseClick())); } QSize s = m_button->sizeHint(); m_button->resize(s.height() - 4, s.height() - 4); m_button->move(w - m_button->width() - 3, 2); text_y = m_button->height() + 4; h += text_y; m_button->show(); }else{ if (m_button){ delete m_button; m_button = NULL; } } if (data->Shadow.toBool()){ w += SHADOW_OFFS; h += SHADOW_OFFS; } resize(QSize(w, h)); switch (data->Position.toULong()){ case 1: move(x + data->Offset.toULong(), y + data->Offset.toULong()); break; case 2: move(x + rcScreen.width() - data->Offset.toULong() - w, y + rcScreen.height() - data->Offset.toULong() - h); break; case 3: move(x + rcScreen.width() - data->Offset.toULong() - w, y + data->Offset.toULong()); break; case 4: move(x + (rcScreen.width() - w) / 2, y + rcScreen.height() - data->Offset.toULong() - h); break; case 5: move(x + (rcScreen.width() - w) / 2, y + data->Offset.toULong()); break; case 6: move(x + (rcScreen.width() - w) / 2, y + (rcScreen.height() - h) /2); break; default: move(x + data->Offset.toULong(), y + rcScreen.height() - data->Offset.toULong() - h); } if (!data->Background.toBool() || data->Shadow.toBool()){ QBitmap mask(w, h); p.begin(&mask); #ifdef WIN32 QColor bg(255, 255, 255); QColor fg(0, 0, 0); #else QColor bg(0, 0, 0); QColor fg(255, 255, 255); #endif p.fillRect(0, 0, w, h, bg); if (data->Background.toBool()){ p.fillRect(0, 0, w - SHADOW_OFFS, h - SHADOW_OFFS, fg); p.fillRect(SHADOW_OFFS, SHADOW_OFFS, w - SHADOW_OFFS, h - SHADOW_OFFS, fg); }else{ p.setPen(fg); p.setFont(font()); if (data->Shadow.toBool()){ rc = QRect(SHADOW_OFFS, SHADOW_OFFS, w - SHADOW_OFFS, h - SHADOW_OFFS); p.drawText(rc, AlignLeft | AlignTop | WordBreak, str); rc = QRect(0, 0, w - SHADOW_OFFS, h - SHADOW_OFFS); p.drawText(rc, AlignLeft | AlignTop | WordBreak, str); }else{ rc = QRect(0, 0, w, h); p.drawText(rc, AlignLeft | AlignTop | WordBreak, str); } } p.end(); setMask(mask); } qApp->syncX(); QPixmap pict = QPixmap::grabWindow(QApplication::desktop()->winId(), this->x(), this->y(), width(), height()); intensity(pict, -0.50f); p.begin(&pict); rc = QRect(0, 0, w, h); if (data->Background.toBool()){ if (data->Shadow.toBool()){ w -= SHADOW_OFFS; h -= SHADOW_OFFS; rc = QRect(0, 0, w, h); } QBrush bg(data->BgColor.toULong()); p.fillRect(rc, bg); style().drawPrimitive(QStyle::PE_PanelPopup, &p, rc, colorGroup()); rc = QRect(XOSD_MARGIN, XOSD_MARGIN, w - XOSD_MARGIN * 2, h - XOSD_MARGIN * 2); } p.setFont(font()); p.setPen(QColor(data->Color.toULong())); rc.setTop(text_y); p.drawText(rc, AlignLeft | AlignTop | WordBreak, str); p.end(); bgPict = pict; #ifdef WIN32 //SetWindowLongW(this->winId(), GWL_EXSTYLE, GetWindowLongW(this->winId(), GWL_EXSTYLE) & (~WS_EX_LAYERED)); if (data->Fading.toBool()){ slwa = (slwa_ptr)QLibrary::resolve("user32.dll","SetLayeredWindowAttributes"); if (slwa == NULL) return; transCounter=100; SetWindowLongW(this->winId(), GWL_EXSTYLE, GetWindowLongW(this->winId(), GWL_EXSTYLE) | WS_EX_LAYERED); BYTE d = (BYTE) QMIN((100 - transCounter) * 256 / 100, 255); slwa(this->winId(), this->colorGroup().background().rgb(), d, LWA_ALPHA); RedrawWindow(this->winId(), NULL, NULL, RDW_UPDATENOW); m_transTimer = new QTimer(this); } QWidget::show(); raise(); if (data->Fading.toBool()){ connect(m_transTimer, SIGNAL(timeout()), this, SLOT(m_transTimerFadeInTimeout())); m_transTimer->start(5); } #else QWidget::show(); raise(); #endif }
/** Input point is on [-1,1]², 0 being at the center, and positive directions are →top/→right. Maps to the coordinates used in QImages with the 0 point at the top left corner. -1 +1 +1+-----------+ | + | | --0++ | | - | -1+-----------+ vvv mapped to v 0 x 0+------+ |0++ | |- | |- | y+------+ With y: 1. Scale from [-1,1] to [0,1] with y01 := (y+1)/2 2. Invert (Orientation of the y axis changes) with y10 := 1-y01 3. Scale from [1,0] to [height-1,0] with yy := (height-1) * y10 x does not need to be inverted. */ QPoint VectorscopeGenerator::mapToCircle(const QSize &targetSize, const QPointF &point) const { return QPoint( (targetSize.width() -1) * (point.x()+1)/2, (targetSize.height()-1) * (1 - (point.y()+1)/2) ); }
FilterAction DImgBuiltinFilter::filterAction() const { FilterAction action; switch (m_type) { case NoOperation: default: return action; case Rotate90: case Rotate180: case Rotate270: { action = FilterAction("transform:rotate", 1); int angle; if (m_type == Rotate90) { angle = 90; } else if (m_type == Rotate180) { angle = 180; } else { angle = 270; } action.addParameter("angle", angle); break; } case FlipHorizontally: case FlipVertically: { action = FilterAction("transform:flip", 1); action.addParameter("direction", m_type == FlipHorizontally ? "horizontal" : "vertical"); break; } case Crop: { action = FilterAction("transform:crop", 1); QRect r = m_arg.toRect(); action.addParameter("x", r.x()); action.addParameter("y", r.y()); action.addParameter("width", r.width()); action.addParameter("height", r.height()); break; } case Resize: { action = FilterAction("transform:resize", 1); QSize s = m_arg.toSize(); action.addParameter("width", s.width()); action.addParameter("height", s.height()); break; } case ConvertTo8Bit: case ConvertTo16Bit: { action = FilterAction("transform:convertDepth", 1); action.addParameter("depth", m_type == ConvertTo8Bit ? 8 : 16); break; } } action.setDisplayableName(displayableName()); return action; }
virtual QSize minimumSizeHint( ) const { QSize s = QComboBox::minimumSizeHint( ); return s.expandedTo( minimumSize( ) ); }
// 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( display_video_rect.top() - (display_video_rect.height() / 6)); display_video_rect.setHeight(display_video_rect.height() * 4 / 3); } else if (adjustfill == kAdjustFill_VerticalFill && display_video_rect.height() > 0) { // Video fills screen vertically. May be cropped left and right float factor = (float)display_visible_rect.height() / (float)display_video_rect.height(); QSize newsize = QSize((int) (display_video_rect.width() * factor), (int) (display_video_rect.height() * factor)); QSize temp = (display_video_rect.size() - newsize) / 2; QPoint newloc = display_video_rect.topLeft() + QPoint(temp.width(), temp.height()); display_video_rect = QRect(newloc, newsize); } else if (adjustfill == kAdjustFill_HorizontalFill && display_video_rect.width() > 0) { // Video fills screen horizontally. May be cropped top and bottom float factor = (float)display_visible_rect.width() / (float)display_video_rect.width(); QSize newsize = QSize((int) (display_video_rect.width() * factor), (int) (display_video_rect.height() * factor)); QSize temp = (display_video_rect.size() - newsize) / 2; QPoint newloc = display_video_rect.topLeft() + QPoint(temp.width(), temp.height()); display_video_rect = QRect(newloc, newsize); } }