Skip to content

Commit

Permalink
UI|Client: Store console width persistently
Browse files Browse the repository at this point in the history
  • Loading branch information
skyjake committed Feb 20, 2014
1 parent 4b7fd40 commit 3e61726
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 1 deletion.
7 changes: 6 additions & 1 deletion doomsday/client/include/ui/widgets/consolewidget.h
Expand Up @@ -23,6 +23,7 @@
#include <de/GuiWidget>
#include <de/ButtonWidget>
#include <de/LogWidget>
#include <de/IPersistent>

#include "consolecommandwidget.h"

Expand All @@ -34,7 +35,7 @@
*
* @ingroup gui
*/
class ConsoleWidget : public de::GuiWidget
class ConsoleWidget : public de::GuiWidget, public de::IPersistent
{
Q_OBJECT

Expand Down Expand Up @@ -63,6 +64,10 @@ class ConsoleWidget : public de::GuiWidget
void update();
bool handleEvent(de::Event const &event);

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

signals:
void commandModeChanged();
void commandLineGotFocus();
Expand Down
17 changes: 17 additions & 0 deletions doomsday/client/src/ui/widgets/consolewidget.cpp
Expand Up @@ -35,6 +35,7 @@
#include <de/PopupMenuWidget>
#include <de/ToggleWidget>
#include <de/LogWidget>
#include <de/PersistentState>
#include <QCursor>

using namespace de;
Expand Down Expand Up @@ -422,6 +423,22 @@ bool ConsoleWidget::handleEvent(Event const &event)
return false;
}

void ConsoleWidget::operator >> (PersistentState &toState) const
{
toState.names().set("console.width", d->width->value());
}

void ConsoleWidget::operator << (PersistentState const &fromState)
{
d->width->set(fromState.names()["console.width"]);

if(!d->opened)
{
// Make sure it stays out of the view.
d->horizShift->set(-rule().width().valuei() - 1);
}
}

void ConsoleWidget::openLog()
{
if(d->opened) return;
Expand Down

0 comments on commit 3e61726

Please sign in to comment.