void K3bIsoImageWritingDialog::slotContextMenu( KListView*, QListViewItem*, const QPoint& pos ) { if( !d->haveMd5Sum ) return; QPopupMenu popup; int copyItem = popup.insertItem( i18n("Copy checksum to clipboard") ); int compareItem = popup.insertItem( i18n("Compare checksum...") ); int r = popup.exec( pos ); if( r == compareItem ) { bool ok; QString md5sumToCompare = KInputDialog::getText( i18n("MD5 Sum Check"), i18n("Please insert the MD5 Sum to compare:"), QString::null, &ok, this ); if( ok ) { if( md5sumToCompare.lower().utf8() == m_md5Job->hexDigest().lower() ) KMessageBox::information( this, i18n("The MD5 Sum of %1 equals the specified.").arg(imagePath()), i18n("MD5 Sums Equal") ); else KMessageBox::sorry( this, i18n("The MD5 Sum of %1 differs from the specified.").arg(imagePath()), i18n("MD5 Sums Differ") ); } } else if( r == copyItem ) { QApplication::clipboard()->setText( m_md5Job->hexDigest().lower(), QClipboard::Clipboard ); } }
//つぶやくボタン void TweetDialog::on_tweetButton_clicked() { //認証済みか確認 if(user_id().length() == 0) return; //画像が指定されてるか if(!QFile::exists(imagePath())) return; //画像のバイナリデータを読み込む QFile file(imagePath()); if(!file.open(QIODevice::ReadOnly)) return; QDataStream in(&file); QByteArray imagedata(in.device()->readAll()); file.close(); // qDebug() << "image:" << imagedata.length() << "," << imagePath(); //つぶやく QVariantMap map; QVariantList list; list.append(imagedata); QStringList slist; slist.append(imagePath()); map.insert("status", ui->tweetTextEdit->document()->toPlainText()); map.insert("media", slist); m_status.updateStatuses(map); //消す ui->tweetTextEdit->clear(); setImagePath(""); close(); }
void RefImage::imageFromFile() { QFile file(imagePath()); if (file.exists()) { QFileInfo fileinfo(imagePath()); QPixmap pixmap; pixmap.load(imagePath(),NULL,Qt::AutoColor); insertImage(pixmap,fileinfo.fileName()); } }
void BlackBoardWidget::saveImage() { if (m_parentApplet->destroyed()){ KIO::del(imagePath()); }else{ if (m_changed){ KSaveFile imageFile(imagePath()); imageFile.open(); m_pixmap.save(&imageFile, "PNG"); imageFile.finalize(); imageFile.close(); } } }
// Image definition bool CLwoWriter::WriteImageDefinitions() { CLwoFile::CLayer::ImageVector& images = m_curLayer.GetImageVector(); CLwoFile::CLayer::ImageVector::iterator imageBegin, imageIt, imageEnd; imageBegin = images.begin(); imageEnd = images.end(); for(imageIt = imageBegin; imageIt != imageEnd; ++imageIt) // For each LWO face { std::string imagePath(*imageIt); ushort still_size = (ushort)GetStringSize(imagePath); MSG_DEBUG("CLIP | STIL: '" << imagePath << "'"); // "CLIP" + size WriteTag(CLwoFile::CHUNK_CLIP); WriteLong(4 + 4 + 2 + still_size); // imageIndex + "STIL" + stilSize + pathString ulong imageIndex = (imageIt - imageBegin); WriteLong(imageIndex); // image index : 0-based index WriteTag(CLwoFile::CHUNK_STIL); // STIL WriteShort(still_size); // Write the image path WriteString(imagePath); } return true; }
/*! Creates a input tag with type="image" and src=\a "src". The \a src must be one of URL, a absolute path or a relative path. If \a src is a relative path, it must exist in the public/images directory. */ QString TViewHelper::submitImageTag(const QString &src, const THtmlAttribute &attributes) const { THtmlAttribute attr = attributes; attr.prepend("src", imagePath(src)); attr.prepend("type", "image"); return selfClosingTag("input", attr); }
QVariant ThumbnailModel::data(const QModelIndex &index, int role) const { if (role == Qt::DecorationRole && index.isValid()) { QString id = itemId(index).toString(); QFutureWatcher<QImage> *future = cache.object(id); if (!future) { future = new QFutureWatcher<QImage>; QString path = imagePath(index); if (!path.isEmpty()) { future->setFuture(QtConcurrent::run(ThumbnailModel::load, path)); connect(future, SIGNAL(finished()), this, SLOT(thumbnailLoaded())); } cache.insert(id, future); } return !future->isCanceled() ? future->result() : QVariant(); } else { return QGalleryQueryModel::data(index, role); } }
void BlackBoardWidget::loadImage() { m_painter.end(); m_pixmap.load(imagePath(), "PNG"); update(contentsRect()); m_painter.begin(&m_pixmap); m_painter.setPen(QPen(m_color, 3)); }
void MainWindow::showGraphicsIconTextLayout() { QString imagePath(":/widgets/images/graphicsiconstext_layout_"); QString cnt; cnt.setNum( iLayoutCount ); imagePath.append( cnt ); imagePath.append( ".jpg" ); ui->layoutGraphics->setPixmap(QPixmap(imagePath)); }
Button::Button(Display* display, Window parent, XContext context, BrowserControl* control, WKRect size, ButtonType type) : VisualComponent(display, control, size) , m_type(type) { createXWindow(parent, context); m_surface = cairo_xlib_surface_create(display, m_window, DefaultVisual(display, 0), m_size.size.width, m_size.size.height); m_image = cairo_image_surface_create_from_png(imagePath(type)); m_cairo = cairo_create(m_surface); }
void K3bIsoImageWritingDialog::saveUserDefaults( KConfigBase* c ) { m_writingModeWidget->saveConfig( c ), c->writeEntry( "simulate", m_checkDummy->isChecked() ); c->writeEntry( "verify_data", m_checkVerify->isChecked() ); c->writeEntry( "copies", m_spinCopies->value() ); m_writerSelectionWidget->saveConfig( c ); c->writePathEntry( "image path", imagePath() ); }
void YGWidget::sltLocaleChanged(const QLocale&) { QLocale::Language appLang = ygApp->locale().language(); QString imagePath_ = imagePath(appLang); if( /*locale.language() == appLang && */imagePath_.isEmpty()) { return; } m_bgImage = QImage(imagePath_); repaint(); // That is better than update(); }
void AddCharacterDialog::onItemClicked(QTreeWidgetItem * item, int column) { if (mPrevName == item->text(0)) return; mPrevName = item->text(0); QString path = imagePath(item); QPixmap pixmap = mPixmapCache.value(path, QPixmap()); if (! pixmap.isNull()) mUi.lImage->setPixmap(pixmap); }
QHash<QString, QString> AddCharacterDialog::statesAndImagePaths() { QTreeWidgetItem* item = 0; QHash<QString, QString> statesToPaths; for(int i=0; i < mUi.statusTreeWidget->topLevelItemCount(); i++) { item = mUi.statusTreeWidget->topLevelItem(i); statesToPaths.insert(item->text(0), imagePath(item)); } return statesToPaths; }
void RefImage::thumbFromFile() { QFile file(imagePath()); if (file.exists()) { QImageReader* imageReader = new QImageReader(imagePath()); int imageWidth = imageReader->size().width() * (float)CAROUSEL_HEIGHT/imageReader->size().height(); int imageHeight = CAROUSEL_HEIGHT; imageReader->setScaledSize(QSize(imageWidth, imageHeight)); QImage image; if (imageReader->read(&image)) { insertThumb(QPixmap::fromImage(image)); } else { qDebug() << "read failed"; } } }
QUrl SDeclarativeStyleInternal::toolBarIconPath(const QUrl &path, bool inverted) const { if (!path.isEmpty()) { const QString scheme = path.scheme(); const QFileInfo fileInfo = path.path(); const QString completeBaseName = fileInfo.completeBaseName(); if ((scheme.isEmpty() || scheme == QLatin1String("file") || scheme == QLatin1String("qrc")) && completeBaseName.startsWith(QLatin1String("toolbar-")) && completeBaseName.lastIndexOf(QLatin1Char('.')) == -1) return imagePath(completeBaseName, inverted); } return path; }
FileBrowser::FileBrowser( const char *name, QWidget *parent ) : BrowserCategory( name, parent ) , d( new FileBrowser::Private( this ) ) { setLongDescription( i18n( "The file browser lets you browse files anywhere on your system, " \ "regardless of whether these files are part of your local collection. " \ "You can then add these files to the playlist as well as perform basic "\ "file operations." ) ); setImagePath( KStandardDirs::locate( "data", "amarok/images/hover_info_files.png" ) ); // set background if( AmarokConfig::showBrowserBackgroundImage() ) setBackgroundImage( imagePath() ); QTimer::singleShot( 0, this, SLOT(initView()) ); }
/*! Creates a \<img\> image tag with src=\a "src". The \a src must be one of URL, a absolute path or a relative path. If \a src is a relative path, it must exist in the public/images directory. If \a withTimestamp is true, the timestamp of the image file is append to \a src as a query parameter. */ QString TViewHelper::imageTag(const QString &src, bool withTimestamp, const QSize &size, const QString &alt, const THtmlAttribute &attributes) const { THtmlAttribute attr = attributes; if (!alt.isEmpty()) { attr.prepend("alt", alt); } else { attr.prepend("alt", ""); // output 'alt' always } if (size.height() > 0) { attr.prepend("height", QString::number(size.height())); } if (size.width() > 0) { attr.prepend("width", QString::number(size.width())); } attr.prepend("src", imagePath(src, withTimestamp)); return selfClosingTag("img", attr); }
K3bIsoImageWritingDialog::K3bIsoImageWritingDialog( QWidget* parent, const char* name, bool modal ) : K3bInteractionDialog( parent, name, i18n("Burn Iso9660 Image"), i18n("to DVD"), START_BUTTON|CANCEL_BUTTON, START_BUTTON, "DVD image writing", modal ) { d = new Private(); setAcceptDrops(true); setupGui(); m_writerSelectionWidget->setWantedMediumType( K3bDevice::MEDIA_WRITABLE_DVD ); m_writerSelectionWidget->setWantedMediumState( K3bDevice::STATE_EMPTY ); m_writerSelectionWidget->setSupportedWritingApps( K3b::GROWISOFS ); m_writingModeWidget->setSupportedModes( K3b::DAO|K3b::WRITING_MODE_INCR_SEQ|K3b::WRITING_MODE_RES_OVWR ); m_md5Job = new K3bMd5Job( 0, this ); connect( m_md5Job, SIGNAL(finished(bool)), this, SLOT(slotMd5JobFinished(bool)) ); connect( m_md5Job, SIGNAL(percent(int)), this, SLOT(slotMd5JobPercent(int)) ); updateImageSize( imagePath() ); connect( m_writerSelectionWidget, SIGNAL(writerChanged()), this, SLOT(slotWriterChanged()) ); connect( m_writerSelectionWidget, SIGNAL(writingAppChanged(int)), this, SLOT(slotWriterChanged()) ); connect( m_writingModeWidget, SIGNAL(writingModeChanged(int)), this, SLOT(slotWriterChanged()) ); connect( m_editImagePath, SIGNAL(textChanged(const QString&)), this, SLOT(updateImageSize(const QString&)) ); connect( m_checkDummy, SIGNAL(toggled(bool)), this, SLOT(slotWriterChanged()) ); }
static bool setImageAndSymbolPath(JNIEnv* env, jobject obj) { jboolean isCopy; jclass clazz = env->GetObjectClass(obj); jstring path; const char* buf; path = (jstring) env->GetStaticObjectField(clazz, imagePath_ID); buf = env->GetStringUTFChars(path, &isCopy); CHECK_EXCEPTION_(false); AutoJavaString imagePath(env, path, buf); path = (jstring) env->GetStaticObjectField(clazz, symbolPath_ID); buf = env->GetStringUTFChars(path, &isCopy); CHECK_EXCEPTION_(false); AutoJavaString symbolPath(env, path, buf); IDebugSymbols* ptrIDebugSymbols = (IDebugSymbols*) env->GetLongField(obj, ptrIDebugSymbols_ID); CHECK_EXCEPTION_(false); ptrIDebugSymbols->SetImagePath(imagePath); ptrIDebugSymbols->SetSymbolPath(symbolPath); return true; }
void SearchDialog::doRemoveTerms( bool allowSelectTrans /* = true */, bool confirmBeforeRemove /* = true */ ) { int selectedItemCount = 0; // Find all the translation languages of the selected terms. QStringList translationLanguages; for( int i = 0; i < resultsListView->topLevelItemCount(); i++ ) { ResultListItem* termItem = (ResultListItem*)resultsListView->topLevelItem( i ); if( termItem->isSelected() ) { selectedItemCount++; Term* term = termItem->getTerm(); for( Term::TranslationMap::ConstIterator it = term->translationsBegin(); it != term->translationsEnd(); it++ ) { const Translation& trans = *it; if( !translationLanguages.contains( trans.getLanguage() ) ) translationLanguages.append( trans.getLanguage() ); } } } if( selectedItemCount == 0 ) return; if( translationLanguages.count() <= 2 ) { int response; if( confirmBeforeRemove ) { QMessageBox msgBox( QObject::tr( "Warning" ), tr( "ConfirmRemoveSelectedTerms" ), QMessageBox::Warning, QMessageBox::Yes, QMessageBox::No | QMessageBox::Default | QMessageBox::Escape, QMessageBox::NoButton, this ); msgBox.setButtonText( QMessageBox::Yes, tr( "Yes" ) ); msgBox.setButtonText( QMessageBox::No, tr( "No" ) ); response = msgBox.exec(); } else response = QMessageBox::Yes; if( response == QMessageBox::Yes ) { for( int i = 0; i < resultsListView->topLevelItemCount(); i++ ) { ResultListItem* termItem = (ResultListItem*)resultsListView->topLevelItem( i ); if( termItem->isSelected() ) { Term* term = termItem->getTerm(); Vocabulary* vocab = controller->getVocabTree()->getVocabulary( term->getVocabId() ); if( !term->getImagePath().isNull() ) { QDir imagePath( term->getImagePath() ); if( imagePath.isRelative() ) { const QString& imagePath = controller->getApplicationDirName() + "/" + vocab->getParent()->getPath() + "/v-" + QString::number( vocab->getId() ) + "/" + term->getImagePath(); QFile imageFile( imagePath ); if( imageFile.exists() ) { if( !imageFile.remove() ) cerr << "Could not remove image " << qPrintable( imagePath ) << endl; } } } vocab->removeTerm( term->getId() ); delete( termItem ); vocab->setModificationDate( QDateTime::currentDateTime() ); vocab->setDirty( true ); } } resultsListView->clearSelection(); updateUi(); emit termsRemoved(); } } else { int response; QStringList selectedLanguages; if( allowSelectTrans ) { TranslationSelectionDialog msgBox( tr( "MultipleTranslationsDetectedForRemoveTermsCaption" ), tr( "MultipleTranslationsDetectedForRemoveTerms" ), translationLanguages, TranslationSelectionDialog::selectionModeTargetLanguage, controller, this ); msgBox.setMaximumHeight( size().height() - 40 ); msgBox.setMaximumWidth( size().width() - 40 ); response = msgBox.exec(); if( response ) selectedLanguages = msgBox.getSelectedLanguages(); } else { selectedLanguages = QStringList(); selectedLanguages.append( controller->getPreferences().getFirstLanguage() ); selectedLanguages.append( controller->getPreferences().getTestLanguage() ); } if( selectedLanguages.count() == 0 ) return; for( int i = 0; i < resultsListView->topLevelItemCount(); i++ ) { ResultListItem* termItem = (ResultListItem*)resultsListView->topLevelItem( i ); if( termItem->isSelected() ) { Term* term = termItem->getTerm(); Vocabulary* vocab = controller->getVocabTree()->getVocabulary( term->getVocabId() ); for( QStringList::ConstIterator it = selectedLanguages.begin(); it != selectedLanguages.end(); it++ ) { QString lang = *it; term->removeTranslation( lang ); } if( term->getTranslationCount() == 0 ) { if( !term->getImagePath().isNull() ) { QDir imagePath( term->getImagePath() ); if( imagePath.isRelative() ) { const QString& imagePath = controller->getApplicationDirName() + "/" + vocab->getParent()->getPath() + "/v-" + QString::number( vocab->getId() ) + "/" + term->getImagePath(); QFile imageFile( imagePath ); if( imageFile.exists() ) { if( !imageFile.remove() ) cerr << "Could not remove image " << qPrintable( imagePath ) << endl; } } } vocab->removeTerm( term->getId() ); delete( termItem ); vocab->setModificationDate( QDateTime::currentDateTime() ); vocab->setDirty( true ); } } } resultsListView->clearSelection(); updateUi(); } }
void SimpleViewer::processQUrlList(QList<QUrl>& images, QDomDocument& xmlDoc, QDomElement& galleryElem, QDomElement& photosElem) { QImage image; QImage thumbnail; QString tmp; QString newName; int index = 1; int maxSize = d->settings->imagesExportSize; bool resizeImages = d->settings->resizeExportImages; bool fixOrientation = d->settings->fixOrientation; QUrl thumbsDir = QUrl::fromLocalFile(d->tempDir->path()); thumbsDir.setPath(thumbsDir.path() + QLatin1String("/thumbs/")); QUrl imagesDir = QUrl::fromLocalFile(d->tempDir->path()); imagesDir.setPath(imagesDir.path() + QLatin1String("/images/")); qSort(images.begin(), images.end(), cmpUrl); for (QList<QUrl>::ConstIterator it = images.constBegin(); !d->canceled && (it != images.constEnd()) ; ++it) { QApplication::processEvents(); QUrl url = *it; QFileInfo fi(url.toLocalFile()); //video can't be exported, need to add for all video files if (fi.suffix().toUpper() == QLatin1String("MOV")) continue; d->progressWdg->addedAction(i18n("Processing %1", url.fileName()), StartingMessage); // Clear image. image = QImage(); if (d->interface) { image = d->interface->preview(url); } if (image.isNull()) { image.load(url.toLocalFile()); } if (image.isNull()) { d->progressWdg->addedAction(i18n("Could not open image '%1'", url.fileName()), WarningMessage); continue; } if (d->settings->plugType == 0) { // Thumbnails are generated only for simpleviewer plugin if (!createThumbnail(image, thumbnail)) { d->progressWdg->addedAction(i18n("Could not create thumbnail from '%1'", url.fileName()), WarningMessage); continue; } } if (resizeImages && !resizeImage(image, maxSize, image)) { d->progressWdg->addedAction(i18n("Could not resize image '%1'", url.fileName()), WarningMessage); continue; } if (d->meta && d->meta->load(url)) { bool rotated = false; newName = QString::fromUtf8("%1.%2").arg(tmp.sprintf("%03i", index)).arg(QLatin1String("jpg")); if (d->settings->plugType == 0) { QUrl thumbnailPath(thumbsDir); thumbnailPath.setPath(thumbnailPath.path() + newName); if (resizeImages && fixOrientation) d->meta->rotateExifQImage(thumbnail, d->meta->getImageOrientation()); thumbnail.save(thumbnailPath.toLocalFile(), "JPEG"); } QUrl imagePath(imagesDir); imagePath.setPath(imagePath.path() + newName); if (resizeImages && fixOrientation) rotated = d->meta->rotateExifQImage(image, d->meta->getImageOrientation()); image.save(imagePath.toLocalFile(), "JPEG"); // Backup metadata from original image. d->meta->setImageProgramId(QLatin1String("Kipi-plugins"), kipipluginsVersion()); d->meta->setImageDimensions(image.size()); if (rotated) d->meta->setImageOrientation(MetadataProcessor::NORMAL); d->meta->save(imagePath); } d->width = image.width(); d->height = image.height(); if (d->settings->plugType!=2) cfgAddImage(xmlDoc, galleryElem, url, newName); else cfgAddImage(xmlDoc, photosElem, url, newName); d->progressWdg->setProgress(++d->action, d->totalActions); index++; } }
void AddCharacterDialog::clearCache(QTreeWidgetItem * item) { QString path = imagePath(item); if (mPixmapCache.contains(path)) mPixmapCache.remove(path); }
PlaylistBrowserNS::DynamicCategory::DynamicCategory( QWidget* parent ) : BrowserCategory( "dynamic category", parent ) { setPrettyName( i18n( "Dynamic Playlists" ) ); setShortDescription( i18n( "Dynamically updating parameter based playlists" ) ); setIcon( KIcon( "dynamic-amarok" ) ); setLongDescription( i18n( "With a dynamic playlist, Amarok becomes your own personal dj, automatically selecting tracks for you, based on a number of parameters that you select." ) ); setImagePath( KStandardDirs::locate( "data", "amarok/images/hover_info_dynamic_playlists.png" ) ); // set background if( AmarokConfig::showBrowserBackgroundImage() ) setBackgroundImage( imagePath() ); bool enabled = AmarokConfig::dynamicMode(); setContentsMargins( 0, 0, 0, 0 ); KHBox* controls2Layout = new KHBox( this ); QLabel *label; label = new QLabel( i18n( "Previous:" ), controls2Layout ); label->setAlignment( Qt::AlignRight | Qt::AlignVCenter ); m_previous = new QSpinBox( controls2Layout ); m_previous->setMinimum( 0 ); m_previous->setToolTip( i18n( "Number of previous tracks to remain in the playlist." ) ); m_previous->setValue( AmarokConfig::previousTracks() ); QObject::connect( m_previous, SIGNAL(valueChanged(int)), this, SLOT(setPreviousTracks(int)) ); label = new QLabel( i18n( "Upcoming:" ), controls2Layout ); // label->setSizePolicy( QSizePolicy::MinimumExpanding, QSizePolicy::MinimumExpanding ); label->setAlignment( Qt::AlignRight | Qt::AlignVCenter ); m_upcoming = new QSpinBox( controls2Layout ); m_upcoming->setMinimum( 1 ); m_upcoming->setToolTip( i18n( "Number of upcoming tracks to add to the playlist." ) ); m_upcoming->setValue( AmarokConfig::upcomingTracks() ); QObject::connect( m_upcoming, SIGNAL(valueChanged(int)), this, SLOT(setUpcomingTracks(int)) ); QObject::connect( (const QObject*)Amarok::actionCollection()->action( "playlist_clear" ), SIGNAL(triggered(bool)), this, SLOT(playlistCleared()) ); QObject::connect( (const QObject*)Amarok::actionCollection()->action( "disable_dynamic" ), SIGNAL(triggered(bool)), this, SLOT(playlistCleared()), Qt::DirectConnection ); // -- the tool bar KHBox* presetLayout = new KHBox( this ); KToolBar* presetToolbar = new KToolBar( presetLayout ); presetToolbar->setIconSize( QSize( 22, 22 ) ); presetToolbar->setToolButtonStyle( Qt::ToolButtonIconOnly ); presetToolbar->setMovable( false ); presetToolbar->setFloatable( false ); presetToolbar->setSizePolicy( QSizePolicy::MinimumExpanding, QSizePolicy::Preferred ); m_onOffButton = new QToolButton( presetToolbar ); m_onOffButton->setText( i18nc( "Turn dynamic mode on", "On") ); m_onOffButton->setCheckable( true ); m_onOffButton->setIcon( KIcon( "dynamic-amarok" ) ); m_onOffButton->setToolTip( i18n( "Turn dynamic mode on." ) ); presetToolbar->addWidget( m_onOffButton ); m_duplicateButton = new QToolButton( presetToolbar ); m_duplicateButton->setText( i18n("Duplicates") ); m_duplicateButton->setCheckable( true ); m_duplicateButton->setChecked( allowDuplicates() ); m_duplicateButton->setIcon( KIcon( "edit-copy" ) ); m_duplicateButton->setToolTip( i18n( "Allow duplicate songs in result" ) ); presetToolbar->addWidget( m_duplicateButton ); m_addButton = new QToolButton( presetToolbar ); m_addButton->setText( i18n("New") ); m_addButton->setIcon( KIcon( "document-new" ) ); m_addButton->setToolTip( i18n( "New playlist" ) ); presetToolbar->addWidget( m_addButton ); m_editButton = new QToolButton( presetToolbar ); m_editButton->setText( i18n("Edit") ); m_editButton->setIcon( KIcon( "document-properties-amarok" ) ); m_editButton->setToolTip( i18n( "Edit the selected playlist or bias" ) ); presetToolbar->addWidget( m_editButton ); m_deleteButton = new QToolButton( presetToolbar ); m_deleteButton->setText( i18n("Delete") ); m_deleteButton->setEnabled( false ); m_deleteButton->setIcon( KIcon( "edit-delete" ) ); m_deleteButton->setToolTip( i18n( "Delete the selected playlist or bias") ); presetToolbar->addWidget( m_deleteButton ); m_repopulateButton = new QPushButton( presetLayout ); m_repopulateButton->setText( i18n("Repopulate") ); m_repopulateButton->setToolTip( i18n("Replace the upcoming tracks with fresh ones.") ); m_repopulateButton->setIcon( KIcon( "view-refresh-amarok" ) ); m_repopulateButton->setEnabled( enabled ); // m_repopulateButton->setSizePolicy( QSizePolicy( QSizePolicy::Preferred, QSizePolicy::Preferred ) ); QObject::connect( m_repopulateButton, SIGNAL(clicked(bool)), The::playlistActions(), SLOT(repopulateDynamicPlaylist()) ); // -- the tree view m_tree = new DynamicView( this ); connect( m_tree->selectionModel(), SIGNAL(selectionChanged(QItemSelection,QItemSelection)), this, SLOT(selectionChanged()) ); connect( m_onOffButton, SIGNAL(toggled(bool)), The::playlistActions(), SLOT(enableDynamicMode(bool)) ); connect( m_duplicateButton, SIGNAL(toggled(bool)), this, SLOT(setAllowDuplicates(bool)) ); connect( m_addButton, SIGNAL(clicked(bool)), m_tree, SLOT(addPlaylist()) ); connect( m_editButton, SIGNAL(clicked(bool)), m_tree, SLOT(editSelected()) ); connect( m_deleteButton, SIGNAL(clicked(bool)), m_tree, SLOT(removeSelected()) ); navigatorChanged(); selectionChanged(); connect( The::playlistActions(), SIGNAL(navigatorChanged()), this, SLOT(navigatorChanged()) ); }
int main(int argc, char *argv[]) { QApplication a(argc, argv); // No CLI arguments if (argc == 1) { try{ MainWindow w; w.show(); return a.exec(); } catch(std::out_of_range e) { std::cout<<"Out-of-range: "<<e.what()<<std::endl; } catch(const char e[]) { qDebug() << "EXCEPTION: "<<e; } catch(QString e) { qDebug() << "EXCEPTION: "<<e; } return -1; } // COMMAND-LINE INTERFACE // Common variables QString imagePath(QDir::currentPath()), featureName, indexer("Sequential indexer"), trainingSet("training_set.txt"), params, queryImage; QStringList optimizeVars; int useIndex(-1); int verbosityLevel(0); QStringList qargv = a.arguments(); // Shortcut for argv as QStringList // Arguments parser for (int i(1); i<argc; i++) { if (qargv[i] == "-help") { usage(); return 0; } else if (qargv[i] == "-path") { if (i+1 == argc) { std::cerr << "Error: -path requires an argument: path to images\n\n"; usage(); return -1; } imagePath = qargv[i+1]; i++; //std::cerr << "Path " << imagePath.constData()-> << "\n\n"; //qDebug() << "Path" << imagePath; } else if (qargv[i] == "-feature") { if (i+1 == argc) { std::cerr << "Error: -feature requires an argument: name of feature\n\n"; usage(); return -1; } featureName = qargv[i+1]; i++; //qDebug() << "Ft" << featureName; } else if (qargv[i] == "-indexer") { if (i+1 == argc) { std::cerr << "Error: -indexer requires an argument: name of indexer\n\n"; usage(); return -1; } indexer = qargv[i+1]; i++; } else if (qargv[i] == "-optimize") { if (i+1 == argc) { std::cerr << "Error: -optimize requires an argument: comma separated list of variables to optimize\n\n"; usage(); return -1; } optimizeVars = qargv[i+1].split(','); i++; //qDebug() << "Optimize" << optimizeVars; } else if (qargv[i] == "-trainingset") { if (i+1 == argc) { std::cerr << "Error: -trainingset requires an argument: filename of list of files for optimizer training\n\n"; usage(); return -1; } trainingSet = qargv[i+1]; i++; } else if (qargv[i] == "-reuseindex") { int idx(0); // Check if second parameter is index number if (i+1 < argc) { bool ok; idx = qargv[i+1].toInt(&ok); if (!ok) idx=0; else i++; } useIndex = idx; } else if (qargv[i] == "-params") { if (i+1 == argc) { std::cerr << "Error: -params requires an argument: semicolon separated list of params\n\n"; usage(); return -1; } params = qargv[i+1]; i++; } else if (qargv[i] == "-query") { if (i+1 == argc) { std::cerr << "Error: -query requires an argument: path to query image\n\n"; usage(); return -1; } queryImage = qargv[i+1]; i++; } else if (qargv[i] == "-verbose") { verbosityLevel++; // TODO: add more levels } else { std::cerr << "Error: argument not recognized: "<<argv[i]<<"\n\n"; usage(); return -1; } } // No feature name given - nothing to do if (useIndex == -1 && featureName.isEmpty()) { std::cerr << "Error: you must specify -featurename with that option\n\n"; usage(); return -1; } // Start work Indexer* idx; ImageFeatures* feature; try { if (useIndex == -1) { feature = ImageFeatures::factory(featureName); if (!params.isEmpty()) { // Check for invalid params try { feature->setParams(params); } catch (QString s) { qDebug() << s; return -1; } catch (const char e[]) { std::cerr << e << std::endl; return -1; } } idx = Indexer::factory(indexer, feature, imagePath); if (verbosityLevel>0) std::cerr << "Building first index...\n"; double t1 = getTime(); idx->buildIndex(); double t2 = getTime(); if (verbosityLevel>0) std::cerr << "Indexing time: " << t2 << " ms\n"; } else { idx = Indexer::createIndex(imagePath, useIndex); feature = idx->getAlgorithm(); } // Query a single image if (!queryImage.isEmpty()) { QVector<Indexer::Result> results = idx->search(queryImage); for (int i(0); i<results.size(); i++) std::cout << results[i].fileName.toAscii().data() << " " << results[i].distance << std::endl; return 0; } PRTest prtest(imagePath, feature, idx); if (!prtest.loadCategories()) { std::cerr << "Error: failed to load categories.\nDo you have a file named categories.txt in work path?\n"; return -2; } // If not optimize, do a simple PR test if (optimizeVars.isEmpty()) { if (verbosityLevel>0) std::cerr << "Starting PRtest...\n"; double t1 = getTime(); prtest.execute(); double t2 = getTime(); std::cout << "MAP = "<<prtest.MAP << " AP16 = "<<prtest.AP16<<" AWP16 = "<<prtest.AWP16<<" ANMRR = "<<prtest.ANMRR<<std::endl; if (verbosityLevel>0) std::cerr << "PRtest time: " << t2 << " ms\n"; } // Do optimize run else { // TODO: use signals-slots to read values from PRtest class and output while using verbosity level etc. prtest.optimize(optimizeVars, trainingSet); } } catch(std::out_of_range e) { std::cout<<"Out-of-range: "<<e.what()<<std::endl; } catch(const char e[]) { qDebug() << "EXCEPTION: "<<e; } catch(QString e) { qDebug() << "EXCEPTION: "<<e; } return 0; }
void K3bIsoImageWritingDialog::slotStartClicked() { if( !d->isIsoImage ) { if( KMessageBox::warningContinueCancel( this, i18n("The image you selected is not a valid ISO9660 image. " "Are you sure you want to burn it anyway? " "(There may exist other valid image types that are not detected by K3b but " "will work fine.)"), i18n("Burn") ) == KMessageBox::Cancel ) return; } K3bIso9660 isoFs( imagePath() ); if( isoFs.open() ) { if( K3b::imageFilesize( KURL::fromPathOrURL( imagePath() ) ) < (KIO::filesize_t)(isoFs.primaryDescriptor().volumeSpaceSize*2048) ) { if( KMessageBox::questionYesNo( this, i18n("<p>This image has an invalid file size." "If it has been downloaded make sure the download is complete." "<p>Only continue if you know what you are doing."), i18n("Warning"), i18n("Continue"), i18n("Cancel") ) == KMessageBox::No ) return; } } m_md5Job->cancel(); // save the path KConfig* c = k3bcore->config(); c->setGroup( configGroup() ); if( c->readPathEntry( "last written image" ).isEmpty() ) c->writePathEntry( "last written image", imagePath() ); // create a progresswidget K3bBurnProgressDialog dlg( kapp->mainWidget(), "burnProgress", true ); // create the job K3bIso9660ImageWritingJob* job = new K3bIso9660ImageWritingJob( &dlg ); job->setBurnDevice( m_writerSelectionWidget->writerDevice() ); job->setSpeed( m_writerSelectionWidget->writerSpeed() ); job->setSimulate( m_checkDummy->isChecked() ); job->setWritingMode( m_writingModeWidget->writingMode() ); job->setVerifyData( m_checkVerify->isChecked() ); job->setCopies( m_checkDummy->isChecked() ? 1 : m_spinCopies->value() ); job->setImagePath( imagePath() ); // HACK (needed since if the medium is forced the stupid K3bIso9660ImageWritingJob defaults to cd writing) job->setWritingApp( K3b::GROWISOFS ); if( !exitLoopOnHide() ) hide(); dlg.startJob( job ); delete job; if( KConfigGroup( k3bcore->config(), "General Options" ).readBoolEntry( "keep action dialogs open", false ) && !exitLoopOnHide() ) show(); else close(); }
QList<photo*>* db::getUnlabeledPhotos(){ bool a=false; QSqlQuery query(database); query.prepare("SELECT DISTINCT Iid FROM HasFaces WHERE Pid = 1 "); a=query.exec(); // QList<int> photoId; QList<photo*>* pl = new QList<photo*>(); while(query.next()){ int imageId=query.value(0).toInt(); // photoId.append(imageId); QList<face*>* fl = new QList<face*>(); QSqlQuery query4(database); query4.prepare("SELECT DISTINCT path FROM Images WHERE Iid = :imageId "); query4.bindValue(":imageId", imageId); bool k4 = query4.exec(); query4.next(); QString imagePath(query4.value(0).toString()); QSqlQuery query2(database); query2.prepare("SELECT DISTINCT Fid,Pid FROM HasFaces WHERE Iid = :imageId "); query2.bindValue(":imageId", imageId); bool k=query2.exec(); while(query2.next()){ int faceId = query2.value(0).toInt(); int personId = query2.value(1).toInt(); QSqlQuery query3(database); query3.prepare("SELECT * FROM Faces WHERE Fid = :FId "); query3.bindValue(":FId", faceId); bool k3=query3.exec(); //facelist olcak while(query3.next()){ double x=query3.value(1).toDouble(); double y=query3.value(2).toDouble(); double width=query3.value(3).toDouble(); double height=query3.value(4).toDouble(); double tw=query3.value(5).toDouble(); double th=query3.value(6).toDouble(); QString featureListStr = query3.value(7).toString(); QSqlQuery query5(database); query5.prepare("SELECT name FROM Person WHERE Pid = :PId "); query5.bindValue(":PId", personId); bool k5=query5.exec(); query5.next(); QString lbl(query5.value(0).toString()); double* featureList = returnFacialFeatures(featureListStr); face* f = new face(faceId,QStringToString(imagePath),x,y,width,height,tw,th,featureList,QStringToString(lbl)); f->setPhotoID(imageId); fl->append(f); } } photo* p = new photo(imagePath,fl); p->setID(imageId); pl->append(p); } return pl; }
PlaylistBrowserNS::APGCategory::APGCategory( QWidget* ) : BrowserCategory ( "APG", 0 ) { m_qualityFactor = AmarokConfig::qualityFactorAPG(); setPrettyName( i18n( "Automated Playlist Generator" ) ); setShortDescription( i18n("Create playlists by specifying criteria") ); setIcon( KIcon( "playlist-generator" ) ); // set background if( AmarokConfig::showBrowserBackgroundImage() ) setBackgroundImage( imagePath() ); setLongDescription( i18n("Create playlists by specifying criteria") ); setContentsMargins( 0, 0, 0, 0 ); APG::PresetModel* presetmodel = APG::PresetModel::instance(); connect( presetmodel, SIGNAL(lock(bool)), this, SLOT(setDisabled(bool)) ); /* Create the toolbar -- Qt's Designer doesn't let us put a toolbar * anywhere except in a MainWindow, so we've got to create it by hand here. */ QToolBar* toolBar_Actions = new QToolBar( this ); toolBar_Actions->setMovable( false ); toolBar_Actions->setFloatable( false ); toolBar_Actions->setIconSize( QSize( 22, 22 ) ); toolBar_Actions->setSizePolicy( QSizePolicy::MinimumExpanding, QSizePolicy::Preferred ); QAction* a; a = toolBar_Actions->addAction( KIcon( "list-add-amarok" ), i18n("Add new preset") ); connect( a, SIGNAL(triggered(bool)), presetmodel, SLOT(addNew()) ); a = toolBar_Actions->addAction( KIcon( "document-properties-amarok" ), i18n("Edit selected preset") ); a->setEnabled( false ); connect( a, SIGNAL(triggered(bool)), presetmodel, SLOT(edit()) ); connect( this, SIGNAL(validIndexSelected(bool)), a, SLOT(setEnabled(bool)) ); a = toolBar_Actions->addAction( KIcon( "list-remove-amarok" ), i18n("Delete selected preset") ); a->setEnabled( false ); connect( a, SIGNAL(triggered(bool)), presetmodel, SLOT(removeActive()) ); connect( this, SIGNAL(validIndexSelected(bool)), a, SLOT(setEnabled(bool)) ); a = toolBar_Actions->addAction( KIcon( "document-import-amarok" ), i18n("Import a new preset") ); a->setEnabled( true ); connect( a, SIGNAL(triggered(bool)), presetmodel, SLOT(import()) ); a = toolBar_Actions->addAction( KIcon( "document-export-amarok" ), i18n("Export the selected preset") ); a->setEnabled( false ); connect( a, SIGNAL(triggered(bool)), presetmodel, SLOT(exportActive()) ); connect( this, SIGNAL(validIndexSelected(bool)), a, SLOT(setEnabled(bool)) ); toolBar_Actions->addSeparator(); a = toolBar_Actions->addAction( KIcon( "go-next-amarok" ), i18n("Run APG with selected preset") ); a->setEnabled( false ); connect( a, SIGNAL(triggered(bool)), this, SLOT(runGenerator()) ); connect( this, SIGNAL(validIndexSelected(bool)), a, SLOT(setEnabled(bool)) ); /* Create the preset list view */ QLabel* label_Title = new QLabel( i18n("APG Presets"), this ); label_Title->setAlignment( Qt::AlignCenter ); Amarok::PrettyTreeView* listView = new Amarok::PrettyTreeView( this ); listView->setHeaderHidden( true ); listView->setRootIsDecorated( false ); listView->setModel( presetmodel ); listView->setSelectionMode( QAbstractItemView::SingleSelection ); listView->setFrameShape( QFrame::NoFrame ); listView->setAutoFillBackground( false ); connect( listView->selectionModel(), SIGNAL(currentChanged(QModelIndex,QModelIndex)), this, SLOT(activeChanged(QModelIndex)) ); connect( listView, SIGNAL(doubleClicked(QModelIndex)), presetmodel, SLOT(editPreset(QModelIndex)) ); // Speed/Quality tradeoff slider QLabel* label_Tradeoff = new QLabel( i18n("Generator Optimization"), this ); label_Tradeoff->setAlignment( Qt::AlignCenter ); QFrame* qual_Frame = new QFrame( this ); QLabel* label_Speed = new QLabel( i18n("Speed"), qual_Frame ); QSlider* qual_Slider = new QSlider( Qt::Horizontal, qual_Frame ); qual_Slider->setRange( 0, APG::ConstraintSolver::QUALITY_RANGE ); qual_Slider->setValue( m_qualityFactor ); connect( qual_Slider, SIGNAL(sliderMoved(int)), this, SLOT (setQualityFactor(int)) ); QLabel* label_Quality = new QLabel( i18n("Accuracy"), qual_Frame ); QLayout* qf_Layout = new QHBoxLayout( qual_Frame ); qf_Layout->addWidget( label_Speed ); qf_Layout->addWidget( qual_Slider ); qf_Layout->addWidget( label_Quality ); qual_Frame->setLayout( qf_Layout ); QMetaObject::connectSlotsByName( this ); }
/** * Install this executable as a service */ void SCM::install(const string& serviceName, const string& serviceDesc, const string& args, DWORD startType, const string& account, const string& password, const string& depends) { // Handle dependent service name list; Windows wants a set of nul-separated // names ending with a double nul. string depends2 = depends; if (!depends2.empty()) { // CDL to null delimiter w/ trailing double null size_t p = 0; while ((p = depends2.find_first_of( ',', p)) != string::npos) depends2.replace(p, 1, 1, '\0'); depends2.push_back('\0'); depends2.push_back('\0'); } #if 0 // I'm nervous about adding a user/password check here. Is this a // potential attack vector, letting users check passwords without // control? -Steve Huston, Feb 24, 2011 // Validate account, password HANDLE hToken = NULL; bool logStatus = false; if (!account.empty() && !password.empty() && !(logStatus = ::LogonUserA(account.c_str(), "", password.c_str(), LOGON32_LOGON_NETWORK, LOGON32_PROVIDER_DEFAULT, &hToken ) != 0)) std::cout << "warning: supplied account & password failed with LogonUser." << std::endl; if (logStatus) ::CloseHandle(hToken); #endif // Get fully qualified .exe name char myPath[MAX_PATH]; DWORD myPathLength = ::GetModuleFileName(NULL, myPath, MAX_PATH); QPID_WINDOWS_CHECK_NOT(myPathLength, 0); string imagePath(myPath, myPathLength); if (!args.empty()) imagePath += " " + args; // Ensure there's a handle to the SCM database. openSvcManager(); // Create the service SC_HANDLE svcHandle; svcHandle = ::CreateService(scmHandle, // SCM database serviceName.c_str(), // name of service serviceDesc.c_str(), // name to display SERVICE_ALL_ACCESS, // desired access SERVICE_WIN32_OWN_PROCESS, // service type startType, // start type SERVICE_ERROR_NORMAL, // error cntrl type imagePath.c_str(), // path to service's binary w/ optional arguments NULL, // no load ordering group NULL, // no tag identifier depends2.empty() ? NULL : depends2.c_str(), account.empty() ? NULL : account.c_str(), // account name, or NULL for LocalSystem password.empty() ? NULL : password.c_str()); // password, or NULL for none QPID_WINDOWS_CHECK_NULL(svcHandle); ::CloseServiceHandle(svcHandle); QPID_LOG(info, "Service installed successfully"); }