From 66f820c2c7e2d7c6d883c995bf7b2da37aa963c7 Mon Sep 17 00:00:00 2001
From: Kevin Smith <git@kismith.co.uk>
Date: Sun, 28 Aug 2011 10:18:40 +0100
Subject: Disable the 'Decrease font size' menu item in chats when it's already
 minimal.

Resolves: #968

diff --git a/Swift/QtUI/QtChatView.cpp b/Swift/QtUI/QtChatView.cpp
index c533525..4c6a729 100644
--- a/Swift/QtUI/QtChatView.cpp
+++ b/Swift/QtUI/QtChatView.cpp
@@ -229,6 +229,7 @@ void QtChatView::resizeFont(int fontSizeSteps) {
 	foreach (QWebElement span, spans) {
 		span.setStyleProperty("font-size", sizeString);
 	}
+	webView_->setFontSizeIsMinimal(size == 1.0);
 }
 
 void QtChatView::resetView() {
diff --git a/Swift/QtUI/QtWebView.cpp b/Swift/QtUI/QtWebView.cpp
index 5d25071..5f9539e 100644
--- a/Swift/QtUI/QtWebView.cpp
+++ b/Swift/QtUI/QtWebView.cpp
@@ -39,6 +39,10 @@ void QtWebView::dragEnterEvent(QDragEnterEvent*) {
 
 }
 
+void QtWebView::setFontSizeIsMinimal(bool minimum) {
+	fontSizeIsMinimal = minimum;
+}
+
 void QtWebView::contextMenuEvent(QContextMenuEvent* ev) {
 	// Filter out the relevant actions from the standard actions
 	QMenu* menu = page()->createStandardContextMenu();
@@ -60,7 +64,10 @@ void QtWebView::contextMenuEvent(QContextMenuEvent* ev) {
 	// Add our own custom actions
 	menu->addAction(tr("Clear"), this, SIGNAL(clearRequested()));
 	menu->addAction(tr("Increase font size"), this, SIGNAL(fontGrowRequested()));
-	menu->addAction(tr("Decrease font size"), this, SIGNAL(fontShrinkRequested()));
+	QAction* shrink = new QAction(tr("Decrease font size"), this);
+	shrink->setEnabled(!fontSizeIsMinimal);
+	connect(shrink, SIGNAL(triggered()), this, SIGNAL(fontShrinkRequested()));
+	menu->addAction(shrink);
 
 	menu->exec(ev->globalPos());
 	delete menu;
diff --git a/Swift/QtUI/QtWebView.h b/Swift/QtUI/QtWebView.h
index eb5a82d..202037f 100644
--- a/Swift/QtUI/QtWebView.h
+++ b/Swift/QtUI/QtWebView.h
@@ -18,6 +18,7 @@ namespace Swift {
 			void keyPressEvent(QKeyEvent* event);
 			void dragEnterEvent(QDragEnterEvent *event);
 			void contextMenuEvent(QContextMenuEvent* ev);
+			void setFontSizeIsMinimal(bool minimum);
 
 		signals:
 			void gotFocus();
@@ -30,5 +31,6 @@ namespace Swift {
 
 		private:
 			std::vector<QWebPage::WebAction> filteredActions;
+			bool fontSizeIsMinimal;
 	};
 }
-- 
cgit v0.10.2-6-g49f6