Exemplo n.º 1
0
ContextWidget::ContextWidget(QWidget *parent)
    : QWidget(parent)
    , job(0)
    , alwaysCollapsed(false)
    , backdropType(PlayQueueView::BI_Cover)
    , darkBackground(false)
    , useFanArt(0!=constFanArtApiKey.latin1())
    , albumCoverBackdrop(false)
    , oldIsAlbumCoverBackdrop(false)
    , fadeValue(1.0)
    , isWide(false)
    , stack(0)
    , onlineContext(0)
    , splitter(0)
    , viewSelector(0)
{
    QHBoxLayout *layout=new QHBoxLayout(this);
    mainStack=new QStackedWidget(this);
    standardContext=new QWidget(mainStack);
    mainStack->addWidget(standardContext);
    layout->setMargin(0);
    layout->addWidget(mainStack);
    animator.setPropertyName("fade");
    animator.setTargetObject(this);

    appLinkColor=QApplication::palette().color(QPalette::Link);
    artist = new ArtistView(standardContext);
    album = new AlbumView(standardContext);
    song = new SongView(standardContext);
    minWidth=album->picSize().width()*2.5;

    artist->addEventFilter(this);
    album->addEventFilter(this);
    song->addEventFilter(this);

    connect(artist, SIGNAL(findArtist(QString)), this, SIGNAL(findArtist(QString)));
    connect(artist, SIGNAL(findAlbum(QString,QString)), this, SIGNAL(findAlbum(QString,QString)));
    connect(album, SIGNAL(playSong(QString)), this, SIGNAL(playSong(QString)));
    readConfig();
    setZoom();
    setWide(true);

    #ifndef SCALE_CONTEXT_BGND
    QDesktopWidget *dw=QApplication::desktop();
    if (dw) {
        QSize geo=dw->availableGeometry(this).size()-QSize(32, 64);
        minBackdropSize=geo;
        minBackdropSize.setWidth(((int)(minBackdropSize.width()/32))*32);
        minBackdropSize.setHeight(((int)(minBackdropSize.height()/32))*32);
        maxBackdropSize=QSize(geo.width()*1.25, geo.height()*1.25);
    } else {
        minBackdropSize=QSize(Utils::scaleForDpi(1024*3), Utils::scaleForDpi(768*3);
        maxBackdropSize=QSize(minBackdropSize.width()*2, minBackdropSize.height()*2);
    }
    #endif
}
Exemplo n.º 2
0
//TODO: rewrite/rework to not use recursion. It's way to resource heavy.
FRESULT scan_files (char* path)
{
    FRESULT res;
    FILINFO fno;
    DIR dir;
    int i;
    char *fn;
	
    res = f_opendir(&dir, path);
    if (res == FR_OK) {
        i = strlen(path);
        for (;;) {
        	vTaskDelay(0);
            res = f_readdir(&dir, &fno);
            if (res != FR_OK || fno.fname[0] == 0) break;
			if ((fno.fattrib & AM_HID) || (fno.fname[0] == '.')) continue;
			fn = fno.fname;
            if (fno.fattrib & AM_DIR) {
				path[i]='/';  //sprintf(&path[i], "/%s", fn);  
				strcpy(&path[i+1],fn);  //get the whole file-path
                res = scan_files(path);
                if (res != FR_OK) break;
                path[i] = 0;
            } else {
				char* got_ext = strrchr(fn,'.');
				if ((got_ext != NULL) && (0 == strncmp(got_ext, ".MP3", 4)) ){
					FIL file; //to open file and read mp3 id3 data
					char tag[20]; //to read mp3 id3 data to.
					path[i]='/';  //sprintf(&path[i], "/%s", fn);  
					strcpy(&path[i+1],fn);  //get the whole file-path
					if (FR_OK == f_open(&file, path, (FA_READ | FA_OPEN_EXISTING)))
						
					/* ---- find/create artist node ---- */
					read_ID3_info(ARTIST_ID3,tag,sizeof(tag),&file);  //read artist-name
					//rprintf("(by %s) ",tag);
					Artist * this_artist = findArtist(tag); //search for this artist in the database.
					if (this_artist == NULL) {  //didn't find artist (hasn't been found before)
						this_artist = (Artist *)malloc(sizeof(Artist));
						if (this_artist == NULL) { rprintf("malloc null 1"); return res;} //watch out for a linked list that's too big, malloc returns null
						strcpy(this_artist->name, tag);
						this_artist->tracks = NULL;
						this_artist->next = artist_list;
						artist_list = this_artist;
					}
					/* ---- create track node ---- */
					Track * this_track = (Track *)malloc(sizeof(Track));
					if (this_track == NULL) { rprintf("malloc null 2"); return res;} //watch out for a linked list that's too big, malloc returns null
					read_ID3_info(TITLE_ID3,tag,sizeof(tag),&file);  //read track-name
					strcpy(this_track->name, tag);
					strncpy(this_track->filename, path, sizeof(this_track->filename) ); //get the file path/name..
					read_ID3_info(TRACK_NUM_ID3,tag,sizeof(tag),&file);  //read track-name
					if (tag[1]=='/') tag[1]=0; else if (tag[2]=='/') tag[2]=0; //track num is in form "1/14", so we put a null at the / (assuming it's in char 1 or 2)
					this_track->id = atoi(tag);
					if (read_ID3_info(YEAR_ID3,tag,sizeof(tag),&file)) { //read the track's year
						this_track->year = atoi(tag);
					} else { this_track->year = 0; }
					this_track->next = this_artist->tracks;
					this_artist->tracks = this_track;
					//rprintf("-> %s\n",tag);
					
					path[i] = 0;  //restore path to what it was before.
				}
            }
        }
    } else rprintf("error opening [%i]\n",res);
	
    return res;
}