[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-commits
Subject: [konversation] /: Add font zooming to ircview
From: Peter Simonsson <peter.simonsson () gmail ! com>
Date: 2016-09-14 17:57:22
Message-ID: E1bkER0-0008WT-1t () code ! kde ! org
[Download RAW message or body]
Git commit 66fc2f36af5290c436e3ff1abc62ad942a1f89ff by Peter Simonsson.
Committed on 14/09/2016 at 17:56.
Pushed by psn into branch 'master'.
Add font zooming to ircview
Ported patch by mayank jha to KF5
BUG:306545
M +5 -1 data/konversationui.rc
M +27 -0 src/mainwindow.cpp
M +30 -0 src/viewer/ircview.cpp
M +5 -0 src/viewer/ircview.h
M +26 -2 src/viewer/viewcontainer.cpp
M +4 -0 src/viewer/viewcontainer.h
http://commits.kde.org/konversation/66fc2f36af5290c436e3ff1abc62ad942a1f89ff
diff --git a/data/konversationui.rc b/data/konversationui.rc
index 171d32a..1f33a21 100644
--- a/data/konversationui.rc
+++ b/data/konversationui.rc
@@ -1,5 +1,5 @@
<!DOCTYPE kpartgui>
-<kpartgui name="konversation" version="54">
+<kpartgui name="konversation" version="55">
<MenuBar>
<Menu name="file">
@@ -15,6 +15,10 @@
<Menu name="edit">
<Action name="clear_lines" />
<Separator />
+ <Action name="increase_font" />
+ <Action name="shrink_font" />
+ <Action name="reset_font" />
+ <Separator />
<Action name="clear_window" />
<Action name="clear_tabs" />
</Menu>
diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp
index 0f88743..40423d2 100644
--- a/src/mainwindow.cpp
+++ b/src/mainwindow.cpp
@@ -411,6 +411,33 @@ MainWindow::MainWindow() : KXmlGuiWindow(0)
actionCollection()->addAction(QStringLiteral("clear_lines"), action);
action=new QAction(this);
+ action->setText(i18n("Enlarge Font Size"));
+ actionCollection()->setDefaultShortcuts(action, KStandardShortcut::zoomIn());
+ action->setEnabled(false);
+ action->setIcon(QIcon::fromTheme(QStringLiteral("zoom-in")));
+ action->setStatusTip(i18n("Increase the current font size"));
+ connect(action, SIGNAL(triggered()), m_viewContainer, SLOT(zoomIn()));
+ actionCollection()->addAction(QStringLiteral("increase_font"), action);
+
+ action=new QAction(this);
+ action->setText(i18n("Reset Font Size"));
+ actionCollection()->setDefaultShortcut(action, \
QKeySequence(QStringLiteral("Ctrl+0"))); + action->setEnabled(false);
+ action->setIcon(QIcon::fromTheme(QStringLiteral("zoom-original")));
+ action->setStatusTip(i18n("Reset the current font size to settings values"));
+ connect(action, SIGNAL(triggered()), m_viewContainer, SLOT(resetFont()));
+ actionCollection()->addAction(QStringLiteral("reset_font"), action);
+
+ action=new QAction(this);
+ action->setText(i18n("Decrease Font Size"));
+ actionCollection()->setDefaultShortcuts(action, KStandardShortcut::zoomOut());
+ action->setEnabled(false);
+ action->setIcon(QIcon::fromTheme(QStringLiteral("zoom-out")));
+ action->setStatusTip(i18n("Decrease the current font size"));
+ connect(action, SIGNAL(triggered()), m_viewContainer, SLOT(zoomOut()));
+ actionCollection()->addAction(QStringLiteral("shrink_font"), action);
+
+ action=new QAction(this);
action->setText(i18n("&Clear Window"));
actionCollection()->setDefaultShortcut(action,QKeySequence(QStringLiteral("Ctrl+L")));
action->setEnabled(false);
diff --git a/src/viewer/ircview.cpp b/src/viewer/ircview.cpp
index fe9bcb7..3e9d94c 100644
--- a/src/viewer/ircview.cpp
+++ b/src/viewer/ircview.cpp
@@ -140,6 +140,25 @@ IRCView::~IRCView()
{
}
+void IRCView::increaseFontSize()
+{
+ QFont newFont;
+ newFont.setPointSize(font().pointSize() + 1);
+ setFont(newFont);
+}
+
+void IRCView::decreaseFontSize()
+{
+ QFont newFont;
+ newFont.setPointSize(font().pointSize() - 1);
+ setFont(newFont);
+}
+
+void IRCView::resetFontSize()
+{
+ setFont(Preferences::self()->textFont());
+}
+
void IRCView::setServer(Server* newServer)
{
if (m_server == newServer)
@@ -1894,6 +1913,17 @@ void IRCView::mousePressEvent(QMouseEvent* ev)
QTextBrowser::mousePressEvent(ev);
}
+void IRCView::wheelEvent(QWheelEvent *ev)
+{
+ if(ev->modifiers()==Qt::ControlModifier)
+ {
+ if(ev->delta() < 0) decreaseFontSize();
+ if(ev->delta() > 0) increaseFontSize();
+ }
+
+ QTextBrowser::wheelEvent(ev);
+}
+
void IRCView::mouseReleaseEvent(QMouseEvent *ev)
{
if (ev->button() == Qt::LeftButton)
diff --git a/src/viewer/ircview.h b/src/viewer/ircview.h
index 7bc02ae..03b545e 100644
--- a/src/viewer/ircview.h
+++ b/src/viewer/ircview.h
@@ -205,6 +205,10 @@ class IRCView : public QTextBrowser
/// Emits the doSearchPrevious signal.
void findPreviousText();
+ void increaseFontSize();
+ void decreaseFontSize();
+ void resetFontSize();
+
protected Q_SLOTS:
void highlightedSlot(const QString& link);
void anchorClicked(const QUrl& url);
@@ -279,6 +283,7 @@ class IRCView : public QTextBrowser
virtual void mouseMoveEvent(QMouseEvent* ev);
virtual void keyPressEvent(QKeyEvent* ev);
virtual void contextMenuEvent(QContextMenuEvent* ev);
+ virtual void wheelEvent(QWheelEvent* ev);
QChar::Direction basicDirection(const QString &string);
diff --git a/src/viewer/viewcontainer.cpp b/src/viewer/viewcontainer.cpp
index 520c42c..a2fe93d 100644
--- a/src/viewer/viewcontainer.cpp
+++ b/src/viewer/viewcontainer.cpp
@@ -254,6 +254,23 @@ void ViewContainer::setupTabWidget()
updateTabWidgetAppearance();
}
+void ViewContainer::resetFont()
+{
+ m_frontView->getTextView()->resetFontSize();
+}
+
+void ViewContainer::zoomIn()
+{
+ if (m_frontView->getTextView())
+ m_frontView->getTextView()->increaseFontSize();
+}
+
+void ViewContainer::zoomOut()
+{
+ if (m_frontView->getTextView())
+ m_frontView->getTextView()->decreaseFontSize();
+}
+
void ViewContainer::setupViewTree()
{
unclutterTabs();
@@ -761,11 +778,9 @@ void ViewContainer::updateViewActions(int index)
action = actionCollection()->action("reconnect_server");
if (action) action->setEnabled(true);
-
action = actionCollection()->action("disconnect_server");
if (action) action->setEnabled(server->isConnected() || \
server->isConnecting() || server->isScheduledToConnect());
-
action = actionCollection()->action("join_channel");
if (action) action->setEnabled(server->isConnected());
}
@@ -826,6 +841,15 @@ void ViewContainer::updateViewActions(int index)
action = actionCollection()->action("clear_tabs");
if (action) action->setEnabled(true);
+ action = actionCollection()->action("increase_font");
+ if (action) action->setEnabled(true);
+
+ action = actionCollection()->action("shrink_font");
+ if (action) action->setEnabled(true);
+
+ action = actionCollection()->action("reset_font");
+ if (action) action->setEnabled(true);
+
action = actionCollection()->action("toggle_away");
if (action) action->setEnabled(true);
diff --git a/src/viewer/viewcontainer.h b/src/viewer/viewcontainer.h
index 4c12f41..113ed3f 100644
--- a/src/viewer/viewcontainer.h
+++ b/src/viewer/viewcontainer.h
@@ -190,6 +190,10 @@ class ViewContainer : public QAbstractItemModel
void addKonsolePanel();
+ void zoomIn();
+ void zoomOut();
+ void resetFont();
+
void addUrlCatcher();
void closeUrlCatcher();
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic