Qt: Create byte views at the proper zoom level.
authorGerald Combs <gerald@wireshark.org>
Thu, 18 Jan 2018 16:31:58 +0000 (08:31 -0800)
committerAnders Broman <a.broman58@gmail.com>
Sun, 21 Jan 2018 14:19:10 +0000 (14:19 +0000)
Add a zoomed argument to WiresharkApplication::monospaceFont so that we
can easily fetch the font at its current zoom level. Set the zoomed font
when we create new ByteViewTexts.

Change-Id: I1293f206e37bb798247b1ac4b314fdfe88d4c55c
Reviewed-on: https://code.wireshark.org/review/25371
Reviewed-by: Gerald Combs <gerald@wireshark.org>
Petri-Dish: Gerald Combs <gerald@wireshark.org>
Tested-by: Petri Dish Buildbot
Reviewed-by: Anders Broman <a.broman58@gmail.com>
ui/qt/byte_view_tab.cpp
ui/qt/wireshark_application.cpp
ui/qt/wireshark_application.h

index 7d54c8433fcdd91413d35bfeea32e24c9da5de86..36a21c0d1f72290c345284bb8855098fb4119490 100644 (file)
@@ -99,7 +99,7 @@ void ByteViewTab::addTab(const char *name, tvbuff_t *tvb) {
 
     ByteViewText * byte_view_text = new ByteViewText(data, encoding, this);
     byte_view_text->setAccessibleName(name);
-    byte_view_text->setMonospaceFont(wsApp->monospaceFont());
+    byte_view_text->setMonospaceFont(wsApp->monospaceFont(true));
 
     if ( tvb )
     {
index 3dab45e1baef408ab165658ca08dce271f54a7ec..cfe6a91f7f66d2445a7d8f86e2c320c2708d46c2 100644 (file)
@@ -288,6 +288,14 @@ void WiresharkApplication::helpTopicAction(topic_action_e action)
     }
 }
 
+const QFont WiresharkApplication::monospaceFont(bool zoomed) const
+{
+    if (zoomed) {
+        return zoomed_font_;
+    }
+    return mono_font_;
+}
+
 void WiresharkApplication::setMonospaceFont(const char *font_string) {
 
     if (font_string && strlen(font_string) > 0) {
@@ -1288,7 +1296,7 @@ void WiresharkApplication::zoomTextFont(int zoomLevel)
 {
     // Scale by 10%, rounding to nearest half point, minimum 1 point.
     // XXX Small sizes repeat. It might just be easier to create a map of multipliers.
-    QFont zoomed_font_ = mono_font_;
+    zoomed_font_ = mono_font_;
     qreal zoom_size = mono_font_.pointSize() * 2 * qPow(qreal(1.1), zoomLevel);
     zoom_size = qRound(zoom_size) / qreal(2.0);
     zoom_size = qMax(zoom_size, qreal(1.0));
index a10928fb8c09165d9e2ab40e44874708d6186cad..186a676e72a9ddd9f2bb17e4b9a97f4aa96db1a7 100644 (file)
@@ -101,7 +101,7 @@ public:
     void setLastOpenDir(const char *dir_name);
     void setLastOpenDir(QString dir_str);
     void helpTopicAction(topic_action_e action);
-    const QFont monospaceFont() const { return mono_font_; }
+    const QFont monospaceFont(bool zoomed = false) const;
     void setMonospaceFont(const char *font_string);
     int monospaceTextSize(const char *str);
     void setConfigurationProfile(const gchar *profile_name, bool write_recent = true);
@@ -134,6 +134,7 @@ private:
     bool initialized_;
     bool is_reloading_lua_;
     QFont mono_font_;
+    QFont zoomed_font_;
     QTimer recent_timer_;
     QTimer addr_resolv_timer_;
     QTimer tap_update_timer_;