コード例 #1
0
ファイル: galleryview.cpp プロジェクト: JGunning/OpenAOL-TV
/** \fn     GalleryView::MenuInformation()
 *  \brief  Shows the menu when the INFO key was pressed
 *  \return void
 */
void GalleryView::MenuInformation()
{
    QString label = tr("Image Information");
    MythMenu *menu = new MythMenu(label, this, "infomenu");

    // only show the slideshow options and details menu when
    // the item is a video or image file
    ImageMetadata *im = GetImageMetadataFromSelectedButton();
    if (im)
    {
        if (im->m_type == kImageFile ||
            im->m_type == kVideoFile)
        {
            menu->AddItem(tr("Normal SlideShow"), SLOT(ShowFiles()));
            menu->AddItem(tr("Random Slideshow"), SLOT(ShowRandomFiles()));
        }

        if (im->m_type == kImageFile)
            menu->AddItem(tr("Show Details"), SLOT(FileDetails()));
    }

    m_menuPopup = new MythDialogBox(menu, m_popupStack, "menuPopup");
    if (!m_menuPopup->Create())
    {
        delete m_menuPopup;
        m_menuPopup = NULL;
        return;
    }

    m_popupStack->AddScreen(m_menuPopup);
}
コード例 #2
0
int _tmain(int argc, TCHAR * argv[]) {
    // process the command line to extract that flags for SimpleOpt 
    int nFlags = SO_O_USEALL;
    CSimpleOpt args(argc, argv, g_rgFlags, SO_O_NOERR|SO_O_EXACT);
    while (args.Next()) {
        nFlags |= args.OptionId();
    }

    // now process the remainder of the command line with these flags
    args.Init(args.FileCount(), args.Files(), g_rgOptions, nFlags);
    while (args.Next()) {
        if (args.LastError() != SO_SUCCESS) {
            _tprintf(
                _T("%s: '%s' (use --help to get command line help)\n"),
                GetLastErrorText(args.LastError()), args.OptionText());
            continue;
        }

        switch (args.OptionId()) {
        case OPT_HELP:
            ShowUsage();
            return 0;
        case OPT_MULTI:  
            DoMultiArgs(args, -1);
            break;
        case OPT_MULTI0: 
            DoMultiArgs(args, 0);
            break;
        case OPT_MULTI1: 
            DoMultiArgs(args, 1);
            break;
        case OPT_MULTI2: 
            DoMultiArgs(args, 2);
            break;
        case OPT_STOP:
            args.Stop();
            break;
        default:
            if (args.OptionArg()) {
                _tprintf(_T("option: %2d, text: '%s', arg: '%s'\n"),
                    args.OptionId(), args.OptionText(), args.OptionArg());
            }
            else {
                _tprintf(_T("option: %2d, text: '%s'\n"),
                    args.OptionId(), args.OptionText());
            }
        }
    }

    /* process files from command line */
    ShowFiles(args.FileCount(), args.Files());

	return 0;
}
コード例 #3
0
/* 构造函数 */
FileListWidget::FileListWidget(QListWidget* parent):QListWidget(parent)
{
    setIconSize(QSize(W_ICONSIZE,H_ICONSIZE));
    setViewMode(QListView::IconMode);
    setMovement(QListView::Static);
    
    setSpacing(SPACING);

//    setContextMenuPolicy(Qt::DefaultContextMenu);
    connect(this,SIGNAL(ShowFilesSig(QStringList)),this,SLOT(ShowFiles(QStringList)));

}
コード例 #4
0
rc_t CC KMain(int argc, char* argv[]) {
    rc_t rc = 0;

    Params prm;
    KConfig* cfg = NULL;

    if (rc == 0)
    {   rc = ParamsConstruct(argc, argv, &prm); }

    if (rc == 0) {
        rc = KConfigMake(&cfg, NULL);
        DISP_RC(rc, "while calling KConfigMake");
    }

    if (rc == 0) {
        if (prm.modeSetNode)
        {   rc = SetNode(cfg, &prm); }
        if (prm.modeShowCfg)
        {   rc = ShowConfig(cfg, &prm); }
        if (prm.modeShowFiles) {
            rc_t rc3 = ShowFiles(cfg, &prm);
            if (rc3 != 0 && rc == 0)
            {   rc = rc3; }
        }
        if (prm.modeShowModules) {
            rc_t rc3 = ShowModules(cfg, &prm);
            if (rc3 != 0 && rc == 0)
            {   rc = rc3; }
        }
        if (prm.modeShowLoadPath) {
            const char* path = NULL;
            rc_t rc3 = KConfigGetLoadPath(cfg, &path);
            if (rc3 == 0) {
                if (path != NULL && path[0])
                {   OUTMSG(("%s\n", path)); }
            }
            else if (rc == 0)
            {   rc = rc3; }
        }
    }

    if (prm.modeShowEnv)
    {   ShowEnv(&prm); }

    RELEASE(KConfig, cfg);

    if (rc == 0 && prm.modeCreate)
    {   rc = CreateConfig(argv[0]); }

    ParamsDestruct(&prm);
    return rc;
}
コード例 #5
0
void
SVNListBase::HandleContextMenu
	(
	const JIndex index
	)
{
	if (index == kDiffEditedSelectedFilesCtxCmd)
		{
		JString rev;
		if (GetBaseRevision(&rev))
			{
			CompareEdited(rev);
			}
		}
	else if (index == kDiffCurrentSelectedFilesCtxCmd)
		{
		JString rev;
		GetBaseRevision(&rev);
		CompareCurrent(rev);
		}
	else if (index == kDiffPrevSelectedFilesCtxCmd)
		{
		JString rev;
		GetBaseRevision(&rev);
		ComparePrev(rev);
		}

	else if (index == kInfoLogSelectedFilesCtxCmd)
		{
		(GetDirector())->ShowInfoLog(this);
		}
	else if (index == kPropSelectedFilesCtxCmd)
		{
		(GetDirector())->ShowProperties(this);
		}

	else if (index == kIgnoreSelectionCtxCmd)
		{
		Ignore();
		}

	else if (index == kShowSelectedFilesCtxCmd)
		{
		ShowFiles();
		}
}
コード例 #6
0
ファイル: filesel.c プロジェクト: feraligatr/fceugx
/****************************************************************************
 * FileSelector
 *
 * Let user select a file from the listing
****************************************************************************/
int FileSelector (int method)
{
    u32 p = 0;
	u32 wp = 0;
	u32 ph = 0;
	u32 wh = 0;
    signed char gc_ay = 0;
	signed char gc_sx = 0;
	signed char wm_ay = 0;
	signed char wm_sx = 0;

    int haverom = 0;
    int redraw = 1;
    int selectit = 0;

	int scroll_delay = 0;
	bool move_selection = 0;
	#define SCROLL_INITIAL_DELAY	15
	#define SCROLL_LOOP_DELAY		2

    while (haverom == 0)
    {
        if (redraw)
            ShowFiles (filelist, maxfiles, offset, selection);
        redraw = 0;

		VIDEO_WaitVSync();	// slow things down a bit so we don't overread the pads

		gc_ay = PAD_StickY (0);
		gc_sx = PAD_SubStickX (0);

        p = PAD_ButtonsDown (0);
		ph = PAD_ButtonsHeld (0);
#ifdef HW_RVL
		wm_ay = WPAD_StickY (0, 0);
		wm_sx = WPAD_StickX (0, 1);

		wp = WPAD_ButtonsDown (0);
		wh = WPAD_ButtonsHeld (0);
#endif

		/*** Check for exit combo ***/
		if ( (gc_sx < -70) || (wm_sx < -70) || (wp & WPAD_BUTTON_HOME) || (wp & WPAD_CLASSIC_BUTTON_HOME) )
			return 0;

		/*** Check buttons, perform actions ***/
		if ( (p & PAD_BUTTON_A) || selectit || (wp & (WPAD_BUTTON_A | WPAD_CLASSIC_BUTTON_A)) )
		{
			if ( selectit )
				selectit = 0;
			if (filelist[selection].flags) // This is directory
			{
				/* update current directory and set new entry list if directory has changed */
				int status = UpdateDirName(method);
				if (status == 1) // ok, open directory
				{
					switch (method)
					{
						case METHOD_SD:
						case METHOD_USB:
						maxfiles = ParseFATdirectory(method);
						break;

						case METHOD_DVD:
						maxfiles = ParseDVDdirectory();
						break;

						case METHOD_SMB:
						maxfiles = ParseSMBdirectory();
						break;
					}

					if (!maxfiles)
					{
						WaitPrompt ((char*) "Error reading directory !");
						haverom = 1; // quit menu
					}
				}
				else if (status == -1)	// directory name too long
				{
					haverom = 1; // quit menu
				}
			}
			else	// this is a file
			{
				// store the filename (w/o ext) - used for state saving
				StripExt(romFilename, filelist[selection].filename);

				ShowAction ((char *)"Loading...");

				switch (method)
				{
					case METHOD_SD:
					case METHOD_USB:
					LoadFATFile (filelist[selection].filename,
					 filelist[selection].length);
					break;

					case METHOD_DVD:
					dvddir = filelist[selection].offset;
					dvddirlength = filelist[selection].length;
					LoadDVDFile (nesromptr);
					break;

					case METHOD_SMB:
					LoadSMBFile (filelist[selection].filename,
					filelist[selection].length);
					break;
				}

				if (GCMemROM() >= 0)
				{
					//hasloaded = 1; // indicator for memmap.cpp
					//Memory.LoadROM ("BLANK.SMC");
					//Memory.LoadSRAM ("BLANK");
					//haverom = 1;
					return 1;
				}
				else
				{
					WaitPrompt((char*) "Error loading ROM!");
				}
			}
			redraw = 1;
		}	// End of A
        if ( (p & PAD_BUTTON_B) || (wp & (WPAD_BUTTON_B | WPAD_CLASSIC_BUTTON_B)) )
        {
            while ( (PAD_ButtonsDown(0) & PAD_BUTTON_B)
#ifdef HW_RVL
					|| (WPAD_ButtonsDown(0) & (WPAD_BUTTON_B | WPAD_CLASSIC_BUTTON_B))
#endif
					)
                VIDEO_WaitVSync();
			if ( strcmp(filelist[0].filename,"..") == 0 )
			{
				selection = 0;
				selectit = 1;
			}
			else if ( strcmp(filelist[1].filename,"..") == 0 )
			{
                selection = selectit = 1;
			} else {
                return 0;
			}
        }	// End of B
        if ( ((p | ph) & PAD_BUTTON_DOWN) || ((wp | wh) & (WPAD_BUTTON_DOWN | WPAD_CLASSIC_BUTTON_DOWN)) || (gc_ay < -PADCAL) || (wm_ay < -PADCAL) )
        {
			if ( (p & PAD_BUTTON_DOWN) || (wp & (WPAD_BUTTON_DOWN | WPAD_CLASSIC_BUTTON_DOWN)) ) { /*** Button just pressed ***/
				scroll_delay = SCROLL_INITIAL_DELAY;	// reset scroll delay.
				move_selection = 1;	//continue (move selection)
			}
			else if (scroll_delay == 0) { 		/*** Button is held ***/
				scroll_delay = SCROLL_LOOP_DELAY;
				move_selection = 1;	//continue (move selection)
			} else {
				scroll_delay--;	// wait
			}

			if (move_selection)
			{
	            selection++;
	            if (selection == maxfiles)
	                selection = offset = 0;
	            if ((selection - offset) >= PAGESIZE)
	                offset += PAGESIZE;
	            redraw = 1;
				move_selection = 0;
			}
        }	// End of down
        if ( ((p | ph) & PAD_BUTTON_UP) || ((wp | wh) & (WPAD_BUTTON_UP | WPAD_CLASSIC_BUTTON_UP)) || (gc_ay > PADCAL) || (wm_ay > PADCAL) )
        {
			if ( (p & PAD_BUTTON_UP) || (wp & (WPAD_BUTTON_UP | WPAD_CLASSIC_BUTTON_UP)) ) { /*** Button just pressed***/
				scroll_delay = SCROLL_INITIAL_DELAY;	// reset scroll delay.
				move_selection = 1;	//continue (move selection)
			}
			else if (scroll_delay == 0) { 		/*** Button is held ***/
				scroll_delay = SCROLL_LOOP_DELAY;
				move_selection = 1;	//continue (move selection)
			} else {
				scroll_delay--;	// wait
			}

			if (move_selection)
			{
	            selection--;
	            if (selection < 0) {
	                selection = maxfiles - 1;
	                offset = selection - PAGESIZE + 1;
	            }
	            if (selection < offset)
	                offset -= PAGESIZE;
	            if (offset < 0)
	                offset = 0;
	            redraw = 1;
				move_selection = 0;
			}
        }	// End of Up
        if ( (p & PAD_BUTTON_LEFT) || (wp & (WPAD_BUTTON_LEFT | WPAD_CLASSIC_BUTTON_LEFT)) )
        {
            /*** Go back a page ***/
            selection -= PAGESIZE;
            if (selection < 0)
            {
                selection = maxfiles - 1;
                offset = selection - PAGESIZE + 1;
            }
            if (selection < offset)
                offset -= PAGESIZE;
            if (offset < 0)
                offset = 0;
            redraw = 1;
        }
        if ( (p & PAD_BUTTON_RIGHT) || (wp & (WPAD_BUTTON_RIGHT | WPAD_CLASSIC_BUTTON_RIGHT)) )
        {
            /*** Go forward a page ***/
            selection += PAGESIZE;
            if (selection > maxfiles - 1)
                selection = offset = 0;
            if ((selection - offset) >= PAGESIZE)
                offset += PAGESIZE;
            redraw = 1;
        }
    }
    return 0;
}
コード例 #7
0
ファイル: filesel.cpp プロジェクト: feraligatr/snes9xgx
int
FileSelector ()
{
    int p, wp;
    signed char a;
    int haverom = 0;
    int redraw = 1;
    int selectit = 0;
    
    while (haverom == 0)    
    {
        if (redraw)
            ShowFiles (offset, selection);
        redraw = 0;
        p = PAD_ButtonsDown (0);
		wp = WPAD_ButtonsDown (0);
        a = PAD_StickY (0);
        if ( (p & PAD_BUTTON_A) || (wp & WPAD_BUTTON_A) || selectit )
        {
            if ( selectit )
                selectit = 0;
            if (filelist[selection].flags)                        /*** This is directory ***/
            {
                if (loadtype == LOAD_SDC)
                {
                    /* memorize last entries list, actual root directory and selection for next access */
                    haveSDdir = 1;
                    
                    /* update current directory and set new entry list if directory has changed */
                    int status = updateSDdirname();
                    if (status == 1)	// ok, open directory
                    {
                        maxfiles = parseSDdirectory();
                        if (!maxfiles)
                        {
                            WaitPrompt ((char*) "Error reading directory !");
                            haverom   = 1; // quit SD menu
                            haveSDdir = 0; // reset everything at next access
                        }
                    }
                    else if (status == -1)	// directory name too long
                    {
                        haverom   = 1; // quit SD menu
                        haveSDdir = 0; // reset everything at next access
                    }
                }
                else
                {
                    if ( (strcmp (filelist[selection].filename, "..") == 0)
                        &&  ((unsigned int)rootdir == filelist[selection].offset) )
                        return 0;
                    else
                    {
                        rootdir = filelist[selection].offset;
                        rootdirlength = filelist[selection].length;
                        offset = selection = 0;
                        maxfiles = parsedirectory ();
                    }
                }
            }
            else	// this is a file
            {
                rootdir = filelist[selection].offset;
                rootdirlength = filelist[selection].length;
                
                switch (loadtype)
                {
                    case LOAD_DVD:
                        /*** Now load the DVD file to it's offset ***/
                        ARAM_ROMSIZE = LoadDVDFile (Memory.ROM);
                        break;
                    
                    case LOAD_SMB:
                        /*** Load from SMB ***/
                        ARAM_ROMSIZE =
                        LoadSMBFile (filelist[selection].filename,
                             filelist[selection].length);
                        break;
                    
                    case LOAD_SDC:
                        /*** Load from SD Card ***/
                        /* memorize last entries list, actual root directory and selection for next access */
                        haveSDdir = 1;
                        ARAM_ROMSIZE = LoadSDFile (filelist[selection].filename,
                                         filelist[selection].length);
                        break;
                }
                
                if (ARAM_ROMSIZE > 0)
                {
                    hasloaded = 1;
                    Memory.LoadROM ("BLANK.SMC");
                
                    Memory.LoadSRAM ("BLANK");
                    haverom = 1;
                    
                    return 1;
                }
                else
                {
                    WaitPrompt((char*) "Error loading ROM!");
                }
            }
            redraw = 1;
        }	// End of A
        if ( (p & PAD_BUTTON_B) || (wp & WPAD_BUTTON_B) )
        {
            while ( (PAD_ButtonsDown(0) & PAD_BUTTON_B) || (PAD_ButtonsDown(0) & WPAD_BUTTON_B) )
                VIDEO_WaitVSync();
            //if ((strcmp(filelist[1].filename,"..") == 0) && (strlen (filelist[0].filename) != 0))
			if ( strcmp(filelist[0].filename,"..") == 0 ) 
			{
				selection = 0;
				selectit = 1;
			}
			else if ( strcmp(filelist[1].filename,"..") == 0 ) 
			{
                selection = selectit = 1;
			} else {
                return 0;
			}
        }	// End of B
        if ( (p & PAD_BUTTON_DOWN) || (wp & WPAD_BUTTON_DOWN) || (a < -PADCAL) )
        {
            selection++;
            if (selection == maxfiles)
                selection = offset = 0;
            if ((selection - offset) >= PAGESIZE)
                offset += PAGESIZE;
            redraw = 1;
        }	// End of down
        if ( (p & PAD_BUTTON_UP) || (wp & WPAD_BUTTON_UP) || (a > PADCAL) )
        {
            selection--;
            if (selection < 0)
            {
                selection = maxfiles - 1;
                offset = selection - PAGESIZE + 1;
            }
            if (selection < offset)
                offset -= PAGESIZE;
            if (offset < 0)
                offset = 0;
            redraw = 1;
        }	// End of Up
        if ( (PAD_ButtonsHeld(0) & PAD_BUTTON_LEFT) || (WPAD_ButtonsHeld(0) & WPAD_BUTTON_LEFT) )
        {
            /*** Go back a page ***/
            selection -= PAGESIZE;
            if (selection < 0)
            {
                selection = maxfiles - 1;
                offset = selection - PAGESIZE + 1;
            }
            if (selection < offset)
                offset -= PAGESIZE;
            if (offset < 0)
                offset = 0;
            redraw = 1;
        }
        if ( (PAD_ButtonsHeld(0) & PAD_BUTTON_RIGHT) || (WPAD_ButtonsHeld(0) & WPAD_BUTTON_RIGHT) )
        {
            /*** Go forward a page ***/
            selection += PAGESIZE;
            if (selection > maxfiles - 1)
                selection = offset = 0;
            if ((selection - offset) >= PAGESIZE)
                offset += PAGESIZE;
            redraw = 1;
        }
    }
    return 0;
}
コード例 #8
0
ファイル: filesel.cpp プロジェクト: feraligatr/snes9xgx
int
FileSelector ()
{
    u32 p, wp, ph, wh;
    signed char a, c;
    int haverom = 0;
    int redraw = 1;
    int selectit = 0;
	float mag = 0;
	float mag2 = 0;
	u16 ang = 0;
	u16 ang2 = 0;
	int scroll_delay = 0;
	bool move_selection = 0;
	#define SCROLL_INITIAL_DELAY	15
	#define SCROLL_LOOP_DELAY		4
    
    while (haverom == 0)    
    {
        if (redraw)
            ShowFiles (offset, selection);
        redraw = 0;

		VIDEO_WaitVSync();	// slow things down a bit so we don't overread the pads
		
        p = PAD_ButtonsDown (0);
		ph = PAD_ButtonsHeld (0);
#ifdef HW_RVL
		wp = WPAD_ButtonsDown (0);
		wh = WPAD_ButtonsHeld (0);
		wpad_get_analogues(0, &mag, &ang, &mag2, &ang2);		// get joystick info from wii expansions
#else
		wp = 0;
		wh = 0;
#endif
		a = PAD_StickY (0);
		c = PAD_SubStickX (0);
        
		/*** Check for exit combo ***/
		if ( (c < -70) || (wp & WPAD_BUTTON_HOME) || (wp & WPAD_CLASSIC_BUTTON_HOME) ) return 0;
		
		/*** Check buttons, perform actions ***/
        if ( (p & PAD_BUTTON_A) || selectit || (wp & (WPAD_BUTTON_A | WPAD_CLASSIC_BUTTON_A)) )
        {
            if ( selectit )
                selectit = 0;
            if (filelist[selection].flags)                        /*** This is directory ***/
            {
                if (loadtype == LOAD_SDC || loadtype == LOAD_USB)
                {
                    /* memorize last entries list, actual root directory and selection for next access */
					if (loadtype == LOAD_SDC)
						haveSDdir = 1;
					else
						haveUSBdir = 1;
                    
                    /* update current directory and set new entry list if directory has changed */
                    int status = updateFATdirname();
                    if (status == 1)	// ok, open directory
                    {
                        maxfiles = parseFATdirectory();
                        if (!maxfiles)
                        {
                            WaitPrompt ((char*) "Error reading directory !");
                            haverom   = 1; // quit SD menu
                            if (loadtype == LOAD_SDC)  // reset everything at next access
								haveSDdir = 0;
							else
								haveUSBdir = 0;
                        }
                    }
                    else if (status == -1)	// directory name too long
                    {
                        haverom   = 1; // quit SD menu
                        if (loadtype == LOAD_SDC)  // reset everything at next access
							haveSDdir = 0;
						else
							haveUSBdir = 0;
                    }
                }
                else
                {
                    if ( (strcmp (filelist[selection].filename, "..") == 0)
                        &&  ((unsigned int)rootdir == filelist[selection].offset) )
                        return 0;
                    else
                    {
                        rootdir = filelist[selection].offset;
                        rootdirlength = filelist[selection].length;
                        offset = selection = 0;
                        maxfiles = parsedirectory ();
                    }
                }
            }
            else	// this is a file
            {
                rootdir = filelist[selection].offset;
                rootdirlength = filelist[selection].length;
				
				/*** store the filename (used for sram/freeze naming) ***/
				strip_ext(filelist[selection].filename, Memory.ROMFilename);	// store stripped filename in Memory.ROMFilename
                
                switch (loadtype)
                {
                    case LOAD_DVD:
                        /*** Now load the DVD file to it's offset ***/
                        ARAM_ROMSIZE = LoadDVDFile (Memory.ROM);
                        break;
                    
                    case LOAD_SMB:
                        /*** Load from SMB ***/
                        ARAM_ROMSIZE = LoadSMBFile (filelist[selection].filename,
                             filelist[selection].length);
                        break;
                    
					case LOAD_USB:
                    case LOAD_SDC:
                        /*** Load from SD Card ***/
                        /* memorize last entries list, actual root directory and selection for next access */
                        haveSDdir = 1;
                        ARAM_ROMSIZE = LoadSDFile (filelist[selection].filename,
                                         filelist[selection].length);
                        break;
                }
                
                if (ARAM_ROMSIZE > 0)
                {
                    hasloaded = 1;
                    Memory.LoadROM ("BLANK.SMC");
                
                    Memory.LoadSRAM ("BLANK");
                    haverom = 1;
                    
                    return 1;
                }
                else
                {
                    WaitPrompt((char*) "Error loading ROM!");
                }
            }
            redraw = 1;
        }	// End of A
        if ( (p & PAD_BUTTON_B) || (wp & (WPAD_BUTTON_B | WPAD_CLASSIC_BUTTON_B)) )
        {
            while ( (PAD_ButtonsDown(0) & PAD_BUTTON_B) 
#ifdef HW_RVL
					|| (WPAD_ButtonsDown(0) & (WPAD_BUTTON_B | WPAD_CLASSIC_BUTTON_B)) 
#endif
					)
                VIDEO_WaitVSync();
            //if ((strcmp(filelist[1].filename,"..") == 0) && (strlen (filelist[0].filename) != 0))
			if ( strcmp(filelist[0].filename,"..") == 0 ) 
			{
				selection = 0;
				selectit = 1;
			}
			else if ( strcmp(filelist[1].filename,"..") == 0 ) 
			{
                selection = selectit = 1;
			} else {
                return 0;
			}
        }	// End of B
        if ( ((p | ph) & PAD_BUTTON_DOWN) || ((wp | wh) & (WPAD_BUTTON_DOWN | WPAD_CLASSIC_BUTTON_DOWN)) || (a < -PADCAL) || (mag>JOY_THRESHOLD && (ang>130 && ang<230)) )
        {
			if ( (p & PAD_BUTTON_DOWN) || (wp & (WPAD_BUTTON_DOWN | WPAD_CLASSIC_BUTTON_DOWN)) ) { /*** Button just pressed ***/
				scroll_delay = SCROLL_INITIAL_DELAY;	// reset scroll delay.
				move_selection = 1;	//continue (move selection)
			} 
			else if (scroll_delay == 0) { 		/*** Button is held ***/
				scroll_delay = SCROLL_LOOP_DELAY;
				move_selection = 1;	//continue (move selection)
			} else {
				scroll_delay--;	// wait
			}
				
			if (move_selection)
			{
	            selection++;
	            if (selection == maxfiles)
	                selection = offset = 0;
	            if ((selection - offset) >= PAGESIZE)
	                offset += PAGESIZE;
	            redraw = 1;
				move_selection = 0;
			}
        }	// End of down
        if ( ((p | ph) & PAD_BUTTON_UP) || ((wp | wh) & (WPAD_BUTTON_UP | WPAD_CLASSIC_BUTTON_UP)) || (a > PADCAL) || (mag>JOY_THRESHOLD && (ang>300 || ang<50)) )
        {	
			if ( (p & PAD_BUTTON_UP) || (wp & (WPAD_BUTTON_UP | WPAD_CLASSIC_BUTTON_UP)) ) { /*** Button just pressed***/
				scroll_delay = SCROLL_INITIAL_DELAY;	// reset scroll delay.
				move_selection = 1;	//continue (move selection)
			} 
			else if (scroll_delay == 0) { 		/*** Button is held ***/
				scroll_delay = SCROLL_LOOP_DELAY;
				move_selection = 1;	//continue (move selection)
			} else {
				scroll_delay--;	// wait
			}
			
			if (move_selection)
			{
	            selection--;
	            if (selection < 0) {
	                selection = maxfiles - 1;
	                offset = selection - PAGESIZE + 1;
	            }
	            if (selection < offset)
	                offset -= PAGESIZE;
	            if (offset < 0)
	                offset = 0;
	            redraw = 1;
				move_selection = 0;
			}
        }	// End of Up
        if ( (p & PAD_BUTTON_LEFT) || (wp & (WPAD_BUTTON_LEFT | WPAD_CLASSIC_BUTTON_LEFT)) )
        {
            /*** Go back a page ***/
            selection -= PAGESIZE;
            if (selection < 0)
            {
                selection = maxfiles - 1;
                offset = selection - PAGESIZE + 1;
            }
            if (selection < offset)
                offset -= PAGESIZE;
            if (offset < 0)
                offset = 0;
            redraw = 1;
        }
        if ( (p & PAD_BUTTON_RIGHT) || (wp & (WPAD_BUTTON_RIGHT | WPAD_CLASSIC_BUTTON_RIGHT)) )
        {
            /*** Go forward a page ***/
            selection += PAGESIZE;
            if (selection > maxfiles - 1)
                selection = offset = 0;
            if ((selection - offset) >= PAGESIZE)
                offset += PAGESIZE;
            redraw = 1;
        }
    }
    return 0;
}
コード例 #9
0
ファイル: filesel.cpp プロジェクト: feraligatr/vbagx
/****************************************************************************
 * FileSelector
 *
 * Let user select a file from the listing
 ***************************************************************************/
int FileSelector (int method)
{
    u32 p = 0;
	u32 wp = 0;
	u32 ph = 0;
	u32 wh = 0;
    signed char gc_ay = 0;
	signed char gc_sx = 0;
	signed char wm_ay = 0;
	signed char wm_sx = 0;

    int haverom = 0;
    int redraw = 1;
    int selectit = 0;

	int scroll_delay = 0;
	bool move_selection = 0;
	#define SCROLL_INITIAL_DELAY	15
	#define SCROLL_LOOP_DELAY		2

    while (haverom == 0)
    {
        if (redraw)
            ShowFiles (filelist, maxfiles, offset, selection);
        redraw = 0;

		VIDEO_WaitVSync();	// slow things down a bit so we don't overread the pads

		gc_ay = PAD_StickY (0);
		gc_sx = PAD_SubStickX (0);

        p = PAD_ButtonsDown (0);
		ph = PAD_ButtonsHeld (0);
#ifdef HW_RVL
		wm_ay = WPAD_Stick (0, 0, 0);
		wm_sx = WPAD_Stick (0, 1, 1);

		wp = WPAD_ButtonsDown (0);
		wh = WPAD_ButtonsHeld (0);
#endif

		/*** Check for exit combo ***/
		if ( (gc_sx < -70) || (wm_sx < -70) || (wp & WPAD_BUTTON_HOME) || (wp & WPAD_CLASSIC_BUTTON_HOME) )
			return 0;

		/*** Check buttons, perform actions ***/
		if ( (p & PAD_BUTTON_A) || selectit || (wp & (WPAD_BUTTON_A | WPAD_CLASSIC_BUTTON_A)) )
		{
			if ( selectit )
				selectit = 0;
			if (filelist[selection].flags) // This is directory
			{
				/* update current directory and set new entry list if directory has changed */
				int status;

				if(inSz && selection == 0) // inside a 7z, requesting to leave
				{
					if(method == METHOD_DVD)
					{
						// go to directory the 7z was in
						dvddir = filelist[0].offset;
						dvddirlength = filelist[0].length;
					}
					inSz = false;
					status = 1;
					SzClose();
				}
				else
				{
					status = UpdateDirName(method);
				}

				if (status == 1) // ok, open directory
				{
					switch (method)
					{
						case METHOD_SD:
						case METHOD_USB:
						maxfiles = ParseFATdirectory(method);
						break;

						case METHOD_DVD:
						maxfiles = ParseDVDdirectory();
						break;

						case METHOD_SMB:
						maxfiles = ParseSMBdirectory();
						break;
					}

					if (!maxfiles)
					{
						WaitPrompt ((char*) "Error reading directory !");
						haverom = 1; // quit menu
					}
				}
				else if (status == -1)	// directory name too long
				{
					haverom = 1; // quit menu
				}
			}
			else	// this is a file
			{
				// 7z file - let's open it up to select a file inside
				if(IsSz())
				{
					// we'll store the 7z filepath for extraction later
					if(!MakeROMPath(szpath, method))
					{
						WaitPrompt((char*) "Maximum filepath length reached!");
						return -1;
					}
					int szfiles = SzParse(szpath, method);
					if(szfiles)
					{
						maxfiles = szfiles;
						inSz = true;
					}
					else
						WaitPrompt((char*) "Error opening archive!");
				}
				else
				{
					// store the filename (w/o ext) - used for sram/freeze naming
					StripExt(ROMFilename, filelist[selection].filename);

					ShowAction ((char *)"Loading...");

					ROMLoaded = LoadVBAROM(method);
					inSz = false;

					if (ROMLoaded)
					{
						return 1;
					}
					else
					{
						WaitPrompt((char*) "Error loading ROM!");
					}
				}
			}
			redraw = 1;
		}	// End of A
        if ( (p & PAD_BUTTON_B) || (wp & (WPAD_BUTTON_B | WPAD_CLASSIC_BUTTON_B)) )
        {
            while ( (PAD_ButtonsDown(0) & PAD_BUTTON_B)
#ifdef HW_RVL
					|| (WPAD_ButtonsDown(0) & (WPAD_BUTTON_B | WPAD_CLASSIC_BUTTON_B))
#endif
					)
                VIDEO_WaitVSync();
			if ( strcmp(filelist[0].filename,"..") == 0 )
			{
				selection = 0;
				selectit = 1;
			}
			else if ( strcmp(filelist[1].filename,"..") == 0 )
			{
                selection = selectit = 1;
			} else {
                return 0;
			}
        }	// End of B
        if ( ((p | ph) & PAD_BUTTON_DOWN) || ((wp | wh) & (WPAD_BUTTON_DOWN | WPAD_CLASSIC_BUTTON_DOWN)) || (gc_ay < -PADCAL) || (wm_ay < -PADCAL) )
        {
			if ( (p & PAD_BUTTON_DOWN) || (wp & (WPAD_BUTTON_DOWN | WPAD_CLASSIC_BUTTON_DOWN)) ) { /*** Button just pressed ***/
				scroll_delay = SCROLL_INITIAL_DELAY;	// reset scroll delay.
				move_selection = 1;	//continue (move selection)
			}
			else if (scroll_delay == 0) { 		/*** Button is held ***/
				scroll_delay = SCROLL_LOOP_DELAY;
				move_selection = 1;	//continue (move selection)
			} else {
				scroll_delay--;	// wait
			}

			if (move_selection)
			{
	            selection++;
	            if (selection == maxfiles)
	                selection = offset = 0;
	            if ((selection - offset) >= PAGESIZE)
	                offset += PAGESIZE;
	            redraw = 1;
				move_selection = 0;
			}
        }	// End of down
        if ( ((p | ph) & PAD_BUTTON_UP) || ((wp | wh) & (WPAD_BUTTON_UP | WPAD_CLASSIC_BUTTON_UP)) || (gc_ay > PADCAL) || (wm_ay > PADCAL) )
        {
			if ( (p & PAD_BUTTON_UP) || (wp & (WPAD_BUTTON_UP | WPAD_CLASSIC_BUTTON_UP)) ) { /*** Button just pressed***/
				scroll_delay = SCROLL_INITIAL_DELAY;	// reset scroll delay.
				move_selection = 1;	//continue (move selection)
			}
			else if (scroll_delay == 0) { 		/*** Button is held ***/
				scroll_delay = SCROLL_LOOP_DELAY;
				move_selection = 1;	//continue (move selection)
			} else {
				scroll_delay--;	// wait
			}

			if (move_selection)
			{
	            selection--;
	            if (selection < 0) {
	                selection = maxfiles - 1;
	                offset = selection - PAGESIZE + 1;
	            }
	            if (selection < offset)
	                offset -= PAGESIZE;
	            if (offset < 0)
	                offset = 0;
	            redraw = 1;
				move_selection = 0;
			}
        }	// End of Up
        if ( (p & PAD_BUTTON_LEFT) || (wp & (WPAD_BUTTON_LEFT | WPAD_CLASSIC_BUTTON_LEFT)) )
        {
            /*** Go back a page ***/
            selection -= PAGESIZE;
            if (selection < 0)
            {
                selection = maxfiles - 1;
                offset = selection - PAGESIZE + 1;
            }
            if (selection < offset)
                offset -= PAGESIZE;
            if (offset < 0)
                offset = 0;
            redraw = 1;
        }
        if ( (p & PAD_BUTTON_RIGHT) || (wp & (WPAD_BUTTON_RIGHT | WPAD_CLASSIC_BUTTON_RIGHT)) )
        {
            /*** Go forward a page ***/
            selection += PAGESIZE;
            if (selection > maxfiles - 1)
                selection = offset = 0;
            if ((selection - offset) >= PAGESIZE)
                offset += PAGESIZE;
            redraw = 1;
        }
    }
    return 0;
}
コード例 #10
0
ファイル: galleryview.cpp プロジェクト: JGunning/OpenAOL-TV
/** \fn     GalleryView::keyPressEvent(QKeyEvent *)
 *  \brief  Translates the keypresses and keys bound to the
 *          plugin to specific actions within the plugin
 *  \param  event The pressed key
 *  \return True if key was used, otherwise false
 */
bool GalleryView::keyPressEvent(QKeyEvent *event)
{
    if (GetFocusWidget()->keyPressEvent(event))
        return true;

    bool handled = false;
    QStringList actions;
    handled = GetMythMainWindow()->TranslateKeyPress("Images", event, actions);

    for (int i = 0; i < actions.size() && !handled; i++)
    {
        QString action = actions[i];
        handled = true;

        if (action == "MENU")
            MenuMain();
        else if (action == "INFO")
            MenuInformation();
        else if (action == "ROTRIGHT")
            FileRotateCW();
        else if (action == "ROTLEFT")
            FileRotateCCW();
        else if (action == "FLIPHORIZONTAL")
            FileFlipHorizontal();
        else if (action == "FLIPVERTICAL")
            FileFlipVertical();
        else if (action == "ZOOMIN")
            FileZoomIn();
        else if (action == "ZOOMOUT")
            FileZoomOut();
        else if (action == "SLIDESHOW")
            ShowFiles();
        else if (action == "RANDOMSHOW")
            ShowRandomFiles();
        else if (action == "MARK")
        {
            ImageMetadata *im = GetImageMetadataFromSelectedButton();
            if (im)
            {
                if (im->m_selected)
                    FileSelectOne();
                else
                    FileDeselectOne();
            }
        }
        else if (action == "ESCAPE")
        {
            // If the jumppoint is not active and the first node is of
            // the type kUpFolder then allow going up one directory
            if (!GetMythMainWindow()->IsExitingToMain())
            {
                ImageMetadata *data = m_galleryViewHelper->GetImageMetadataFromNode(0);
                if (data && data->m_type == kUpDirectory)
                    handled = DirSelectUp();
                else
                    handled = false;
            }
            else
                handled = false;
        }
        else
            handled = false;
    }

    if (!handled && MythScreenType::keyPressEvent(event))
        handled = true;

    return handled;
}