From: Pasi Kallinen Date: Wed, 12 Sep 2018 15:42:29 +0000 (+0300) Subject: Qt: Remember the tile and font size X-Git-Tag: NetHack-3.6.2_Released~198^2~4 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=b33b66aa29527e3d2226b9b6f25382c007130f7c;p=nethack Qt: Remember the tile and font size The QT_TILEWIDTH and QT_TILEHEIGHT read from NetHack config file override the remembered settings. Also set the smallest tile size to 6x6 --- diff --git a/doc/fixes36.2 b/doc/fixes36.2 index 9f76fc3e8..69a952609 100644 --- a/doc/fixes36.2 +++ b/doc/fixes36.2 @@ -162,6 +162,7 @@ unix: Makefile.src and Makefile.utl inadvertently relied on a 'gnu make' Qt: add Qt5 specific hints file for linux and Mac OS X (Ray Chason) Qt: enable compiling Qt5 on Windows (Ray Chason) Qt: entering extended commands, hide non-matching ones +Qt: remember tile and font size General New Features diff --git a/win/Qt4/qt4main.cpp b/win/Qt4/qt4main.cpp index 4fd8d14da..547cc3e62 100644 --- a/win/Qt4/qt4main.cpp +++ b/win/Qt4/qt4main.cpp @@ -490,6 +490,10 @@ NetHackQtMainWindow::NetHackQtMainWindow(NetHackQtKeyBuffer& ks) : addToolBar(toolbar); menubar = menuBar(); + QCoreApplication::setOrganizationName("The NetHack DevTeam"); + QCoreApplication::setOrganizationDomain("nethack.org"); + QCoreApplication::setApplicationName("NetHack"); + setWindowTitle("Qt NetHack"); if ( qt_compact_mode ) setWindowIcon(QIcon(QPixmap(nh_icon_small))); diff --git a/win/Qt4/qt4set.cpp b/win/Qt4/qt4set.cpp index 03de1f6f7..f9bfa246e 100644 --- a/win/Qt4/qt4set.cpp +++ b/win/Qt4/qt4set.cpp @@ -36,10 +36,11 @@ int qt_compact_mode = 0; namespace nethack_qt4 { -#define TILEWMIN 1 -#define TILEHMIN 1 +#define TILEWMIN 6 +#define TILEHMIN 6 NetHackQtSettings::NetHackQtSettings(int w, int h) : + settings(), tilewidth(this), tileheight(this), widthlbl("&Width:",this), @@ -63,9 +64,9 @@ NetHackQtSettings::NetHackQtSettings(int w, int h) : heightlbl.setBuddy(&tileheight); tileheight.setRange(TILEHMIN, 128); - default_fontsize=2; - tilewidth.setValue(16); - tileheight.setValue(16); + tilewidth.setValue(settings.value("tilewidth", 16).toInt()); + tileheight.setValue(settings.value("tileheight", 16).toInt()); + default_fontsize = settings.value("fontsize", 2).toInt(); // Tile/font sizes read from .nethackrc if (qt_tilewidth != NULL) { @@ -100,7 +101,7 @@ NetHackQtSettings::NetHackQtSettings(int w, int h) : fontsize.addItem("Small"); fontsize.addItem("Tiny"); fontsize.setCurrentIndex(default_fontsize); - connect(&fontsize,SIGNAL(activated(int)),this,SIGNAL(fontChanged())); + connect(&fontsize,SIGNAL(activated(int)),this,SLOT(changedFont())); QGridLayout* grid = new QGridLayout(this); grid->addWidget(&whichsize, 0, 0, 1, 2); @@ -126,11 +127,19 @@ NetHackQtGlyphs& NetHackQtSettings::glyphs() return *theglyphs; } +void NetHackQtSettings::changedFont() +{ + settings.setValue("fontsize", fontsize.currentIndex()); + emit fontChanged(); +} + void NetHackQtSettings::resizeTiles() { int w = tilewidth.value(); int h = tileheight.value(); + settings.setValue("tilewidth", tilewidth.value()); + settings.setValue("tileheight", tileheight.value()); theglyphs->setSize(w,h); emit tilesChanged(); } diff --git a/win/Qt4/qt4set.h b/win/Qt4/qt4set.h index e2253a8d6..48b90f306 100644 --- a/win/Qt4/qt4set.h +++ b/win/Qt4/qt4set.h @@ -33,6 +33,7 @@ public slots: void setGlyphSize(bool); private: + QSettings settings; QSpinBox tilewidth; QSpinBox tileheight; QLabel widthlbl; @@ -48,6 +49,7 @@ private: private slots: void resizeTiles(); + void changedFont(); }; extern NetHackQtSettings* qt_settings;