Skip to content

Commit

Permalink
UI|Home: Began revising the package popup dialog
Browse files Browse the repository at this point in the history
The package popup will show all information and the actions that can
be taken on the package (such as selecting contents or uninstalling).
  • Loading branch information
skyjake committed Jan 10, 2017
1 parent ac0821f commit 006b29f
Show file tree
Hide file tree
Showing 3 changed files with 100 additions and 29 deletions.
10 changes: 5 additions & 5 deletions doomsday/apps/client/include/ui/widgets/packagepopupwidget.h
@@ -1,4 +1,4 @@
/** @file packagepopupwidget.h Popup showing information about a package.
/** @file packagepopupwidget.h Popup showing information and actions about a package.
*
* @authors Copyright (c) 2016 Jaakko Keränen <jaakko.keranen@iki.fi>
*
Expand All @@ -19,19 +19,19 @@
#ifndef DENG_CLIENT_UI_PACKAGEPOPUPWIDGET_H
#define DENG_CLIENT_UI_PACKAGEPOPUPWIDGET_H

#include <de/DocumentPopupWidget>
#include <de/DialogWidget>

/**
* Popup showing information about a package.
*/
class PackagePopupWidget : public de::DocumentPopupWidget
class PackagePopupWidget : public de::DialogWidget
{
public:
PackagePopupWidget(de::String const &packageId);
PackagePopupWidget(de::File const *packageFile);

protected:
bool setup(de::File const *file);
private:
DENG2_PRIVATE(d)
};

#endif // DENG_CLIENT_UI_PACKAGEPOPUPWIDGET_H
6 changes: 3 additions & 3 deletions doomsday/apps/client/src/ui/home/packagescolumnwidget.cpp
Expand Up @@ -66,9 +66,9 @@ DENG_GUI_PIMPL(PackagesColumnWidget)
{
actions << new ui::SubwidgetItem(tr("..."), ui::Down, [this] () -> PopupWidget *
{
String const packageId = packages->actionPackage();
return new PackagePopupWidget(packages->actionPackage());

auto *popMenu = new PopupMenuWidget;
/*auto *popMenu = new PopupMenuWidget;
popMenu->setColorTheme(Inverted);
popMenu->items() << new ui::SubwidgetItem(tr("Info"), ui::Down,
[this, packageId] () -> PopupWidget * {
Expand All @@ -87,7 +87,7 @@ DENG_GUI_PIMPL(PackagesColumnWidget)
popMenu->items()
<< new ui::Item(ui::Item::Separator)
<< new ui::ActionItem(style().images().image("close.ring"), tr("Uninstall..."));
return popMenu;
return popMenu;*/
});

countLabel = new LabelWidget;
Expand Down
113 changes: 92 additions & 21 deletions doomsday/apps/client/src/ui/widgets/packagepopupwidget.cpp
Expand Up @@ -19,46 +19,90 @@
#include "ui/widgets/packagepopupwidget.h"

#include <de/App>
#include <de/LabelWidget>
#include <de/DocumentWidget>
#include <de/PackageLoader>
#include <de/SequentialLayout>

using namespace de;

PackagePopupWidget::PackagePopupWidget(String const &packageId)
DENG2_PIMPL(PackagePopupWidget)
{
if (!setup(App::packageLoader().select(packageId)))
LabelWidget *title;
LabelWidget *path;
DocumentWidget *description;
LabelWidget *icon;
LabelWidget *metaInfo;

Impl(Public *i) : Base(i)
{
document().setText(packageId);
self().useInfoStyle();

// The Close button is always available. Other actions are shown depending
// on what kind of package is being displayed.
self().buttons()
<< new DialogButtonItem(Default | Accept, tr("Close"));

createWidgets();
}
}

PackagePopupWidget::PackagePopupWidget(File const *packageFile)
{
if (!setup(packageFile))
void createWidgets()
{
document().setText(tr("No package"));
}
}
auto &area = self().area();

bool PackagePopupWidget::setup(File const *file)
{
enableCloseButton(true);
document().setMaximumLineWidth(rule("home.popup.width").valuei());
setPreferredHeight(rule("home.popup.height"));
title = LabelWidget::newWithText("", &area);
title->setFont("heading");
title->setSizePolicy(ui::Filled, ui::Expand);
title->setTextColor("inverted.text");

path = LabelWidget::newWithText("", &area);
path->setFont("small");
path->setSizePolicy(ui::Filled, ui::Expand);
path->setTextColor("inverted.text");

description = new DocumentWidget;
description->setWidthPolicy(ui::Fixed);
description->rule().setInput(Rule::Height, Const(2*150));
area.add(description);

Record const &names = file->objectNamespace();
if (file && names.has(Package::VAR_PACKAGE))
SequentialLayout layout(area.contentRule().left(),
area.contentRule().top(),
ui::Down);
layout.setOverrideWidth(Const(2*300));
layout << *title
<< *path
<< *description;

area.setContentSize(layout.width(), layout.height());
}

bool setup(File const *file)
{
/*enableCloseButton(true);
document().setMaximumLineWidth(rule("home.popup.width").valuei());
setPreferredHeight(rule("home.popup.height"));*/

Record const &names = file->objectNamespace();
if (!file || !names.has(Package::VAR_PACKAGE)) return false;

Record const &meta = names.subrecord(Package::VAR_PACKAGE);

String msg = String(_E(1) "%1" _E(.) "\n%2\n"
title->setText(meta.gets(Package::VAR_TITLE));
path->setText(String(_E(b) "%1" _E(.) "\n%2")
.arg("WAD")
.arg(file->source()->description()));

String msg;/* = String(_E(1) "%1" _E(.) "\n%2\n"
_E(l) "Version: " _E(.) "%3\n"
_E(l) "License: " _E(.)_E(>) "%4" _E(<)
_E(l) "\nFile: " _E(.)_E(>)_E(C) "%5" _E(.)_E(<))
.arg(meta.gets(Package::VAR_TITLE))
.arg(meta.gets("ID"))
.arg(meta.gets("version"))
.arg(meta.gets("license"))
.arg(file->description());
.arg(file->description());*/

msg = "Description of the package.";

if (meta.has("author"))
{
Expand Down Expand Up @@ -90,8 +134,35 @@ bool PackagePopupWidget::setup(File const *file)
}
}

document().setText(msg);
description->setText(msg);
//document().setText(msg);

// Show applicable package actions:
// - play in game (WADs, PK3s); does not add in the profile
// - add to profile
// - configure / select contents (in a collection)
// - uninstall (user packages)

return true;
}
return false;
};

PackagePopupWidget::PackagePopupWidget(String const &packageId)
: DialogWidget("packagepopup")
, d(new Impl(this))
{
if (!d->setup(App::packageLoader().select(packageId)))
{
//document().setText(packageId);
}
}

PackagePopupWidget::PackagePopupWidget(File const *packageFile)
: DialogWidget("packagepopup")
, d(new Impl(this))
{
if (!d->setup(packageFile))
{
//document().setText(tr("No package"));
}
}

0 comments on commit 006b29f

Please sign in to comment.