Пример #1
0
/* Filter Class - Sets up regex filter */
Filter::Filter(int cFlags)
{
  m_cFlags = cFlags;

  loadFilters();

} // end Filter()
Пример #2
0
void
Filter::changeFilterFile(const QString& newfile)
{
    m_file = newfile;

    loadFilters();
}
Пример #3
0
   void run(int argc, char* argv[], char* env[])
      {
      U_TRACE(5, "Application::run(%d,%p,%p)", argc, argv, env)

      IR::run(argc, argv, env);

      if (IR::openCDB(true))
         {
         IR::setBadWords();

         loadFilters();

         // process all filenames in argument DIRECTORY

      // operation = 0; // add

         IR::loadFiles();

         // register to constant database (CDB)

         IR::closeCDB(false);

         UApplication::exit_value = 0;
         }
      }
Пример #4
0
/* Filter Class - Sets up regex filter */
Filter::Filter(const QString& file, int cFlags)
{
  m_file = file;
  m_cFlags = cFlags;

  loadFilters();

} // end Filter()
Пример #5
0
void FramePlaybackWindow::contextMenuFilters(QPoint pos)
{
    QMenu *menu = new QMenu(this);
    menu->setAttribute(Qt::WA_DeleteOnClose);
    menu->addAction(tr("Save filter definition to file"), this, SLOT(saveFilters()));
    menu->addAction(tr("Load filter definition from file"), this, SLOT(loadFilters()));
    menu->popup(ui->listID->mapToGlobal(pos));
}
/*
 * Wrapper that enables filters if the window is filtered
 */
static void
colorFilterDrawWindowTexture (CompWindow *w, CompTexture *texture,
			      const FragmentAttrib *attrib, unsigned int mask)
{
    int i, function;

    FILTER_SCREEN (w->screen);
    FILTER_WINDOW (w);

    /* Check if filters have to be loaded and load them if so
     * Maybe should this check be done only if a filter is going to be applied
     * for this texture? */
    if (!cfs->filtersLoaded)
	loadFilters (w->screen, texture);    

    /* Filter texture if :
     *   o GL_ARB_fragment_program available
     *   o Filters are loaded
     *   o Texture's window is filtered */
    /* Note : if required, filter window contents only and not decorations
     * (use that w->texture->name != texture->name for decorations) */
    if (cfs->filtersCount && cfw->isFiltered &&
	(colorfilterGetFilterDecorations (w->screen) ||
	 (texture->name == w->texture->name)))
    {
	FragmentAttrib fa = *attrib;
	if (cfs->currentFilter == 0) /* Cumulative filters mode */
	{
	    /* Enable each filter one by one */
	    for (i = 0; i < cfs->filtersCount; i++)
	    {
		function = cfs->filtersFunctions[i];
		if (function)
		    addFragmentFunction (&fa, function);
	    }
	}
	/* Single filter mode */
	else if (cfs->currentFilter <= cfs->filtersCount)
	{
	    /* Enable the currently selected filter if possible (i.e. if it
	     * was successfully loaded) */
	    function = cfs->filtersFunctions[cfs->currentFilter - 1];
	    if (function)
		addFragmentFunction (&fa, function);
	}
	UNWRAP (cfs, w->screen, drawWindowTexture);
	(*w->screen->drawWindowTexture) (w, texture, &fa, mask);
	WRAP(cfs, w->screen, drawWindowTexture, colorFilterDrawWindowTexture);
    }
    else /* Not filtering */
    {
	UNWRAP (cfs, w->screen, drawWindowTexture);
	(*w->screen->drawWindowTexture) (w, texture, attrib, mask);
	WRAP(cfs, w->screen, drawWindowTexture, colorFilterDrawWindowTexture);
    }
}
Пример #7
0
/* Filter Class - Sets up regex filter */
Filter::Filter(const QString& file, const char* type, int cFlags)
{
  m_file = file;
  m_cFlags = cFlags;
  m_type = type;
  m_filterItems.setAutoDelete(true);

  loadFilters();

} // end Filter()
Пример #8
0
/**
 * @brief Sets the active main widget
 *        Based on this the filters are set up
 * @param widget
 */
void FilterWidget::setActiveWidget(MainWidgets widget)
{
    storeFilters(m_activeWidget);
    m_activeFilters.clear();
    m_activeWidget = widget;
    ui->lineEdit->clearFilters();
    ui->lineEdit->clear();
    setupFilters();
    loadFilters(m_activeWidget);
    emit sigFilterChanged(m_activeFilters, ui->lineEdit->text());
}
Пример #9
0
dFilter::dFilter( dUpload *d ) : m_dupload( d )
{
	ui.setupUi( this );
	setAttribute( Qt::WA_DeleteOnClose );
	setAttribute( Qt::WA_QuitOnClose, false );

	QPixmap pixmap = QPixmap::fromImage( QApplication::clipboard()->image() );

	if ( pixmap.isNull() && QApplication::clipboard()->mimeData()->hasUrls() )
		pixmap.load( QApplication::clipboard()->mimeData()->urls()[0].toLocalFile() );

	if ( pixmap.isNull() )
	{
		pixmap = dDesktopManager::instance()->makeScreenshot();
	}

	if ( pixmap.isNull() )
	{
		close();
		return;
	}

	m_original = pixmap;
	m_current = m_original;
	ui.image->setPixmap(m_current.scaled(ui.image->width(), ui.image->height(), Qt::KeepAspectRatio));

	ui.filterList->setIconSize(QSize(200, 200));

	loadFilters();

	connect(ui.filterList, &QListWidget::itemSelectionChanged, this, &dFilter::filterActivated);
	
	QPoint window_pos = dDesktopManager::instance()->getScreenCoord( dDesktopManager::instance()->getPrimaryScreen() );
	move( window_pos );
	showMaximized();

	#if defined( Q_WS_X11 )
		XClientMessageEvent xev;
		xev.type = ClientMessage;
		xev.window = winId();
		xev.message_type = XInternAtom( QX11Info::display(), "_NET_ACTIVE_WINDOW", False );
		xev.format = 32;
		xev.data.l[0] = 2;
		xev.data.l[1] = QX11Info::appUserTime();

		XSendEvent( QX11Info::display(), QX11Info::appRootWindow(), False, ( SubstructureNotifyMask | SubstructureRedirectMask ), ( XEvent * ) &xev );
	#else
		activateWindow();
		raise();
	#endif
}
Пример #10
0
void AdvancedSettings::loadSettings()
{
    qDebug() << "Loading advanced settings";
    reset();

    QXmlStreamReader xml;
    QFile file(Settings::applicationDir() + "/advancedsettings.xml");
    if (!file.exists())
        file.setFileName(QStandardPaths::writableLocation(QStandardPaths::DataLocation) + "/advancedsettings.xml");

    if (!file.exists())
        return;

    if (!file.open(QIODevice::ReadOnly))
        return;
    xml.addData(file.readAll());
    file.close();

    if (!xml.readNextStartElement() || xml.name().toString() != "advancedsettings")
        return;

    while (xml.readNextStartElement()) {
        if (xml.name() == "log")
            loadLog(xml);
        else if (xml.name() == "gui")
            loadGui(xml);
        else if (xml.name() == "sorttokens")
            loadSortTokens(xml);
        else if (xml.name() == "genres")
            loadGenreMappings(xml);
        else if (xml.name() == "fileFilters")
            loadFilters(xml);
        else if (xml.name() == "audioCodecs")
            loadAudioCodecMappings(xml);
        else if (xml.name() == "videoCodecs")
            loadVideoCodecMappings(xml);
        else if (xml.name() == "certifications")
            loadCertificationMappings(xml);
        else if (xml.name() == "studios")
            loadStudioMappings(xml);
        else if (xml.name() == "countries")
            loadCountryMappings(xml);
        else if (xml.name() == "portableMode")
            m_portableMode = (xml.readElementText() == "true");
        else
            xml.skipCurrentElement();
    }

    qDebug() << "Advanced settings";
    qDebug() << "    debugLog              " << m_debugLog;
    qDebug() << "    logFile               " << m_logFile;
    qDebug() << "    forceCache            " << m_forceCache;
    qDebug() << "    sortTokens            " << m_sortTokens;
    qDebug() << "    genreMappings         " << m_genreMappings;
    qDebug() << "    movieFilters          " << m_movieFilters;
    qDebug() << "    concertFilters        " << m_concertFilters;
    qDebug() << "    tvShowFilters         " << m_tvShowFilters;
    qDebug() << "    subtitleFilters       " << m_subtitleFilters;
    qDebug() << "    audioCodecMappings    " << m_audioCodecMappings;
    qDebug() << "    videoCodecMappings    " << m_videoCodecMappings;
    qDebug() << "    certificationMappings " << m_certificationMappings;
    qDebug() << "    studioMappings        " << m_studioMappings;
    qDebug() << "    useFirstStudioOnly    " << m_useFirstStudioOnly;
    qDebug() << "    countryMappings       " << m_countryMappings;
}
Пример #11
0
bool
Filter::saveFilters(void)
{
  FILE *in;
  FILE *out;
  FilterItem* re;
  char msg[MAXLEN + 1];
  char *p;
  int count = 0;
  bool done  = false;
  bool start = false;
  
#ifdef DEBUG_FILTER
  printf("Filter::saveFilters(void)\n");
#endif
  // if no filename can't save
  if (m_file.isEmpty())
    return false;
  
  // Save filter file
  // Open source and destination files
  QString outfilename = NULL;
  QString infilename = m_file;
  
  outfilename = infilename + ".new";
  in = fopen ((const char*)infilename, "r");
  out = fopen ((const char*)outfilename, "w+");
  if (in == 0)
  {
    fprintf (stderr, "Couldn't open filter file. '%s' - %s\n", 
	     (const char*)infilename, strerror(errno));
  }
  if (out == 0)
  {
    fprintf (stderr, "Couldn't open filter file. '%s' - %s\n", 
	     (const char*)outfilename, strerror(errno));
    return false;
  }
  else
  {
    char *sType = NULL;
    
    if (in)
    {
      // Parse source file
      while (fgets (msg, MAXLEN, in) != NULL)
      {
	// terminate the line
	p = index (msg, '\n');
	if (p)
	  *p = 0;
	p = index (msg, '\r');
	if (p)
	  *p = 0;
	
	// terminate on CF or LF 
	// if this filter uses section names
	if (!m_type.isEmpty())
	{
	  // end of section - dump all items left in list that belong here
	  if (sType && !msg[0])
	  {
	    // if this is our section
	    if (m_type == sType)
	    {
	      // done copying filters that existed in file already
	      // dump whatever is left in list
	      FilterListIterator it(m_filterItems);
	      for (re = it.toFirst(); re != NULL; re = ++it)
	      {
#ifdef DEBUG_FILTER
		printf("OUT: '%s'\n", (const char*)re->name());
#endif
		fprintf(out, "%s\n", (const char*)re->name());
	      }
	      done = true;
	      start = false;
	    } // end if our section
	    free(sType);
	    sType = 0;
	  } // end if end of section
	}
	
	// treat lines beginning with # or ; as comments
	if ( (msg[0] == '#') || (msg[0] == ';'))
	{
#ifdef DEBUG_FILTER
	  printf("OUT: '%s'\n", msg);
#endif
	  fprintf(out, "%s", msg);
	  msg[0] = 0;
	}
	
	// preserve blank lines
	if (!msg[0])
	  fprintf(out, "\n");
	
	if (!m_type.isEmpty())
	{
	  // check for section name
	  if (msg[0] == '[')
	  {
	    p = index(msg, ']');
	    if (p)
	      *p = 0;
	    p = index(msg, '\r');
	    if (p)
	      *p = 0;
	    if (sType)
	      free(sType);
	    sType = strdup(msg + 1);
#ifdef DEBUG_FILTER
	    printf("OUT: '[%s]'\n", sType);
#endif
	    fprintf(out, "[%s]\n", sType);
	    start = true;
	    msg[0] = 0;
	  }
	} // end if filter uses section names  
	
	if (msg[0])
	{
	  // if this is our section
	  if (sType && (m_type == sType))
	  { 
	    // look for a match, if found put it in the file and 
	    // remove it from the list
	    FilterListIterator it(m_filterItems);
	    for (re = it.toFirst(); re != NULL; re = ++it)
	    {
	      // if we found a match, output it
	      if (re->name() ==  msg)
	      {
#ifdef DEBUG_FILTER
		printf("OUT: '%s'\n", msg);
#endif
		fprintf(out, "%s\n", msg);
		count++;
		remFilter(msg);
		break;
	      }
	     } // for all items in list
	  } // end if our section
	  
	  // someone elses section, just output it without alteration
	  else
	  {
#ifdef DEBUG_FILTER
	    printf("OUT: '%s'\n", msg);
#endif
	    fprintf(out, "%s\n", msg);
	  }
	} // end if msg
      }  // end while lines in source file
    } // end if source file
    
    // if we still have filters in our list, we never found our section
    // add it
    if (!done)
    {
      if (!m_type.isEmpty() && !start)
      {
#ifdef DEBUG_FILTER
	printf("done parsing file... creating section '%s'\n", 
	       (const char*)m_type);
#endif
	fprintf(out, "\n[%s]\n", (const char*)m_type);
      }
       
      // done copying filters that existed in file already
      // dump whatever is left in list
      FilterListIterator it(m_filterItems);
      for (re = it.toFirst(); re != NULL; re = ++it)
      {
#ifdef DEBUG_FILTER
	printf("OUT: '%s'\n", (const char*)re->name());
#endif
	fprintf(out, "%s\n", (const char*)re->name());
      }
    }
    if (fflush (out))
      fprintf (stderr, "Couldn't flush filter file. '%s' - %s\n", 
	       (const char*)outfilename, strerror(errno));
    if (fclose (out))
      fprintf (stderr, "Couldn't flush filter file. '%s' - %s\n", 
	       (const char*)outfilename, strerror(errno));
    if (in)
      fclose (in);
    
    //  printf ("Filter file saved '%s'\n", outfilename);
    
    // rename files
    int result;
    QString bakFileName = infilename + ".bak";
    // rename input file to filename.bak
    result = rename((const char*)infilename,
		    (const char*)bakFileName);
    if (result != 0)
      fprintf(stderr, "rename '%s' to '%s' failed: (%d): %s\n",
	      (const char*)infilename, (const char*)bakFileName,
	      errno, strerror(errno));

    // rename the output file to the input filename
    result = rename((const char*)outfilename,
		    (const char*)infilename);

    if (result != 0)
      fprintf(stderr, "rename '%s' to '%s' failed: (%d): %s\n",
	      (const char*)outfilename, (const char*)infilename,
	      errno, strerror(errno));

     if (sType)
       free(sType);
  }
  
  // re-read the filters from file
  loadFilters();
  
  return true;
} // end saveFilters