Yikes! Fixed a really, really bad first run bug I never noticed because I

never go through the first run process.
This commit is contained in:
casey langen 2016-12-27 17:33:27 -08:00
parent 3641acd7bf
commit c3653ffa19
4 changed files with 24 additions and 27 deletions

View File

@ -303,28 +303,31 @@ void SettingsLayout::OnVisibilityChanged(bool visible) {
void SettingsLayout::CheckShowFirstRunDialog() {
if (!this->libraryPrefs->GetBool(box::prefs::keys::FirstRunSettingsDisplayed)) {
std::shared_ptr<DialogOverlay> dialog(new DialogOverlay());
if (!this->firstRunDialog) {
this->firstRunDialog.reset(new DialogOverlay());
(*dialog)
.SetTitle("welcome to musikbox!")
.SetMessage(boost::str(boost::format(
"add some directories that contain music files, "
"then press '%s' to show the library view and start listening!\n\n"
"for troubleshooting, press '%s' to enter the console view.\n\n"
"other keyboard shorcuts are displayed in the command bar at the "
"bottom of the screen. toggle command mode by pressing 'ESC'.\n\n"
"select 'ok' to get started.")
(*this->firstRunDialog)
.SetTitle("welcome to musikbox!")
.SetMessage(boost::str(boost::format(
"add some directories that contain music files, "
"then press '%s' to show the library view and start listening!\n\n"
"for troubleshooting, press '%s' to enter the console view.\n\n"
"other keyboard shorcuts are displayed in the command bar at the "
"bottom of the screen. toggle command mode by pressing 'ESC'.\n\n"
"select 'ok' to get started.")
% Hotkeys::Get(Hotkeys::NavigateLibrary)
% Hotkeys::Get(Hotkeys::NavigateConsole)))
.AddButton(
"KEY_ENTER",
"ENTER",
"ok",
[this](std::string key) {
this->libraryPrefs->SetBool(box::prefs::keys::FirstRunSettingsDisplayed, true);
});
.AddButton(
"KEY_ENTER",
"ENTER",
"ok",
[this](std::string key) {
this->libraryPrefs->SetBool(box::prefs::keys::FirstRunSettingsDisplayed, true);
this->firstRunDialog.reset();
});
App::Overlays().Push(dialog);
App::Overlays().Push(this->firstRunDialog);
}
}
}

View File

@ -41,6 +41,7 @@
#include <cursespp/SimpleScrollAdapter.h>
#include <cursespp/TextLabel.h>
#include <cursespp/TextInput.h>
#include <cursespp/DialogOverlay.h>
#include <app/window/TrackListView.h>
#include <app/service/PlaybackService.h>
@ -124,6 +125,8 @@ namespace musik {
std::shared_ptr<cursespp::TextLabel> hotkeyLabel;
std::shared_ptr<cursespp::TextInput> hotkeyInput;
std::shared_ptr<cursespp::DialogOverlay> firstRunDialog;
cursespp::SimpleScrollAdapter addedPathsAdapter;
DirectoryAdapter browseAdapter;
};

View File

@ -137,12 +137,6 @@ bool DialogOverlay::KeyPress(const std::string& key) {
return LayoutBase::KeyPress(key);
}
void DialogOverlay::OnVisibilityChanged(bool visible) {
if (visible) {
this->Redraw();
}
}
void DialogOverlay::RecalculateSize() {
int lastWidth = this->width;

View File

@ -68,9 +68,6 @@ namespace cursespp {
virtual void Layout();
virtual bool KeyPress(const std::string& key);
protected:
virtual void OnVisibilityChanged(bool visible);
private:
void Redraw();
void RecalculateSize();