Exemplo n.º 1
0
Main::Main(QWidget *)  //parent
{
        ui.setupUi(this);
	ui.paraula->setParent(this);
	ui.llistat->setParent(this);
	ui.definicio->setFather(this);

	resize(QSize(270,300));

	installEventFilter(this);

	m_numberFound=0;

	m_cat_eng = new QToolButton;
	m_cat_eng->setText(tr("cat->eng"));
	m_cat_eng->setCheckable(1);
	ui.toolBar->addWidget(m_cat_eng);

	m_eng_cat = new QToolButton;
	m_eng_cat->setText(tr("eng->cat"));
	m_eng_cat->setCheckable(1);
	ui.toolBar->addWidget(m_eng_cat);

	ui.toolBar->addSeparator();

	ui.definicio->setProcess(&m_browser);

	QAction *copy = ui.toolBar->addAction(QIcon(":icons/editcopy.png"),tr("Copy"));
	QAction *paste = ui.toolBar->addAction(QIcon(":icons/editpaste.png"),tr("Paste"));
	connect(copy,SIGNAL(triggered()),this,SLOT(copy_definition()));
	connect(paste,SIGNAL(triggered()),this,SLOT(paste_word()));
	
        connect(ui.Buscar,SIGNAL(clicked()),this,SLOT(buscarClicked()));
        connect(ui.editConfigureAction,SIGNAL(triggered()),this,SLOT(obrir_configuracio_slot()));
        connect(ui.editSelectAction,SIGNAL(triggered()),this,SLOT(select_word()));

	connect(m_cat_eng,SIGNAL(clicked()),this,SLOT(cat_engf()));
	connect(m_eng_cat,SIGNAL(clicked()),this,SLOT(eng_catf()));
	
	connect(ui.fileChangeDictionaryAction,SIGNAL(triggered()),this,SLOT(switchDictionary()));
	connect(ui.paraula,SIGNAL(returnPressed()),this,SLOT(buscarEnter()));
	connect(ui.helpAboutAction,SIGNAL(triggered()),this,SLOT(obrir_about()));

	connect(ui.llistat,SIGNAL(itemDoubleClicked(QListWidgetItem *)),this,SLOT(searchListWord(QListWidgetItem*)));
	connect(ui.paraula,SIGNAL(textChanged(const QString &)),this,SLOT(paraulaChanged(const QString &)));

	connect(&m_festival,SIGNAL(error(QProcess::ProcessError)),this,SLOT(FestivalError(QProcess::ProcessError)));
	connect(&m_festival,SIGNAL(finished(int,QProcess::ExitStatus)),this,SLOT(FestivalFinished(int,QProcess::ExitStatus)));
	connect(&m_browser,SIGNAL(error(QProcess::ProcessError)),this,SLOT(BrowserError(QProcess::ProcessError)));
	
	carrega_config(1);

	ui.clipboard->hide();
}
Exemplo n.º 2
0
    void Browser::browse_callback(AvahiServiceBrowser *b,
				  AvahiIfIndex interface,
				  AvahiProtocol protocol,
				  AvahiBrowserEvent event,
				  const char *name,
				  const char *type,
				  const char *domain,
				  AvahiLookupResultFlags,
				  void* data)
    {
	assert(b);
	AvahiClient *client = avahi_service_browser_get_client(b);
	assert(data);
	Browser *browser = static_cast<Browser *>(data);

	switch (event) {
	case AVAHI_BROWSER_FAILURE:
	    cerr << "[Browser] " << avahi_strerror(avahi_client_errno(avahi_service_browser_get_client(b))) << endl;
	    throw BrowserError(avahi_client_errno(client));
	    //a->Stop();
	    return;

	case AVAHI_BROWSER_NEW:
	    //cerr << "[Browser] New service '" << name << "' of type '" << type << "' in domain '" << domain << "'" << endl;

	    if (!(avahi_service_resolver_new(client, interface, protocol, name, type, domain, AVAHI_PROTO_UNSPEC,
					     (AvahiLookupFlags)0, resolve_callback, browser)))
		cerr << "Failed to resolve service '" << name << "': " << avahi_strerror(avahi_client_errno(client)) << endl;
	    break;

	case AVAHI_BROWSER_REMOVE:
	    //cerr << "[Browser] Removed service " << name << " of type " << type << " in domain " << domain << endl;
	    // XXX Remove cached service, broadcast
	    browser->remove_service(name);
	    break;

	case AVAHI_BROWSER_ALL_FOR_NOW:
	    //cerr << "[Browser] All for now." << endl;
	    break;

	case AVAHI_BROWSER_CACHE_EXHAUSTED:
	    //cerr << "[Browser] Cache exhausted." << endl;
	    break;
	}
    }