Skip to content

Commit

Permalink
Shell: Continued revising the Shell
Browse files Browse the repository at this point in the history
  • Loading branch information
skyjake committed Sep 1, 2019
1 parent 50ef7ac commit ddd248d
Show file tree
Hide file tree
Showing 12 changed files with 472 additions and 452 deletions.
11 changes: 0 additions & 11 deletions doomsday/libs/gui/include/de/gui/basewindow.h
Expand Up @@ -93,20 +93,9 @@ class LIBGUI_PUBLIC BaseWindow : public LIBAPPFW_BASEWINDOW_SUPER
#endif

protected:
/*
* Called when a draw request has been received. This method should carry out any
* preparations necessary before the frame can be drawn. It can also cancel the
* frame is needed.
*
* @return @c true to continue drawing the frame, @c false to abort the frame.
*/
// virtual bool prepareForDraw();

virtual void preDraw();
virtual void postDraw();

// virtual bool handleFallbackEvent(Event const &event) = 0;

private:
DE_PRIVATE(d)
};
Expand Down
60 changes: 29 additions & 31 deletions doomsday/tools/shell/src/aboutdialog.cpp
@@ -1,42 +1,40 @@
#include "aboutdialog.h"
#include "guishellapp.h"
#include "utils.h"
#include <QLabel>
#include <QDialogButtonBox>
#include <QVBoxLayout>
#include <QPushButton>
//#include "utils.h"
//#include <QLabel>
//#include <QDialogButtonBox>
//#include <QVBoxLayout>
//#include <QPushButton>

AboutDialog::AboutDialog(QWidget *parent)
: QDialog(parent)
AboutDialog::AboutDialog()
{
setWindowTitle(tr("About Doomsday Shell"));
setWindowFlags(windowFlags() & ~Qt::WindowContextHelpButtonHint);
title().setText("Doomsday Shell");

QVBoxLayout *box = new QVBoxLayout;
setLayout(box);
box->setSizeConstraint(QLayout::SetFixedSize);
// QVBoxLayout *box = new QVBoxLayout;
// setLayout(box);
// box->setSizeConstraint(QLayout::SetFixedSize);

QImage logo(imageResourcePath(":/images/shell.png"));
// QImage logo(imageResourcePath(":/images/shell.png"));

QLabel *img = new QLabel;
img->setPixmap(QPixmap::fromImage(logo));
box->addWidget(img, 0, Qt::AlignHCenter);
// QLabel *img = new QLabel;
// img->setPixmap(QPixmap::fromImage(logo));
// box->addWidget(img, 0, Qt::AlignHCenter);

QLabel *txt = new QLabel;
box->addWidget(txt);
txt->setMaximumWidth(logo.width() * 1.5f);
txt->setTextFormat(Qt::RichText);
txt->setWordWrap(true);
txt->setText(tr("<b><big>Doomsday Shell %1</big></b><p>Copyright &copy; %2<p>"
"The Shell is a utility for controlling and monitoring "
"Doomsday servers.")
.arg(SHELL_VERSION)
.arg("2013-2018 <a href=\"http://dengine.net/\">Deng Team</a>"));
// QLabel *txt = new QLabel;
// box->addWidget(txt);
// txt->setMaximumWidth(logo.width() * 1.5f);
// txt->setTextFormat(Qt::RichText);
// txt->setWordWrap(true);
// txt->setText(tr("<b><big>Doomsday Shell %1</big></b><p>Copyright &copy; %2<p>"
// "The Shell is a utility for controlling and monitoring "
// "Doomsday servers.")
// .arg(SHELL_VERSION)
// .arg("2013-2018 <a href=\"http://dengine.net/\">Deng Team</a>"));

connect(txt, SIGNAL(linkActivated(QString)), &GuiShellApp::app(), SLOT(openWebAddress(QString)));
// connect(txt, SIGNAL(linkActivated(QString)), &GuiShellApp::app(), SLOT(openWebAddress(QString)));

QDialogButtonBox *bbox = new QDialogButtonBox;
box->addWidget(bbox);
QPushButton *button = bbox->addButton(QDialogButtonBox::Close);
connect(button, SIGNAL(clicked()), this, SLOT(accept()));
// QDialogButtonBox *bbox = new QDialogButtonBox;
// box->addWidget(bbox);
// QPushButton *button = bbox->addButton(QDialogButtonBox::Close);
// connect(button, SIGNAL(clicked()), this, SLOT(accept()));
}
4 changes: 2 additions & 2 deletions doomsday/tools/shell/src/aboutdialog.h
@@ -1,9 +1,9 @@
#ifndef ABOUTDIALOG_H
#define ABOUTDIALOG_H

#include <de/DialogWidget>
#include <de/MessageDialog>

class AboutDialog : public de::DialogWidget
class AboutDialog : public de::MessageDialog
{
public:
explicit AboutDialog();
Expand Down
57 changes: 28 additions & 29 deletions doomsday/tools/shell/src/errorlogdialog.cpp
@@ -1,54 +1,53 @@
#include "errorlogdialog.h"
#include "preferences.h"
#include <QLabel>
#include <QDialogButtonBox>
#include <QTextEdit>
#include <QVBoxLayout>
//#include <QLabel>
//#include <QDialogButtonBox>
//#include <QTextEdit>
//#include <QVBoxLayout>

using namespace de;

DE_PIMPL(ErrorLogDialog)
{
QLabel *msg;
QTextEdit *text;
// QLabel *msg;
// QTextEdit *text;

Impl(Public *i) : Base(i)
{
QVBoxLayout *layout = new QVBoxLayout;
// QVBoxLayout *layout = new QVBoxLayout;

msg = new QLabel;
layout->addWidget(msg, 0);
// msg = new QLabel;
// layout->addWidget(msg, 0);

text = new QTextEdit;
text->setReadOnly(true);
text->setFont(Preferences::consoleFont());
QFontMetrics metrics(text->font());
text->setMinimumWidth(metrics.width("A") * 120);
text->setMinimumHeight(metrics.height() * 15);
layout->addWidget(text, 1);
// text = new QTextEdit;
// text->setReadOnly(true);
// text->setFont(Preferences::consoleFont());
// QFontMetrics metrics(text->font());
// text->setMinimumWidth(metrics.width("A") * 120);
// text->setMinimumHeight(metrics.height() * 15);
// layout->addWidget(text, 1);

QDialogButtonBox *buttons = new QDialogButtonBox;
buttons->addButton(QDialogButtonBox::Ok);
QObject::connect(buttons, SIGNAL(accepted()), thisPublic, SLOT(accept()));
layout->addWidget(buttons, 0);
// QDialogButtonBox *buttons = new QDialogButtonBox;
// buttons->addButton(QDialogButtonBox::Ok);
// QObject::connect(buttons, SIGNAL(accepted()), thisPublic, SLOT(accept()));
// layout->addWidget(buttons, 0);

self().setLayout(layout);
// self().setLayout(layout);
}
};

ErrorLogDialog::ErrorLogDialog(QWidget *parent) : QDialog(parent),
d(new Impl(this))
ErrorLogDialog::ErrorLogDialog()
: d(new Impl(this))
{
setWindowTitle(tr("Error Log"));
setWindowFlags(windowFlags() & ~Qt::WindowContextHelpButtonHint);
title().setText("Error Log");
}

void ErrorLogDialog::setMessage(QString const &message)
void ErrorLogDialog::setMessage(const String &messageText)
{
d->msg->setText(message);
message().setText(messageText);
}

void ErrorLogDialog::setLogContent(QString const &text)
void ErrorLogDialog::setLogContent(const String &text)
{
d->text->setText(text);
//d->text->setText(text);
}
30 changes: 20 additions & 10 deletions doomsday/tools/shell/src/guishellapp.cpp
Expand Up @@ -17,15 +17,18 @@
*/

#include "guishellapp.h"
#include "linkwindow.h"
#include "opendialog.h"

#include "aboutdialog.h"
#include "linkwindow.h"
#include "localserverdialog.h"
#include "opendialog.h"
#include "preferences.h"
#include "shellwindowsystem.h"
//#include "utils.h"
#include <de/EscapeParser>
#include <de/Id>
#include <de/comms/LocalServer>
#include <de/comms/ServerFinder>
#include <de/EscapeParser>
//#include <QMenuBar>
//#include <QMessageBox>
//#include <QUrl>
Expand All @@ -40,6 +43,7 @@ using namespace de::shell;

DE_PIMPL_NOREF(GuiShellApp)
{
std::unique_ptr<ShellWindowSystem> winSys;
ServerFinder finder;

// QMenuBar *menuBar;
Expand Down Expand Up @@ -124,7 +128,13 @@ GuiShellApp::GuiShellApp(const StringList &args)
// connect(&d->localCheckTimer, SIGNAL(timeout()), this, SLOT(checkLocalServers()));
// d->localCheckTimer.start();

newOrReusedConnectionWindow();
// newOrReusedConnectionWindow();
}

void GuiShellApp::initSubsystems(App::SubsystemInitFlags flags)
{
BaseGuiApp::initSubsystems(flags);
d->winSys.reset(new ShellWindowSystem);
}

LinkWindow *GuiShellApp::newOrReusedConnectionWindow()
Expand All @@ -146,19 +156,19 @@ LinkWindow *GuiShellApp::newOrReusedConnectionWindow()
// if (!other) other = win;
// }

// if (!found)
// {
// found = new LinkWindow;
if (!found)
{
found = d->winSys->newWindow<LinkWindow>(Stringf("link%04u", Id().asUInt32()));
// connect(found, SIGNAL(linkOpened(LinkWindow*)),this, SLOT(updateMenu()));
// connect(found, SIGNAL(linkClosed(LinkWindow*)), this, SLOT(updateMenu()));
// connect(found, SIGNAL(closed(LinkWindow *)), this, SLOT(windowClosed(LinkWindow *)));

// // Initial position and size.
// Initial position and size.
// if (other)
// {
// found->move(other->pos() + QPoint(30, 30));
// }
// }
}

// d->windows.prepend(found);
// found->show();
Expand Down Expand Up @@ -314,7 +324,7 @@ void GuiShellApp::showHelp()
// QDesktopServices::openUrl(QUrl(tr("http://wiki.dengine.net/w/Shell_Help")));
}

void GuiShellApp::openWebAddress(const QString& url)
void GuiShellApp::openWebAddress(const String &url)
{
// QDesktopServices::openUrl(QUrl(url));
}
Expand Down
2 changes: 2 additions & 0 deletions doomsday/tools/shell/src/guishellapp.h
Expand Up @@ -30,6 +30,8 @@ class GuiShellApp : public de::BaseGuiApp
public:
GuiShellApp(const de::StringList &args);

void initSubsystems(SubsystemInitFlags flags = DefaultSubsystems) override;

LinkWindow *newOrReusedConnectionWindow();
de::shell::ServerFinder &serverFinder();

Expand Down
16 changes: 14 additions & 2 deletions doomsday/tools/shell/src/linkwindow.cpp
Expand Up @@ -255,8 +255,8 @@ DE_PIMPL(LinkWindow)
}
};

LinkWindow::LinkWindow()
: BaseWindow(Stringf("link-%p", this))
LinkWindow::LinkWindow(const String &id)
: BaseWindow(id)
, d(new Impl(*this))
{
#if 0
Expand Down Expand Up @@ -396,6 +396,18 @@ GuiRootWidget &LinkWindow::root()
return d->root;
}

de::Vec2f LinkWindow::windowContentSize() const
{
// Current root widget size.
return d->root.viewRule().size();
}

void LinkWindow::drawWindowContent()
{
GLState::current().target().clear(GLFramebuffer::ColorDepth);
d->root.draw();
}

//void LinkWindow::setTitle(const QString &title)
//{
// setWindowTitle(title + " - " + tr("Doomsday Shell"));
Expand Down
13 changes: 8 additions & 5 deletions doomsday/tools/shell/src/linkwindow.h
Expand Up @@ -31,11 +31,14 @@
class LinkWindow : public de::BaseWindow
{
public:
LinkWindow();
LinkWindow(const de::String &id);

de::GuiRootWidget &root();

// void setTitle(QString const &title);
de::Vec2f windowContentSize() const override;
void drawWindowContent() override;

// void setTitle(QString const &title);

bool isConnected() const;

Expand All @@ -44,9 +47,9 @@ class LinkWindow : public de::BaseWindow
// void closeEvent(QCloseEvent *);

//signals:
void linkOpened(LinkWindow *window);
void linkClosed(LinkWindow *window);
void closed(LinkWindow *window);
// void linkOpened(LinkWindow *window);
// void linkClosed(LinkWindow *window);
// void closed(LinkWindow *window);

void openConnection(const de::String &address);
void waitForLocalConnection(de::duint16 localPort, de::NativePath const &errorLogPath, const de::String &name);
Expand Down
5 changes: 3 additions & 2 deletions doomsday/tools/shell/src/main.cpp
Expand Up @@ -17,7 +17,7 @@
*/

#include "guishellapp.h"
#include <de/libcore.h>
#include "linkwindow.h"

using namespace de;

Expand All @@ -27,8 +27,9 @@ int main(int argc, char *argv[])
init_Foundation();
try
{
GuiShellApp app({argv, argv + argc});
GuiShellApp app(makeList(argc, argv));
app.initSubsystems();
app.newOrReusedConnectionWindow()->show();
result = app.exec();
}
catch (const Error &er)
Expand Down

0 comments on commit ddd248d

Please sign in to comment.