Am Dienstag, dem 16.08.2022 um 12:44 +0200 schrieb Jürgen Spitzmüller:
> I've seen now that you flagged it for localization. But this is still
> to anglocentric. Use bformat to construct the string. BTW there is
> also
> a qt_() function, no need for toqstr(_()).
> 
> My point that one-letter abbreviations in UI are a no-go still holds.

Attached the way I'd recommend to do it:

* do not use abbreviations
* allow to enable the stats measures individually
* left click on stats in status bar opens stats dialog (as in LO and
Word)

The rationale besides the accessibility argument is that I'd figure
that users seldom need all three stats values. The value they need
might depend on the editorial instructions they get. These might rely
on either of the three. So give the user the choice to see what they
need.

-- 
Jürgen
diff --git a/lib/ui/stdcontext.inc b/lib/ui/stdcontext.inc
index 554798c11a..8eb8ddde82 100644
--- a/lib/ui/stdcontext.inc
+++ b/lib/ui/stdcontext.inc
@@ -732,7 +732,9 @@ Menuset
 		Item "Show Zoom Level|Z" "ui-toggle zoomlevel"
 		Item "Show Zoom Slider|S" "ui-toggle zoomslider"
 		Separator
-		Item "Show Statistics|t" "ui-toggle statistics"
+		Item "Show Word Count|W" "ui-toggle statistics-w"
+		Item "Show Character Count (Incl. Blanks)|C" "ui-toggle statistics-cb"
+		Item "Show Character Count (Without Blanks)|h" "ui-toggle statistics-c"
 	End
 
 End
diff --git a/src/LyXAction.cpp b/src/LyXAction.cpp
index ae8245d070..6c80fb1d37 100644
--- a/src/LyXAction.cpp
+++ b/src/LyXAction.cpp
@@ -4091,16 +4091,20 @@ void LyXAction::init()
  * \var lyx::FuncCode lyx::LFUN_UI_TOGGLE
  * \li Action: Various UI visibility-toggling actions.
  * \li Syntax: ui-toggle <statusbar|menubar|scrollbar|frame|fullscreen>
- * \li Params: statusbar  : Toggle visibility of the statusbar.\n
-               menubar    : Toggle visibility of the menubar.\n
-               scrollbar  : Toggle visibility of the scrollbar.\n
-               frame      : Toggle visibility of the frames around editing window.\n
-               zoomslider : Toggle visibility of the zoom slider in statusbar.\n
-               zoomlevel  : Toggle visibility of the zoom level display in statusbar.\n
-               statistics : Toggle visibility of the document statistics count in statusbar.\n
-               fullscreen : Toggle fullscreen mode. This also covers calling the
-                            previous functions. However #LFUN_TOOLBAR_TOGGLE for the
-                            custom tweaks of the toolbars should be used.
+ * \li Params: statusbar     : Toggle visibility of the statusbar.\n
+               menubar       : Toggle visibility of the menubar.\n
+               scrollbar     : Toggle visibility of the scrollbar.\n
+               frame         : Toggle visibility of the frames around editing window.\n
+               zoomslider    : Toggle visibility of the zoom slider in statusbar.\n
+               zoomlevel     : Toggle visibility of the zoom level display in statusbar.\n
+               statistics-w  : Toggle visibility of the document word count in statusbar.\n
+               statistics-cb : Toggle visibility of the document character count (incl. blanks)
+                               in statusbar.\n
+               statistics-c  : Toggle visibility of the document character count (excl. blanks)
+                               in statusbar.\n
+               fullscreen    : Toggle fullscreen mode. This also covers calling the
+                               previous functions. However #LFUN_TOOLBAR_TOGGLE for the
+                               custom tweaks of the toolbars should be used.
  * \li Origin: sanda, 9 Feb 2007
  * \endvar
  */
diff --git a/src/frontends/qt/GuiView.cpp b/src/frontends/qt/GuiView.cpp
index d03fe3bc2f..043a839caa 100644
--- a/src/frontends/qt/GuiView.cpp
+++ b/src/frontends/qt/GuiView.cpp
@@ -568,7 +568,8 @@ QSet<Buffer const *> GuiView::GuiViewPrivate::busyBuffers;
 
 GuiView::GuiView(int id)
 	: d(*new GuiViewPrivate(this)), id_(id), closing_(false), busy_(0),
-	  command_execute_(false), minibuffer_focus_(false), stat_counts_enabled_(true),
+	  command_execute_(false), minibuffer_focus_(false), word_count_enabled_(true),
+	  char_count_enabled_(true),  char_nb_count_enabled_(false),
 	  toolbarsMovable_(true), devel_mode_(false)
 {
 	connect(this, SIGNAL(bufferViewChanged()),
@@ -645,12 +646,14 @@ GuiView::GuiView(int id)
 		busySVG, SLOT(hide()));
 	connect(busySVG, SIGNAL(pressed()), this, SLOT(checkCancelBackground()));
 
-	stat_counts_ = new QLabel(statusBar());
+	stat_counts_ = new GuiClickableLabel(statusBar());
 	stat_counts_->setAlignment(Qt::AlignCenter);
 	stat_counts_->setFrameStyle(QFrame::StyledPanel);
 	stat_counts_->hide();
 	statusBar()->addPermanentWidget(stat_counts_);
 
+	connect(stat_counts_, SIGNAL(clicked()), this, SLOT(statsPressed()));
+
 
 	QFontMetrics const fm(statusBar()->fontMetrics());
 
@@ -820,6 +823,11 @@ void GuiView::checkCancelBackground()
 		Systemcall::killscript();
 }
 
+void GuiView::statsPressed()
+{
+	DispatchResult dr;
+	dispatch(FuncRequest(LFUN_STATISTICS), dr);
+}
 
 void GuiView::zoomSliderMoved(int value)
 {
@@ -977,7 +985,9 @@ void GuiView::saveLayout() const
 	settings.setValue("icon_size", toqstr(d.iconSize(iconSize())));
 	settings.setValue("zoom_value_visible", zoom_value_->isVisible());
 	settings.setValue("zoom_slider_visible", zoom_slider_->isVisible());
-	settings.setValue("document_stats_enabled", stat_counts_enabled_);
+	settings.setValue("word_count_enabled", word_count_enabled_);
+	settings.setValue("char_count_enabled", char_count_enabled_);
+	settings.setValue("char_nb_count_enabled", char_nb_count_enabled_);
 }
 
 
@@ -1027,8 +1037,10 @@ bool GuiView::restoreLayout()
 	zoom_in_->setVisible(show_zoom_slider);
 	zoom_out_->setVisible(show_zoom_slider);
 
-	stat_counts_enabled_ = settings.value("document_stats_enabled", true).toBool();
-	stat_counts_->setVisible(stat_counts_enabled_);
+	word_count_enabled_ = settings.value("word_count_enabled", true).toBool();
+	char_count_enabled_ = settings.value("char_count_enabled", true).toBool();
+	char_nb_count_enabled_ = settings.value("char_nb_count_enabled", true).toBool();
+	stat_counts_->setVisible(word_count_enabled_ || char_count_enabled_ || char_nb_count_enabled_);
 
 	if (guiApp->platformName() == "qt4x11" || guiApp->platformName() == "xcb") {
 		QPoint pos = settings.value("pos", QPoint(50, 50)).toPoint();
@@ -1408,7 +1420,7 @@ void GuiView::clearMessage()
 
 void GuiView::showStats()
 {
-	if (!stat_counts_enabled_)
+	if (!word_count_enabled_ && !char_count_enabled_ && !char_nb_count_enabled_)
 		return;
 
 
@@ -1440,13 +1452,27 @@ void GuiView::showStats()
 
 			buf->updateStatistics(from, to);
 
-			int const words = buf->wordCount();
-			int const chars = buf->charCount(false);
+			QString stats;
+			bool first = true;
+			if (word_count_enabled_) {
+				int const words = buf->wordCount();
+				stats = toqstr(bformat(_("%1$d Words"), words));
+				first = false;
+			}
 			int const chars_with_blanks = buf->charCount(true);
+			if (char_count_enabled_) {
+				if (!first)
+					stats += qt_(", [[stats separator]]");
+				stats += toqstr(bformat(_("%1$d Characters"), chars_with_blanks));
+				first = false;
+			}
+			if (char_nb_count_enabled_) {
+				int const chars = buf->charCount(false);
+				if (!first)
+					stats += qt_(", [[stats separator]]");
+				stats += toqstr(bformat(_("%1$d Characters (no Blanks)"), chars));
+			}
 
-			QString stats = toqstr(_("w:[[words]]")) + QString::number(words) + " " +
-				toqstr(_("c:[[characters]]")) +  QString::number(chars) + " " +
-				toqstr(_("cb:[[characters with blanks]]")) + QString::number(chars_with_blanks);
 			stat_counts_->setText(stats);
 			stat_counts_->show();
 
@@ -2503,8 +2529,12 @@ bool GuiView::getStatus(FuncRequest const & cmd, FuncStatus & flag)
 			flag.setOnOff(zoom_value_ ? zoom_value_->isVisible() : false);
 		} else if (cmd.argument() == "zoomslider") {
 			flag.setOnOff(zoom_slider_ ? zoom_slider_->isVisible() : false);
-		} else if (cmd.argument() == "statistics") {
-			flag.setOnOff(stat_counts_enabled_);
+		} else if (cmd.argument() == "statistics-w") {
+			flag.setOnOff(word_count_enabled_);
+		} else if (cmd.argument() == "statistics-cb") {
+			flag.setOnOff(char_count_enabled_);
+		} else if (cmd.argument() == "statistics-c") {
+			flag.setOnOff(char_nb_count_enabled_);
 		} else
 			flag.setOnOff(isFullScreen());
 		break;
@@ -4993,10 +5023,13 @@ bool GuiView::lfunUiToggle(string const & ui_component)
 		zoom_slider_->setVisible(!zoom_slider_->isVisible());
 		zoom_in_->setVisible(zoom_slider_->isVisible());
 		zoom_out_->setVisible(zoom_slider_->isVisible());
-	} else if (ui_component == "statistics") {
-		stat_counts_enabled_ = !stat_counts_enabled_;
-		stat_counts_->setVisible(stat_counts_enabled_);
-	} else if (ui_component == "frame") {
+	} else if (ui_component == "statistics-w")
+		word_count_enabled_ = !word_count_enabled_;
+	else if (ui_component == "statistics-cb")
+		char_count_enabled_ = !char_count_enabled_;
+	else if (ui_component == "statistics-c")
+		char_nb_count_enabled_ = !char_nb_count_enabled_;
+	else if (ui_component == "frame") {
 		int const l = contentsMargins().left();
 
 		//are the frames in default state?
@@ -5017,6 +5050,7 @@ bool GuiView::lfunUiToggle(string const & ui_component)
 		toggleFullScreen();
 	} else
 		return false;
+	stat_counts_->setVisible(word_count_enabled_ || char_count_enabled_ || char_nb_count_enabled_);
 	return true;
 }
 
diff --git a/src/frontends/qt/GuiView.h b/src/frontends/qt/GuiView.h
index 2f7c34e422..9eafddf228 100644
--- a/src/frontends/qt/GuiView.h
+++ b/src/frontends/qt/GuiView.h
@@ -251,6 +251,8 @@ private Q_SLOTS:
 	///
 	void checkCancelBackground();
 	///
+	void statsPressed();
+	///
 	void zoomSliderMoved(int);
 	///
 	void zoomValueChanged(int);
@@ -514,8 +516,13 @@ private:
 	QLabel * version_control_;
 	/// Statusbar widget that document count statistics
 	QLabel * stat_counts_;
-	/// Stats info feature can be disabled by context menu
-	bool stat_counts_enabled_;
+	/// Word count info feature can be disabled by context menu
+	bool word_count_enabled_;
+	/// Char count info feature can be disabled by context menu
+	bool char_count_enabled_;
+	/// Char count info feature can be disabled by context menu
+	/// This excludes blanks
+	bool char_nb_count_enabled_;
 	/// Statusbar widget that shows zoom value
 	QLabel * zoom_value_;
 	/// The zoom slider widget

Attachment: signature.asc
Description: This is a digitally signed message part

-- 
lyx-devel mailing list
lyx-devel@lists.lyx.org
http://lists.lyx.org/mailman/listinfo/lyx-devel

Reply via email to