Skip to content

Commit

Permalink
UI|Client: Added MessageDialog; relocated rest of updater sources
Browse files Browse the repository at this point in the history
  • Loading branch information
skyjake committed Aug 21, 2013
1 parent 027e446 commit 8be9b35
Show file tree
Hide file tree
Showing 6 changed files with 139 additions and 5 deletions.
11 changes: 6 additions & 5 deletions doomsday/client/client.pro
Expand Up @@ -370,6 +370,7 @@ DENG_HEADERS += \
include/ui/widgets/listcontext.h \
include/ui/widgets/logwidget.h \
include/ui/widgets/menuwidget.h \
include/ui/widgets/messagedialog.h \
include/ui/widgets/notificationwidget.h \
include/ui/widgets/popupmenuwidget.h \
include/ui/widgets/popupwidget.h \
Expand All @@ -387,6 +388,9 @@ DENG_HEADERS += \
include/ui/windowsystem.h \
include/ui/zonedebug.h \
include/updater.h \
include/updater/downloaddialog.h \
include/updater/processcheckdialog.h \
include/updater/updateavailabledialog.h \
include/updater/updatersettings.h \
include/updater/updatersettingsdialog.h \
include/uri.hh \
Expand Down Expand Up @@ -429,10 +433,7 @@ DENG_HEADERS += \
include/world/surface.h \
include/world/thinkers.h \
include/world/vertex.h \
include/world/world.h \
src/updater/downloaddialog.h \
src/updater/processcheckdialog.h \
src/updater/updateavailabledialog.h
include/world/world.h

INCLUDEPATH += \
$$DENG_INCLUDE_DIR \
Expand Down Expand Up @@ -684,6 +685,7 @@ SOURCES += \
src/ui/widgets/listcontext.cpp \
src/ui/widgets/logwidget.cpp \
src/ui/widgets/menuwidget.cpp \
src/ui/widgets/messagedialog.cpp \
src/ui/widgets/notificationwidget.cpp \
src/ui/widgets/popupmenuwidget.cpp \
src/ui/widgets/popupwidget.cpp \
Expand All @@ -702,7 +704,6 @@ SOURCES += \
src/updater/processcheckdialog.cpp \
src/updater/updateavailabledialog.cpp \
src/updater/updater.cpp \
src/updater/updaterdialog.cpp \
src/updater/updatersettings.cpp \
src/updater/updatersettingsdialog.cpp \
src/uri.cpp \
Expand Down
46 changes: 46 additions & 0 deletions doomsday/client/include/ui/widgets/messagedialog.h
@@ -0,0 +1,46 @@
/** @file messagedialog.h Dialog for showing a message.
*
* @authors Copyright (c) 2013 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_MESSAGEDIALOG_H
#define DENG_CLIENT_MESSAGEDIALOG_H

#include "dialogwidget.h"

/**
* Dialog for showing a message.
*/
class MessageDialog : public DialogWidget
{
public:
MessageDialog(de::String const &name = "");

LabelWidget &title();
LabelWidget &message();

protected:
/**
* Derived classes should call this after they add or remove widgets in the
* dialog content area.
*/
void updateLayout();

private:
DENG2_PRIVATE(d)
};

#endif // DENG_CLIENT_MESSAGEDIALOG_H
87 changes: 87 additions & 0 deletions doomsday/client/src/ui/widgets/messagedialog.cpp
@@ -0,0 +1,87 @@
/** @file messagedialog.cpp Dialog for showing a message.
*
* @authors Copyright (c) 2013 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/widgets/messagedialog.h"
#include "ui/widgets/sequentiallayout.h"

using namespace de;
using namespace ui;

DENG2_PIMPL(MessageDialog)
{
LabelWidget *title;
LabelWidget *message;

Instance(Public *i) : Base(i)
{
ScrollAreaWidget &area = self.area();

// Create widgets.
area.add(title = new LabelWidget);
area.add(message = new LabelWidget);

// Configure style.
title->setFont("title");
title->setTextColor("accent");
title->setSizePolicy(ui::Fixed, ui::Expand);
title->setAlignment(ui::AlignLeft);
title->setTextLineAlignment(ui::AlignLeft);
message->setSizePolicy(ui::Fixed, ui::Expand);
message->setAlignment(ui::AlignLeft);
message->setTextLineAlignment(ui::AlignLeft);

updateLayout();
}

void updateLayout()
{
ScrollAreaWidget &area = self.area();

// Simple vertical layout.
SequentialLayout layout(area.contentRule().left(),
area.contentRule().top());
layout.setOverrideWidth(self.style().rules().rule("dialog.message.width"));

// Put all the widgets into the layout.
foreach(Widget *w, area.childWidgets())
{
layout << w->as<GuiWidget>();
}

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

MessageDialog::MessageDialog(String const &name)
: DialogWidget(name), d(new Instance(this))
{}

LabelWidget &MessageDialog::title()
{
return *d->title;
}

LabelWidget &MessageDialog::message()
{
return *d->message;
}

void MessageDialog::updateLayout()
{
d->updateLayout();
}

0 comments on commit 8be9b35

Please sign in to comment.