settings-manager.cpp 1.1 KB

123456789101112131415161718192021222324252627282930313233
  1. SettingsManager::SettingsManager(View* view) : PanelList(view, Size{~0, ~0}) {
  2. setCollapsible().setVisible(false);
  3. listView.onChange([&] { onChange(); });
  4. }
  5. auto SettingsManager::show() -> void {
  6. listView.selectNone().doChange();
  7. refresh();
  8. setVisible(true);
  9. }
  10. auto SettingsManager::hide() -> void {
  11. setVisible(false);
  12. }
  13. auto SettingsManager::refresh() -> void {
  14. listView.reset();
  15. listView.append(ListViewItem().setText("Video").setIcon(Icon::Device::Display));
  16. listView.append(ListViewItem().setText("Audio").setIcon(Icon::Device::Speaker));
  17. listView.append(ListViewItem().setText("Input").setIcon(Icon::Device::Joypad));
  18. listView.append(ListViewItem().setText("Hotkeys").setIcon(Icon::Device::Keyboard));
  19. }
  20. auto SettingsManager::onChange() -> void {
  21. if(auto item = listView.selected()) {
  22. if(item.text() == "Video") return program.setPanelItem(videoSettings);
  23. if(item.text() == "Audio") return program.setPanelItem(audioSettings);
  24. if(item.text() == "Input") return program.setPanelItem(inputSettings);
  25. if(item.text() == "Hotkeys") return program.setPanelItem(hotkeySettings);
  26. }
  27. return program.setPanelItem(home);
  28. }