[SCM] ktp-text-ui packaging branch, master, updated. debian/15.12.1-1-1918-gdf4b0ec
Maximiliano Curia
maxy at moszumanska.debian.org
Sat May 28 00:19:14 UTC 2016
Gitweb-URL: http://git.debian.org/?p=pkg-kde/applications/ktp-text-ui.git;a=commitdiff;h=3ada3f4
The following commit has been merged in the master branch:
commit 3ada3f4100c270c8dc69fd45f3b52393e05feb70
Author: Francesco Nwokeka <francesco.nwokeka at gmail.com>
Date: Sun Apr 3 16:59:55 2011 +0200
Enable next/previous search buttons and actions only when needed
the findNext and findPrevious buttons and actions are enabled only when needed. Works also with more than one chat tab
---
app/chat-window.cpp | 20 ++++++++++++++++++--
app/chat-window.h | 7 ++++---
lib/chat-search-bar.cpp | 17 ++++++++++++++++-
lib/chat-search-bar.h | 6 ++++++
4 files changed, 44 insertions(+), 6 deletions(-)
diff --git a/app/chat-window.cpp b/app/chat-window.cpp
index 0725ca6..ca1778a 100644
--- a/app/chat-window.cpp
+++ b/app/chat-window.cpp
@@ -35,6 +35,7 @@
#include <KSettings/Dialog>
#include <KNotifyConfigWidget>
#include <KMenuBar>
+#include <KLineEdit>
#include <TelepathyQt4/TextChannel>
@@ -48,8 +49,9 @@ ChatWindow::ChatWindow()
// keyboard shortcuts for the search bar
KStandardAction::find(this, SLOT(onSearchActionToggled()), actionCollection());
- KStandardAction::findNext(this, SLOT(onFindNextText()), actionCollection());
- KStandardAction::findPrev(this, SLOT(onFindPreviousText()), actionCollection());
+ // start disabled
+ KStandardAction::findNext(this, SLOT(onFindNextText()), actionCollection())->setEnabled(false);
+ KStandardAction::findPrev(this, SLOT(onFindPreviousText()), actionCollection())->setEnabled(false);
// set up m_tabWidget
m_tabWidget = new KTabWidget(this);
@@ -101,6 +103,7 @@ void ChatWindow::startChat(Tp::TextChannelPtr incomingTextChannel)
connect(chatTab, SIGNAL(userTypingChanged(bool)), this, SLOT(onTabStateChanged()));
connect(chatTab, SIGNAL(unreadMessagesChanged(int)), this, SLOT(onTabStateChanged()));
connect(chatTab, SIGNAL(contactPresenceChanged(Tp::Presence)), this, SLOT(onTabStateChanged()));
+ connect(chatTab->chatSearchBar(), SIGNAL(enableSearchButtonsSignal(bool)), this, SLOT(onEnableSearchActions(bool)));
m_tabWidget->addTab(chatTab, chatTab->icon(), chatTab->title());
m_tabWidget->setCurrentWidget(chatTab);
@@ -156,6 +159,19 @@ void ChatWindow::onCurrentIndexChanged(int index)
ChatTab* currentChatTab = qobject_cast<ChatTab*>(m_tabWidget->widget(index));
setWindowTitle(currentChatTab->title());
setWindowIcon(currentChatTab->icon());
+
+ // when the tab changes I need to "refresh" the window's findNext and findPrev actions
+ if (currentChatTab->chatSearchBar()->searchBar()->text().isEmpty()) {
+ onEnableSearchActions(false);
+ } else {
+ onEnableSearchActions(true);
+ }
+}
+
+void ChatWindow::onEnableSearchActions(bool enable)
+{
+ actionCollection()->action(KStandardAction::name(KStandardAction::FindNext))->setEnabled(enable);
+ actionCollection()->action(KStandardAction::name(KStandardAction::FindPrev))->setEnabled(enable);
}
void ChatWindow::onFindNextText()
diff --git a/app/chat-window.h b/app/chat-window.h
index 45ba617..8a55655 100644
--- a/app/chat-window.h
+++ b/app/chat-window.h
@@ -52,9 +52,10 @@ public slots:
private slots:
void onCurrentIndexChanged(int index);
- void onFindNextText(); /** go to next text the user is searching for */
- void onFindPreviousText(); /** go to previous text the user is searching for */
- void onSearchActionToggled(); /** toggle search bar visibility */
+ void onEnableSearchActions(bool enable); /** enables/disables menu search actions */
+ void onFindNextText(); /** go to next text the user is searching for */
+ void onFindPreviousText(); /** go to previous text the user is searching for */
+ void onSearchActionToggled(); /** toggle search bar visibility */
void onTabStateChanged();
void onTabTextChanged(const QString &newTitle);
void onTabIconChanged(const KIcon &newIcon);
diff --git a/lib/chat-search-bar.cpp b/lib/chat-search-bar.cpp
index 6b137b3..0659f93 100644
--- a/lib/chat-search-bar.cpp
+++ b/lib/chat-search-bar.cpp
@@ -44,7 +44,9 @@ ChatSearchBar::ChatSearchBar(QWidget* parent)
// search line setup
m_searchInput->setPlaceholderText(i18n("Insert search text..."));
- // search arrows
+ // search arrows, start disabled
+ enableSearchButtons(false);
+
connect(m_nextButton, SIGNAL(clicked()), this, SLOT(onNextButtonClicked()));
connect(m_previousButton, SIGNAL(clicked()), this, SLOT(onPreviousButtonClicked()));
@@ -74,6 +76,13 @@ ChatSearchBar::~ChatSearchBar()
}
+void ChatSearchBar::enableSearchButtons(bool enable)
+{
+ m_nextButton->setEnabled(enable);
+ m_previousButton->setEnabled(enable);
+ emit enableSearchButtonsSignal(enable);
+}
+
QWebPage::FindFlags ChatSearchBar::findFlags()
{
QWebPage::FindFlags flags;
@@ -143,6 +152,12 @@ void ChatSearchBar::toggleView(bool toggle)
void ChatSearchBar::textChanged(const QString& text)
{
+ // enable/disable next and previous buttons
+ if (!m_searchInput->text().isEmpty()) {
+ enableSearchButtons(true);
+ } else {
+ enableSearchButtons(false);
+ }
emit(findTextSignal(text, findFlags()));
}
diff --git a/lib/chat-search-bar.h b/lib/chat-search-bar.h
index 796280f..fbaac99 100644
--- a/lib/chat-search-bar.h
+++ b/lib/chat-search-bar.h
@@ -69,7 +69,13 @@ signals:
/** emitted when search criteria is changed by user and updates current view */
void flagsChangedSignal(const QString &, QWebPage::FindFlags flags);
+ /** send signal to mainwindow to enable/disable search buttons */
+ void enableSearchButtonsSignal(bool enable);
+
private:
+ /** enable/disable next and previous buttons for search */
+ void enableSearchButtons(bool enable);
+
/** returns selected search criteria chosen by user */
QWebPage::FindFlags findFlags();
--
ktp-text-ui packaging
More information about the pkg-kde-commits
mailing list