Skip to content

Commit

Permalink
UI|Home: Persistent state for the Packages search terms
Browse files Browse the repository at this point in the history
  • Loading branch information
skyjake committed Feb 27, 2016
1 parent 6b6914f commit 1c68ff5
Show file tree
Hide file tree
Showing 6 changed files with 29 additions and 5 deletions.
7 changes: 6 additions & 1 deletion doomsday/apps/client/include/ui/home/packageswidget.h
Expand Up @@ -20,17 +20,22 @@
#define DENG_CLIENT_UI_HOME_PACKAGESWIDGET_H

#include <de/GuiWidget>
#include <de/IPersistent>

/**
* Listing of packages with search and filtering options.
*
* Controls its own height; other position rules must be set by the owner.
*/
class PackagesWidget : public de::GuiWidget
class PackagesWidget : public de::GuiWidget, public de::IPersistent
{
public:
PackagesWidget(de::String const &name = "");

// Implements IPersistent.
void operator >> (de::PersistentState &toState) const;
void operator << (de::PersistentState const &fromState);

public slots:
void refreshPackages();

Expand Down
3 changes: 2 additions & 1 deletion doomsday/apps/client/src/ui/home/gamecolumnwidget.cpp
Expand Up @@ -245,7 +245,8 @@ String GameColumnWidget::tabHeading() const

String GameColumnWidget::configVariableName() const
{
return "home.columns." + (!d->gameFamily.isEmpty()? d->gameFamily : String("otherGames"));
return "home.columns." + (!d->gameFamily.isEmpty()? d->gameFamily
: String("otherGames"));
}

void GameColumnWidget::setHighlighted(bool highlighted)
Expand Down
4 changes: 3 additions & 1 deletion doomsday/apps/client/src/ui/home/homemenuwidget.cpp
Expand Up @@ -76,8 +76,10 @@ void HomeMenuWidget::setSelectedIndex(int index)
if(index >= 0 && index < childWidgets().size())
{
unselectAll();
childWidgets().at(index)->as<HomeItemWidget>().setSelected(true);
d->selectedIndex = index;

HomeItemWidget &widget = childWidgets().at(index)->as<HomeItemWidget>();
widget.setSelected(true);
}
}

Expand Down
Expand Up @@ -224,7 +224,7 @@ MultiplayerColumnWidget::MultiplayerColumnWidget()
d->menu->rule().height());

header().title().setText(_E(s) "dengine.net\n" _E(.)_E(w) + tr("Multiplayer Games"));
header().info().setText(tr("Multiplayer servers are located via the dengine.net master server and broadcasting on the local network."));
header().info().setText(tr("Multiplayer servers are located via the dengine.net master server and by broadcasting on the local network."));
}

String MultiplayerColumnWidget::tabHeading() const
Expand Down
2 changes: 1 addition & 1 deletion doomsday/apps/client/src/ui/home/packagescolumnwidget.cpp
Expand Up @@ -28,7 +28,7 @@ DENG_GUI_PIMPL(PackagesColumnWidget)
Instance(Public *i) : Base(i)
{
ScrollAreaWidget &area = self.scrollArea();
area.add(packages = new PackagesWidget);
area.add(packages = new PackagesWidget("home-packages"));
packages->rule()
.setInput(Rule::Width, area.contentRule().width())
.setInput(Rule::Top, self.header().rule().bottom() +
Expand Down
16 changes: 16 additions & 0 deletions doomsday/apps/client/src/ui/home/packageswidget.cpp
Expand Up @@ -444,6 +444,22 @@ PackagesWidget::PackagesWidget(String const &name)
refreshPackages();
}

void PackagesWidget::operator >> (PersistentState &toState) const
{
if(name().isEmpty()) return;

Record &rec = toState.objectNamespace();
rec.set(name().concatenateMember("search"), d->search->text());
}

void PackagesWidget::operator << (PersistentState const &fromState)
{
if(name().isEmpty()) return;

Record const &rec = fromState.objectNamespace();
d->search->setText(rec.gets(name().concatenateMember("search"), ""));
}

void PackagesWidget::refreshPackages()
{
App::fileSystem().refresh();
Expand Down

0 comments on commit 1c68ff5

Please sign in to comment.