void GameArea::draw_nextItem() //显示下一个要出现的图形 { QPainter painter(this); painter.drawRect(gameArea_width+20,10,4*step,4*step); painter.setBrush(this->boxBrushColor); for(int i=0;i<4;i++) for(int j=0;j<4;j++) { if(*(theNextItem + i*4 +j)==1) { if(this->is_draw_box_picture) { QPixmap pix; pix.load(this->boxPicture); painter.drawPixmap(gameArea_width+20+j*step,10+i*step,step,step,pix); } painter.drawRect(gameArea_width+20+j*step,10+i*step,step,step); } } }
void MainWindow::openImage(const QString &path) { QString fileName = path; if (fileName.isNull()) fileName = QFileDialog::getOpenFileName(this, tr("Open Image"), "", tr("Image Files (*.png *.jpg *.bmp)")); if (!fileName.isEmpty()) { QPixmap newImage; if (!newImage.load(fileName)) { QMessageBox::warning(this, tr("Open Image"), tr("The image file could not be loaded."), QMessageBox::Cancel); return; } puzzleImage = newImage; setupPuzzle(); } }
void GPS::initializeImages(){ QPixmap gpsPix; gpsPix.load(":gps"); // Create new picture for transparent QPixmap transparent(gpsPix.size()); // Do transparency transparent.fill(Qt::transparent); QPainter p(&transparent); p.setCompositionMode(QPainter::CompositionMode_Source); p.drawPixmap(0, 0, gpsPix); p.setCompositionMode(QPainter::CompositionMode_DestinationIn); // Set transparency level to 150 (possible values are 0-255) p.fillRect(transparent.rect(), QColor(0, 0, 0, 150)); p.end(); // Set original picture's reference to new transparent one gpsPix = transparent; gps = new QGraphicsPixmapItem(gpsPix); halfSizeImage = gpsPix.size().height() / 2; gps->setTransformationMode(Qt::SmoothTransformation); gps->setScale(sizes[index]); gps->setOffset(-halfSizeImage, -halfSizeImage); QFont b; gpsScene->addItem(gps); b.setStyleHint(QFont::Decorative); b.setBold(true); b.setPointSize(16); latitude=gpsScene->addSimpleText("Latitude: 0",b); longitude=gpsScene->addSimpleText("Longitude: 0",b); latitude->setPos(latitudePosition.x() * sizes[index] - halfSizeImage * sizes[index], latitudePosition.y() * sizes[index] - halfSizeImage * sizes[index]); longitude->setPos(longitudePosition.x() * sizes[index] - halfSizeImage * sizes[index], longitudePosition.y() * sizes[index] - halfSizeImage * sizes[index]); }
int main(int argc, char *argv[]) { KAboutData aboutData( "WebPhonon", "WebPhonon", ki18n("WebPhonon"), "1.4", ki18n("Media Player"), KAboutData::License_GPL, ki18n("Copyright (c) 2013 Zakhrov") ); KCmdLineArgs::init( argc, argv, &aboutData ); KCmdLineOptions options; //new options.add("+[file]", ki18n("Document to open")); //new KCmdLineArgs::addCmdLineOptions(options); //new QApplication a(argc, argv); QCoreApplication::setApplicationName("WebPhonon"); MainWindow w; QPixmap img; img.load(":/splash/WebPhonon-Master-text2.png"); QSplashScreen spl; spl.setPixmap(img); spl.show(); QStringList cmd=a.arguments(); // QTextStream cout(stdout); // cout<<argv[0]<<endl; // cout<<argv[1]<<endl; // if(!cmd.isEmpty()) // { // w.cmdopen(cmd.last()); // } KCmdLineArgs *args = KCmdLineArgs::parsedArgs(); //new if(args->count()) //new { w.cmdopen(args->url(0).url()); //new } w.showMaximized(); return a.exec(); }
void KWindowInfo::display( const QString &text, const QPixmap &pix ) { QPixmap icon; if ( pix.isNull() ) icon.load( "bell.png" ); else icon = pix; if ( win->inherits( "KSystemTray" ) ) { KSystemTray *tray = static_cast<KSystemTray *>( win ); tray->setPixmap( icon ); QToolTip::add( tray, text ); return; } win->setCaption( text ); win->setIcon( icon ); #ifdef Q_WS_X11 KWin::setIcons( win->winId(), icon, icon ); #endif }
QPixmap * MrmlView::getPixmap( const KURL& url ) { QString u = url.url(); QPixmap *pix = m_pixmapCache.find( u ); if ( pix ) return pix; if ( url.isLocalFile() ) { QPixmap p; if ( !p.load( url.path() ) ) p = m_unavailablePixmap; m_pixmapCache.insert( u, p ); return m_pixmapCache.find( u ); } else { // remote url, download with KIO Loader::self()->requestDownload( url ); } return 0L; }
void PixmapViewer::mousePressEvent(QMouseEvent* e) { if (e->buttons()) { if (e->buttons() & Qt::RightButton) { if ( QMessageBox::warning(0, "Unset image?", QString("Unset image?")) ) { setPixmap(QPixmap()); emit changed(); } } else { QString file = QFileDialog::getOpenFileName(0, "Select an image"); QPixmap tmp; if (!file.isEmpty()) { if (tmp.load ( file ) ) { setPixmap(tmp); QMessageBox::warning(0, "Failure loading image", QString("Failed load image file %1").arg(file)); emit changed(); } } } } }
void KEmoticonsProvider::addEmoticonIndex(const QString &path, const QStringList &emoList) { foreach(const QString &s, emoList) { KEmoticonsProvider::Emoticon e; QPixmap p; QString escaped = Qt::escape(s); e.picPath = path; p.load(path); e.picHTMLCode = QString("<img align=\"center\" title=\"%1\" alt=\"%1\" src=\"%2\" width=\"%3\" height=\"%4\" />").arg(escaped).arg(path).arg(p.width()).arg(p.height()); e.matchTextEscaped = escaped; e.matchText = s; if (!s.isEmpty() && !escaped.isEmpty()) { d->m_emoticonsIndex[escaped[0]].append(e); d->m_emoticonsIndex[s[0]].append(e); } }
void qmainstackwidget::set_editsearch() { edit_search = new QLineEdit(this); edit_search->setGeometry(0, 110, 283, 25); edit_search->setFont(QFont("Timers", 10, QFont::StyleOblique)); edit_search->setStyleSheet("QLineEdit{border: 2px solid rgb(22, 154, 218);padding: 0 8px;background: rgb(21, 127, 178);selection-background-color: darkgray;color:rgb(240, 255, 255);}"); QPushButton *search = new QPushButton(this); search->setFlat(true); QPixmap pix; pix.load("search.jpg"); pix = pix.scaled(18, 18); QIcon icon_search(pix); search->setIcon(icon_search); search->setFixedSize(18, 18); search->move(edit_search->width() - search->width() - 2, (edit_search->height() - search->height()) / 2); search->setGeometry(263, 115, search->width(), search->height()); search->setStyleSheet("QPushButton{ border-image:url(search.png); }" "QPushButton:press{border-image:url(search_press.png);}" "QPushButton:hover{border-image:url(search_hover.png);}"); search->setCursor(QCursor(Qt::PointingHandCursor)); }
void QGroupList::makeIcon(QCPItem* anItem) { QPixmap orig(ICON_DIM, ICON_DIM); QPixmap pix; orig.fill(Qt::transparent); QPainter painter(&orig); painter.drawPixmap(0, 0, ICON_DIM, ICON_DIM, anItem->icon().pixmap(ICON_DIM)); if ( anItem->isRootRequired() && pix.load(ROOT_PICTURE) ) { painter.drawPixmap(orig.width() - pix.width(), 0 , pix); anItem->setIcon(QIcon(orig)); } anItem->setIcon(QIcon(orig)); }
void TileList::loadTile(const QString &path) { QString fileName = path; if (fileName.isNull()) fileName = QFileDialog::getOpenFileName(this, tr("Open Image"), "", "Image Files (*.png *.jpg *.bmp)"); if (!fileName.isEmpty()) { QPixmap newImage; if (!newImage.load(fileName)) { QMessageBox::warning(this, tr("Open Image"), tr("The image file could not be loaded."), QMessageBox::Cancel); return; } this->tileImage = newImage; } }
void GraphicsEngine::reloadSprites() { runeSprites_.clear(); QString runeFilePath = Paths::RUNES; // Load all rune images for (Rune* r : globalRunes_) { QString name = r->descriptor_.naturalName_; QPixmap runeImage; if (runeImage.load(runeFilePath + name.toLower() + Paths::IMAGEEXTENSION)) { runeSprites_.push_back(runeImage); } else { cout << "ERROR : couldn't load " << (runeFilePath + name.toLower() + Paths::IMAGEEXTENSION).toStdString() << endl; runeSprites_.push_back(runeImage); } } }
void VideoPlayerTool::run() { for(;;) { mutex.lock(); waitCondition.wait(&mutex, play_period_ms); mutex.unlock(); playTimer->stop(); // while(playContinuous) { slotStepMovie(); } QPixmap icon; if(icon.load(":/images/pixmaps/VcrPlay.png")) { playMovie->setPixmap(icon); } } }
void GameArea::draw_next_block() { QPainter painter(this); painter.drawRect(_area_width+20, 10, 4*_step, 4*_step); painter.setBrush(_block_brush_color); for (int i = 0; i < 4; ++i) { for (int j = 0; j < 4; ++j) { if (*(_next_block + i*4 + j) == 1) { if (_is_draw_block_pic) { QPixmap pix; pix.load(_block_pic); painter.drawPixmap(_area_width + 20 + j*_step, 10 + i*_step, _step, _step, pix); } painter.drawRect(_area_width + 20 + j*_step, 10 + i*_step, _step, _step); } } } }
QPixmap loadPixmap(const QString &path) { qreal ratio = 1.0; QPixmap pixmap; const qreal devicePixelRatio = qApp->devicePixelRatio(); if (!qFuzzyCompare(ratio, devicePixelRatio)) { QImageReader reader; reader.setFileName(qt_findAtNxFile(path, devicePixelRatio, &ratio)); if (reader.canRead()) { reader.setScaledSize(reader.size() * (devicePixelRatio / ratio)); pixmap = QPixmap::fromImage(reader.read()); pixmap.setDevicePixelRatio(devicePixelRatio); } } else { pixmap.load(path); } return pixmap; }
void PreviewFileDialog::setPreviewPicture(const QString &picture) { QPixmap pixmapPicture; if (pixmapPicture.load(picture)) { int x, y; double ratio; x = pixmapPicture.width(); y = pixmapPicture.height(); ratio = double(x) / double(y); if ((x > labelPreview.width()) || (y > labelPreview.height())) { labelPreview.setScaledContents(true); if (x > y) labelPreview.setMinimumHeight(int(labelPreview.size().width() / ratio)); else labelPreview.setMinimumWidth(int(labelPreview.size().height() * ratio)); } else { labelPreview.setScaledContents(false); labelPreview.setMinimumSize(100,100); } labelPreview.setPixmap(picture); labelPreviewWidthText.setText(tr("Width:")); labelPreviewHeightText.setText(tr("Height:")); labelPreviewRatioText.setText(tr("Ratio:")); labelPreviewWidth.setText(tr("%1 px").arg(x)); labelPreviewHeight.setText(tr("%1 px").arg(y)); labelPreviewRatio.setText(tr("%1").arg(ratio,0,'f',3)); } else { labelPreview.clear(); labelPreviewWidthText.clear(); labelPreviewHeightText.clear(); labelPreviewRatioText.clear(); labelPreviewWidth.clear(); labelPreviewHeight.clear(); labelPreviewRatio.clear(); } }
void TextRoom::loadStyleSheet(const QString &fcolor, const QString &bcolor, const QString &scolor) { QColor textColor; textColor.setNamedColor(fcolor); QColor backgroundColor; backgroundColor.setNamedColor(bcolor); QColor statusbarColor; statusbarColor.setNamedColor(scolor); QPalette palette; palette.setColor(QPalette::Text, textColor); palette.setColor(QPalette::Base, QColor(0, 0, 0, 0)); textEdit->setPalette(palette); QPalette bgPalette; if ( backgroundImage == 0 ) { bgPalette.setColor(QPalette::Window, backgroundColor); } else { QPixmap bgmain; bgmain.load( backgroundImage ); QDesktopWidget* desktopWidget = QApplication::desktop(); QRect rect = desktopWidget->geometry(); QSize size(rect.width() , rect.height()); QPixmap bg(bgmain.scaled(size)); bgPalette.setBrush(QPalette::Window, bg); } TextRoom::setPalette(bgPalette); QPalette palette2; palette2.setColor(QPalette::WindowText, statusbarColor); palette2.setColor(QPalette::Window, QColor(0, 0, 0, 0)); horizontalSlider->setPalette(palette2); statsLabel->setPalette(palette2); deadlineLabel->setPalette(palette2); }
void MatWindow::updateTexture() { return; QString allTxt = matText->toPlainText(); int posText = allTxt.indexOf("texture "); if(posText != -1){ QString textureName; for(int i=posText+8; i<allTxt.size(); ++i){ textureName += allTxt.at(i); } textureName.truncate(textureName.indexOf('.')); QPixmap img; std::cout << QString(texturePath+textureName).toLocal8Bit().data() << std::endl; if(img.load(texturePath+textureName)){ img = img.scaled(150, 150); textureLbl->setText(textureName); textureLbl->setPixmap(img); } else textureLbl->setText("Image Unavailable"); } }
page0::page0(QWidget *parent) : page(parent), ui(new Ui::page0) { ui->setupUi(this); /* load and show the splash screen*/ QPixmap splash; if (splash.load(SPLASH_FILE)) { LOG_PRINT(verbose_e, "Splash file: '%s'\n", SPLASH_FILE); ui->label->setPixmap(splash); ui->label->update(); } else { LOG_PRINT(verbose_e, "Cannot load splash file: '%s'\n", SPLASH_FILE); } ui->progressBar->setValue(0); first_time = true; }
void QtApplication::initialise() { // Splash QPixmap pixmap; // Query for custom splash screens bool foundCustomSplash = false; const auto pSplash = this->get<ISplash>(); if (pSplash != nullptr) { std::unique_ptr<BinaryBlock> splashData; std::string format; const auto loaded = pSplash->loadData(splashData, format); if (loaded) { foundCustomSplash = pixmap.loadFromData(static_cast<const uchar*>(splashData->data()), static_cast<uint>(splashData->length()), format.c_str()); } } // Use default splash screen if (!foundCustomSplash) { pixmap.load(":/qt_app/splash"); } splash_.reset(new QSplashScreen(pixmap)); splash_->show(); auto qtFramework = this->get<IQtFramework>(); TF_ASSERT(qtFramework != nullptr); if (qtFramework != nullptr) { auto palette = qtFramework->palette(); if (palette != nullptr) { application_->setPalette(palette->toQPalette()); } } }
QSize SIconPool::defaultSize(const QString &fileName) { QSize defSize; // Get the default size from svg renderer or pixmap size if (!fileName.isEmpty()) { // SVG? Use QSvgRenderer if (fileName.endsWith(".svg")) { QSvgRenderer *svgRenderer = getSvgRenderer(fileName); if (svgRenderer->isValid()) { defSize = svgRenderer->defaultSize(); } } else { // Otherwise load with QPixmap QPixmap pixmap; pixmap.load(fileName); defSize = pixmap.size(); } } return defSize; }
void START::paintEvent(QPaintEvent *) { QPainter painter(this); QPixmap pix; if(type == 0){ if(red == 1)pix.load(":/Image/play.png"); else pix.load(":/Image/play0.png"); } else if(type == 1){ if(red == 1)pix.load(":/Image/help.png"); else pix.load(":/Image/help0.png"); } else if(type == 2){ if(red == 1)pix.load(":/Image/quit.png"); else pix.load(":/Image/quit0.png"); }else{ pix.load(":/Image/thank_you.png"); } painter.drawPixmap(0,0,wid,hei,pix); }
void QSPixmapClass::load( QSEnv *env ) { if ( env->numArgs() != 1 ) { env->throwError( QString::fromLatin1( "Pixmap.load() called with %1 arguments. 1 argument expected." ). arg( env->numArgs() ) ); return; } if ( !env->arg( 0 ).isString() ) { env->throwError( QString::fromLatin1( "Pixmap.load() called with an argument of type %1. " "Type String is expeced" ). arg( env->arg( 0 ).typeName() ) ); return; } QSObject t = env->thisValue(); QSPixmapClass *pac = (QSPixmapClass*)t.objectType(); QPixmap *pix = pac->pixmap( &t ); pix->load( env->arg( 0 ).toString() ); return; }
QPixmap loadIcon(const QString nam, bool forceUseColor) { static ScPixmapCache<QString> pxCache; if (pxCache.contains(nam)) return *pxCache[nam]; QString iconFilePath(QString("%1%2").arg(ScPaths::instance().iconDir()).arg(nam)); QPixmap *pm = new QPixmap(); if (!QFile::exists(iconFilePath)) qWarning("Unable to load icon %s: File not found", iconFilePath.toLatin1().constData()); else { pm->load(iconFilePath); if (pm->isNull()) qWarning("Unable to load icon %s: Got null pixmap", iconFilePath.toLatin1().constData()); if (PrefsManager::instance()->appPrefs.uiPrefs.grayscaleIcons && !forceUseColor) iconToGrayscale(pm); } pxCache.insert(nam, pm); return *pm; }
void PixmapEdit::selectPixmap() { const QString fileName(selectPixmapFileName()); if (fileName.isEmpty()) return; QPixmap pm; if (!pm.load(fileName)) { //! @todo err msg return; } setValue(pm); /* KDE4: #ifdef Q_WS_WIN //save last visited path KUrl url(fileName); if (url.isLocalFile()) KRecentDirs::add(":lastVisitedImagePath", url.directory()); #endif */ }
void MyScene::setBackground(QString backgroundPath, bool repeat){ //set new background QPixmap newBackground; newBackground.load(backgroundPath); for(int i = 0; i < m_background.length(); i++) this->removeItem(m_background[i]); m_background.clear(); if(repeat){ for(int number = 0;number < int(m_sceneWidth / newBackground.width())+1;number++){ m_background.append(this->addPixmap(newBackground)); m_background.last()->setData(0,backgroundPath); m_background[number]->setPos(int(newBackground.width()*number), 0); m_background[number]->setZValue(-1); } } else{ m_background.append(this->addPixmap(newBackground)); m_background.last()->setData(0,backgroundPath); m_background.last()->setZValue(-1); } m_saved = false; }
StudentDashBoard::StudentDashBoard(QWidget *parent) : QMainWindow(parent), ui(new Ui::StudentDashBoard) { ui->setupUi(this); //set style Style style; style.styleWork(this); statusLabel = new QLabel; statusLabel->setAlignment(Qt::AlignRight|Qt::AlignBottom); ui->statusbar->addWidget(statusLabel,this->width()); //set timer timer = new QTimer; messageCheck = new QTimer; hasMessage = false; broadCastTimer = new QTimer; clearBroadCastContent = new QTimer; showBroadCastWin = new ShowBroadCastContent; clearHelpContent = new QTimer; // ppt window pptWin = new PPTView; // pptWin->setWindowFlags(Qt::WType_TopLevel|Qt::WStyle_StaysOnTop |Qt::WindowTitleHint); //coding win codingWin = new CodingWindow; codingWin->setWindowFlags(Qt::WType_TopLevel|Qt::WStyle_StaysOnTop |Qt::WindowTitleHint); questionWin = new QuestionWindow; message = QString(tr("test message from server")); socket = new QTcpSocket; videoViewWin = new VideoView; // videoViewWin->setWindowFlags(Qt::WType_TopLevel|Qt::WStyle_StaysOnTop |Qt::WindowTitleHint); questionId = 0; QPixmap pix; pix.load("resource/dashboardbg.jpg",0,Qt::AvoidDither | Qt::ThresholdAlphaDither | Qt::ThresholdDither); resize(pix.size()); setMask(pix.mask()); createActions(); createGlobalActions(); // showHelpInfo(); }
void VideoPlayerTool::slotRewindMovie() { fprintf(stderr, "[VideoPlayerT]:%s:%d : rewind file '%s'\n", __func__, __LINE__, VideoFile); // read first frame to see if format is supported if(m_fileVA) m_fileVA->rewindMovie(); else setFile(VideoFile); if(m_fileVA) { playScrollBar->blockSignals(TRUE); playScrollBar->setValue(0); playScrollBar->blockSignals(FALSE); slotStepMovie(); } // if playFile else { fprintf(stderr, "[RT]: rewind File '%s' not found\n", VideoFile); return; } if(!playTimer) { playTimer = new QTimer(this); connect(playTimer, SIGNAL(timeout()), this, SLOT(slotStepMovie())); } playTimer->changeInterval((int)(1000.f / (playSpeed * playFPS))); playTimer->stop(); QPixmap icon; if(icon.load(":/images/pixmaps/VcrPlay.png")) playMovie->setPixmap(icon); // playHBox->show(); }
void MainWindow::openFile(const QString &mml_file_name) { m_mml_widget->clear(); m_compare_image->clear(); QFile file(mml_file_name); if (!file.open(QIODevice::ReadOnly)) { showWarning("File error: Could not open \"" + mml_file_name + "\": " + file.errorString()); return; } QTextStream stream(&file); // stream.setEncoding(QTextStream::UnicodeUTF8); QString text = stream.readAll(); file.close(); QString error_msg; int error_line, error_column; bool result = m_mml_widget->setContent(text, &error_msg, &error_line, &error_column); if (!result) { showWarning("Parse error: line " + QString::number(error_line) + ", col " + QString::number(error_column) + ": " + error_msg); return; } QPixmap pm; int idx = mml_file_name.lastIndexOf('.'); if (idx != -1) { QString image_file_name = mml_file_name.mid(0, idx + 1) + "png"; if (pm.load(image_file_name)) m_compare_image->setPixmap(pm); } }
void HoIModDesigner::DisplayContourMap() { QPixmap newPixmap; newPixmap.load("E:/temp/building_airbase.dds"); m_View->m_Scene->addPixmap(newPixmap); ParserHoI3 parser(nullptr,nullptr); HoI3Script *script = parser.ParseScript("E:/Spiele/HoI3/events/ClaimingMemel.txt"); if( script == nullptr ) { return; } HoI3Scriptparser scriptParser; scriptParser.SaveScript( *script, "E:/Spiele/HoI3/events/ClaimingMemel2.txt" ); // // QDockWidget *dock = new QDockWidget(tr("Script"), this); // dock->setAllowedAreas(Qt::LeftDockWidgetArea | Qt::RightDockWidgetArea); // m_TreeView = new QTreeWidget(dock); // m_TreeView->setColumnCount(2); // // QList<QTreeWidgetItem*> topLevelItems; // QList<HoI3Token>::const_iterator iter; // for( iter = script->m_TokenList.constBegin(); iter != script->m_TokenList.constEnd(); iter++ ) // { // QStringList newData; // newData << iter->m_Name << iter->m_Value; // QTreeWidgetItem *newTopLevelItem = new QTreeWidgetItem( m_TreeView, newData ); // CreateColumn( newTopLevelItem, (*iter) ); // } // // m_TreeView->addTopLevelItems(topLevelItems); // m_TreeView->expandAll(); // // dock->setWidget(m_TreeView); // addDockWidget(Qt::RightDockWidgetArea, dock); // m_DockWidgetsMenu->addAction(dock->toggleViewAction()); }