Skip to content

Commit

Permalink
Refactor|UI|Client: Use DocumentPopupWidget
Browse files Browse the repository at this point in the history
  • Loading branch information
skyjake committed Jan 28, 2014
1 parent c24775a commit 81b8be2
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 50 deletions.
5 changes: 3 additions & 2 deletions doomsday/client/data/defaultstyle.pack/rules.dei
Expand Up @@ -16,7 +16,8 @@ group label {
rule scrollarea.bar { constant $= UNIT }

group document {
rule progress { constant $= UNIT * 30 }
rule progress { constant $= UNIT * 30 }
rule popup.width { constant $= UNIT * 120 }
}

group editor {
Expand Down Expand Up @@ -60,7 +61,7 @@ group console {
}

group gameselection {
rule max.width { constant $= UNIT * 200 }
rule max.width { constant $= UNIT * 215 }
rule max.height { constant $= UNIT * 150 }
}

Expand Down
4 changes: 0 additions & 4 deletions doomsday/client/include/ui/dialogs/aboutdialog.h
Expand Up @@ -31,10 +31,6 @@ class AboutDialog : public de::DialogWidget
public:
AboutDialog();

protected slots:
void showGLInfo();
void showAudioInfo();

private:
DENG2_PRIVATE(d)
};
Expand Down
35 changes: 9 additions & 26 deletions doomsday/client/src/ui/dialogs/aboutdialog.cpp
Expand Up @@ -28,33 +28,26 @@
#include <de/SequentialLayout>
#include <de/SignalAction>
#include <de/LabelWidget>
#include <de/PopupWidget>
#include <de/DocumentWidget>
#include <de/DocumentPopupWidget>
#include <de/Style>

using namespace de;

DENG2_PIMPL(AboutDialog)
{
PopupWidget *glPopup;
PopupWidget *audioPopup;
DocumentPopupWidget *glPopup;
DocumentPopupWidget *audioPopup;

Instance(Public *i) : Base(i)
{
// Popup with GL info.
glPopup = new PopupWidget;
glPopup->useInfoStyle();
DocumentWidget *doc = new DocumentWidget;
doc->setText(Sys_GLDescription());
glPopup->setContent(doc);
glPopup = new DocumentPopupWidget;
glPopup->document().setText(Sys_GLDescription());
self.add(glPopup);

// Popup with audio info.
audioPopup = new PopupWidget;
audioPopup->useInfoStyle();
doc = new DocumentWidget;
doc->setText(AudioDriver_InterfaceDescription());
audioPopup->setContent(doc);
audioPopup = new DocumentPopupWidget;
audioPopup->document().setText(AudioDriver_InterfaceDescription());
self.add(audioPopup);
}
};
Expand Down Expand Up @@ -111,21 +104,11 @@ AboutDialog::AboutDialog() : DialogWidget("about"), d(new Instance(this))

buttons()
<< new DialogButtonItem(DialogWidget::Accept | DialogWidget::Default, tr("Close"))
<< new DialogButtonItem(DialogWidget::Action, tr("GL"), new SignalAction(this, SLOT(showGLInfo())))
<< new DialogButtonItem(DialogWidget::Action, tr("Audio"), new SignalAction(this, SLOT(showAudioInfo())))
<< new DialogButtonItem(DialogWidget::Action, tr("GL"), new SignalAction(d->glPopup, SLOT(open())))
<< new DialogButtonItem(DialogWidget::Action, tr("Audio"), new SignalAction(d->audioPopup, SLOT(open())))
<< new DialogButtonItem(DialogWidget::Action, tr("Homepage..."), new SignalAction(&ClientApp::app(), SLOT(openHomepageInBrowser())));

// The popups are anchored to their button.
d->glPopup->setAnchorAndOpeningDirection(buttonWidget(tr("GL")).rule(), ui::Up);
d->audioPopup->setAnchorAndOpeningDirection(buttonWidget(tr("Audio")).rule(), ui::Up);
}

void AboutDialog::showGLInfo()
{
d->glPopup->open();
}

void AboutDialog::showAudioInfo()
{
d->audioPopup->open();
}
34 changes: 16 additions & 18 deletions doomsday/client/src/ui/dialogs/multiplayerdialog.cpp
Expand Up @@ -28,7 +28,7 @@
#include <de/SignalAction>
#include <de/SequentialLayout>
#include <de/ChildWidgetOrganizer>
#include <de/DocumentWidget>
#include <de/DocumentPopupWidget>
#include <de/ui/Item>

using namespace de;
Expand Down Expand Up @@ -75,8 +75,7 @@ DENG_GUI_PIMPL(MultiplayerDialog)
ButtonWidget *extra;
ButtonWidget *join;
QScopedPointer<SequentialLayout> layout;
PopupWidget *popup;
DocumentWidget *info;
DocumentPopupWidget *info;

struct JoinAction : public Action
{
Expand Down Expand Up @@ -147,14 +146,12 @@ DENG_GUI_PIMPL(MultiplayerDialog)
rule().setSize(layout->width(), title->rule().height());

// Extra info popup.
popup = new PopupWidget;
popup->useInfoStyle();
popup->setContent(info = new DocumentWidget);
info->setMaximumLineWidth(style().rules().rule("dialog.multiplayer.width").valuei());
popup->setAnchorAndOpeningDirection(extra->rule(), ui::Up);
add(popup);

extra->setAction(new SignalAction(popup, SLOT(open())));
info = new DocumentPopupWidget;
info->document().setMaximumLineWidth(style().rules().rule("dialog.multiplayer.width").valuei());
info->setAnchorAndOpeningDirection(extra->rule(), ui::Up);
add(info);

extra->setAction(new SignalAction(info, SLOT(open())));
}

void updateFromItem(ServerListItem const &item)
Expand Down Expand Up @@ -187,13 +184,14 @@ DENG_GUI_PIMPL(MultiplayerDialog)

// Extra information.
#define TABBED(A, B) _E(Ta)_E(l) " " A _E(.) " " _E(\t) B "\n"
info->setText(String(_E(b) "%1" _E(.) "\n%2\n" _E(T`)
TABBED("Joinable:", "%5")
TABBED("Players:", "%3 / %4%13")
TABBED("Game:", "%9\n%10\n%12 %11")
TABBED("PWADs:", "%14")
TABBED("Address:", "%6:%7")
TABBED("Ping:", "%8 ms (approx)"))
info->document()
.setText(String(_E(b) "%1" _E(.) "\n%2\n" _E(T`)
TABBED("Joinable:", "%5")
TABBED("Players:", "%3 / %4%13")
TABBED("Game:", "%9\n%10\n%12 %11")
TABBED("PWADs:", "%14")
TABBED("Address:", "%6:%7")
TABBED("Ping:", "%8 ms (approx)"))
.arg(sv.name)
.arg(sv.description)
.arg(sv.numPlayers)
Expand Down

0 comments on commit 81b8be2

Please sign in to comment.