Skip to content

Commit

Permalink
Shell: Added an About dialog
Browse files Browse the repository at this point in the history
  • Loading branch information
skyjake committed Feb 2, 2013
1 parent 9adf75e commit e2c6ca6
Show file tree
Hide file tree
Showing 5 changed files with 109 additions and 10 deletions.
8 changes: 6 additions & 2 deletions doomsday/tools/shell/shell-text/shell-text.pro
Expand Up @@ -15,6 +15,8 @@ VERSION = 1.0.0

CONFIG -= app_bundle

DEFINES += LIBSHELL_VERSION=\\\"$$VERSION\\\"

include(../../../dep_deng2.pri)
include(../../../dep_shell.pri)
include(../../../dep_curses.pri)
Expand All @@ -29,7 +31,8 @@ HEADERS += \
src/main.h \
src/shellapp.h \
src/statuswidget.h \
src/openconnectiondialog.h
src/openconnectiondialog.h \
src/aboutdialog.h

SOURCES += \
src/commandlinewidget.cpp \
Expand All @@ -39,7 +42,8 @@ SOURCES += \
src/main.cpp \
src/shellapp.cpp \
src/statuswidget.cpp \
src/openconnectiondialog.cpp
src/openconnectiondialog.cpp \
src/aboutdialog.cpp

# Installation --------------------------------------------------------------

Expand Down
53 changes: 53 additions & 0 deletions doomsday/tools/shell/shell-text/src/aboutdialog.cpp
@@ -0,0 +1,53 @@
/** @file aboutdialog.cpp Dialog for information about the program.
*
* @authors Copyright © 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 "aboutdialog.h"
#include <de/shell/LabelWidget>

using namespace de;
using namespace de::shell;

AboutDialog::AboutDialog()
{
LabelWidget *label = new LabelWidget;
label->setLabel(tr("Doomsday Shell %1\nCopyright (c) %2\n\n"
"The Shell is a utility for controlling and monitoring "
"Doomsday servers using a text-based (curses) user interface.")
.arg(LIBSHELL_VERSION)
.arg("2013 Deng Team"));

label->setExpandsToFitLines(true);
label->rule()
.setLeftTop(rule().left(), rule().top())
.setInput(RuleRectangle::Width, rule().width());

add(label);

rule().setSize(Const(40), label->rule().height());
}

bool AboutDialog::handleEvent(Event const *event)
{
if(event->type() == Event::KeyPress)
{
accept();
return true;
}

return DialogWidget::handleEvent(event);
}
35 changes: 35 additions & 0 deletions doomsday/tools/shell/shell-text/src/aboutdialog.h
@@ -0,0 +1,35 @@
/** @file aboutdialog.h Dialog for information about the program.
*
* @authors Copyright © 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 ABOUTDIALOG_H
#define ABOUTDIALOG_H

#include <de/shell/DialogWidget>

/**
* Dialog for information about the program.
*/
class AboutDialog : public de::shell::DialogWidget
{
public:
AboutDialog();

bool handleEvent(de::Event const *event);
};

#endif // ABOUTDIALOG_H
22 changes: 14 additions & 8 deletions doomsday/tools/shell/shell-text/src/shellapp.cpp
Expand Up @@ -21,6 +21,7 @@
#include "commandlinewidget.h"
#include "statuswidget.h"
#include "openconnectiondialog.h"
#include "aboutdialog.h"
#include <de/shell/LabelWidget>
#include <de/shell/MenuWidget>
#include <de/shell/Link>
Expand Down Expand Up @@ -94,7 +95,7 @@ struct ShellApp::Instance
menu->appendSeparator();
menu->appendItem(new Action(tr("Start new server")));
menu->appendSeparator();
menu->appendItem(new Action(tr("About")));
menu->appendItem(new Action(tr("About"), &self, SLOT(showAbout())));
menu->appendItem(new Action(tr("Quit Shell"),
KeyEvent(Qt::Key_X, KeyEvent::Control),
&self, SLOT(quit())), "Ctrl-X");
Expand Down Expand Up @@ -157,14 +158,9 @@ void ShellApp::openConnection(String const &address)
connect(d->link, SIGNAL(disconnected()), this, SLOT(disconnected()));
}

void ShellApp::askToOpenConnection()
void ShellApp::showAbout()
{
OpenConnectionDialog dlg;
dlg.exec(rootWidget());
if(!dlg.address().isEmpty())
{
openConnection(dlg.address());
}
AboutDialog().exec(rootWidget());
}

void ShellApp::closeConnection()
Expand All @@ -182,6 +178,16 @@ void ShellApp::closeConnection()
}
}

void ShellApp::askToOpenConnection()
{
OpenConnectionDialog dlg;
dlg.exec(rootWidget());
if(!dlg.address().isEmpty())
{
openConnection(dlg.address());
}
}

void ShellApp::sendCommandToServer(String command)
{
if(d->link)
Expand Down
1 change: 1 addition & 0 deletions doomsday/tools/shell/shell-text/src/shellapp.h
Expand Up @@ -34,6 +34,7 @@ class ShellApp : public CursesApp
void openConnection(de::String const &address);

public slots:
void showAbout();
void askToOpenConnection();
void closeConnection();
void sendCommandToServer(de::String command);
Expand Down

0 comments on commit e2c6ca6

Please sign in to comment.