From ec37179a7cd91977cadfa84051a99d83607f2c73 Mon Sep 17 00:00:00 2001 From: RemixDev Date: Wed, 19 Feb 2020 19:03:21 +0100 Subject: [PATCH] Started implementing settings --- deemix/ui/MainFrame.py | 31 ++++++++++++++++++++++++++++++- deemix/ui/SettingsDialog.py | 37 +++++++++++++++++++++++++++++++++++++ 2 files changed, 67 insertions(+), 1 deletion(-) create mode 100644 deemix/ui/SettingsDialog.py diff --git a/deemix/ui/MainFrame.py b/deemix/ui/MainFrame.py index 1abd8c0..4e1bb2e 100644 --- a/deemix/ui/MainFrame.py +++ b/deemix/ui/MainFrame.py @@ -1,13 +1,32 @@ #!/usr/bin/env python3 import wx +from deemix.ui.SettingsDialog import SettingsDialog from deemix.app.functions import downloadTrack, getIDFromLink, getTypeFromLink +menuIDs = { + "SETTINGS": 1 +} class MainFrame(wx.Frame): - def __init__(self): + def __init__(self, *args, **kwargs): super().__init__(parent=None, title='deemix') panel = wx.Panel(self) + + self.settings = {} + + # Menubar + menubar = wx.MenuBar() + fileMenu = wx.Menu() + settingsItem = fileMenu.Append(menuIDs['SETTINGS'], 'Settings', 'Edit Settings') + fileMenu.AppendSeparator() + quitItem = fileMenu.Append(wx.ID_EXIT, 'Quit', 'Quit application') + menubar.Append(fileMenu, '&File') + self.SetMenuBar(menubar) + self.Bind(wx.EVT_MENU, self.close_app, quitItem) + self.Bind(wx.EVT_MENU, self.open_settings, settingsItem) + + # Main app main_sizer = wx.BoxSizer(wx.VERTICAL) search_sizer = wx.BoxSizer(wx.HORIZONTAL) main_sizer.Add(search_sizer, 0, wx.EXPAND, 5) @@ -30,3 +49,13 @@ class MainFrame(wx.Frame): if type == "track": downloadTrack(id, 9) self.text_ctrl.SetValue("") + + def close_app(self, event): + self.Close() + + def open_settings(self, event): + settings_dialog = SettingsDialog(self.settings, self) + res = settings_dialog.ShowModal() + if res == wx.ID_OK: + self.settings = settings_dialog.GetSettings() + settings_dialog.Destroy() diff --git a/deemix/ui/SettingsDialog.py b/deemix/ui/SettingsDialog.py new file mode 100644 index 0000000..0b3971a --- /dev/null +++ b/deemix/ui/SettingsDialog.py @@ -0,0 +1,37 @@ +#!/usr/bin/env python3 +import wx + +class SettingsDialog(wx.Dialog): + def __init__(self, settings, *args, **kwargs): + wx.Dialog.__init__(self, title="Settings", size=wx.Size(600,400), *args, **kwargs) + self.settings = settings + + panel = wx.Panel(self) + main_sizer = wx.BoxSizer(wx.VERTICAL) + nb = wx.Notebook(panel, style=wx.NB_LEFT) + nb.AddPage(wx.Window(nb), "App Settings") + nb.AddPage(wx.Window(nb), "Path Settings") + nb.AddPage(wx.Window(nb), "Tagging Settings") + main_sizer.Add(nb, 1, wx.ALL, 5) + + button_ok = wx.Button(panel, label="OK") + button_cancel = wx.Button(panel, label="Cancel") + button_ok.Bind(wx.EVT_BUTTON, self.onOk) + button_cancel.Bind(wx.EVT_BUTTON, self.onCancel) + + footer_sizer = wx.BoxSizer(wx.HORIZONTAL) + footer_sizer.Add(button_ok, 0, wx.ALL, 5) + footer_sizer.Add(button_cancel, 0, wx.ALL, 5) + main_sizer.Add(footer_sizer, 0, wx.ALIGN_RIGHT) + + panel.SetSizerAndFit(main_sizer) + + def onCancel(self, e): + self.EndModal(wx.ID_CANCEL) + + def onOk(self, e): + # Check each page and save all data + self.EndModal(wx.ID_OK) + + def GetSettings(self): + return self.settings