Exemplo n.º 1
0
    def handleChange():
        title = ui.titleInput.text()
        artist = ui.artistInput.text()
        lyrics = ui.lyricsInput.toPlainText()
        if title and lyrics:
            if ui.mode == 'add':
                id = add_song(title=title, artist=artist, lyrics=lyrics)
                refreshSongList(mainUi)

                # select new song on create
                match = list(
                    filter(lambda song: song['_id'] == id, mainUi.allSongs))
                if match:
                    newSong = match[0]
                    newIndex = mainUi.allSongs.index(newSong)
                    setCurrentSong(mainUi, newSong)
                    setCurrentSongListIndex(mainUi, newIndex)

            elif ui.mode == 'edit':
                currentSongId = ui.currentSong['_id']
                edit_song(currentSongId,
                          title=title,
                          artist=artist,
                          lyrics=lyrics)
                refreshSongList(mainUi)
            setCurrentTab(mainUi, 0)
            window.close()
        elif not title:
            mainWindow.showAlert('Please fill in song title!')
            ui.titleInput.setFocus()
        elif not lyrics:
            mainWindow.showAlert('Please fill in song lyrics!')
            ui.lyricsInput.setFocus()
Exemplo n.º 2
0
 def handleChange():
     title = ui.chordsNameInput.text()
     body = ui.lyricsInput.toPlainText()
     currentSongId = ui.currentSong['_id']
     if body:
         if ui.mode == 'add':
             newIndex = len(mainUi.allCurrentSongChords)
             add_chords(title=title, body=body, songId=currentSongId)
             refreshSongList(mainUi)
             refreshChordsData(mainUi, newIndex=newIndex)
         elif ui.mode == 'edit':
             currentChordsId = ui.currentChords['_id']
             currentChordsIndex = mainUi.currentChordsIndex
             edit_chords(currentChordsId, title=title, body=body)
             refreshChordsData(mainUi, newIndex=currentChordsIndex)
         setCurrentTab(mainUi, 1)
         window.close()
     else:
         mainWindow.showAlert('Chords cannot be empty!')
         ui.lyricsInput.setFocus()
Exemplo n.º 3
0
 def handleChange():
     refreshSongList(ui)
Exemplo n.º 4
0
 def handleChange():
     if not ui.userData:
         ui.favOnlyCheckbox.setChecked(False)
         ui.actionSign_In.trigger()
     else:
         refreshSongList(ui)
Exemplo n.º 5
0
 def handleChange(index):
     if index == 1:
         ui.sortBy = 'artist'
     else:
         ui.sortBy = 'title'
     refreshSongList(ui)
Exemplo n.º 6
0
 def handleChange():
     ui.favOnlyCheckbox.setChecked(False)
     setSongFav(ui, [])
     refreshSongList(ui)
Exemplo n.º 7
0
 def handleChange():
     setCurrentUser(ui, None)
     refreshSongList(ui)
     window.showAlert('Logged out.', 'Message')