added settings and fixed a bug where the autocompletion could lead to a crash if a string without slashes were to be inserted

This commit is contained in:
janis
2022-08-22 19:37:08 +02:00
parent 0f8b20be69
commit 359562ec0c
5 changed files with 62 additions and 29 deletions

View File

@@ -18,9 +18,11 @@ class AutoComplete:
self.path = "" self.path = ""
self.check = "" self.check = ""
self.check_in = "" self.check_in = ""
self.okay = True
def autocomplete(self, text): def autocomplete(self, text):
self.text = str(text) self.text = str(text)
self.okay = True
if self.text[len(self.text) - 2:] == "\t\n": if self.text[len(self.text) - 2:] == "\t\n":
self.text = self.text[:len(self.text) - 2] self.text = self.text[:len(self.text) - 2]
elif self.text[len(self.text) - 1:] == "\t": elif self.text[len(self.text) - 1:] == "\t":
@@ -42,26 +44,32 @@ class AutoComplete:
self.check = "" self.check = ""
self.check_in = self.text self.check_in = self.text
while self.check_in[len(self.check_in) - 1:] != "/": while self.check_in[len(self.check_in) - 1:] != "/":
self.check += str(self.check_in[len(self.check_in) - 1:]) if len(self.check_in) < 1:
self.check_in = self.check_in[:len(self.check_in) - 1] self.okay = False
self.check = self.check[::-1]
for self.item in self.__command_list:
if self.check == self.item[:len(self.check)]:
self.__possible_completion.append(f'{self.path}{self.item}/')
else: else:
pass self.check += str(self.check_in[len(self.check_in) - 1:])
if len(self.__possible_completion) < 1: self.check_in = self.check_in[:len(self.check_in) - 1]
self.__return_value = ["No such file or directory", self.text[:len(self.text)]] if self.okay:
elif len(self.__possible_completion) == 1: self.check = self.check[::-1]
self.__return_value = ["", str(self.__possible_completion.pop(0))] for self.item in self.__command_list:
else: if self.check == self.item[:len(self.check)]:
for self.items in self.__possible_completion: self.__possible_completion.append(f'{self.path}{self.item}/')
self.__return_value_assembly += f"{str(self.items)} "
if self.__command_count > 2:
self.__return_value_assembly += "\n"
self.__command_count = 0
else: else:
self.__command_count += 1 pass
self.__return_value.append(self.__return_value_assembly) if len(self.__possible_completion) < 1:
self.__return_value.append(self.text[:len(self.text)]) self.__return_value = ["No such file or directory", self.text[:len(self.text)]]
return self.__return_value elif len(self.__possible_completion) == 1:
self.__return_value = ["", str(self.__possible_completion.pop(0))]
else:
for self.items in self.__possible_completion:
self.__return_value_assembly += f"{str(self.items)} "
if self.__command_count > 2:
self.__return_value_assembly += "\n"
self.__command_count = 0
else:
self.__command_count += 1
self.__return_value.append(self.__return_value_assembly)
self.__return_value.append(self.text[:len(self.text)])
return self.__return_value
else:
pass

View File

@@ -46,7 +46,7 @@ RootScreen:
<invalidpathPU>: <invalidpathPU>:
title: "NOTICE!" title: "NOTICE!"
font_size: 50 font_size: 50
size_hint: 0.5, 0.4 size_hint: 0.7, 0.6
auto_dismiss: False auto_dismiss: False
GridLayout: GridLayout:
cols:1 cols:1
@@ -56,6 +56,9 @@ RootScreen:
Label: Label:
text: "Please enter a valid path and try again" text: "Please enter a valid path and try again"
font_size: 15 font_size: 15
Label:
text: "Please be aware, that you cannot specify any other file type other than \"Directory\""
font_size: 12
Button: Button:
text:"Ok" text:"Ok"
on_release: on_release:
@@ -71,7 +74,8 @@ RootScreen:
GridLayout: GridLayout:
cols: 1 cols: 1
Label: Label:
text: "MusicPlayer V1.0" id: titleapp
text: root.initapp()
color: app.theme_cls.primary_color color: app.theme_cls.primary_color
font_size: 50 font_size: 50
bold: True bold: True

View File

@@ -0,0 +1,9 @@
[Performance]
# Specifies the refresh rate in seconds in between refreshes
# (lower = more up to date but higher resource usage)
showcaseRefreshRate = 0.5
[Info]
version = V1.1
subVersion =

View File

@@ -1,3 +1,3 @@
9 0
Ancient.mp3,Arm_Candy.mp3,Beach_Disco.mp3,Beach_Walk.mp3,Bird_Therapist.mp3,Carol_of_the_Bells.mp3,Castlevania.mp3,Cats_Searching_for_the_Truth.mp3,Classique.mp3,Cloud_Chaser.mp3,Dragonfly.mp3,Easy_Seas.mp3,Entire.mp3,Eyes_of_Glory.mp3,Finding_Me.mp3,Forgiveness.mp3,Fun_in_the_Sun.mp3,Half_Measures.mp3,Happy_Sixth.mp3,Hear_the_Noise.mp3,Hi_Q.mp3,Hot_Coffee.mp3,How_it_Began.mp3,I_ll_Follow_You.mp3,If_I_Had_a_Chicken.mp3,Jal_Edge_of_Water.mp3,Juno_In_The_Space_Maze.mp3,Ladybug.mp3,Late_Night_Drive.mp3,Meteor.mp3,Modern_Situations.mp3,Move_Out.mp3,Official_National_Anthem.mp3,Plenty_Step.mp3,Point_Green_Getdown.mp3,Retrograde.mp3,Right_Here_Beside_You.mp3,Safety_Net.mp3,Same_Time.mp3,Static.mp3,Stranger_Danger.mp3,Subharmonic_Bliss.mp3,Sun_Machine_One.mp3,The_Computer_Has_Feelings.mp3,Thinking_Of_Us.mp3,This_is_Not_IDM.mp3,This_is_Not_Jazz.mp3,This_is_Not_a_Ballad.mp3,Time_s_Up.mp3,Triumph.mp3,Unstoppable.mp3,Western_Spaghetti.mp3,Zameen_Movement_of_Earth.mp3,bensound-clearday.mp3,bensound-endlessmotion.mp3,bensound-energy.mp3,bensound-happyrock.mp3 Ancient.mp3,Arm_Candy.mp3,Beach_Disco.mp3,Beach_Walk.mp3,Bird_Therapist.mp3,Carol_of_the_Bells.mp3,Castlevania.mp3,Cats_Searching_for_the_Truth.mp3,Classique.mp3,Cloud_Chaser.mp3,Dragonfly.mp3,Easy_Seas.mp3,Entire.mp3,Eyes_of_Glory.mp3,Finding_Me.mp3,Forgiveness.mp3,Fun_in_the_Sun.mp3,Half_Measures.mp3,Happy_Sixth.mp3,Hear_the_Noise.mp3,Hi_Q.mp3,Hot_Coffee.mp3,How_it_Began.mp3,I_ll_Follow_You.mp3,If_I_Had_a_Chicken.mp3,Jal_Edge_of_Water.mp3,Juno_In_The_Space_Maze.mp3,Ladybug.mp3,Late_Night_Drive.mp3,Meteor.mp3,Modern_Situations.mp3,Move_Out.mp3,Official_National_Anthem.mp3,Plenty_Step.mp3,Point_Green_Getdown.mp3,Retrograde.mp3,Right_Here_Beside_You.mp3,Safety_Net.mp3,Same_Time.mp3,Static.mp3,Stranger_Danger.mp3,Subharmonic_Bliss.mp3,Sun_Machine_One.mp3,The_Computer_Has_Feelings.mp3,Thinking_Of_Us.mp3,This_is_Not_IDM.mp3,This_is_Not_Jazz.mp3,This_is_Not_a_Ballad.mp3,Time_s_Up.mp3,Triumph.mp3,Unstoppable.mp3,Western_Spaghetti.mp3,Zameen_Movement_of_Earth.mp3,bensound-clearday.mp3,bensound-endlessmotion.mp3,bensound-energy.mp3,bensound-happyrock.mp3
110.88689422607422 161.23936462402344
1 9 0
2 Ancient.mp3,Arm_Candy.mp3,Beach_Disco.mp3,Beach_Walk.mp3,Bird_Therapist.mp3,Carol_of_the_Bells.mp3,Castlevania.mp3,Cats_Searching_for_the_Truth.mp3,Classique.mp3,Cloud_Chaser.mp3,Dragonfly.mp3,Easy_Seas.mp3,Entire.mp3,Eyes_of_Glory.mp3,Finding_Me.mp3,Forgiveness.mp3,Fun_in_the_Sun.mp3,Half_Measures.mp3,Happy_Sixth.mp3,Hear_the_Noise.mp3,Hi_Q.mp3,Hot_Coffee.mp3,How_it_Began.mp3,I_ll_Follow_You.mp3,If_I_Had_a_Chicken.mp3,Jal_Edge_of_Water.mp3,Juno_In_The_Space_Maze.mp3,Ladybug.mp3,Late_Night_Drive.mp3,Meteor.mp3,Modern_Situations.mp3,Move_Out.mp3,Official_National_Anthem.mp3,Plenty_Step.mp3,Point_Green_Getdown.mp3,Retrograde.mp3,Right_Here_Beside_You.mp3,Safety_Net.mp3,Same_Time.mp3,Static.mp3,Stranger_Danger.mp3,Subharmonic_Bliss.mp3,Sun_Machine_One.mp3,The_Computer_Has_Feelings.mp3,Thinking_Of_Us.mp3,This_is_Not_IDM.mp3,This_is_Not_Jazz.mp3,This_is_Not_a_Ballad.mp3,Time_s_Up.mp3,Triumph.mp3,Unstoppable.mp3,Western_Spaghetti.mp3,Zameen_Movement_of_Earth.mp3,bensound-clearday.mp3,bensound-endlessmotion.mp3,bensound-energy.mp3,bensound-happyrock.mp3 Ancient.mp3,Arm_Candy.mp3,Beach_Disco.mp3,Beach_Walk.mp3,Bird_Therapist.mp3,Carol_of_the_Bells.mp3,Castlevania.mp3,Cats_Searching_for_the_Truth.mp3,Classique.mp3,Cloud_Chaser.mp3,Dragonfly.mp3,Easy_Seas.mp3,Entire.mp3,Eyes_of_Glory.mp3,Finding_Me.mp3,Forgiveness.mp3,Fun_in_the_Sun.mp3,Half_Measures.mp3,Happy_Sixth.mp3,Hear_the_Noise.mp3,Hi_Q.mp3,Hot_Coffee.mp3,How_it_Began.mp3,I_ll_Follow_You.mp3,If_I_Had_a_Chicken.mp3,Jal_Edge_of_Water.mp3,Juno_In_The_Space_Maze.mp3,Ladybug.mp3,Late_Night_Drive.mp3,Meteor.mp3,Modern_Situations.mp3,Move_Out.mp3,Official_National_Anthem.mp3,Plenty_Step.mp3,Point_Green_Getdown.mp3,Retrograde.mp3,Right_Here_Beside_You.mp3,Safety_Net.mp3,Same_Time.mp3,Static.mp3,Stranger_Danger.mp3,Subharmonic_Bliss.mp3,Sun_Machine_One.mp3,The_Computer_Has_Feelings.mp3,Thinking_Of_Us.mp3,This_is_Not_IDM.mp3,This_is_Not_Jazz.mp3,This_is_Not_a_Ballad.mp3,Time_s_Up.mp3,Triumph.mp3,Unstoppable.mp3,Western_Spaghetti.mp3,Zameen_Movement_of_Earth.mp3,bensound-clearday.mp3,bensound-endlessmotion.mp3,bensound-energy.mp3,bensound-happyrock.mp3
3 110.88689422607422 161.23936462402344

View File

@@ -1,10 +1,9 @@
import multiprocessing import multiprocessing
import os import os
import signal import signal
# os.environ["KIVY_NO_CONSOLELOG"] = "1" os.environ["KIVY_NO_CONSOLELOG"] = "1"
from kivy.core.window import Window, Config from kivy.core.window import Window, Config
from kivy.uix.screenmanager import ScreenManager from kivy.uix.screenmanager import ScreenManager
from kivymd.uix.textfield import MDTextField
from kivymd.uix.screen import MDScreen from kivymd.uix.screen import MDScreen
from kivymd.app import MDApp from kivymd.app import MDApp
from kivy.base import Builder from kivy.base import Builder
@@ -15,7 +14,12 @@ import bin.filepathanalysis
import bin.player import bin.player
import math import math
import bin.autocomplete import bin.autocomplete
import time import configparser
config = configparser.ConfigParser()
config.read('./data/settings.ini')
version_app = f"Music Player {config['Info']['version']}{config['Info']['subVersion']}"
pl = bin.player.Player() pl = bin.player.Player()
@@ -48,6 +52,9 @@ class invalidpathPU(Popup):
class Home(MDScreen): class Home(MDScreen):
def initapp(self):
return version_app
def change_screen(self): def change_screen(self):
if self.ids.filepath.text != "": if self.ids.filepath.text != "":
self.analyse_dir() self.analyse_dir()
@@ -135,7 +142,12 @@ class Main(MDScreen):
def initialize(self): def initialize(self):
try: try:
Clock.schedule_interval(self.screen_updating, 1) self.refreshspeed = int(config["Performance"]["showcaseRefreshRate"])
except ValueError:
self.refreshspeed = 1
try:
Clock.schedule_interval(self.screen_updating, self.refreshspeed)
except: except:
pass pass