Ejemplo n.º 1
0
void show_alert()
{

    if (dialog_create_alert(&alert_dialog) != BPS_SUCCESS) {
        fprintf(stderr, "Failed to create alert dialog.");
        return;
    }
    dialog_set_size(alert_dialog,DIALOG_SIZE_FULL);

	if (dialog_set_alert_message_text(alert_dialog,
			"Download our brand new application Compass: \n\nThis is the first magnetic compass written natively for the BlackBerry® PlayBook. It does not use GPS (no movement necessary to get a correct direction), instead the Magnetometer is used.Keep the PlayBook out of range of any metallic object, as this can interfere with the compass!\nTry it!\nFeatures:\n\n- Real magnetic compass (no GPS and/or movement needed)\n- Stunning graphics\n- Swipe down for easy to understand calibration") != BPS_SUCCESS) {
		fprintf(stderr, "Failed to set alert dialog message text.");
		dialog_destroy(alert_dialog);
		alert_dialog = 0;
		return;
	}


    /*
     * Use a button label of our own. Don't attach a context to the button.
     */
    if (dialog_add_button(alert_dialog, "Cancel", true, 0, true) != BPS_SUCCESS) {
        fprintf(stderr, "Failed to add button to alert dialog.");
        dialog_destroy(alert_dialog);
        alert_dialog = 0;
        return;
    }
    if (dialog_add_button(alert_dialog, "mappau.com", true, 0, true) != BPS_SUCCESS) {
        fprintf(stderr, "Failed to add button to alert dialog.");
        dialog_destroy(alert_dialog);
        alert_dialog = 0;
        return;
    }

    if (dialog_add_button(alert_dialog, "Download", true, 0, true) != BPS_SUCCESS) {
        fprintf(stderr, "Failed to add button to alert dialog.");
        dialog_destroy(alert_dialog);
        alert_dialog = 0;
        return;
    }

    if (dialog_show(alert_dialog) != BPS_SUCCESS) {
        fprintf(stderr, "Failed to show alert dialog.");
        dialog_destroy(alert_dialog);
        alert_dialog = 0;
        return;
    }
}
Ejemplo n.º 2
0
void
create_dialog()
{
    if (main_dialog) {
        return;
    }

    dialog_create_alert(&main_dialog);
    dialog_set_alert_message_text(main_dialog, "\n");
    dialog_set_group_id(main_dialog, get_window_group_id());
    dialog_set_cancel_required(main_dialog, true);

    dialog_add_button(main_dialog, "Query", true, "query", true);
    dialog_add_button(main_dialog, "Vol Up", true, "double", true);
    dialog_add_button(main_dialog, "Vol Down", true, "half", true);
    dialog_add_button(main_dialog, "Toggle Mute", true, "toggle", true);

    dialog_show(main_dialog);
}
void ScoreLoopThread::DisplayDialog(AppData_t *app, const char* title, const char* message) {
	/* Close a former dialog - if any */
	if (app->dialog) {
		dialog_destroy(app->dialog);
		app->dialog = 0;
	}

	/* Open a new alert dialog here - you would probably want to do something more elaborate */
	dialog_create_alert(&app->dialog);
	dialog_set_title_text(app->dialog, title);
	dialog_set_alert_message_text(app->dialog, message);
	dialog_add_button(app->dialog, DIALOG_OK_LABEL, true, NULL, true);
	dialog_show(app->dialog);
}
bool QQnxFileDialogHelper::show(Qt::WindowFlags flags, Qt::WindowModality modality, QWindow *parent)
{
    Q_UNUSED(flags);
    qFileDialogHelperDebug() << Q_FUNC_INFO;

    QQnxBpsEventFilter *eventFilter = m_integration->bpsEventFilter();
    // We *really* need the bps event filter ;)
    if (!eventFilter)
        return false;

    // Native dialogs can only handle application modal use cases so far
    if (modality != Qt::ApplicationModal)
        return false;

    // Tear down any existing dialog and start again as dialog mode may have changed
    if (m_dialog) {
        dialog_destroy(m_dialog);
        m_dialog = 0;
    }

    // Create dialog
    const QSharedPointer<QFileDialogOptions> &opts = options();
    if (opts->acceptMode() == QFileDialogOptions::AcceptOpen) {
        if (dialog_create_filebrowse(&m_dialog) != BPS_SUCCESS) {
            qWarning("dialog_create_filebrowse failed");
            return false;
        }

        // Select one or many files?
        bool multiSelect = (opts->fileMode() == QFileDialogOptions::ExistingFiles);
        dialog_set_filebrowse_multiselect(m_dialog, multiSelect);

        // Set the actual list of extensions
        if (!opts->nameFilters().isEmpty()) {
            qFileDialogHelperDebug() << "nameFilters =" << opts->nameFilters();
            setNameFilter(opts->nameFilters().first());
        } else {
            QString defaultNameFilter = QStringLiteral("*.*");
            setNameFilter(defaultNameFilter);
        }
    } else {
        if (dialog_create_filesave(&m_dialog) != BPS_SUCCESS) {
            qWarning("dialog_create_filesave failed");
            return false;
        }

        // Maybe pre-select a filename
        if (!opts->initiallySelectedFiles().isEmpty()) {
            QString fileName = opts->initiallySelectedFiles().first().toLocalFile();
            dialog_set_filesave_filename(m_dialog, QFile::encodeName(fileName).constData());
        }

        // Add OK and Cancel buttons. We add the buttons in the order "CANCEL" followed by "OK
        // such that they have indices matching the buttons on the file open dialog which
        // is automatically populated with buttons.
        if (dialog_add_button(m_dialog, tr("CANCEL").toLocal8Bit().constData(), true, 0, true) != BPS_SUCCESS) {
            qWarning("dialog_add_button failed");
            return false;
        }

        if (dialog_add_button(m_dialog, tr("OK").toLocal8Bit().constData(), true, 0, true) != BPS_SUCCESS) {
            qWarning("dialog_add_button failed");
            return false;
        }
    }

    // Cache the accept mode so we know which functions to use to get the results back
    m_acceptMode = opts->acceptMode();

    // Set the libscreen window group and common properties

    QQnxScreen *nativeScreen = parent ? static_cast<QQnxScreen *>(parent->screen()->handle()) :
                                        m_integration->primaryDisplay();
    Q_ASSERT(nativeScreen);
    dialog_set_group_id(m_dialog, nativeScreen->windowGroupName());
    dialog_set_title_text(m_dialog, opts->windowTitle().toLocal8Bit().constData());

    // Register ourselves for dialog domain events from bps
    eventFilter->registerForDialogEvents(this);

    // Show the dialog
    dialog_show(m_dialog);

    return true;
}
Ejemplo n.º 5
0
int dialog_select_game(char * isofilename, char *isoDir, int *videoPlugin, int *disableSound){
	char path[MAXPATHLEN];
	int i, rc;

	rc = snprintf(path, MAXPATHLEN, "%s", isoDir);
	if ((rc == -1) || (rc >= MAXPATHLEN)) {
		return -1;
	}

	dialog_instance_t dialog = 0;
	bps_event_t *event;
	dialog_create_popuplist(&dialog);

	DIR *dirp;
	struct dirent* direntp;
	int count=0, domain=0;
	const char ** list = 0;
	const char * label;

	dirp = opendir(isoDir);
	if( dirp != NULL ) {
		for(;;) {
			direntp = readdir( dirp );
			if( direntp == NULL ) break;
			printf( "%s\n", direntp->d_name );
			count++;
		}
		rewinddir(dirp);

		if(count==2){
			printf("No ISO's found!");
		}

		list = (const char**)malloc(count*sizeof(char*));
		count = 0;

		for(;;){
			direntp = readdir( dirp );
			if( direntp == NULL ) break;
			list[count] = (char*)direntp->d_name;
			count++;
		}

		int j = 0, m;
		int disabled[count];

		//If a cue exists, disable the bin for easier readability
		for(i=0; i<count;i++){

			if( strcmp(list[i], ".") == 0 || strcmp(list[i], "..") == 0 ){
				disabled[j++] = i;
				continue;
			}

			//Check if current index is a valid rom, .n64, .v64, .z64
			if( strncasecmp(list[i]+strlen(list[i])-4, ".n64", 4) != 0 &&
				strncasecmp(list[i]+strlen(list[i])-4, ".v64", 4) != 0 &&
				strncasecmp(list[i]+strlen(list[i])-4, ".z64", 4) != 0)
			{
				disabled[j++] = i;
				continue;
			}
		}

		int k = 0;
		char * compact[count-j+6];
		compact[k++] = "Video Plugin";
		compact[k++] = "Video Rice";
		compact[k++] = "GLES2N64";
		compact[k++] = "Audio Plugin";
		compact[k++] = "Disable Sound";
		compact[k++] = "Roms";

		//For each index
		for(i=0;i<count;i++){
			//search disabled for a match
			for(m=0;m<j;m++){
				if(i==disabled[m]){
					//If we do find that i is disabled don't copy
					break;
				}
			}
			if(m==j){
				compact[k++] = list[i];
			}
		}

		//Sort compact list
		qsort( compact+6, k-6, sizeof(char *), compare );
		int indice[] = {0,3,5};
		dialog_set_popuplist_items(dialog, compact, k);
		dialog_set_popuplist_separator_indices(dialog, (int*)&indice, 3);
		indice[0] = 1;
		dialog_set_popuplist_selected_indices(dialog, (int*)&indice, 1);

		char* cancel_button_context = "Canceled";
		char* okay_button_context = "Okay";
		dialog_add_button(dialog, DIALOG_CANCEL_LABEL, true, cancel_button_context, true);
		dialog_add_button(dialog, DIALOG_OK_LABEL, true, okay_button_context, true);
		dialog_set_popuplist_multiselect(dialog, true);
		dialog_show(dialog);

		while(1){
			bps_get_event(&event, -1);

			if (event) {
				domain = bps_event_get_domain(event);
				if (domain == dialog_get_domain()) {
					int *response = NULL;
					int num = 0;
					int videoOption = 0;
					label = dialog_event_get_selected_label(event);

					if(strcmp(label, DIALOG_OK_LABEL) == 0){
						dialog_event_get_popuplist_selected_indices(event, (int**)&response, &num);
						if(num > 0){
							for(i=0;i<num;i++){
								if(	(response[i] == 1) ||
									(response[i] == 2) )
								{
									videoOption +=1;
								}
							}
							if(videoOption != 1){
								printf("Must pick only 1 video Plugin...\n");fflush(stdout);
								return -1;
							}
						}

						int vid = 0, sound = 0, rom = 0;
						switch(num){
						case 0:
						case 1:
							printf("Must pick at least a video plugin and rom...\n");
							return -1;
							break;
						case 2:
							if(response[1] == 4 || response[0] == 4){
								printf("Must pick a Rom...\n");
								return -1;
							}
							*disableSound = 0;
							if(response[0] == 2 || response[1] == 2){
								*videoPlugin = VIDEO_PLUGIN_GLES2N64;
							} else {
								*videoPlugin = VIDEO_PLUGIN_RICE;
							}
							if(response[0] == 2 || response[0] == 1){
								strcpy(isofilename, compact[response[1]]);
							}else {
								strcpy(isofilename, compact[response[0]]);
							}
							break;
						case 3:
							for(i=0;i<num;i++){
								if(response[i] == 1){
									vid = 1;
									*videoPlugin = VIDEO_PLUGIN_RICE;
								} else if (response[i] == 2){
									vid = 1;
									*videoPlugin = VIDEO_PLUGIN_GLES2N64;
								} else if (response[i] == 4){
									sound = 1;
								} else if( response[i] > 5){
									rom = 1;
									strcpy(isofilename, compact[response[i]]);
								}
							}
							if(vid != 1 || sound != 1 || rom != 1){
								printf("Must pick a rom...");fflush(stdout);
								return -1;
							}
							*disableSound = 1;
							break;
						}
						bps_free(response);
					} else {
						printf("User has canceled ISO dialog.");
						free(list);
						closedir(dirp);
						return -1;
					}
					break;
				}
			}
		}

		free(list);
		closedir(dirp);
	}

	if (strlen(path) + strlen(isofilename) + 1 < MAXPATHLEN) {
		strcat(path, isofilename);
		strcpy(isofilename, path);
	} else
		isofilename[0] = 0;
	return 0;
}