diff --git a/doomsday/apps/client/include/clientapp.h b/doomsday/apps/client/include/clientapp.h index 087613b672..bff900d383 100644 --- a/doomsday/apps/client/include/clientapp.h +++ b/doomsday/apps/client/include/clientapp.h @@ -46,7 +46,7 @@ class BusyRunner; class ClientApp : public de::BaseGuiApp, public DoomsdayApp { public: - ClientApp(int &argc, char **argv); + ClientApp(const de::StringList &args); /** * Sets up all the subsystems of the application. Must be called before the diff --git a/doomsday/apps/client/include/network/serverlink.h b/doomsday/apps/client/include/network/serverlink.h index 2a189d42a8..03509bd046 100644 --- a/doomsday/apps/client/include/network/serverlink.h +++ b/doomsday/apps/client/include/network/serverlink.h @@ -35,15 +35,13 @@ class ServerLink : public de::shell::AbstractLink { public: - DE_DEFINE_AUDIENCE2(DiscoveryUpdate, void linkDiscoveryUpdate(ServerLink const &link)) - DE_DEFINE_AUDIENCE2(PingResponse, void pingResponse(de::Address const &, de::TimeSpan)) - DE_DEFINE_AUDIENCE2(MapOutline, void mapOutlineReceived(de::Address const &, de::shell::MapOutlinePacket const &)) + DE_DEFINE_AUDIENCE2(Discovery, void serversDiscovered(const ServerLink &link)) + DE_DEFINE_AUDIENCE2(PingResponse, void pingResponse(de::Address const &, de::TimeSpan)) + DE_DEFINE_AUDIENCE2(MapOutline, void mapOutlineReceived(de::Address const &, de::shell::MapOutlinePacket const &)) DE_DEFINE_AUDIENCE2(Join, void networkGameJoined()) DE_DEFINE_AUDIENCE2(Leave, void networkGameLeft()) - DE_DEFINE_AUDIENCE2(Discovery, void serversDiscovered()) - enum Flag { DiscoverLocalServers = 0x1, ManualConnectionOnly = 0, diff --git a/doomsday/apps/client/src/clientapp.cpp b/doomsday/apps/client/src/clientapp.cpp index 128e6420f7..38b82f60b7 100644 --- a/doomsday/apps/client/src/clientapp.cpp +++ b/doomsday/apps/client/src/clientapp.cpp @@ -19,7 +19,6 @@ #include "de_platform.h" -#include //#include //#include //#include @@ -28,29 +27,6 @@ //#include //#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include - #include "audio/audiosystem.h" #include "busyrunner.h" #include "clientapp.h" @@ -97,15 +73,39 @@ # include "dd_uinit.h" #endif +#include +#include +#include + #include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include -#include "ui/splash.xpm" +#include + +//#include "ui/splash.xpm" using namespace de; static ClientApp *clientAppSingleton = 0; -static void handleLegacyCoreTerminate(char const *msg) +DE_NORETURN static void handleLegacyCoreTerminate(char const *msg) { App_Error("Application terminated due to exception:\n%s\n", msg); } @@ -134,7 +134,7 @@ static Value *Function_App_GamePlugin(Context &, Function::ArgumentValues const } String name = DoomsdayApp::plugins().fileForPlugin(App_CurrentGame().pluginId()) .name().fileNameWithoutExtension(); - if (name.beginsWith("lib")) name.remove(0, 3); + if (name.beginsWith("lib")) name.remove(BytePos(0), 3); return new TextValue(name); } @@ -216,7 +216,7 @@ DE_PIMPL(ClientApp) } } - for (String msg : formatter.logEntryToTextLines(entry)) + for (const String &msg : formatter.logEntryToTextLines(entry)) { ClientApp::alert(msg, entry.level()); } @@ -269,7 +269,7 @@ DE_PIMPL(ClientApp) } catch (Error const &er) { - qWarning() << "Exception during ~ClientApp:" << er.asText(); + warning("Exception during ~ClientApp: %s", er.asText().c_str()); DE_ASSERT_FAIL("Unclean shutdown: exception in ~ClientApp"); } @@ -414,7 +414,7 @@ DE_PIMPL(ClientApp) Con_Executef(CMDS_DDAY, false, "setdefaultskill %i; setmap %s", prof->autoStartSkill(), - prof->autoStartMap()); + prof->autoStartMap().c_str()); } } } @@ -447,9 +447,9 @@ DE_PIMPL(ClientApp) { String const name = LogFilter::domainRecordName(LogEntry::Context(1 << i)); logSettings - .define(Prof::ConfigVariable, String("log.filter.%1.minLevel").arg(name)) - .define(Prof::ConfigVariable, String("log.filter.%1.allowDev").arg(name)) - .define(Prof::ConfigVariable, String("alert.%1").arg(name)); + .define(Prof::ConfigVariable, String::format("log.filter.%s.minLevel", name.c_str())) + .define(Prof::ConfigVariable, String::format("log.filter.%s.allowDev", name.c_str())) + .define(Prof::ConfigVariable, "alert." + name); } uiSettings @@ -471,19 +471,19 @@ DE_PIMPL(ClientApp) networkSettings .define(Prof::ConfigVariable, "apiUrl") .define(Prof::ConfigVariable, "resource.localPackages") - .define(Prof::IntCVar, "net-dev", 0); + .define(Prof::IntCVar, "net-dev", NumberValue::zero); audioSettings - .define(Prof::IntCVar, "sound-volume", 255 * 2/3) - .define(Prof::IntCVar, "music-volume", 255 * 2/3) - .define(Prof::FloatCVar, "sound-reverb-volume", 0.5f) - .define(Prof::IntCVar, "sound-info", 0) + .define(Prof::IntCVar, "sound-volume", NumberValue(255 * 2/3)) + .define(Prof::IntCVar, "music-volume", NumberValue(255 * 2/3)) + .define(Prof::FloatCVar, "sound-reverb-volume", NumberValue(0.5f)) + .define(Prof::IntCVar, "sound-info", NumberValue::zero) //.define(Prof::IntCVar, "sound-rate", 11025) //.define(Prof::IntCVar, "sound-16bit", 0) - .define(Prof::IntCVar, "sound-3d", 0) - .define(Prof::IntCVar, "sound-overlap-stop", 0) - .define(Prof::IntCVar, "music-source", AudioSystem::MUSP_EXT) - .define(Prof::StringCVar, "music-soundfont", "") + .define(Prof::IntCVar, "sound-3d", NumberValue::zero) + .define(Prof::IntCVar, "sound-overlap-stop", NumberValue::zero) + .define(Prof::IntCVar, "music-source", NumberValue(AudioSystem::MUSP_EXT)) + .define(Prof::StringCVar, "music-soundfont", TextValue()) .define(Prof::ConfigVariable, "audio.soundPlugin") .define(Prof::ConfigVariable, "audio.musicPlugin") .define(Prof::ConfigVariable, "audio.cdPlugin") @@ -493,13 +493,7 @@ DE_PIMPL(ClientApp) } #ifdef UNIX - void printVersionToStdOut() - { - printf("%s\n", String("%1 %2") - .arg(DOOMSDAY_NICENAME) - .arg(DOOMSDAY_VERSION_FULLTEXT) - .toLatin1().constData()); - } + void printVersionToStdOut() { printf("%s %s\n", DOOMSDAY_NICENAME, DOOMSDAY_VERSION_FULLTEXT); } void printHelpToStdOut() { @@ -518,24 +512,24 @@ DE_PIMPL(ClientApp) String mapClientStatePath(String const &mapId) const { - return String("maps/%1ClientState").arg(mapId); + return String::format("maps/%sClientState", mapId.c_str()); } String mapObjectStatePath(String const &mapId) const { - return String("maps/%1ObjectState").arg(mapId); + return String::format("maps/%sObjectState", mapId.c_str()); } }; -ClientApp::ClientApp(int &argc, char **argv) - : BaseGuiApp(argc, argv) +ClientApp::ClientApp(const StringList &args) + : BaseGuiApp(args) , DoomsdayApp([] () -> Player * { return new ClientPlayer; }) , d(new Impl(this)) { novideo = false; // Use the host system's proxy configuration. - QNetworkProxyFactory::setUseSystemConfiguration(true); +// QNetworkProxyFactory::setUseSystemConfiguration(true); // Metadata. setMetadata("Deng Team", "dengine.net", "Doomsday Engine", DOOMSDAY_VERSION_BASE); @@ -551,7 +545,7 @@ ClientApp::ClientApp(int &argc, char **argv) << DE_FUNC_NOARG (App_GamePlugin, "gamePlugin") << DE_FUNC_NOARG (App_Quit, "quit"); -#if !defined (DE_MOBILE) +/*#if !defined (DE_MOBILE) /// @todo Remove the splash screen when file system indexing can be done as /// a background task and the main window can be opened instantly. -jk QPixmap const pixmap(doomsdaySplashXpm); @@ -562,7 +556,7 @@ ClientApp::ClientApp(int &argc, char **argv) QColor(90, 110, 95)); processEvents(); splash->deleteLater(); -#endif +#endif*/ } void ClientApp::initialize() @@ -708,9 +702,9 @@ void ClientApp::postFrame() Garbage_Recycle(); } -void ClientApp::checkPackageCompatibility(StringList const &packageIds, - String const &userMessageIfIncompatible, - std::function finalizeFunc) +void ClientApp::checkPackageCompatibility(const StringList &packageIds, + const String &userMessageIfIncompatible, + const std::function& finalizeFunc) { if (packageIds.isEmpty() || // Metadata did not specify packages. GameProfiles::arePackageListsCompatible(packageIds, loadedPackagesAffectingGameplay())) @@ -859,7 +853,7 @@ ClientApp &ClientApp::app() #if defined (DE_HAVE_UPDATER) Updater &ClientApp::updater() { - DE_ASSERT(!app().d->updater.isNull()); + DE_ASSERT(app().d->updater); return *app().d->updater; } #endif diff --git a/doomsday/apps/client/src/main_client.cpp b/doomsday/apps/client/src/main_client.cpp index 4bf8a3b3b6..3da59eea9b 100644 --- a/doomsday/apps/client/src/main_client.cpp +++ b/doomsday/apps/client/src/main_client.cpp @@ -94,7 +94,7 @@ int main(int argc, char **argv) { // ClientApp::setDefaultOpenGLFormat(); - ClientApp clientApp(argc, argv); + ClientApp clientApp(makeList(argc, argv)); /** * @todo Translations are presently disabled because lupdate can't seem to diff --git a/doomsday/apps/client/src/network/serverlink.cpp b/doomsday/apps/client/src/network/serverlink.cpp index c59773cc88..a4ec984e47 100644 --- a/doomsday/apps/client/src/network/serverlink.cpp +++ b/doomsday/apps/client/src/network/serverlink.cpp @@ -36,25 +36,23 @@ #include #include #include +#include #include #include #include #include #include #include +#include #include #include #include #include #include -#include -#include - using namespace de; -enum LinkState -{ +enum LinkState { None, Discovering, Pinging, @@ -73,11 +71,11 @@ DE_PIMPL(ServerLink) std::unique_ptr finder; ///< Finding local servers. LinkState state; bool fetching; - typedef QMap Servers; + typedef Map Servers; Servers discovered; Servers fromMaster; - QElapsedTimer pingTimer; - QList pings; + ElapsedTimer pingTimer; + List pings; int pingCounter; std::unique_ptr serverProfile; ///< Profile used when joining. std::function profileResultCallback; @@ -98,8 +96,7 @@ DE_PIMPL(ServerLink) void notifyDiscoveryUpdate() { - DE_FOR_PUBLIC_AUDIENCE2(DiscoveryUpdate, i) i->linkDiscoveryUpdate(self()); - emit self().serversDiscovered(); + DE_FOR_PUBLIC_AUDIENCE2(Discovery, i) i->serversDiscovered(self()); } bool handleInfoResponse(Block const &reply) @@ -109,29 +106,29 @@ DE_PIMPL(ServerLink) // Address of the server where the info was received. Address svAddress = self().address(); - // Local addresses are all represented as "localhost". - if (svAddress.isLocal()) svAddress.setHost(QHostAddress::LocalHost); +// Local addresses are all represented as "localhost". +// if (svAddress.isLocal()) svAddress.setHost(QHostAddress::LocalHost); // Close the connection; that was all the information we need. self().disconnect(); // Did we receive what we expected to receive? - if (reply.size() >= 5 && reply.startsWith("Info\n")) + if (reply.size() >= 5 && reply.beginsWith("Info\n")) { try { - QVariant const response = parseJSON(String::fromUtf8(reply.mid(5))); - std::unique_ptr rec(Value::constructFrom(response.toMap())); + const Record response = parseJSON(reply.mid(5)); + /*std::unique_ptr rec(Value::constructFrom(response.toMap())); if (!is(*rec)) { throw Error("ServerLink::handleInfoResponse", "Failed to parse response contents"); - } - shell::ServerInfo svInfo(*rec->as().record()); + }*/ + shell::ServerInfo svInfo(response); //*rec->as().record()); LOG_NET_VERBOSE("Discovered server at ") << svAddress; // Update with the correct address. - svAddress = Address(svAddress.host(), svInfo.port()); + svAddress = Address(svAddress.hostName(), svInfo.port()); svInfo.setAddress(svAddress); svInfo.printToLog(0, true); @@ -173,7 +170,7 @@ DE_PIMPL(ServerLink) LOG_NET_WARNING("Info reply from %s was invalid: %s") << svAddress << er.asText(); } } - else if (reply.size() >= 11 && reply.startsWith("MapOutline\n")) + else if (reply.size() >= 11 && reply.beginsWith("MapOutline\n")) { try { @@ -705,8 +702,7 @@ void ServerLink::initiateCommunications() { pName = "Player"; } - String req = String("Join %1 %2").arg(SV_VERSION, 4, 16, QChar('0')).arg(pName); - *this << req.toUtf8(); + *this << String::format("Join %04x %s", SV_VERSION, pName.c_str()); d->state = WaitingForJoinResponse; @@ -714,7 +710,7 @@ void ServerLink::initiateCommunications() break; } default: - DE_ASSERT(false); + DE_ASSERT_FAIL("Initiate"); break; } } @@ -730,7 +726,7 @@ void ServerLink::handleIncomingPackets() return; LOG_AS("ServerLink"); - forever + for (;;) { // Only BlockPackets received (see interpret()). QScopedPointer packet(static_cast(nextPacket())); diff --git a/doomsday/apps/client/src/ui/widgets/gamewidget.cpp b/doomsday/apps/client/src/ui/widgets/gamewidget.cpp index b223ba828f..75aaa237ba 100644 --- a/doomsday/apps/client/src/ui/widgets/gamewidget.cpp +++ b/doomsday/apps/client/src/ui/widgets/gamewidget.cpp @@ -54,10 +54,6 @@ #include #include -#include -#include -#include - /** * Maximum number of milliseconds spent uploading textures at the beginning * of a frame. Note that non-uploaded textures will appear as pure white @@ -216,8 +212,8 @@ void GameWidget::renderCubeMap(uint size, String const &outputImagePath) // Notify the world that a new render frame has begun. App_World().beginFrame(CPP_BOOL(R_NextViewer())); - QImage composited(QSize(6 * size, size), QImage::Format_RGB32); - QPainter painter(&composited); + Image composited(Image::Size(6 * size, size), Image::RGB_888); +// QPainter painter(&composited); int const baseYaw = 180; @@ -232,19 +228,17 @@ void GameWidget::renderCubeMap(uint size, String const &outputImagePath) Rend_SetFixedView(player, baseYaw, i == 4? -90 : 90, 90, fbSize); } d->renderPlayerViewToFramebuffer(player, destFb); - painter.drawImage(i * size, 0, destFb.toImage()); + composited.draw(i * size, 0, destFb.toImage()); } App_World().endFrame(); // Write the composited image to a file. { - QBuffer buf; - buf.open(QBuffer::WriteOnly); - composited.save(&buf, outputImagePath.fileNameExtension().mid(1).toLatin1()); + const Block buf = composited.serialize(outputImagePath.fileNameExtension().toString()); // Choose a unique name. - int counter = 0; + int counter = 0; String uniquePath = outputImagePath; while (FS::tryLocate(uniquePath)) { @@ -254,7 +248,7 @@ void GameWidget::renderCubeMap(uint size, String const &outputImagePath) } File &outFile = FS::get().root().replaceFile(uniquePath); - outFile << Block(buf.data()); + outFile << buf; outFile.flush(); LOG_GL_MSG("Cube map saved to \"%s\"") << outFile.correspondingNativePath(); @@ -377,7 +371,7 @@ bool GameWidget::handleEvent(Event const &event) Keyboard_Submit(ev.state() == KeyEvent::Pressed? IKE_DOWN : ev.state() == KeyEvent::Repeat? IKE_REPEAT : IKE_UP, - ev.ddKey(), ev.nativeCode(), ev.text().toLatin1()); + ev.ddKey(), ev.scancode(), ev.text()); } return false; diff --git a/doomsday/apps/client/src/world/base/map.cpp b/doomsday/apps/client/src/world/base/map.cpp index 43b928a1e6..9808d156ef 100644 --- a/doomsday/apps/client/src/world/base/map.cpp +++ b/doomsday/apps/client/src/world/base/map.cpp @@ -3423,7 +3423,7 @@ String Map::objectSummaryAsStyledText() const String str; #define TABBED(count, label) String::format(_E(Ta) " %i " _E(Tb) "%s\n", count, label) - if (thCount) str += TABBED(thCount, String::format("Thinkers (%i in stasis)", thCountInStasis)); + if (thCount) str += TABBED(thCount, stringf("Thinkers (%i in stasis)", thCountInStasis).c_str()); #ifdef __CLIENT__ //if (biasSourceCount()) str += TABBED(biasSourceCount(), "Bias Sources"); if (generatorCount()) str += TABBED(generatorCount(), "Generators"); diff --git a/doomsday/apps/gloom/gloom/world/mapimport.cpp b/doomsday/apps/gloom/gloom/world/mapimport.cpp index 0b4b94227f..c1e4f2bb02 100644 --- a/doomsday/apps/gloom/gloom/world/mapimport.cpp +++ b/doomsday/apps/gloom/gloom/world/mapimport.cpp @@ -28,8 +28,8 @@ #include #include -#include -#include +#include +#include using namespace de; @@ -58,7 +58,7 @@ DE_PIMPL_NOREF(MapImport) res::IdTech1TextureLib textureLib; String mapId; Map map; - QSet textures; + Set textures; Vec3d metersPerUnit; double worldAspectRatio = 1.2; @@ -167,19 +167,19 @@ DE_PIMPL_NOREF(MapImport) const int linedefsCount = (levelFormat == DoomFormat ? doomLinedefs.size() : hexenLinedefs.size()); - QVector mappedVertex(idVertices.size()); + List mappedVertex(idVertices.size()); struct MappedSector { - ID sector = 0; - ID floor = 0; - ID liquid = 0; - ID ceiling = 0; - QSet points; - QVector boundaryLines; + ID sector = 0; + ID floor = 0; + ID liquid = 0; + ID ceiling = 0; + Set points; + List boundaryLines; }; - QVector mappedSectors(idSectors.size()); + List mappedSectors(idSectors.size()); - QVector mappedLines(linedefsCount); + List mappedLines(linedefsCount); // -------- Create planes for all sectors: each gets a separate floor and ceiling -------- @@ -188,8 +188,8 @@ DE_PIMPL_NOREF(MapImport) const auto &sec = idSectors[i]; // Plane materials. - String floorTexture = "flat." + res::wad::nameString(sec.floorTexture).toLower(); - String ceilingTexture = "flat." + res::wad::nameString(sec.ceilingTexture).toLower(); + String floorTexture = "flat." + res::wad::nameString(sec.floorTexture).lower(); + String ceilingTexture = "flat." + res::wad::nameString(sec.ceilingTexture).lower(); if (isSky(sec.floorTexture)) { @@ -273,9 +273,9 @@ DE_PIMPL_NOREF(MapImport) sectors[p] = le16u(sdef.sector); line.surfaces[p].sector = (sectors[p] != invalidIndex? mappedSectors[sectors[p]].sector : 0); - const auto midTex = res::wad::nameString(sdef.middleTexture).toLower(); - const auto upTex = res::wad::nameString(sdef.upperTexture).toLower(); - const auto lowTex = res::wad::nameString(sdef.lowerTexture).toLower(); + const auto midTex = res::wad::nameString(sdef.middleTexture).lower(); + const auto upTex = res::wad::nameString(sdef.upperTexture).lower(); + const auto lowTex = res::wad::nameString(sdef.lowerTexture).lower(); if (midTex != "-") { @@ -383,7 +383,7 @@ String MapImport::mapId() const StringList MapImport::materials() const { - return compose(d->textures.constBegin(), d->textures.constEnd()); + return compose(d->textures.begin(), d->textures.end()); } Image MapImport::materialImage(const String &name) const @@ -457,22 +457,21 @@ void MapImport::exportPackage(const String &packageRootPath) const // Materials used in the map. { - Block dei; - QTextStream os(&dei); - os.setCodec("UTF-8"); +// Block dei; + std::ostringstream os; - foreach (String name, materials()) + for (const String &name : materials()) { - qDebug() << "Exporting:" << name; + debug("Exporting: %s", name.c_str()); const DotPath path{name}; - const String category = path.segment(0); + const String category = path.segment(0).toString(); const String subfolder = (category == "texture" ? "textures" : "flats"); const String imgPath = subfolder / path.segment(1) + "_diffuse.png"; const double ppm = 1.0 / d->metersPerUnit.x; - os.setRealNumberPrecision(16); + os << std::setprecision(16); os << "asset material." << name << " {\n ppm = " << ppm << "\n"; os << " verticalAspect = " << (category == "texture"? "True" : "False") << "\n"; os << " diffuse: " << imgPath << "\n}\n\n"; @@ -480,15 +479,16 @@ void MapImport::exportPackage(const String &packageRootPath) const const auto image = materialImage(name); DE_ASSERT(!image.isNull()); - Block imgData; - { - QBuffer outBuf(&imgData); - outBuf.open(QIODevice::WriteOnly); - image.toQImage().rgbSwapped().save(&outBuf, "PNG", 1); - } +// const Block imgData = ; +// { +// QBuffer outBuf(&imgData); +// outBuf.open(QIODevice::WriteOnly); +// image.toQImage().rgbSwapped().save(&outBuf, "PNG", 1); + +// } File &f = root.replaceFile(imgPath); - f << imgData; + f << image.serialize(Image::Png); f.reinterpret(); // ".diffuse", ".specgloss", ".emissive", ".normaldisp" @@ -497,10 +497,10 @@ void MapImport::exportPackage(const String &packageRootPath) const // - opaque/transparent } - os.flush(); +// os.flush(); File &f = root.replaceFile("materials.dei"); - f << dei; + f << String(os.str()); f.flush(); } } diff --git a/doomsday/apps/gloom/src/editor.cpp b/doomsday/apps/gloom/src/editor.cpp index 2dec2f98e2..d4cf292d82 100644 --- a/doomsday/apps/gloom/src/editor.cpp +++ b/doomsday/apps/gloom/src/editor.cpp @@ -199,8 +199,7 @@ DE_PIMPL(Editor) : mode == EditPlanes ? map.planes() .size() : mode == EditVolumes ? map.volumes() .size() : 0) - .arg(selText) - .arg(actionText()); + .arg(selText, actionText()); if (hoverPoint) { text += QString(" \u25aa%1").arg(hoverPoint, 0, 16); @@ -1089,7 +1088,7 @@ DE_PIMPL(Editor) dlg.setWindowTitle(tr("Import Map")); QVBoxLayout *layout = new QVBoxLayout; QListWidget *list = new QListWidget; - list->addItems(compose(maps.begin(), maps.end())); + list->addItems(de::map(maps, convertToQString)); layout->addWidget(list, 1); connect(list, SIGNAL(itemDoubleClicked(QListWidgetItem*)), &dlg, SLOT(accept())); QDialogButtonBox *box = new QDialogButtonBox; @@ -1146,7 +1145,7 @@ DE_PIMPL(Editor) { if (self().parentWidget()) { - self().parentWidget()->setWindowTitle(QString("%1 (%2)").arg(text).arg(convert(mapId))); + self().parentWidget()->setWindowTitle(QString("%1 (%2)").arg(text, convert(mapId))); } } @@ -1730,10 +1729,10 @@ void Editor::mouseReleaseEvent(QMouseEvent *event) QMenu *eType = pop->addMenu("Type"); const ID entityId = d->hoverEntity; - for (const auto &i : entityMetadata) + for (auto i = entityMetadata.begin(); i != entityMetadata.end(); ++i) { - /*QAction *a = */ eType->addAction(i.second, [this, entityId, i] () { - d->map.entity(entityId).setType(i.first); + /*QAction *a = */ eType->addAction(i.value(), [this, entityId, i] () { + d->map.entity(entityId).setType(i.key()); }); } pop->popup(mapToGlobal(event->pos())); diff --git a/doomsday/apps/gloom/src/utils.h b/doomsday/apps/gloom/src/utils.h index cce0e14fae..b60f2460d5 100644 --- a/doomsday/apps/gloom/src/utils.h +++ b/doomsday/apps/gloom/src/utils.h @@ -27,9 +27,19 @@ inline de::String convert(const QString &qstr) return qstr.toStdWString(); } +inline de::String convertToString(const QString &qstr) +{ + return convert(qstr); +} + inline QString convert(const de::String &str) { return QString::fromUtf8(str); } +inline QString convertToQString(const de::String &str) +{ + return convert(str); +} + #endif // GLOOMAPP_UTILS_H diff --git a/doomsday/tools/shell/src/qtguiapp.cpp b/doomsday/tools/shell/src/qtguiapp.cpp index d6cca64082..b9c6735a7f 100644 --- a/doomsday/tools/shell/src/qtguiapp.cpp +++ b/doomsday/tools/shell/src/qtguiapp.cpp @@ -58,7 +58,7 @@ bool QtGuiApp::notify(QObject *receiver, QEvent *event) } catch (Error const &er) { - QMessageBox::critical(NULL, "Uncaught Exception", er.asText()); + QMessageBox::critical(nullptr, "Uncaught Exception", er.asText().c_str()); } return false; } diff --git a/doomsday/tools/shell/src/qtrootwidget.cpp b/doomsday/tools/shell/src/qtrootwidget.cpp index ec0450a1b3..abbee2c52f 100644 --- a/doomsday/tools/shell/src/qtrootwidget.cpp +++ b/doomsday/tools/shell/src/qtrootwidget.cpp @@ -18,6 +18,7 @@ #include "qtrootwidget.h" #include "qttextcanvas.h" +#include "utils.h" #include #include #include @@ -157,36 +158,86 @@ void QtRootWidget::keyPressEvent(QKeyEvent *ev) << "mods:" << ev->modifiers(); */ - if (!ev->text().isEmpty() && ev->text()[0].isPrint() && - !ev->modifiers().testFlag(CONTROL_MOD)) + if (!ev->text().isEmpty() && ev->text().at(0).isPrint() && + !ev->modifiers().testFlag(CONTROL_MOD)) { - eaten = d->root.processEvent(KeyEvent(ev->text())); + eaten = d->root.processEvent(KeyEvent(convert(ev->text()))); } else { - int key = ev->key(); - KeyEvent::Modifiers mods = ev->modifiers().testFlag(CONTROL_MOD)? - KeyEvent::Control : KeyEvent::None; + shell::Key key = shell::Key::None; + switch (ev->key()) + { + case Qt::Key_Escape: key = shell::Key::Escape; break; + case Qt::Key_Up: key = shell::Key::Up; break; + case Qt::Key_Down: key = shell::Key::Down; break; + case Qt::Key_Left: key = shell::Key::Left; break; + case Qt::Key_Right: key = shell::Key::Right; break; + case Qt::Key_Home: key = shell::Key::Home; break; + case Qt::Key_End: key = shell::Key::End; break; + case Qt::Key_PageUp: key = shell::Key::PageUp; break; + case Qt::Key_PageDown: key = shell::Key::PageDown; break; + case Qt::Key_Insert: key = shell::Key::Insert; break; + case Qt::Key_Delete: key = shell::Key::Delete; break; + case Qt::Key_Enter: key = shell::Key::Enter; break; + case Qt::Key_Return: key = shell::Key::Enter; break; + case Qt::Key_Backspace: key = shell::Key::Backspace; break; + case Qt::Key_Tab: key = shell::Key::Tab; break; + case Qt::Key_Backtab: key = shell::Key::Backtab; break; + case Qt::Key_F1: key = shell::Key::F1; break; + case Qt::Key_F2: key = shell::Key::F2; break; + case Qt::Key_F3: key = shell::Key::F3; break; + case Qt::Key_F4: key = shell::Key::F4; break; + case Qt::Key_F5: key = shell::Key::F5; break; + case Qt::Key_F6: key = shell::Key::F6; break; + case Qt::Key_F7: key = shell::Key::F7; break; + case Qt::Key_F8: key = shell::Key::F8; break; + case Qt::Key_F9: key = shell::Key::F9; break; + case Qt::Key_F10: key = shell::Key::F10; break; + case Qt::Key_F11: key = shell::Key::F11; break; + case Qt::Key_F12: key = shell::Key::F12; break; + } - if (key == Qt::Key_Return) key = Qt::Key_Enter; + KeyEvent::Modifiers mods = + ev->modifiers().testFlag(CONTROL_MOD) ? KeyEvent::Control : KeyEvent::None; // Special control key mappings. if (mods & KeyEvent::Control) { - switch (key) + switch (ev->key()) { case Qt::Key_A: - key = Qt::Key_Home; + key = shell::Key::Home; mods = KeyEvent::None; break; case Qt::Key_D: - key = Qt::Key_Delete; + key = shell::Key::Delete; mods = KeyEvent::None; break; case Qt::Key_E: - key = Qt::Key_End; + key = shell::Key::End; + mods = KeyEvent::None; + break; + + case Qt::Key_C: + key = shell::Key::Break; + mods = KeyEvent::None; + break; + + case Qt::Key_K: + key = shell::Key::Kill; + mods = KeyEvent::None; + break; + + case Qt::Key_X: + key = shell::Key::Cancel; + mods = KeyEvent::None; + break; + + case Qt::Key_Z: + key = shell::Key::Substitute; mods = KeyEvent::None; break; @@ -250,11 +301,11 @@ void QtRootWidget::paintEvent(QPaintEvent *) QPoint pos = origin + QPoint(d->charSize.x * d->canvas->cursorPosition().x, d->charSize.y * d->canvas->cursorPosition().y); - TextCanvas::Char ch = d->canvas->at(d->canvas->cursorPosition()); + TextCanvas::AttribChar ch = d->canvas->at(d->canvas->cursorPosition()); painter.setPen(Qt::NoPen); painter.fillRect(QRect(pos, QSize(de::max(1, d->charSize.x / 5), d->charSize.y)), - ch.attribs.testFlag(TextCanvas::Char::Reverse)? + ch.attribs.testFlag(TextCanvas::AttribChar::Reverse)? d->canvas->backgroundColor() : d->canvas->foregroundColor()); }