Esempio n. 1
0
void Qaul::QaulCheckEvents(void)
{
    int myEvent = Qaullib_TimedCheckAppEvent();

    if(myEvent > 0)
    {
        if(myEvent == QAUL_EVENT_CHOOSEFILE)
        {
            // open file selection
            QString fileName = QFileDialog::getOpenFileName(
                        this,
                        tr("Add File"),
                        "/home",
                        tr("Files (*.*)"));
            // file was selected
            if(fileName != NULL)
            {
                qDebug() << "file selected " << fileName;
                Qaullib_FilePicked(2, fileName.toLocal8Bit().data());
            }
            else
            {
                qDebug() << "file selection canceld ";
            }

        }
        else if(myEvent == QAUL_EVENT_OPENFILE)
        {
            // open file in default application
            QString filepath = "file://";
            filepath += Qaullib_GetAppEventOpenPath();
            qDebug() << filepath;
            QDesktopServices::openUrl(QUrl(filepath));
        }
        else if(myEvent == QAUL_EVENT_OPENURL)
        {
            // open URL in browser
            QString urlpath = Qaullib_GetAppEventOpenURL();
            qDebug() << urlpath;
            QDesktopServices::openUrl(QUrl(urlpath));
        }
        else if(myEvent == QAUL_EVENT_QUIT)
        {
            // quit application
            QApplication::quit();
        }
        else if(myEvent == QAUL_EVENT_NOTIFY && myEvent == QAUL_EVENT_RING)
        {
            // play beep
            // does not work under linux
            QApplication::beep();
        }
    }
}
Esempio n. 2
0
gboolean qaul_timerEvent(gpointer data)
{
    int myEvent;
    gchar myFilePath[MAX_URL_LEN +8];
	GError *myError;
	GtkWidget *myDialog;
	char *myFileChoose;

    myEvent = Qaullib_TimedCheckAppEvent();

    if(myEvent > 0)
    {
		printf("qaul_timerEvent: event [%i] found \n", myEvent);

    	if(myEvent == QAUL_EVENT_CHOOSEFILE)
        {
			printf("QAUL_EVENT_CHOOSEFILE \n");
    		myDialog = gtk_file_chooser_dialog_new("Choose File",
								  GTK_WINDOW(qaulMainWindow),
								  GTK_FILE_CHOOSER_ACTION_OPEN,
								  GTK_STOCK_CANCEL,
								  GTK_RESPONSE_CANCEL,
								  GTK_STOCK_OPEN,
								  GTK_RESPONSE_ACCEPT,
								  NULL);
			if (gtk_dialog_run(GTK_DIALOG(myDialog)) == GTK_RESPONSE_ACCEPT)
			{
				myFileChoose = gtk_file_chooser_get_filename(GTK_FILE_CHOOSER(myDialog));
				Qaullib_FilePicked(2, myFileChoose);
				g_free(myFileChoose);
			}
			gtk_widget_destroy(myDialog);
        }
        else if(myEvent == QAUL_EVENT_OPENFILE)
        {
			printf("QAUL_EVENT_OPENFILE \n");

        	// open file in default program
            myError = NULL;
            g_snprintf(myFilePath, MAX_URL_LEN +8, "file://%s", Qaullib_GetAppEventOpenPath());
            if(gtk_show_uri(gdk_screen_get_default(), myFilePath, gtk_get_current_event_time(), &myError))
				printf("Open file %s\n", myFilePath);
			else
				printf("Error opening file %s\n", myFilePath);

        	if(myError != NULL)
        	{
        		g_printerr("Error QAUL_EVENT_OPENFILE: %s\n", myError->message);
        		g_error_free(myError);
        	}
        }
        else if(myEvent == QAUL_EVENT_OPENURL)
        {
			printf("QAUL_EVENT_OPENURL \n");

        	// open URL in default browser
        	myError = NULL;
            if(gtk_show_uri(
					NULL,
					Qaullib_GetAppEventOpenURL(),
					GDK_CURRENT_TIME,
					&myError
				))
				printf("Open URL %s\n", Qaullib_GetAppEventOpenURL());
			else
				printf("Error opening URL %s\n", Qaullib_GetAppEventOpenURL());

        	if(myError != NULL)
        	{
        		g_printerr("Error QAUL_EVENT_OPENURL: %s\n", myError->message);
        		g_error_free(myError);
        	}
        }
        else if(myEvent == QAUL_EVENT_QUIT)
        {
			printf("QAUL_EVENT_QUIT \n");

            // quit application
			qaul_onquit();
			gtk_main_quit();
        }
        else if(myEvent == QAUL_EVENT_NOTIFY || myEvent == QAUL_EVENT_RING)
        {
			printf("QAUL_EVENT_NOTIFY || QAUL_EVENT_RING \n");

            // play beep
            gdk_beep();
        }
        else if(myEvent == QAUL_EVENT_GETINTERFACES)
        {
			printf("QAUL_EVENT_GETINTERFACES \n");

            // search for Interfaces
            if(qaul_network_devices_json(network_dbus_connection, network_json_txt))
            {
            	// set Interfaces
            	Qaullib_SetInterfaceJson(network_json_txt);
            }
        }
    }

	return TRUE;
}