bool EFX::saveXML(QDomDocument* doc, QDomElement* wksp_root) { QDomElement root; QDomElement tag; QDomElement subtag; QDomText text; QString str; Q_ASSERT(doc != NULL); Q_ASSERT(wksp_root != NULL); /* Function tag */ root = doc->createElement(KXMLQLCFunction); wksp_root->appendChild(root); /* Common attributes */ saveXMLCommon(&root); /* Fixtures */ QListIterator <EFXFixture*> it(m_fixtures); while (it.hasNext() == true) it.next()->saveXML(doc, &root); /* Propagation mode */ tag = doc->createElement(KXMLQLCEFXPropagationMode); root.appendChild(tag); text = doc->createTextNode(propagationModeToString(m_propagationMode)); tag.appendChild(text); /* Speeds */ saveXMLSpeed(doc, &root); /* Direction */ saveXMLDirection(doc, &root); /* Run order */ saveXMLRunOrder(doc, &root); /* Algorithm */ tag = doc->createElement(KXMLQLCEFXAlgorithm); root.appendChild(tag); text = doc->createTextNode(algorithmToString(algorithm())); tag.appendChild(text); /* Width */ tag = doc->createElement(KXMLQLCEFXWidth); root.appendChild(tag); str.setNum(width()); text = doc->createTextNode(str); tag.appendChild(text); /* Height */ tag = doc->createElement(KXMLQLCEFXHeight); root.appendChild(tag); str.setNum(height()); text = doc->createTextNode(str); tag.appendChild(text); /* Rotation */ tag = doc->createElement(KXMLQLCEFXRotation); root.appendChild(tag); str.setNum(rotation()); text = doc->createTextNode(str); tag.appendChild(text); /* StartOffset */ tag = doc->createElement(KXMLQLCEFXStartOffset); root.appendChild(tag); str.setNum(startOffset()); text = doc->createTextNode(str); tag.appendChild(text); /* IsRelative */ tag = doc->createElement(KXMLQLCEFXIsRelative); root.appendChild(tag); str.setNum(isRelative() ? 1 : 0); text = doc->createTextNode(str); tag.appendChild(text); /******************************************** * X-Axis ********************************************/ tag = doc->createElement(KXMLQLCEFXAxis); root.appendChild(tag); tag.setAttribute(KXMLQLCFunctionName, KXMLQLCEFXX); /* Offset */ subtag = doc->createElement(KXMLQLCEFXOffset); tag.appendChild(subtag); str.setNum(xOffset()); text = doc->createTextNode(str); subtag.appendChild(text); /* Frequency */ subtag = doc->createElement(KXMLQLCEFXFrequency); tag.appendChild(subtag); str.setNum(xFrequency()); text = doc->createTextNode(str); subtag.appendChild(text); /* Phase */ subtag = doc->createElement(KXMLQLCEFXPhase); tag.appendChild(subtag); str.setNum(xPhase()); text = doc->createTextNode(str); subtag.appendChild(text); /******************************************** * Y-Axis ********************************************/ tag = doc->createElement(KXMLQLCEFXAxis); root.appendChild(tag); tag.setAttribute(KXMLQLCFunctionName, KXMLQLCEFXY); /* Offset */ subtag = doc->createElement(KXMLQLCEFXOffset); tag.appendChild(subtag); str.setNum(yOffset()); text = doc->createTextNode(str); subtag.appendChild(text); /* Frequency */ subtag = doc->createElement(KXMLQLCEFXFrequency); tag.appendChild(subtag); str.setNum(yFrequency()); text = doc->createTextNode(str); subtag.appendChild(text); /* Phase */ subtag = doc->createElement(KXMLQLCEFXPhase); tag.appendChild(subtag); str.setNum(yPhase()); text = doc->createTextNode(str); subtag.appendChild(text); return true; }
KDMShutdown::KDMShutdown( int mode, QWidget* _parent, const char* _name, const char* _shutdown, const char* _restart) : FDialog( _parent, _name, true) { shutdown = _shutdown; restart = _restart; int h = 10, w = 0; QFrame* winFrame = new QFrame( this); winFrame->setFrameStyle( QFrame::WinPanel | QFrame::Raised); QBoxLayout* box = new QBoxLayout( winFrame, QBoxLayout::TopToBottom, 10, 10); QString shutdownmsg = klocale->translate( "Shutdown or restart?"); if( mode == KDMConfig::RootOnly) { shutdownmsg += '\n'; shutdownmsg += klocale->translate( "(Enter Root Password)"); } label = new QLabel( shutdownmsg, winFrame); set_fixed( label); h += label->height() + 10; w = label->width(); box->addWidget( label, 0, AlignCenter); QFrame* sepFrame = new QFrame( this); sepFrame->setFrameStyle( QFrame::HLine| QFrame::Sunken); h += sepFrame->height(); box->addWidget( sepFrame); btGroup = new QButtonGroup( /* this */); QRadioButton *rb; rb = new QRadioButton( winFrame /*btGroup*/); rb->setText( klocale->translate("Shutdown")); set_min( rb); rb->setFocusPolicy( StrongFocus); // Default action rb->setChecked( true); rb->setFocus(); cur_action = shutdown; h += rb->height() + 10; w = QMAX( rb->width(), w); box->addWidget( rb); btGroup->insert( rb); rb = new QRadioButton( winFrame /*btGroup*/); rb->setText( klocale->translate("Shutdown and restart")); set_min( rb); rb->setFocusPolicy( StrongFocus); h += rb->height() + 10; w = QMAX( rb->width(), w); box->addWidget( rb); btGroup->insert( rb); rb = new QRadioButton( winFrame /*btGroup*/); rb->setText( klocale->translate("Restart X Server"));//better description set_min( rb); rb->setFocusPolicy( StrongFocus); h += rb->height() + 10; w = QMAX( rb->width(), w); box->addWidget( rb); btGroup->insert( rb); // Passwd line edit if( mode == KDMConfig::RootOnly) { pswdEdit = new QLineEdit( winFrame); //set_min( pswdEdit); pswdEdit->setMinimumHeight( pswdEdit->sizeHint().height()); pswdEdit->setEchoMode( QLineEdit::NoEcho); /*QColorGroup passwdColGroup( QApplication::palette()->normal().foreground(), QApplication::palette()->normal().background(), QApplication::palette()->normal().light(), QApplication::palette()->normal().dark(), QApplication::palette()->normal().mid(), QApplication::palette()->normal().base(), QApplication::palette()->normal().base()); QPalette passwdPalette( passwdColGroup, passwdColGroup, passwdColGroup); pswdEdit->setPalette( passwdPalette); */ pswdEdit->setFocusPolicy( StrongFocus); pswdEdit->setFocus(); h+= pswdEdit->height() + 10; box->addWidget( pswdEdit); } QBoxLayout* box3 = new QBoxLayout( QBoxLayout::LeftToRight, 10); box->addLayout( box3); okButton = new QPushButton( klocale->translate("OK"), winFrame); set_min( okButton); okButton->setFocusPolicy( StrongFocus); cancelButton = new QPushButton( klocale->translate("Cancel"), winFrame); set_min( cancelButton); //cancelButton->setDefault( true); cancelButton->setFocusPolicy( StrongFocus); h += cancelButton->height() + 10; w = QMAX( (okButton->width() + 10 + cancelButton->width()), w); box3->addWidget( okButton); box3->addWidget( cancelButton); // Connections connect( okButton, SIGNAL(clicked()), SLOT(bye_bye())); connect( cancelButton, SIGNAL(clicked()), SLOT(reject())); connect( btGroup, SIGNAL(clicked(int)), SLOT(rb_clicked(int))); if( mode == KDMConfig::RootOnly) { okButton->setEnabled( false); connect( pswdEdit, SIGNAL( returnPressed()), this, SLOT( pw_entered())); } else cancelButton->setFocus(); resize( 20 + w, h); winFrame->setGeometry( 0, 0, width(), height()); }
LogViewWindow::LogViewWindow() : KviWindow(KviWindow::LogView,"log") { g_pLogViewWindow = this; //m_pLogViewWidget = new KviLogViewWidget(this); m_pSplitter = new KviTalSplitter(Qt::Horizontal,this); m_pSplitter->setObjectName("main_splitter"); m_pSplitter->setChildrenCollapsible(false); m_pLeftLayout = new KviTalVBox(m_pSplitter); m_pTabWidget = new QTabWidget(m_pLeftLayout); m_pBottomLayout = new KviTalHBox(m_pLeftLayout); m_pProgressBar = new QProgressBar(m_pBottomLayout); m_pCancelButton = new QPushButton(m_pBottomLayout); m_pCancelButton->setText(__tr2qs_ctx("Cancel","log")); connect(m_pCancelButton,SIGNAL(clicked()),this,SLOT(abortFilter())); m_pBottomLayout->setVisible(false); m_pIndexTab = new KviTalVBox(m_pTabWidget); m_pTabWidget->addTab(m_pIndexTab,__tr2qs_ctx("Index","log")); m_pListView = new LogViewListView(m_pIndexTab); connect(m_pListView,SIGNAL(currentItemChanged(QTreeWidgetItem *,QTreeWidgetItem *)),this,SLOT(itemSelected(QTreeWidgetItem *,QTreeWidgetItem *))); connect(m_pListView,SIGNAL(rightButtonPressed(QTreeWidgetItem *,QPoint)),this,SLOT(rightButtonClicked(QTreeWidgetItem *,QPoint))); m_pSearchTab = new QWidget(m_pTabWidget); m_pTabWidget->addTab(m_pSearchTab,__tr2qs_ctx("Filter","log")); QGridLayout * pLayout = new QGridLayout(m_pSearchTab); m_pShowChannelsCheck = new QCheckBox(__tr2qs_ctx("Show channel logs","log"),m_pSearchTab); m_pShowChannelsCheck->setChecked(true); pLayout->addWidget(m_pShowChannelsCheck,0,0,1,2); m_pShowQueryesCheck = new QCheckBox(__tr2qs_ctx("Show query logs","log"),m_pSearchTab); m_pShowQueryesCheck->setChecked(true); pLayout->addWidget(m_pShowQueryesCheck,1,0,1,2); m_pShowConsolesCheck = new QCheckBox(__tr2qs_ctx("Show console logs","log"),m_pSearchTab); m_pShowConsolesCheck->setChecked(true); pLayout->addWidget(m_pShowConsolesCheck,2,0,1,2); m_pShowDccChatCheck = new QCheckBox(__tr2qs_ctx("Show DCC chat logs","log"),m_pSearchTab); m_pShowDccChatCheck->setChecked(true); pLayout->addWidget(m_pShowDccChatCheck,3,0,1,2); m_pShowOtherCheck = new QCheckBox(__tr2qs_ctx("Show other logs","log"),m_pSearchTab); m_pShowOtherCheck->setChecked(true); pLayout->addWidget(m_pShowOtherCheck,4,0,1,2); QLabel * pLabel; pLabel = new QLabel(__tr2qs_ctx("Contents Filter","log"),m_pSearchTab); pLayout->addWidget(pLabel,5,0,1,2); pLabel = new QLabel(__tr2qs_ctx("Log name mask:","log"),m_pSearchTab); m_pFileNameMask = new QLineEdit(m_pSearchTab); pLayout->addWidget(pLabel,6,0); pLayout->addWidget(m_pFileNameMask,6,1); connect(m_pFileNameMask,SIGNAL(returnPressed()),this,SLOT(applyFilter())); pLabel = new QLabel(__tr2qs_ctx("Log contents mask:","log"),m_pSearchTab); m_pContentsMask = new QLineEdit(m_pSearchTab); pLayout->addWidget(pLabel,7,0); pLayout->addWidget(m_pContentsMask,7,1); connect(m_pContentsMask,SIGNAL(returnPressed()),this,SLOT(applyFilter())); m_pEnableFromFilter = new QCheckBox(__tr2qs_ctx("Only older than:","log"),m_pSearchTab); m_pFromDateEdit = new QDateEdit(m_pSearchTab); m_pFromDateEdit->setDate(QDate::currentDate()); m_pFromDateEdit->setEnabled(false); pLayout->addWidget(m_pEnableFromFilter,8,0); pLayout->addWidget(m_pFromDateEdit,8,1); connect(m_pEnableFromFilter,SIGNAL(toggled(bool)),m_pFromDateEdit,SLOT(setEnabled(bool))); m_pEnableToFilter = new QCheckBox(__tr2qs_ctx("Only newer than:","log"),m_pSearchTab); m_pToDateEdit = new QDateEdit(m_pSearchTab); m_pToDateEdit->setDate(QDate::currentDate()); m_pToDateEdit->setEnabled(false); pLayout->addWidget(m_pEnableToFilter,9,0); pLayout->addWidget(m_pToDateEdit,9,1); connect(m_pEnableToFilter,SIGNAL(toggled(bool)),m_pToDateEdit,SLOT(setEnabled(bool))); m_pFilterButton = new QPushButton(__tr2qs_ctx("Apply Filter","log"),m_pSearchTab); pLayout->addWidget(m_pFilterButton,10,1); connect(m_pFilterButton,SIGNAL(clicked()),this,SLOT(applyFilter())); QWidget * pWidget = new QWidget(m_pSearchTab); pWidget->setSizePolicy(QSizePolicy::Ignored,QSizePolicy::Ignored); pLayout->addWidget(pWidget,11,1); m_pIrcView = new KviIrcView(m_pSplitter,this); m_pIrcView->setMaxBufferSize(INT_MAX); m_pIrcView->setFocusPolicy(Qt::ClickFocus); QList<int> li; li.append(110); li.append(width()-110); m_pSplitter->setSizes(li); // Using setData to track the option ordinal that used to be passed as id m_pExportLogPopup = new QMenu("exportlog", this); QAction* pAction = m_pExportLogPopup->addAction(__tr2qs_ctx("Plain Text File","log")); pAction->setData(LogFile::PlainText); pAction = m_pExportLogPopup->addAction(__tr2qs_ctx("HTML Archive","log")); pAction->setData(LogFile::HTML); //m_pExportLogPopup->addAction(__tr2qs_ctx("XML file","log")); //m_pExportLogPopup->addAction(__tr2qs_ctx("database file","log")); // 18.11.14: Originally this hooked activated, but Qt4 kept sending bullshit IDs here // https://github.com/kvirc/KVIrc/issues/934#issuecomment-124933890 connect(m_pExportLogPopup,SIGNAL(triggered(QAction*)),this,SLOT(exportLog(QAction*))); m_pTimer = new QTimer(this); m_pTimer->setSingleShot(true); m_pTimer->setInterval(0); connect(m_pTimer,SIGNAL(timeout()),this,SLOT(filterNext())); //avoid to execute the long time-consuming procedure of log indexing here: //we could still be inside the context of the "Browse log files" QAction QTimer::singleShot(0,this,SLOT(cacheFileList())); }
void TmultiScore::adjustStaffWidth(TscoreStaff* st) { int scrollOff = verticalScrollBar()->isVisible() ? verticalScrollBar()->width() : 0; st->setViewWidth((width() - 25 - scrollOff) / transform().m11()); }
/* Respond to a mouse moving over a label */ void W_LABEL::highlight(W_CONTEXT *psContext) { /* If there is a tip string start the tool tip */ if (!pTip.isEmpty()) { tipStart(this, pTip, screenPointer->TipFontID, x() + psContext->xOffset, y() + psContext->yOffset, width(), height()); } }
void LevelOutput::paintEvent(QPaintEvent *event) { Q_UNUSED(event); QPainter painter(this); qreal height_levelL = levelOutputL * height(); qreal height_levelR = levelOutputR * height(); painter.fillRect(0,0,width(),height(),Qt::darkGreen); painter.fillRect(0,0,width(),height()*0.2,Qt::darkRed); if(height_levelL<height()*0.8) { painter.fillRect(0,height()-height_levelL,width()/2,height(),Qt::green); } if(height_levelL>=height()*0.8) { painter.fillRect(0,height()-height_levelL,width()/2,height()*0.2,Qt::red); painter.fillRect(0,height()*0.2,width()/2,height(),Qt::green); } if(height_levelR<height()*0.8) { painter.fillRect(width()/2,height()-height_levelR,width(),height(),Qt::green); } if(height_levelR>=height()*0.8) { painter.fillRect(width()/2,height()-height_levelR,width(),height()*0.2,Qt::red); painter.fillRect(width()/2,height()*0.2,width(),height(),Qt::green); } }
void PluginListWidgetItemDelegate::updateItemWidgets(const QList<QWidget *> widgets, const QStyleOptionViewItem &option, const QPersistentModelIndex &index) const { auto checkBox = static_cast<QCheckBox*>(widgets[0]); checkBox->resize(checkBox->sizeHint()); checkBox->move(m_pluginSelector->dependantLayoutValue(MARGIN, checkBox->sizeHint().width(), option.rect.width()), option.rect.height() / 2 - checkBox->sizeHint().height() / 2); auto aboutPushButton = static_cast<QPushButton*>(widgets[1]); auto aboutPushButtonSizeHint = aboutPushButton->sizeHint(); aboutPushButton->resize(aboutPushButtonSizeHint); aboutPushButton->move(m_pluginSelector->dependantLayoutValue(option.rect.width() - MARGIN - aboutPushButtonSizeHint.width(), aboutPushButtonSizeHint.width(), option.rect.width()), option.rect.height() / 2 - aboutPushButtonSizeHint.height() / 2); if (!index.isValid() || !index.internalPointer()) { checkBox->setVisible(false); aboutPushButton->setVisible(false); } else checkBox->setChecked(index.model()->data(index, Qt::CheckStateRole).toBool()); }
void HistoryWindow::resizeEvent(QResizeEvent *e) { QMainWindow::resizeEvent(e); CorePlugin::m_plugin->data.historySize[0].value = width(); CorePlugin::m_plugin->data.historySize[1].value = height(); }
void set_render_to_texture() { EXT_CALL(glBindFramebuffer)(EXT_MACRO(GL_FRAMEBUFFER), framebuffer_id); glViewport(0, 0, width(), height()); }
void SegMeter::paintEvent(QPaintEvent *paintEvent) { int op_pt; int low_region,high_region,clip_region,float_region; int dark_low_region=0; int dark_high_region=0; int dark_clip_region=0; QColor float_color; // // Setup // QPixmap pix(this->size()); pix.fill(this,0,0); int seg_total=seg_size+seg_gap; QPainter *p=new QPainter(&pix); low_region=0; high_region=0; clip_region=0; p->setBrush(low_color); p->setPen(low_color); // // Set Orientation // switch(orient) { case SegMeter::Left: case SegMeter::Up: p->translate(width(),height()); p->rotate(180); break; default: break; } // // The low range // if(solid_bar>high_threshold) { op_pt=high_threshold; } else { op_pt=solid_bar; } switch(orient) { case SegMeter::Left: case SegMeter::Right: low_region=(int)((double)(op_pt-range_min)/ (double)(range_max-range_min)*width()/seg_total); if(op_pt>range_min) { for(int i=0;i<low_region;i++) { p->fillRect(i*seg_total,0,seg_size,height(),low_color); } } break; case SegMeter::Down: case SegMeter::Up: low_region=(int)((double)(op_pt-range_min)/ (double)(range_max-range_min)*height()/seg_total); if(op_pt>range_min) { for(int i=0;i<low_region;i++) { p->fillRect(0,i*seg_total,width(),seg_size,low_color); } } break; } // // The high range // if(solid_bar>clip_threshold) { op_pt=clip_threshold; } else { op_pt=solid_bar; } switch(orient) { case SegMeter::Left: case SegMeter::Right: high_region=(int)((double)(op_pt-high_threshold)/ (double)(range_max-range_min)*width()/seg_total); if(op_pt>high_threshold) { for(int i=low_region;i<low_region+high_region;i++) { p->fillRect(i*seg_total,0,seg_size,height(),high_color); } } break; case SegMeter::Down: case SegMeter::Up: high_region=(int)((double)(op_pt-high_threshold)/ (double)(range_max-range_min)*height()/seg_total); if(op_pt>high_threshold) { for(int i=low_region;i<low_region+high_region;i++) { p->fillRect(0,i*seg_total,width(),seg_size,high_color); } } break; } // // The clip range // if(solid_bar>range_max) { op_pt=range_max; } else { op_pt=solid_bar; } switch(orient) { case SegMeter::Left: case SegMeter::Right: clip_region=(int)((double)(op_pt-clip_threshold)/ (double)(range_max-range_min)*width()/seg_total); if(op_pt>clip_threshold) { for(int i=low_region+high_region; i<low_region+high_region+clip_region;i++) { p->fillRect(i*seg_total,0,seg_size,height(),clip_color); } } break; case SegMeter::Down: case SegMeter::Up: clip_region=(int)((double)(op_pt-range_min)/ (double)(range_max-range_min)*height()/seg_total); if(op_pt>clip_threshold) { for(int i=low_region+high_region; i<low_region+high_region+clip_region;i++) { p->fillRect(0,i*seg_total,width(),seg_size,clip_color); } } break; } // // The dark low range // switch(orient) { case SegMeter::Left: case SegMeter::Right: dark_low_region=(int)((double)(high_threshold-range_min)/ (double)(range_max-range_min)*width()/seg_total); if(op_pt<high_threshold) { for(int i=low_region;i<dark_low_region;i++) { p->fillRect(i*seg_total,0,seg_size,height(),dark_low_color); } } break; case SegMeter::Down: case SegMeter::Up: dark_low_region=(int)((double)(high_threshold-range_min)/ (double)(range_max-range_min)*height()/seg_total); if(op_pt<high_threshold) { for(int i=low_region;i<dark_low_region;i++) { p->fillRect(0,i*seg_total,width(),seg_size,dark_low_color); } } break; } // // The dark high range // if(solid_bar>=high_threshold) { op_pt=low_region+high_region; } else { op_pt=dark_low_region; } switch(orient) { case SegMeter::Left: case SegMeter::Right: dark_high_region=(int)((double)(clip_threshold-range_min)/ (double)(range_max-range_min)*width()/seg_total); if(solid_bar<clip_threshold) { for(int i=op_pt; i<dark_high_region;i++) { p->fillRect(i*seg_total,0,seg_size,height(),dark_high_color); } } break; case SegMeter::Down: case SegMeter::Up: dark_high_region=(int)((double)(clip_threshold-range_min)/ (double)(range_max-range_min)*height()/seg_total); if(solid_bar<clip_threshold) { for(int i=op_pt;i<dark_high_region;i++) { p->fillRect(0,i*seg_total,width(),seg_size,dark_high_color); } } break; } // // The dark clip range // if(solid_bar>clip_threshold) { op_pt=low_region+high_region+clip_region; } else { op_pt=dark_high_region; } switch(orient) { case SegMeter::Left: case SegMeter::Right: dark_clip_region=(int)((double)(range_max-range_min)/ (double)(range_max-range_min)*width()/seg_total); if(solid_bar<range_max) { for(int i=op_pt;i<dark_clip_region;i++) { p->fillRect(i*seg_total,0,seg_size,height(),dark_clip_color); } } break; case SegMeter::Down: case SegMeter::Up: dark_clip_region=(int)((double)(range_max-range_min)/ (double)(range_max-range_min)*height()/seg_total); if(solid_bar<range_max) { for(int i=op_pt; i<dark_clip_region;i++) { p->fillRect(0,i*seg_total,width(),seg_size,dark_clip_color); } } break; } // // The floating segment // if(floating_bar>solid_bar) { if(floating_bar<=high_threshold) { float_color=low_color; } if((floating_bar>high_threshold)&&(floating_bar<=clip_threshold)) { float_color=high_color; } if(floating_bar>clip_threshold) { float_color=clip_color; } switch(orient) { case SegMeter::Left: case SegMeter::Right: float_region=(int)((double)(floating_bar-range_min)/ (double)(range_max-range_min)*width()); float_region=seg_total*(float_region/seg_total); p->fillRect(float_region,0,seg_size,height(),float_color); break; case SegMeter::Down: case SegMeter::Up: float_region=(int)((double)(floating_bar-range_min)/ (double)(range_max-range_min)*height()); float_region=seg_total*(float_region/seg_total); p->fillRect(0,float_region,width(),seg_size,float_color); break; } } p->end(); p->begin(this); p->drawPixmap(0,0,pix); p->end(); delete p; }
void Graph::drawCurves(QPainter *painter) { QRect rect(Margin, Margin, width() - 2 * Margin, height() - 2 * Margin); if(!rect.isValid()) return; painter->setClipRect(rect.adjusted(+1, +1, -1, -1)); QPolygon polyline0, polyline1; QVectorIterator<QPoint> iterator0(pointStorage_0); while(iterator0.hasNext()){ QPoint point = iterator0.next(); int x = rect.left() + point.x(); int y = rect.bottom() - point.y(); polyline0 << QPoint(x, y); } QVectorIterator<QPoint> iterator1(pointStorage_1); while(iterator1.hasNext()){ QPoint point = iterator1.next(); int x = rect.left() + point.x(); int y = rect.bottom() - point.y(); polyline1 << QPoint(x, y); } QPen light = palette().light().color(); QPen bright(Qt::green, 1, Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin); int static xyz = 0; int value0, value1; if(!polyline0.isEmpty()){ value0 = polyline0.last().y(); } if(!polyline1.isEmpty()){ value1 = polyline1.last().y(); } painter->setPen(light); painter->drawPolyline(polyline0); painter->drawText(rect, Qt::AlignCenter, QString::number(value0)); painter->setPen(bright); painter->drawPolyline(polyline1); painter->drawText(rect, Qt::AlignVCenter, QString::number(value1)); painter->setPen(light); painter->drawLine(rect.left() + xyz, rect.left() + 50, rect.left() + xyz, rect.left() + 15); painter->drawRect(rect.adjusted(0, 0, -1, -1)); xyz++; }
void RenderReplaced::paint(PaintInfo& paintInfo, int tx, int ty) { if (!shouldPaint(paintInfo, tx, ty)) return; tx += x(); ty += y(); if (hasBoxDecorations() && (paintInfo.phase == PaintPhaseForeground || paintInfo.phase == PaintPhaseSelection)) paintBoxDecorations(paintInfo, tx, ty); if (paintInfo.phase == PaintPhaseMask) { paintMask(paintInfo, tx, ty); return; } if ((paintInfo.phase == PaintPhaseOutline || paintInfo.phase == PaintPhaseSelfOutline) && style()->outlineWidth()) paintOutline(paintInfo.context, tx, ty, width(), height()); if (paintInfo.phase != PaintPhaseForeground && paintInfo.phase != PaintPhaseSelection) return; if (!paintInfo.shouldPaintWithinRoot(this)) return; bool drawSelectionTint = selectionState() != SelectionNone && !document()->printing(); if (paintInfo.phase == PaintPhaseSelection) { if (selectionState() == SelectionNone) return; drawSelectionTint = false; } bool completelyClippedOut = false; if (style()->hasBorderRadius()) { IntRect borderRect = IntRect(tx, ty, width(), height()); if (borderRect.isEmpty()) completelyClippedOut = true; else { // Push a clip if we have a border radius, since we want to round the foreground content that gets painted. paintInfo.context->save(); IntSize topLeft, topRight, bottomLeft, bottomRight; style()->getBorderRadiiForRect(borderRect, topLeft, topRight, bottomLeft, bottomRight); paintInfo.context->addRoundedRectClip(borderRect, topLeft, topRight, bottomLeft, bottomRight); } } if (!completelyClippedOut) { paintReplaced(paintInfo, tx, ty); if (style()->hasBorderRadius()) paintInfo.context->restore(); } // The selection tint never gets clipped by border-radius rounding, since we want it to run right up to the edges of // surrounding content. if (drawSelectionTint) { IntRect selectionPaintingRect = localSelectionRect(); selectionPaintingRect.move(tx, ty); paintInfo.context->fillRect(selectionPaintingRect, selectionBackgroundColor(), style()->colorSpace()); } }
void GcLabel::paintEvent(QPaintEvent *) { static QIcon left = iconFromPNG(":images/mac/left.png"); static QIcon right = iconFromPNG(":images/mac/right.png"); QPainter painter(this); painter.save(); painter.setRenderHints(QPainter::Antialiasing|QPainter::TextAntialiasing, true); // grr. some want a rect others want a rectf QRectF norm(0,0,width(),height()); QRect all(0,0,width(),height()); if (bg) { // setup a painter and the area to paint if (!underMouse()) { painter.fillRect(all, bgColor); } else { if (filtered) painter.fillRect(all, GColor(CCALCURRENT)); else painter.fillRect(all, Qt::lightGray); } painter.setPen(Qt::gray); painter.drawRect(QRect(0,0,width(),height())); } if (selected) { painter.fillRect(all, GColor(CCALCURRENT)); } if (text() != "<" && text() != ">") { painter.setFont(this->font()); if (!GCColor::isFlat() && (xoff || yoff)) { // draw text in white behind... QRectF off(xoff,yoff,width(),height()); painter.setPen(QColor(255,255,255,200)); painter.drawText(off, alignment(), text()); } if (filtered && !selected && !underMouse()) painter.setPen(GColor(CCALCURRENT)); else { if (isChrome && GCColor::isFlat()) { if (GCColor::luminance(GColor(CCHROME)) < 127) painter.setPen(QColor(Qt::white)); else painter.setPen(QColor(30,30,30,200)); } else painter.setPen(palette().color(QPalette::WindowText)); } painter.drawText(norm, alignment(), text()); if (highlighted) { QColor over = GColor(CCALCURRENT); over.setAlpha(180); painter.setPen(over); painter.drawText(norm, alignment(), text()); } } else { // use standard icons QIcon &icon = text() == "<" ? left : right; Qt::AlignmentFlag alignment = text() == "<" ? Qt::AlignLeft : Qt::AlignRight; icon.paint(&painter, all, alignment|Qt::AlignVCenter); } if (text() != "" && filtered) { QPen pen; pen.setColor(GColor(CCALCURRENT)); pen.setWidth(3); painter.setPen(pen); painter.drawRect(QRect(0,0,width(),height())); } painter.restore(); }
void SessionsInner::paintEvent(QPaintEvent *e) { QRect r(e->rect()); Painter p(this); p.fillRect(r, st::white->b); int32 x = st::sessionPadding.left(), xact = st::sessionTerminateSkip + st::sessionTerminate.iconPos.x();// st::sessionTerminateSkip + st::sessionTerminate.width + st::sessionTerminateSkip; int32 w = width(); if (_current->active.isEmpty() && _list->isEmpty()) { p.setFont(st::noContactsFont->f); p.setPen(st::noContactsColor->p); p.drawText(QRect(0, 0, width(), st::noContactsHeight), lang(lng_contacts_loading), style::al_center); return; } if (r.y() <= st::sessionCurrentHeight) { p.translate(0, st::sessionCurrentPadding.top()); p.setFont(st::sessionNameFont->f); p.setPen(st::black->p); p.drawTextLeft(x, st::sessionPadding.top(), w, _current->name, _current->nameWidth); p.setFont(st::sessionActiveFont->f); p.setPen(st::sessionActiveColor->p); p.drawTextRight(x, st::sessionPadding.top(), w, _current->active, _current->activeWidth); p.setFont(st::sessionInfoFont->f); p.setPen(st::black->p); p.drawTextLeft(x, st::sessionPadding.top() + st::sessionNameFont->height, w, _current->info, _current->infoWidth); p.setPen(st::sessionInfoColor->p); p.drawTextLeft(x, st::sessionPadding.top() + st::sessionNameFont->height + st::sessionInfoFont->height, w, _current->ip, _current->ipWidth); } p.translate(0, st::sessionCurrentHeight - st::sessionCurrentPadding.top()); if (_list->isEmpty()) { p.setFont(st::sessionInfoFont->f); p.setPen(st::sessionInfoColor->p); p.drawText(QRect(st::sessionPadding.left(), 0, width() - st::sessionPadding.left() - st::sessionPadding.right(), st::noContactsHeight), lang(lng_sessions_other_desc), style::al_topleft); return; } p.setFont(st::linkFont->f); int32 count = _list->size(); int32 from = floorclamp(r.y() - st::sessionCurrentHeight, st::sessionHeight, 0, count); int32 to = ceilclamp(r.y() + r.height() - st::sessionCurrentHeight, st::sessionHeight, 0, count); p.translate(0, from * st::sessionHeight); for (int32 i = from; i < to; ++i) { const SessionData &auth(_list->at(i)); p.setFont(st::sessionNameFont->f); p.setPen(st::black->p); p.drawTextLeft(x, st::sessionPadding.top(), w, auth.name, auth.nameWidth); p.setFont(st::sessionActiveFont->f); p.setPen(st::sessionActiveColor->p); p.drawTextRight(xact, st::sessionPadding.top(), w, auth.active, auth.activeWidth); p.setFont(st::sessionInfoFont->f); p.setPen(st::black->p); p.drawTextLeft(x, st::sessionPadding.top() + st::sessionNameFont->height, w, auth.info, auth.infoWidth); p.setPen(st::sessionInfoColor->p); p.drawTextLeft(x, st::sessionPadding.top() + st::sessionNameFont->height + st::sessionInfoFont->height, w, auth.ip, auth.ipWidth); p.translate(0, st::sessionHeight); } }
void PasscodeWidget::resizeEvent(QResizeEvent *e) { _passcode.move((width() - _passcode.width()) / 2, (height() / 3)); _submit.move(_passcode.x(), _passcode.y() + _passcode.height() + st::passcodeSubmitSkip); _logout.move(_passcode.x() + (_passcode.width() - _logout.width()) / 2, _submit.y() + _submit.height() + st::linkFont->ascent); }
void Rest::layout() { if (staff() && staff()->isTabStaff()) { // no rests for tablature _space.setLw(0.0); _space.setRw(0.0); return; } switch(durationType().type()) { case TDuration::V_64TH: case TDuration::V_32ND: dotline = -3; break; case TDuration::V_256TH: case TDuration::V_128TH: dotline = -5; break; default: dotline = -1; break; } qreal _spatium = spatium(); int stepOffset = 0; if (staff()) stepOffset = staff()->staffType()->stepOffset(); int line = lrint(userOff().y() / _spatium); // + ((staff()->lines()-1) * 2); int lineOffset = 0; int lines = staff() ? staff()->lines() : 5; if (segment() && measure() && measure()->mstaff(staffIdx())->hasVoices) { // move rests in a multi voice context bool up = (voice() == 0) || (voice() == 2); // TODO: use style values switch(durationType().type()) { case TDuration::V_LONG: lineOffset = up ? -3 : 5; break; case TDuration::V_BREVE: lineOffset = up ? -3 : 5; break; case TDuration::V_MEASURE: if (duration() >= Fraction(2, 1)) // breve symbol lineOffset = up ? -3 : 5; // fall through case TDuration::V_WHOLE: lineOffset = up ? -4 : 6; break; case TDuration::V_HALF: lineOffset = up ? -4 : 4; break; case TDuration::V_QUARTER: lineOffset = up ? -4 : 4; break; case TDuration::V_EIGHT: lineOffset = up ? -4 : 4; break; case TDuration::V_16TH: lineOffset = up ? -6 : 4; break; case TDuration::V_32ND: lineOffset = up ? -6 : 6; break; case TDuration::V_64TH: lineOffset = up ? -8 : 6; break; case TDuration::V_128TH: lineOffset = up ? -8 : 8; break; case TDuration::V_256TH: // not available lineOffset = up ? -10 : 6; break; default: break; } } else { switch(durationType().type()) { case TDuration::V_LONG: case TDuration::V_BREVE: case TDuration::V_MEASURE: case TDuration::V_WHOLE: if (lines == 1) lineOffset = -2; break; case TDuration::V_HALF: case TDuration::V_QUARTER: case TDuration::V_EIGHT: case TDuration::V_16TH: case TDuration::V_32ND: case TDuration::V_64TH: case TDuration::V_128TH: case TDuration::V_256TH: // not available if (lines == 1) lineOffset = -4; break; default: break; } } int yo; _sym = getSymbol(durationType().type(), line + lineOffset/2, lines, &yo); layoutArticulations(); rypos() = (qreal(yo) + qreal(lineOffset + stepOffset) * .5) * _spatium; Spatium rs; if (dots()) { rs = Spatium(score()->styleS(ST_dotNoteDistance) + dots() * score()->styleS(ST_dotDotDistance)); } Segment* s = segment(); if (s && s->measure() && s->measure()->multiMeasure()) { qreal _spatium = spatium(); qreal h = _spatium * 6.5; qreal w = point(score()->styleS(ST_minMMRestWidth)); setbbox(QRectF(-w * .5, -h + 2 * _spatium, w, h)); } else { if (dots()) { rs = Spatium(score()->styleS(ST_dotNoteDistance) + dots() * score()->styleS(ST_dotDotDistance)); } setbbox(symbols[score()->symIdx()][_sym].bbox(magS())); } _space.setLw(0.0); _space.setRw(width() + point(rs)); }
void PainterWindow::render(QPainter *painter) { painter->drawText(QRectF(0, 0, width(), height()), Qt::AlignCenter, QStringLiteral("QWindow")); }
void DrScript::ExecScript(QPainter *p){ DrMessage("DrScript.ExecScript"); char *cLine = (char *)calloc(256,sizeof(char)); double *From = (double *)calloc(2,sizeof(double)); int *iFrom = (int *)calloc(2,sizeof(int)); double *To = (double *)calloc(2,sizeof(double)); int *iTo = (int *)calloc(2,sizeof(int)); double *Hue = (double *)calloc(4,sizeof(double)); int *iHue = (int *)calloc(4,sizeof(int)); for(int k=0;!(fgets(cLine,256,File2Read)==NULL);k++){ if(strncmp(cLine,"Slide",5)==0) break; else if(strncmp(cLine,"Testo",5)==0){ //Colore fgets(cLine,256,File2Read); sscanf(cLine,"%lf %lf %lf %lf\n",Hue,Hue+1,Hue+2,Hue+3); for(int i=0;i<4;i++) iHue[i] = (int)(255.*Hue[i]); p->setBrush( QColor(iHue[0],iHue[1],iHue[2],iHue[3]) ); //Posizione fgets(cLine,256,File2Read); sscanf(cLine,"%lf %lf\n",From,From+1); iFrom[0] = (int)(width()*From[0]); iFrom[1] = (int)(height()*(1.-From[1])); //Testo char *String = (char *)calloc(512,sizeof(char)); fgets(cLine,512,File2Read); for(int c=0;c<strlen(cLine);c++) String[c] = cLine[c]; p->drawText(iFrom[0],iFrom[1],QString(String),-1,Qt::AlignTop); //printf("Col %d %d %d %d Pos %d %d Text %s\n",iHue[0],iHue[1],iHue[2],iHue[3],iFrom[0],iFrom[1],String); // while(1==1) { // fpos_t FPos; // fgetpos(File2Read,&FPos); // if(fgets(cLine,256,File2Read)==0) break; // if(sscanf(cLine,"%lf %lf\n",From,From+1)!=3){ // fsetpos(File2Read,&FPos); // break; // } // } free(String); } else if(strncmp(cLine,"Picture",4)==0){ //Posizione fgets(cLine,256,File2Read); sscanf(cLine,"%lf %lf\n",From,From+1); iFrom[0] = (int)(width()*From[0]); iFrom[1] = (int)(height()*(1.-From[1])); //Posizione fgets(cLine,256,File2Read); sscanf(cLine,"%lf %lf\n",To,To+1); iTo[0] = (int)(width()*To[0]); iTo[1] = (int)(height()*(1.-To[1])); //Testo char *String = (char *)calloc(512,sizeof(char)); fgets(cLine,512,File2Read); // sprintf(String,"%s",cLine); for(int c=0;c<strlen(cLine)-1;c++) String[c] = cLine[c]; //printf("Apro %s in %d %d -> %d %d\n",String,iFrom[0],iFrom[1],iTo[0],iTo[1]); //p->drawImage(QPoint(iFrom[0],iFrom[1]),QImage(QString(String),0),QRect(0,0,iTo[0]-iFrom[0],iTo[1]-iFrom[1]),0); p->drawImage(QRect(iFrom[0],iFrom[1],iTo[0],iTo[1]),QImage(QString(String),0)); free(String); } else if(strncmp(cLine,"Background",10)==0){ } } free(From); free(To); free(Hue); free(cLine); }
void caGraphics::paintEvent( QPaintEvent *event ) { Q_UNUSED(event); if(thisHide) return; int m_margin = 3; QPointF p1,p2; QPainter painter( this ); painter.setRenderHint( QPainter::Antialiasing ); int margin = thisLineSize/2; int w = width() - 2 * margin; int h = height() - 2 * margin; // do not increase linesize beyond the canvas size if(w <= 0 || h <= 0) { setLineSize(thisLineSize-1); } margin = thisLineSize/2; w = width() - 2 * margin; h = height() - 2 * margin; int x = margin; int y = margin; if(thisLineStyle == Dash) { painter.setPen( QPen( getLineColor(), getLineSize(), Qt::DotLine, Qt::SquareCap) ); } else if (thisLineStyle == BigDash) { painter.setPen( QPen( getLineColor(), getLineSize(), Qt::DashLine, Qt::SquareCap) ); } else { painter.setPen( QPen( getLineColor(), getLineSize(), Qt::SolidLine, Qt::SquareCap) ); } if(thisFillStyle == Filled) { painter.setBrush(getForeground()); } else { //painter.setBrush(QColor(0,0,0,0)); } if(getForm() == Rectangle) { QPolygonF rectangle; rectangle.append(QPointF(x,y)); rectangle.append(QPointF(x+w,y)); rectangle.append(QPointF(x+w,y+h)); rectangle.append(QPointF(x,y+h)); rectangle.append(QPointF(x,y)); // rotate QPolygonF rotated = rotateObject(thisTiltAngle, w, h, thisLineSize, rectangle); painter.drawPolygon(rotated); } else if(getForm() == Circle) { // rotate my calculated ellipse QPolygonF rotated = rotateObject(thisTiltAngle, w, h, thisLineSize, drawCircle(x, x+w, y, y+h)); painter.drawPolygon(rotated); } else if(getForm() == Triangle) { QPolygonF triangle; triangle.append(QPointF(x+w/2,0)); triangle.append(QPointF(x,y+h)); triangle.append(QPointF(x+w,y+h)); triangle.append(QPointF(x+w/2,0)); // rotate QPolygonF rotated = rotateObject(thisTiltAngle, w, h, thisLineSize, triangle); painter.drawPolygon(rotated); } else if(getForm() == Arc) { if(thisFillStyle == Filled) { painter.drawPie (x, y, w, h, thisStartAngle * 16, thisSpanAngle * 16); } else { painter.drawArc (x, y, w, h, thisStartAngle * 16, thisSpanAngle * 16); } } else if(getForm() == Line) { QPolygonF line; line.append(QPointF(x,y+h/2)); line.append(QPointF(x+w,y+h/2)); // rotate QPolygonF rotated = rotateObject(thisTiltAngle, w, h, thisLineSize, line); painter.drawPolygon(rotated); } else if(getForm() == Arrow) { QPolygonF lines; QPolygonF head1; QPolygonF head2; p1 = QPointF( m_margin, height()/2 ); p2 = QPointF( width()-m_margin, height()/2 ); lines.append(p1); lines.append(p2); head1 = getHead(p1,p2); if (getArrowMode() == Double) { head2 = getHead(p2,p1); } for(int i=0; i<head1.count(); i++) lines.append(head1.at(i)); for(int i=0; i<head2.count(); i++) lines.append(head2.at(i)); // rotate QPolygonF rotated = rotateObject(thisTiltAngle, w, h, thisLineSize, lines); painter.drawPolygon(rotated); } }
//VOXOX CHANGE by Rolando - 2009.10.13 void VoxOxToolTipLineEdit::resizeEvent ( QResizeEvent * event ){ _maximumWidthPixels = width(); updateCurrentText(); QLineEdit::resizeEvent(event); }
void ScrollPanner::calculateXsize(int size) { m_sizeX = m_maxX - m_minX + m_viewSize.width(); double d = double(width()) / double(m_sizeX); m_sizeXpan = qMax(int(size * d), 1); }
void VoxOxToolTipLineEdit::init() { _cleared = false; _toolTipTextDone = false; _maximumWidthPixels = width();//VOXOX CHANGE by Rolando - 2009.10.13 }
#include "embeddedsvgviewer.h" EmbeddedSvgViewer::EmbeddedSvgViewer(const QString &filePath) { qApp->setStyleSheet(" QSlider:vertical { width: 50px; } \ QSlider::groove:vertical { border: 1px solid black; border-radius: 3px; width: 6px; } \ QSlider::handle:vertical { height: 25px; margin: 0 -22px; image: url(':/files/v-slider-handle.svg'); } \ "); m_renderer = new QSvgRenderer(filePath); m_imageSize = m_renderer->viewBox().size(); m_viewBoxCenter = (QPointF(m_imageSize.width() / qreal(2.0), m_imageSize.height() / qreal(2.0))); m_zoomSlider = new QSlider(Qt::Vertical, this); m_zoomSlider->setMaximum(150); m_zoomSlider->setMinimum(1); connect(m_zoomSlider, SIGNAL(valueChanged(int)), this, SLOT(setZoom(int))); m_zoomSlider->setValue(100); m_quitButton = new QPushButton("Quit", this); connect(m_quitButton, SIGNAL(pressed()), QApplication::instance(), SLOT(quit())); if (m_renderer->animated()) connect(m_renderer, SIGNAL(repaintNeeded()), this, SLOT(update()));
int ScrollArea::scrollWidth() const { return scrollLeftMax() + width(); }
const uint32 IImage::computeNumberOfPixels() const { return width()*height()*depth(); }
void OsmAnd::OnlineMapRasterTileProvider_P::handleNetworkReply( QNetworkReply* reply, const std::shared_ptr<TileEntry>& tileEntry ) { tileEntry->localPath.dir().mkpath(tileEntry->localPath.dir().absolutePath()); auto error = reply->error(); if(error != QNetworkReply::NetworkError::NoError) { const auto httpStatus = reply->attribute(QNetworkRequest::HttpStatusCodeAttribute).toInt(); LogPrintf(LogSeverityLevel::Warning, "Failed to download tile from %s (HTTP status %d)", qPrintable(reply->request().url().toString()), httpStatus); // 404 means that this tile does not exist, so create a zero file if(httpStatus == 404) { // Save to a file QFile tileFile(tileEntry->localPath.absoluteFilePath()); if(tileFile.open(QIODevice::WriteOnly | QIODevice::Truncate)) tileFile.close(); else LogPrintf(LogSeverityLevel::Error, "Failed to mark tile as non-existent with empty file '%s'", qPrintable(tileEntry->localPath.absoluteFilePath())); } _tiles.removeEntry(tileEntry); return; } #if defined(_DEBUG) || defined(DEBUG) LogPrintf(LogSeverityLevel::Info, "Downloaded tile from %s", reply->request().url().toString().toStdString().c_str()); #endif const auto& data = reply->readAll(); // Save to a file QFile tileFile(tileEntry->localPath.absoluteFilePath()); if(tileFile.open(QIODevice::WriteOnly | QIODevice::Truncate)) { tileFile.write(data); tileFile.close(); #if defined(_DEBUG) || defined(DEBUG) LogPrintf(LogSeverityLevel::Info, "Saved tile from %s to %s", qPrintable(reply->request().url().toString()), qPrintable(tileEntry->localPath.absoluteFilePath())); #endif } else LogPrintf(LogSeverityLevel::Error, "Failed to save tile to '%s'", qPrintable(tileEntry->localPath.absoluteFilePath())); // Decode in-memory if we have receiver if(tileEntry->callback) { auto skBitmap = new SkBitmap(); if(!SkImageDecoder::DecodeMemory(data.data(), data.size(), skBitmap, SkBitmap::Config::kNo_Config, SkImageDecoder::kDecodePixels_Mode)) { LogPrintf(LogSeverityLevel::Error, "Failed to decode tile file from '%s'", reply->request().url().toString().toStdString().c_str()); delete skBitmap; std::shared_ptr<IMapTileProvider::Tile> emptyTile; tileEntry->callback(tileEntry->tileId, tileEntry->zoom, emptyTile, false); _tiles.removeEntry(tileEntry); return; } assert(skBitmap->width() == skBitmap->height()); assert(skBitmap->width() == owner->tileDimension); std::shared_ptr<OnlineMapRasterTileProvider::Tile> tile(new OnlineMapRasterTileProvider::Tile(skBitmap, owner->alphaChannelData)); tileEntry->callback(tileEntry->tileId, tileEntry->zoom, tile, true); _tiles.removeEntry(tileEntry); } }
void LogViewWindow::resizeEvent(QResizeEvent *) { m_pSplitter->setGeometry(0,0,width(),height()); }
void OsmAnd::OnlineMapRasterTileProvider_P::obtainTileDeffered( const TileId& tileId, const ZoomLevel& zoom, IMapTileProvider::TileReadyCallback readyCallback ) { assert(readyCallback != nullptr); std::shared_ptr<TileEntry> tileEntry; _tiles.obtainTileEntry(tileEntry, tileId, zoom, true); { QWriteLocker scopeLock(&tileEntry->stateLock); if(tileEntry->state != TileState::Unknown) return; auto tileUrl = owner->urlPattern; tileUrl .replace(QString::fromLatin1("${zoom}"), QString::number(zoom)) .replace(QString::fromLatin1("${x}"), QString::number(tileId.x)) .replace(QString::fromLatin1("${y}"), QString::number(tileId.y)); tileEntry->sourceUrl = QUrl(tileUrl); const auto& subPath = QString::number(zoom) + QDir::separator() + QString::number(tileId.x) + QDir::separator() + QString::number(tileId.y) + QString::fromLatin1(".tile"); tileEntry->localPath = QFileInfo(_localCachePath.filePath(subPath)); tileEntry->callback = readyCallback; tileEntry->state = TileState::Requested; } Concurrent::pools->localStorage->start(new Concurrent::HostedTask(_taskHostBridge, [tileId, zoom, readyCallback](const Concurrent::Task* task, QEventLoop& eventLoop) { const auto pThis = reinterpret_cast<OnlineMapRasterTileProvider_P*>(static_cast<const Concurrent::HostedTask*>(task)->lockedOwner); // Check if this tile is only in requested state std::shared_ptr<TileEntry> tileEntry; pThis->_tiles.obtainTileEntry(tileEntry, tileId, zoom, true); { QWriteLocker scopeLock(&tileEntry->stateLock); if(tileEntry->state != TileState::Requested) return; tileEntry->state = TileState::LocalLookup; } // Check if file is already in local storage if(tileEntry->localPath.exists()) { // 0-sized tile means there is no data at all if(tileEntry->localPath.size() == 0) { std::shared_ptr<IMapTileProvider::Tile> emptyTile; readyCallback(tileId, zoom, emptyTile, true); pThis->_tiles.removeEntry(tileEntry); return; } //NOTE: Here may be issue that SKIA can not handle opening files on different platforms correctly auto skBitmap = new SkBitmap(); SkFILEStream fileStream(qPrintable(tileEntry->localPath.absoluteFilePath())); if(!SkImageDecoder::DecodeStream(&fileStream, skBitmap, SkBitmap::Config::kNo_Config, SkImageDecoder::kDecodePixels_Mode)) { LogPrintf(LogSeverityLevel::Error, "Failed to decode tile file '%s'", qPrintable(tileEntry->localPath.absoluteFilePath())); delete skBitmap; std::shared_ptr<IMapTileProvider::Tile> emptyTile; readyCallback(tileId, zoom, emptyTile, false); pThis->_tiles.removeEntry(tileEntry); return; } assert(skBitmap->width() == skBitmap->height()); assert(skBitmap->width() == pThis->owner->tileDimension); // Construct tile response std::shared_ptr<OnlineMapRasterTileProvider::Tile> tile(new OnlineMapRasterTileProvider::Tile(skBitmap, pThis->owner->alphaChannelData)); readyCallback(tileId, zoom, tile, true); pThis->_tiles.removeEntry(tileEntry); return; } // Well, tile is not in local cache, we need to download it pThis->obtainTileDeffered(tileEntry); })); }
void QEnhancedTableView::print(QPrinter *printer, bool onePageWide, bool onePageHigh) { QPrinter* p=printer; //p->setPageMargins(10,10,10,10,QPrinter::Millimeter); if (width()>height()) { p->setOrientation(QPrinter::Landscape); } else { p->setOrientation(QPrinter::Portrait); } clearSelection(); /// PRINT HERE ////////////////////////////////////////////////////////////////////////////////// // calculate the total width/height table would need without scaling const int rows = model()->rowCount(); const int cols = model()->columnCount(); double vhw=verticalHeader()->width()+8; double totalWidth = vhw; double minWidth=1e33; double maxWidth=0; for (int c = -1; c < cols; ++c) { double w=columnWidth(c); totalWidth += w; if (w<minWidth) minWidth=w; if (w>maxWidth) maxWidth=w; } double hhh=horizontalHeader()->height()+8; double totalHeight = hhh; double minHeight=1e33; double maxHeight=0; for (int r = 0; r < rows; ++r) { double h=rowHeight(r); totalHeight += h; if (h<minHeight) minHeight=h; if (h>maxHeight) maxHeight=h; } double scale=1.0; // adjust scale, so the widest/highest column fits on one page /*if (maxWidth*scale>p->pageRect().width()) scale=p->pageRect().width()/maxWidth; if (maxHeight*scale>p->pageRect().height()) scale=p->pageRect().height()/maxHeight;*/ if (onePageWide) { if (totalWidth>p->pageRect().width()) scale=p->pageRect().width()/totalWidth; } if (onePageHigh) { if (totalHeight>p->pageRect().height()) scale=qMin(scale, p->pageRect().height()/totalHeight); } //qDebug()<<scale; // print scaled pixmap int pagesWide=1; int pagesHigh=1; QList<int> pageCols, pageRows; pageCols<<0; pageRows<<0; { // find number of pages needed double x=vhw, x0=vhw; if (!onePageWide) { for (int c=0; c<cols; c++) { double cw=columnWidth(c); if (x+cw>p->pageRect().width()/scale) { pagesWide++; x=0; pageCols<<c; } else { x=x+cw; x0=x0+cw; } } } if (pageCols.size()>0 && cols>pageCols.last()) pageCols<<cols; if (pageCols.size()==1) pageCols<<cols; double y=hhh, y0=hhh; if (!onePageHigh) { for (int r=0; r<rows; r++) { double rh=rowHeight(r); if (y+rh>p->pageRect().height()/scale) { pagesHigh++; pageRows<<r; y=hhh; } else { y=y+rh; y0=y0+rh; } } } if (pageRows.size()>0 && rows>pageRows.last()) pageRows<<rows; if (pageRows.size()==1) pageRows<<rows; } QPainter painter(p); paint(painter, scale, -1, hhh, vhw, pageCols, pageRows, p); painter.end(); /// PRINT DONE ////////////////////////////////////////////////////////////////////////////////// }
bool Frame::is_intersected(int x, int y) { x-=_x_shift; y-=_y_shift; if(x<0||y<0||x>=width()||y>=height()) return false; return _mask[_left+x][_top+y]; }