Skip to content

Commit

Permalink
Shell|GUI: Usability improvements
Browse files Browse the repository at this point in the history
More information in the Preferences dialog, current game status shown
in the status bar.

On Windows, tweaked menu item labels. "Disconnect" is disabled when
not connected.
  • Loading branch information
skyjake committed Mar 19, 2013
1 parent 01a6bb7 commit f8af717
Show file tree
Hide file tree
Showing 4 changed files with 50 additions and 6 deletions.
5 changes: 5 additions & 0 deletions doomsday/tools/shell/shell-gui/src/guishellapp.cpp
Expand Up @@ -277,6 +277,11 @@ void GuiShellApp::showHelp()
QDesktopServices::openUrl(QUrl(tr("http://dengine.net/dew/index.php?title=Shell_Help")));
}

void GuiShellApp::openWebAddress(QString url)
{
QDesktopServices::openUrl(QUrl(url));
}

void GuiShellApp::showPreferences()
{
if(!d->prefs)
Expand Down
1 change: 1 addition & 0 deletions doomsday/tools/shell/shell-gui/src/guishellapp.h
Expand Up @@ -49,6 +49,7 @@ public slots:
void updateLocalServerMenu();
void aboutShell();
void showHelp();
void openWebAddress(QString address);
void showPreferences();
void preferencesDone();
void updateMenu();
Expand Down
39 changes: 34 additions & 5 deletions doomsday/tools/shell/shell-gui/src/linkwindow.cpp
Expand Up @@ -39,6 +39,10 @@
#include <QLabel>
#include <QCryptographicHash>

#ifndef MACOSX
# define MENU_IN_LINK_WINDOW
#endif

using namespace de;
using namespace de::shell;

Expand Down Expand Up @@ -66,6 +70,9 @@ DENG2_PIMPL(LinkWindow)
QLabel *timeCounter;
QLabel *currentHost;
QAction *stopAction;
#ifdef MENU_IN_LINK_WINDOW
QAction *disconnectAction;
#endif

Instance(Public &i)
: Base(i),
Expand Down Expand Up @@ -133,6 +140,9 @@ DENG2_PIMPL(LinkWindow)
root->setOverlaidMessage(tr("Disconnected"));
self.statusBar()->clearMessage();
stopAction->setDisabled(true);
#ifdef MENU_IN_LINK_WINDOW
disconnectAction->setDisabled(true);
#endif

status->linkDisconnected();
updateCurrentHost();
Expand All @@ -154,6 +164,19 @@ DENG2_PIMPL(LinkWindow)
tools->addWidget(tb);
return tb;
}

void updateStatusBarWithGameState(de::Record &rec)
{
String gameMode = rec["mode"].value().asText();
String mapId = rec["mapId"].value().asText();
String rules = rec["rules"].value().asText();

String msg = gameMode;
if(!mapId.isEmpty()) msg += " " + mapId;
if(!rules.isEmpty()) msg += " (" + rules + ")";

self.statusBar()->showMessage(msg);
}
};

LinkWindow::LinkWindow(QWidget *parent)
Expand All @@ -169,20 +192,21 @@ LinkWindow::LinkWindow(QWidget *parent)
d->stopAction = new QAction(tr("S&top"), this);
connect(d->stopAction, SIGNAL(triggered()), app, SLOT(stopServer()));

#ifndef MACOSX
#ifdef MENU_IN_LINK_WINDOW
QMenu *fileMenu = menuBar()->addMenu(tr("&File"));
fileMenu->addAction(tr("&Settings..."), app, SLOT(showPreferences()));
fileMenu->addAction(tr("&Quit"), app, SLOT(quit()), QKeySequence(tr("Ctrl+Q")));
fileMenu->addAction(tr("E&xit"), app, SLOT(quit()), QKeySequence(tr("Ctrl+Q")));

// Menus are window-specific on non-Mac platforms.
QMenu *menu = menuBar()->addMenu(tr("&Connection"));
menu->addAction(tr("C&onnect..."), app, SLOT(connectToServer()),
QKeySequence(tr("Ctrl+O", "Connection|Connect")));
menu->addAction(tr("&Disconnect"), this, SLOT(closeConnection()),
QKeySequence(tr("Ctrl+D", "Connection|Disconnect")));
disconnectAction = menu->addAction(tr("&Disconnect"), this, SLOT(closeConnection()),
QKeySequence(tr("Ctrl+D", "Connection|Disconnect")));
disconnectAction->setDisabled(true);

QMenu *svMenu = menuBar()->addMenu(tr("&Server"));
svMenu->addAction(tr("&Start Local Server..."), app, SLOT(startLocalServer()),
svMenu->addAction(tr("Start &New Local Server..."), app, SLOT(startLocalServer()),
QKeySequence(tr("Ctrl+N", "Server|Start Local")));
svMenu->addAction(d->stopAction);
svMenu->addSeparator();
Expand Down Expand Up @@ -427,6 +451,8 @@ void LinkWindow::handleIncomingPackets()
rec["rules"].value().asText(),
rec["mapId"].value().asText(),
rec["mapTitle"].value().asText());

d->updateStatusBarWithGameState(rec);
break; }

case shell::Protocol::MapOutline:
Expand Down Expand Up @@ -471,6 +497,9 @@ void LinkWindow::connected()
statusBar()->clearMessage();
updateWhenConnected();
d->stopAction->setEnabled(true);
#ifdef MENU_IN_LINK_WINDOW
d->disconnectAction->setEnabled(true);
#endif

emit linkOpened(this);
}
Expand Down
11 changes: 10 additions & 1 deletion doomsday/tools/shell/shell-gui/src/preferences.cpp
@@ -1,5 +1,6 @@
#include "preferences.h"
#include "folderselection.h"
#include "guishellapp.h"
#include <de/libdeng2.h>
#include <QCheckBox>
#include <QFormLayout>
Expand Down Expand Up @@ -59,7 +60,7 @@ DENG2_PIMPL(Preferences)

updateFontDesc();

QGroupBox *group = new QGroupBox(tr("IWAD Folder"));
QGroupBox *group = new QGroupBox(tr("Game Data"));
mainLayout->addWidget(group);

useCustomIwad = new QCheckBox(tr("Use a custom IWAD folder"));
Expand All @@ -74,6 +75,14 @@ DENG2_PIMPL(Preferences)
QVBoxLayout *bl = new QVBoxLayout;
bl->addWidget(useCustomIwad);
bl->addWidget(iwadFolder);
QLabel *info = new QLabel("<small>" +
tr("Doomsday tries to locate game data such as "
"<a href=\"http://dengine.net/dew/index.php?title=IWAD_folder\">IWAD files</a> "
"automatically, but that may fail "
"if you have the files in a custom location.") + "</small>");
QObject::connect(info, SIGNAL(linkActivated(QString)), &GuiShellApp::app(), SLOT(openWebAddress(QString)));
info->setWordWrap(true);
bl->addWidget(info);
group->setLayout(bl);

mainLayout->addStretch(1);
Expand Down

0 comments on commit f8af717

Please sign in to comment.