From 4012e2f97f1782a9a7338fefab97a37895967305 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jaakko=20Kera=CC=88nen?= Date: Sat, 23 Jun 2018 21:07:11 +0300 Subject: [PATCH] Shell: Cleanup --- doomsday/tools/shell-text/src/aboutdialog.cpp | 6 +-- doomsday/tools/shell-text/src/aboutdialog.h | 4 +- doomsday/tools/shell-text/src/cursesapp.cpp | 4 +- .../shell-text/src/localserverdialog.cpp | 23 ++++---- .../tools/shell-text/src/localserverdialog.h | 4 +- .../shell-text/src/openconnectiondialog.cpp | 9 ++-- .../shell-text/src/openconnectiondialog.h | 6 +-- .../tools/shell-text/src/persistentdata.cpp | 53 ------------------- .../tools/shell-text/src/persistentdata.h | 44 --------------- doomsday/tools/shell-text/src/shellapp.cpp | 30 +++++------ .../tools/shell-text/src/statuswidget.cpp | 2 +- doomsday/tools/shell-text/src/statuswidget.h | 4 +- 12 files changed, 45 insertions(+), 144 deletions(-) delete mode 100644 doomsday/tools/shell-text/src/persistentdata.cpp delete mode 100644 doomsday/tools/shell-text/src/persistentdata.h diff --git a/doomsday/tools/shell-text/src/aboutdialog.cpp b/doomsday/tools/shell-text/src/aboutdialog.cpp index d93789a939..4ff5772564 100644 --- a/doomsday/tools/shell-text/src/aboutdialog.cpp +++ b/doomsday/tools/shell-text/src/aboutdialog.cpp @@ -17,14 +17,14 @@ */ #include "aboutdialog.h" -#include +#include using namespace de; using namespace de::shell; AboutDialog::AboutDialog() { - LabelTedget *label = new LabelTedget; + LabelWidget *label = new LabelWidget; label->setLabel(String::format("Doomsday Shell %s\nCopyright (c) %s\n\n" "The Shell is a utility for controlling and monitoring " "Doomsday servers using a text-based (curses) user interface.", @@ -48,5 +48,5 @@ bool AboutDialog::handleEvent(Event const &event) accept(); return true; } - return DialogTedget::handleEvent(event); + return DialogWidget::handleEvent(event); } diff --git a/doomsday/tools/shell-text/src/aboutdialog.h b/doomsday/tools/shell-text/src/aboutdialog.h index 088ab35479..f688ba7f03 100644 --- a/doomsday/tools/shell-text/src/aboutdialog.h +++ b/doomsday/tools/shell-text/src/aboutdialog.h @@ -19,12 +19,12 @@ #ifndef ABOUTDIALOG_H #define ABOUTDIALOG_H -#include +#include /** * Dialog for information about the program. */ -class AboutDialog : public de::shell::DialogTedget +class AboutDialog : public de::shell::DialogWidget { public: AboutDialog(); diff --git a/doomsday/tools/shell-text/src/cursesapp.cpp b/doomsday/tools/shell-text/src/cursesapp.cpp index 74c58a22cc..6b42c55197 100644 --- a/doomsday/tools/shell-text/src/cursesapp.cpp +++ b/doomsday/tools/shell-text/src/cursesapp.cpp @@ -26,7 +26,7 @@ #include #include #include -#include +#include #include #include #include @@ -333,7 +333,7 @@ DE_PIMPL(CursesApp) break; default: -#ifdef _DEBUG +#if defined (DE_DEBUG) if (key & KEY_CODE_YES) debug("CURSES 0x%x", key); else diff --git a/doomsday/tools/shell-text/src/localserverdialog.cpp b/doomsday/tools/shell-text/src/localserverdialog.cpp index f7e382c055..fab8d014f3 100644 --- a/doomsday/tools/shell-text/src/localserverdialog.cpp +++ b/doomsday/tools/shell-text/src/localserverdialog.cpp @@ -17,12 +17,11 @@ */ #include "localserverdialog.h" -#include "persistentdata.h" #include -#include -#include -#include -#include +#include +#include +#include +#include #include #include @@ -31,17 +30,17 @@ using namespace de::shell; DE_PIMPL_NOREF(LocalServerDialog) { - ChoiceTedget *choice; - LineEditTedget *port; + ChoiceWidget * choice; + LineEditWidget *port; }; LocalServerDialog::LocalServerDialog() : d(new Impl) { - add(d->choice = new ChoiceTedget ("gameMode")); - add(d->port = new LineEditTedget("serverPort")); + add(d->choice = new ChoiceWidget ("gameMode")); + add(d->port = new LineEditWidget("serverPort")); // Define the contents for the choice list. - ChoiceTedget::Items modes; + ChoiceWidget::Items modes; for (const DoomsdayInfo::Game &game : DoomsdayInfo::allGames()) { modes << game.title; @@ -100,14 +99,14 @@ String LocalServerDialog::gameMode() const void LocalServerDialog::prepare() { - InputDialogTedget::prepare(); + InputDialogWidget::prepare(); root().setFocus(d->choice); } void LocalServerDialog::finish(int result) { - InputDialogTedget::finish(result); + InputDialogWidget::finish(result); if (result) { diff --git a/doomsday/tools/shell-text/src/localserverdialog.h b/doomsday/tools/shell-text/src/localserverdialog.h index d5aee1e0f8..3690acf1a4 100644 --- a/doomsday/tools/shell-text/src/localserverdialog.h +++ b/doomsday/tools/shell-text/src/localserverdialog.h @@ -20,9 +20,9 @@ #define LOCALSERVERDIALOG_H #include -#include +#include -class LocalServerDialog : public de::shell::InputDialogTedget +class LocalServerDialog : public de::shell::InputDialogWidget { public: LocalServerDialog(); diff --git a/doomsday/tools/shell-text/src/openconnectiondialog.cpp b/doomsday/tools/shell-text/src/openconnectiondialog.cpp index 98624ac88e..59f120a813 100644 --- a/doomsday/tools/shell-text/src/openconnectiondialog.cpp +++ b/doomsday/tools/shell-text/src/openconnectiondialog.cpp @@ -17,13 +17,12 @@ */ #include "openconnectiondialog.h" -#include "persistentdata.h" -#include +#include #include using namespace de; -OpenConnectionDialog::OpenConnectionDialog(String const &name) : shell::InputDialogTedget(name) +OpenConnectionDialog::OpenConnectionDialog(String const &name) : shell::InputDialogWidget(name) { setDescription("Enter the address of the server you want to connect to. " "The address can be a domain name or an IP address. " @@ -37,14 +36,14 @@ OpenConnectionDialog::OpenConnectionDialog(String const &name) : shell::InputDia setAcceptLabel("Connect to server"); } -String OpenConnectionDialog::address() +String OpenConnectionDialog::address() const { return text(); } void OpenConnectionDialog::finish(int result) { - InputDialogTedget::finish(result); + InputDialogWidget::finish(result); if (result) { diff --git a/doomsday/tools/shell-text/src/openconnectiondialog.h b/doomsday/tools/shell-text/src/openconnectiondialog.h index e7ef676c43..1a29064550 100644 --- a/doomsday/tools/shell-text/src/openconnectiondialog.h +++ b/doomsday/tools/shell-text/src/openconnectiondialog.h @@ -19,12 +19,12 @@ #ifndef OPENCONNECTIONDIALOG_H #define OPENCONNECTIONDIALOG_H -#include +#include /** * Dialog for specifying address for opening a connection. */ -class OpenConnectionDialog : public de::shell::InputDialogTedget +class OpenConnectionDialog : public de::shell::InputDialogWidget { public: OpenConnectionDialog(de::String const &name = de::String()); @@ -33,7 +33,7 @@ class OpenConnectionDialog : public de::shell::InputDialogTedget * Returns the address that the user entered in the dialog. If the dialog * was rejected, the returned string is empy. */ - de::String address(); + de::String address() const; protected: void finish(int result); diff --git a/doomsday/tools/shell-text/src/persistentdata.cpp b/doomsday/tools/shell-text/src/persistentdata.cpp deleted file mode 100644 index 08ea8d0e3e..0000000000 --- a/doomsday/tools/shell-text/src/persistentdata.cpp +++ /dev/null @@ -1,53 +0,0 @@ -#if 0 -/** @file persistentdata.cpp Data that persists even after restarting the app. - * - * @authors Copyright © 2013-2017 Jaakko Keränen - * - * @par License - * GPL: http://www.gnu.org/licenses/gpl.html - * - * 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 - */ - -#include "persistentdata.h" - -using namespace de; - -PersistentData::PersistentData() -{} - -PersistentData::~PersistentData() -{} - -void PersistentData::set(String const &name, String const &value) -{ - QSettings st; - st.setValue(name, value); -} - -void PersistentData::set(String const &name, int value) -{ - QSettings st; - st.setValue(name, value); -} - -String PersistentData::get(String const &name, String const &defaultValue) -{ - QSettings st; - return st.value(name, defaultValue).toString(); -} - -int PersistentData::geti(String const &name, int defaultValue) -{ - QSettings st; - return st.value(name, defaultValue).toInt(); -} -#endif diff --git a/doomsday/tools/shell-text/src/persistentdata.h b/doomsday/tools/shell-text/src/persistentdata.h deleted file mode 100644 index 73948e98be..0000000000 --- a/doomsday/tools/shell-text/src/persistentdata.h +++ /dev/null @@ -1,44 +0,0 @@ -#if 0 -/** @file persistentdata.h Data that persists even after restarting the app. - * - * @authors Copyright © 2013-2017 Jaakko Keränen - * - * @par License - * GPL: http://www.gnu.org/licenses/gpl.html - * - * 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 - */ - -#ifndef PERSISTENTDATA_H -#define PERSISTENTDATA_H - -#include - -/** - * Data that persists even after restarting the app. - * - * A singleton class. - */ -class PersistentData -{ -public: - PersistentData(); - ~PersistentData(); - - static void set(de::String const &name, de::String const &value); - static void set(de::String const &name, int value); - - static de::String get(de::String const &name, de::String const &defaultValue = ""); - static int geti(de::String const &name, int defaultValue = 0); -}; - -#endif // PERSISTENTDATA_H -#endif diff --git a/doomsday/tools/shell-text/src/shellapp.cpp b/doomsday/tools/shell-text/src/shellapp.cpp index 2a02db464c..2460b1dc5c 100644 --- a/doomsday/tools/shell-text/src/shellapp.cpp +++ b/doomsday/tools/shell-text/src/shellapp.cpp @@ -22,10 +22,10 @@ #include "localserverdialog.h" #include "aboutdialog.h" -#include -#include -#include -#include +#include +#include +#include +#include #include #include #include @@ -41,12 +41,12 @@ using namespace de; using namespace shell; DE_PIMPL(ShellApp) -, DE_OBSERVES(CommandLineTedget, Command) +, DE_OBSERVES(CommandLineWidget, Command) { - MenuTedget * menu; - LogTedget * log; - CommandLineTedget *cli; - LabelTedget * menuLabel; + MenuWidget * menu; + LogWidget * log; + CommandLineWidget *cli; + LabelWidget * menuLabel; StatusWidget * status; Link * link = nullptr; ServerFinder finder; @@ -64,7 +64,7 @@ DE_PIMPL(ShellApp) .setInput(Rule::Left, root.viewLeft()); // Menu button at the left edge. - menuLabel = new LabelTedget; + menuLabel = new LabelWidget; menuLabel->setAlignment(AlignTop); menuLabel->setLabel(" F9:Menu "); menuLabel->setAttribs(TextCanvas::AttribChar::Bold); @@ -81,7 +81,7 @@ DE_PIMPL(ShellApp) menuLabel->addAction(new shell::Action(KeyEvent(Key::Cancel), [this](){ self().quit(); })); // Expanding command line widget. - cli = new CommandLineTedget; + cli = new CommandLineWidget; cli->rule() .setInput(Rule::Left, menuLabel->rule().right()) .setInput(Rule::Right, root.viewRight()) @@ -90,7 +90,7 @@ DE_PIMPL(ShellApp) menuLabel->rule().setInput(Rule::Top, cli->rule().top()); // Log history covers the rest of the view. - log = new LogTedget; + log = new LogWidget; log->rule() .setInput(Rule::Left, root.viewLeft()) .setInput(Rule::Width, root.viewWidth()) @@ -100,7 +100,7 @@ DE_PIMPL(ShellApp) log->addAction(new shell::Action(KeyEvent(Key::F5), [this]() { log->scrollToBottom(); })); // Main menu. - menu = new MenuTedget(MenuTedget::Popup); + menu = new MenuWidget(MenuWidget::Popup); menu->appendItem(new shell::Action("Connect to...", [this]() { self().askToOpenConnection(); })); menu->appendItem(new shell::Action("Disconnect", [this](){ self().closeConnection(); })); @@ -209,10 +209,10 @@ void ShellApp::closeConnection() void ShellApp::askForPassword() { - InputDialogTedget dlg; + InputDialogWidget dlg; dlg.setDescription("The server requires a password."); dlg.setPrompt("Password: "); - dlg.lineEdit().setEchoMode(LineEditTedget::PasswordEchoMode); + dlg.lineEdit().setEchoMode(LineEditWidget::PasswordEchoMode); dlg.lineEdit().setSignalOnEnter(false); if (dlg.exec(rootWidget())) diff --git a/doomsday/tools/shell-text/src/statuswidget.cpp b/doomsday/tools/shell-text/src/statuswidget.cpp index 1fca573d2f..70fd12cc4c 100644 --- a/doomsday/tools/shell-text/src/statuswidget.cpp +++ b/doomsday/tools/shell-text/src/statuswidget.cpp @@ -55,7 +55,7 @@ DE_PIMPL(StatusWidget) }; StatusWidget::StatusWidget(String const &name) - : Tedget(name), d(new Impl(*this)) + : Widget(name), d(new Impl(*this)) { d->updateTimer.audienceForTrigger() += [this]() { d->refresh(); }; } diff --git a/doomsday/tools/shell-text/src/statuswidget.h b/doomsday/tools/shell-text/src/statuswidget.h index 6995fc5761..ace931c67d 100644 --- a/doomsday/tools/shell-text/src/statuswidget.h +++ b/doomsday/tools/shell-text/src/statuswidget.h @@ -19,10 +19,10 @@ #ifndef STATUSWIDGET_H #define STATUSWIDGET_H -#include +#include #include -class StatusWidget : public de::shell::Tedget +class StatusWidget : public de::shell::Widget { public: StatusWidget(de::String const &name = de::String());