Exemple #1
0
bool ClearThumbnailsAction::action()
{
   // http://freedesktop.org/Standards/Home
   // http://triq.net/~jens/thumbnail-spec/index.html

   QDir thumbnailDir( QDir::homePath() + QLatin1String( "/.thumbnails/normal" ));
   thumbnailDir.setFilter( QDir::Files );
   const QStringList entries = thumbnailDir.entryList();
   for( QStringList::const_iterator it = entries.begin() ; it != entries.end() ; ++it) {
      if(!thumbnailDir.remove(*it)) {
         errMsg = i18n("A thumbnail could not be removed.");
         return false;
      }
   }

   thumbnailDir.setPath(QDir::homePath() + QLatin1String( "/.thumbnails/large" ));
   const QStringList entries2 = thumbnailDir.entryList();
   for( QStringList::const_iterator it = entries2.begin() ; it != entries2.end() ; ++it) {
      if(!thumbnailDir.remove(*it)) {
         errMsg = i18n("A thumbnail could not be removed.");
         return false;
      }
   }

   thumbnailDir.setPath(QDir::homePath() + QLatin1String( "/.thumbnails/fail" ));
   const QStringList entries3 = thumbnailDir.entryList();
   for( QStringList::const_iterator it = entries3.begin() ; it != entries3.end() ; ++it) {
      if(!thumbnailDir.remove(*it)) {
         errMsg = i18n("A thumbnail could not be removed.");
         return false;
      }
   }

   return true;
}
Exemple #2
0
void STestCase::initTestCase()
{
    Q_INIT_RESOURCE(silica);
    Q_INIT_RESOURCE(silicatest);
    GlobalConfig::create();
    QVERIFY2(LocalDatabase::instance()->migrate(),
             "Fail to migrate database");
    QDir thumbnailDir(GlobalConfig::instance()->thumbnailPath());
    thumbnailDir.removeRecursively();
}
void cPreferencesDialog::on_pushButton_clear_thumbnail_cache_clicked()
{
	QDir thumbnailDir(systemData.thumbnailDir);
	thumbnailDir.setFilter( QDir::AllEntries | QDir::NoDotAndDotDot );
	int thumbnailDirCount = thumbnailDir.count();

	//confirmation dialog before clearing
	QMessageBox::StandardButton reply;
	reply = QMessageBox::question(
		NULL,
		QObject::tr("Are you sure to clear the thumbnail cache?"),
		QObject::tr("There are currently %1 thumbnails cached. These will be deleted and rerendered when necessary.\n Clear now?").arg(thumbnailDirCount),
		QMessageBox::Yes|QMessageBox::No);

	if (reply == QMessageBox::Yes)
	{
		// match exact 32 char hash images, example filename: c0ad626d8c25ab6a25c8d19a53960c8a.png
		DeleteAllFilesFromDirectory(systemData.thumbnailDir, "????????????????????????????????.*");
	}
	else
	{
		return;
	}
}