Skip to content

Commit

Permalink
UI|Home: Merged popups for configuring data files (IWAD, packages)
Browse files Browse the repository at this point in the history
Also added a button in the end of the Packages list for opening
the Data Files settings.
  • Loading branch information
skyjake committed Mar 9, 2017
1 parent b418318 commit a44ebd4
Show file tree
Hide file tree
Showing 6 changed files with 172 additions and 37 deletions.
39 changes: 39 additions & 0 deletions doomsday/apps/client/include/ui/dialogs/datafilesettingsdialog.h
@@ -0,0 +1,39 @@
/** @file datafilesettingsdialog.h Data file settings.
*
* @authors Copyright (c) 2017 Jaakko Keränen <jaakko.keranen@iki.fi>
*
* @par License
* GPL: http://www.gnu.org/licenses/gpl.html
*
* <small>This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by the
* Free Software Foundation; either version 2 of the License, or (at your
* option) any later version. This program is distributed in the hope that it
* will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty
* of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
* Public License for more details. You should have received a copy of the GNU
* General Public License along with this program; if not, see:
* http://www.gnu.org/licenses</small>
*/

#ifndef DENG_CLIENT_DATAFILESETTINGSDIALOG_H
#define DENG_CLIENT_DATAFILESETTINGSDIALOG_H

#include <de/DirectoryListDialog>

/**
* Dialog for data file settings.
*/
class DataFileSettingsDialog : public de::DirectoryListDialog
{
public:
DataFileSettingsDialog(de::String const &name = "datafilesettings");

protected:
void finish(int result) override;

private:
DENG2_PRIVATE(d)
};

#endif // DENG_CLIENT_DATAFILESETTINGSDIALOG_H
1 change: 1 addition & 0 deletions doomsday/apps/client/include/ui/widgets/packageswidget.h
Expand Up @@ -66,6 +66,7 @@ class PackagesWidget : public de::GuiWidget, public de::IPersistent
void setPopulationEnabled(bool enable);
void setFilterEditorMinimumY(de::Rule const &minY);
void setPackageStatus(IPackageStatus const &packageStatus);
void showProgressIndicator();

/**
* Sets the data items that determine what kind of action buttons get created
Expand Down
89 changes: 89 additions & 0 deletions doomsday/apps/client/src/ui/dialogs/datafilesettingsdialog.cpp
@@ -0,0 +1,89 @@
/** @file datafilesettings.cpp Data file settings.
*
* @authors Copyright (c) 2017 Jaakko Keränen <jaakko.keranen@iki.fi>
*
* @par License
* GPL: http://www.gnu.org/licenses/gpl.html
*
* <small>This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by the
* Free Software Foundation; either version 2 of the License, or (at your
* option) any later version. This program is distributed in the hope that it
* will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty
* of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
* Public License for more details. You should have received a copy of the GNU
* General Public License along with this program; if not, see:
* http://www.gnu.org/licenses</small>
*/

#include "ui/dialogs/datafilesettingsdialog.h"
#include "ui/clientwindow.h"
#include "ui/widgets/consolewidget.h"
#include "ui/widgets/packageswidget.h"

#include <doomsday/DoomsdayApp>
#include <de/Config>

using namespace de;

DENG2_PIMPL_NOREF(DataFileSettingsDialog)
{
Variable &iwadFolders = Config::get("resource.iwadFolder");
Variable &pkgFolders = Config::get("resource.packageFolder");
Id iwadGroup;
Id pkgGroup;
bool modified = false;
};

DataFileSettingsDialog::DataFileSettingsDialog(String const &name)
: DirectoryListDialog(name)
, d(new Impl)
{
buttons().clear()
<< new DialogButtonItem(Default | Accept, tr("Close"));

title().setFont("heading");
title().setText(tr("Data Files"));
title().setStyleImage("package.icon", "heading");

message().hide();

//dlg->title().setFont("heading");
//dlg->title().setStyleImage("package.icon");
//dlg->title().setOverrideImageSize(Style::get().fonts().font("heading").ascent().value());
//dlg->title().setTextGap("dialog.gap");
//dlg->title().setText(QObject::tr("IWAD Folders"));
//dlg->message().setText(QObject::tr("The following folders are searched for game data files:"));

d->iwadGroup = addGroup(tr("IWAD Folders"),
tr("The following folders are searched for game IWAD files:"));
setValue(d->iwadGroup, d->iwadFolders.value());

d->pkgGroup = addGroup(tr("Add-on and Package Folders"),
tr("The following folders and all their subfolders are searched "
"for resource packs and other add-ons:"));
setValue(d->pkgGroup, d->pkgFolders.value());

connect(this, &DirectoryListDialog::arrayChanged, [this] ()
{
d->modified = true;
});
}

void DataFileSettingsDialog::finish(int result)
{
DirectoryListDialog::finish(result);

if (d->modified)
{
d->iwadFolders.set(value(d->iwadGroup));
d->pkgFolders .set(value(d->pkgGroup));

// Reload packages and recheck for game availability.
auto &win = ClientWindow::main();
win.console().closeLogAndUnfocusCommandLine();
win.root().find("home-packages")->as<PackagesWidget>().showProgressIndicator();
DoomsdayApp::app().initWadFolders();
DoomsdayApp::app().initPackageFolders();
}
}
47 changes: 36 additions & 11 deletions doomsday/apps/client/src/ui/home/packagescolumnwidget.cpp
Expand Up @@ -19,6 +19,7 @@
#include "ui/home/packagescolumnwidget.h"
#include "ui/widgets/packageswidget.h"
#include "ui/dialogs/packageinfodialog.h"
#include "ui/dialogs/datafilesettingsdialog.h"
#include "ui/widgets/homeitemwidget.h"
#include "ui/widgets/homemenuwidget.h"

Expand All @@ -38,29 +39,34 @@

using namespace de;

#if 0
static PopupWidget *makePackageFoldersDialog()
{
Variable &pkgFolders = Config::get("resource.packageFolder");

auto *dlg = new DirectoryListDialog;
dlg->title().setFont("heading");
dlg->title().setText(QObject::tr("Add-on and Package Folders"));
dlg->message().setText(QObject::tr("The following folders are searched for resource packs and other add-ons:"));
dlg->setValue(pkgFolders.value());
dlg->setAcceptanceAction(new CallbackAction([dlg, &pkgFolders] ()
//dlg->title().setFont("heading");
//dlg->title().setText(QObject::tr("Add-on and Package Folders"));
//dlg->message().setText(QObject::tr("The following folders are searched for resource packs and other add-ons:"));
Id group = dlg->addGroup(QObject::tr("Add-on and Package Folders"),
QObject::tr("The following folders are searched for resource packs and other add-ons:"));
dlg->setValue(group, pkgFolders.value());
dlg->setAcceptanceAction(new CallbackAction([dlg, &pkgFolders, group] ()
{
pkgFolders.set(dlg->value());
pkgFolders.set(dlg->value(group));

// Reload packages and recheck for game availability.
DoomsdayApp::app().initPackageFolders();
}));
return dlg;
}
#endif

DENG_GUI_PIMPL(PackagesColumnWidget)
{
PackagesWidget *packages;
LabelWidget *countLabel;
ButtonWidget *folderOptionsButton;
ui::ListData actions;
LoopCallback mainCall;

Expand Down Expand Up @@ -95,18 +101,36 @@ DENG_GUI_PIMPL(PackagesColumnWidget)
}
});

// Column menu.
area.add(folderOptionsButton = new ButtonWidget);
folderOptionsButton->setStyleImage("gear", "default");
folderOptionsButton->setText(tr("Data Files"));
folderOptionsButton->setTextAlignment(ui::AlignRight);
folderOptionsButton->setSizePolicy(ui::Fixed, ui::Expand);
folderOptionsButton->rule()
.setInput(Rule::Width, area.contentRule().width())
.setInput(Rule::Left, area.contentRule().left())
.setInput(Rule::Top, packages->rule().bottom());
folderOptionsButton->setAction(new CallbackAction([this] ()
{
auto *dlg = new DataFileSettingsDialog;
dlg->setDeleteAfterDismissed(true);
dlg->setAnchorAndOpeningDirection(folderOptionsButton->rule(), ui::Left);
self().root().addOnTop(dlg);
dlg->open();
}));

// Column actions menu.
self().header().menuButton().setPopup([this] (PopupButtonWidget const &) -> PopupWidget * {
auto *menu = new PopupMenuWidget;
menu->items()
<< new ui::ActionItem(/*style().images().image("refresh"), */tr("Refresh"),
new CallbackAction([this] () { packages->refreshPackages(); }))
<< new ui::SubwidgetItem(tr("Folders"), ui::Left, [menu] () -> PopupWidget *
new CallbackAction([this] () { packages->refreshPackages(); }));
/*<< new ui::SubwidgetItem(tr("Folders"), ui::Left, [menu] () -> PopupWidget *
{
auto *pop = makePackageFoldersDialog();
QObject::connect(pop, SIGNAL(closed()), menu, SLOT(close()));
return pop;
});
});*/
return menu;
}, ui::Down);
}
Expand All @@ -132,7 +156,8 @@ PackagesColumnWidget::PackagesColumnWidget()
scrollArea().setContentSize(maximumContentWidth(),
header().rule().height() +
rule("gap") +
d->packages->rule().height());
d->packages->rule().height() +
d->folderOptionsButton->rule().height()*2);

// Additional layout for the packages list.
d->packages->setFilterEditorMinimumY(scrollArea().margins().top());
Expand Down
5 changes: 5 additions & 0 deletions doomsday/apps/client/src/ui/widgets/packageswidget.cpp
Expand Up @@ -805,6 +805,11 @@ void PackagesWidget::setPackageStatus(IPackageStatus const &packageStatus)
d->packageStatus = &packageStatus;
}

void PackagesWidget::showProgressIndicator()
{
d->showProgressIndicator(true);
}

void PackagesWidget::setActionItems(ui::Data const &actionItems)
{
d->actionItems = &actionItems;
Expand Down
28 changes: 2 additions & 26 deletions doomsday/apps/client/src/ui/widgets/taskbarwidget.cpp
Expand Up @@ -26,6 +26,7 @@
#include "ui/clientwindow.h"
#include "ui/dialogs/aboutdialog.h"
#include "ui/dialogs/audiosettingsdialog.h"
#include "ui/dialogs/datafilesettingsdialog.h"
#include "ui/dialogs/inputsettingsdialog.h"
#include "ui/dialogs/manualconnectiondialog.h"
#include "ui/dialogs/networksettingsdialog.h"
Expand Down Expand Up @@ -351,31 +352,6 @@ static PopupWidget *makeUpdaterSettings()
return new UpdaterSettingsDialog(UpdaterSettingsDialog::WithApplyAndCheckButton);
}

static PopupWidget *makeIWADFolders()
{
DENG2_ASSERT(!App_GameLoaded());

Variable &iwadFolders = App::config("resource.iwadFolder");

auto *dlg = new DirectoryListDialog;
dlg->title().setFont("heading");
dlg->title().setStyleImage("package.icon");
dlg->title().setOverrideImageSize(Style::get().fonts().font("heading").ascent().value());
dlg->title().setTextGap("dialog.gap");
dlg->title().setText(QObject::tr("IWAD Folders"));
dlg->message().setText(QObject::tr("The following folders are searched for game data files:"));
dlg->setValue(iwadFolders.value());
dlg->setAcceptanceAction(new CallbackAction([dlg, &iwadFolders] ()
{
iwadFolders.set(dlg->value());

// Reload packages and recheck for game availability.
ClientWindow::main().console().closeLogAndUnfocusCommandLine();
DoomsdayApp::app().initWadFolders();
}));
return dlg;
}

TaskBarWidget::TaskBarWidget() : GuiWidget("taskbar"), d(new Impl(this))
{
#if 0
Expand Down Expand Up @@ -487,7 +463,7 @@ TaskBarWidget::TaskBarWidget() : GuiWidget("taskbar"), d(new Impl(this))
<< new ui::SubwidgetItem(style().images().image("input"), tr("Input"), ui::Left, makePopup<InputSettingsDialog>)
<< new ui::SubwidgetItem(style().images().image("network"), tr("Network"), ui::Left, makePopup<NetworkSettingsDialog>)
<< new ui::Item(ui::Item::Separator)
<< new ui::SubwidgetItem(style().images().image("package.icon"), tr("Data Files"), ui::Left, makeIWADFolders)
<< new ui::SubwidgetItem(style().images().image("package.icon"), tr("Data Files"), ui::Left, makePopup<DataFileSettingsDialog>)
<< new ui::SubwidgetItem(style().images().image("home.icon"), tr("User Interface"), ui::Left, makePopup<UISettingsDialog>)
<< new ui::SubwidgetItem(style().images().image("updater"), tr("Updater"), ui::Left, makeUpdaterSettings);

Expand Down

0 comments on commit a44ebd4

Please sign in to comment.