Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add option to quit when working directory is missing #7742

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions src/core/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -805,6 +805,23 @@ int main( int argc, char * * argv )
{
using namespace lmms::gui;

// prompt the user to create the LMMS working directory (e.g. ~/Documents/lmms) if it doesn't exist
if (!ConfigManager::inst()->hasWorkingDir())
{
const auto msg = MainWindow::tr("The LMMS working directory %1 does not exist. Create it now?"
" You can change the directory later via Edit -> Settings.")
.arg(ConfigManager::inst()->workingDir());
const auto res = QMessageBox::question(nullptr, MainWindow::tr("Working directory"), msg,
QMessageBox::Yes | QMessageBox::No | QMessageBox::Abort, QMessageBox::Yes);

if (res == QMessageBox::Abort)
{
if (destroyEngine) { Engine::destroy(); }
return EXIT_SUCCESS;
}
else if (res == QMessageBox::Yes) { ConfigManager::inst()->createWorkingDir(); }
}

new GuiApplication();

// re-intialize RNG - shared libraries might have srand() or
Expand Down
12 changes: 0 additions & 12 deletions src/gui/GuiApplication.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -72,20 +72,8 @@ GuiApplication* GuiApplication::instance()
}



GuiApplication::GuiApplication()
{
// prompt the user to create the LMMS working directory (e.g. ~/Documents/lmms) if it doesn't exist
if ( !ConfigManager::inst()->hasWorkingDir() &&
QMessageBox::question( nullptr,
tr( "Working directory" ),
tr( "The LMMS working directory %1 does not "
"exist. Create it now? You can change the directory "
"later via Edit -> Settings." ).arg( ConfigManager::inst()->workingDir() ),
QMessageBox::Yes | QMessageBox::No, QMessageBox::Yes ) == QMessageBox::Yes)
{
ConfigManager::inst()->createWorkingDir();
}
// Init style and palette
QDir::addSearchPath("artwork", ConfigManager::inst()->themeDir());
QDir::addSearchPath("artwork", ConfigManager::inst()->defaultThemeDir());
Expand Down
Loading