diff options
| -rw-r--r-- | COPYING.thirdparty | 17 | ||||
| -rw-r--r-- | Swift/QtUI/QtClosableLineEdit.cpp | 59 | ||||
| -rw-r--r-- | Swift/QtUI/QtClosableLineEdit.h | 43 | ||||
| -rw-r--r-- | Swift/QtUI/Roster/QtFilterWidget.cpp | 17 | ||||
| -rw-r--r-- | Swift/QtUI/Roster/QtFilterWidget.h | 6 | ||||
| -rw-r--r-- | Swift/QtUI/SConscript | 1 | 
6 files changed, 134 insertions, 9 deletions
| diff --git a/COPYING.thirdparty b/COPYING.thirdparty index aeaf066..a4b505c 100644 --- a/COPYING.thirdparty +++ b/COPYING.thirdparty @@ -49,70 +49,71 @@ If You Distribute, or Publicly Perform the Work or any Adaptations or Collection  Except as otherwise agreed in writing by the Licensor or as may be otherwise permitted by applicable law, if You Reproduce, Distribute or Publicly Perform the Work either by itself or as part of any Adaptations or Collections, You must not distort, mutilate, modify or take other derogatory action in relation to the Work which would be prejudicial to the Original Author's honor or reputation. Licensor agrees that in those jurisdictions (e.g. Japan), in which any exercise of the right granted in Section 3(b) of this License (the right to make Adaptations) would be deemed to be a distortion, mutilation, modification or other derogatory action prejudicial to the Original Author's honor and reputation, the Licensor will waive or not assert, as appropriate, this Section, to the fullest extent permitted by the applicable national law, to enable You to reasonably exercise Your right under Section 3(b) of this License (right to make Adaptations) but not otherwise.  5. Representations, Warranties and Disclaimer  UNLESS OTHERWISE MUTUALLY AGREED TO BY THE PARTIES IN WRITING, LICENSOR OFFERS THE WORK AS-IS AND MAKES NO REPRESENTATIONS OR WARRANTIES OF ANY KIND CONCERNING THE WORK, EXPRESS, IMPLIED, STATUTORY OR OTHERWISE, INCLUDING, WITHOUT LIMITATION, WARRANTIES OF TITLE, MERCHANTIBILITY, FITNESS FOR A PARTICULAR PURPOSE, NONINFRINGEMENT, OR THE ABSENCE OF LATENT OR OTHER DEFECTS, ACCURACY, OR THE PRESENCE OF ABSENCE OF ERRORS, WHETHER OR NOT DISCOVERABLE. SOME JURISDICTIONS DO NOT ALLOW THE EXCLUSION OF IMPLIED WARRANTIES, SO SUCH EXCLUSION MAY NOT APPLY TO YOU.  6. Limitation on Liability. EXCEPT TO THE EXTENT REQUIRED BY APPLICABLE LAW, IN NO EVENT WILL LICENSOR BE LIABLE TO YOU ON ANY LEGAL THEORY FOR ANY SPECIAL, INCIDENTAL, CONSEQUENTIAL, PUNITIVE OR EXEMPLARY DAMAGES ARISING OUT OF THIS LICENSE OR THE USE OF THE WORK, EVEN IF LICENSOR HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.  7. Termination  This License and the rights granted hereunder will terminate automatically upon any breach by You of the terms of this License. Individuals or entities who have received Adaptations or Collections from You under this License, however, will not have their licenses terminated provided such individuals or entities remain in full compliance with those licenses. Sections 1, 2, 5, 6, 7, and 8 will survive any termination of this License.  Subject to the above terms and conditions, the license granted here is perpetual (for the duration of the applicable copyright in the Work). Notwithstanding the above, Licensor reserves the right to release the Work under different license terms or to stop distributing the Work at any time; provided, however that any such election will not serve to withdraw this License (or any other license that has been, or is required to be, granted under the terms of this License), and this License will continue in full force and effect unless terminated as stated above.  8. Miscellaneous  Each time You Distribute or Publicly Perform the Work or a Collection, the Licensor offers to the recipient a license to the Work on the same terms and conditions as the license granted to You under this License.  Each time You Distribute or Publicly Perform an Adaptation, Licensor offers to the recipient a license to the original Work on the same terms and conditions as the license granted to You under this License.  If any provision of this License is invalid or unenforceable under applicable law, it shall not affect the validity or enforceability of the remainder of the terms of this License, and without further action by the parties to this agreement, such provision shall be reformed to the minimum extent necessary to make such provision valid and enforceable.  No term or provision of this License shall be deemed waived and no breach consented to unless such waiver or consent shall be in writing and signed by the party to be charged with such waiver or consent.  This License constitutes the entire agreement between the parties with respect to the Work licensed here. There are no understandings, agreements or representations with respect to the Work not specified here. Licensor shall not be bound by any additional provisions that may appear in any communication from You. This License may not be modified without the mutual written agreement of the Licensor and You.  The rights granted under, and the subject matter referenced, in this License were drafted utilizing the terminology of the Berne Convention for the Protection of Literary and Artistic Works (as amended on September 28, 1979), the Rome Convention of 1961, the WIPO Copyright Treaty of 1996, the WIPO Performances and Phonograms Treaty of 1996 and the Universal Copyright Convention (as revised on July 24, 1971). These rights and subject matter take effect in the relevant jurisdiction in which the License terms are sought to be enforced according to the corresponding provisions of the implementation of those treaty provisions in the applicable national law. If the standard suite of rights granted under applicable copyright law includes additional rights not granted under this License, such additional rights are deemed to be included in the License; this License is not intended to restrict the license of any rights under applicable law.  --- END OF CREATE COMMONS ATTRIBUTION 3.0 LICENSE ---  ================  Third-party code  ================  These projects contain source code from third parties:  - Patches from contributors  - Google Breakpad  - Boost  - Expat  - ZLib  - LibIDN +- Trolltech  The licenses under which these contributions and libraries are released are listed below.  ============  Contributors  ============  These projects contain some code contributed under the BSD License, under the following terms:  --- START OF BSD LICENSE  Copyright (c) 2011, Arnt Gulbrandsen  Copyright (c) 2011, Thilo Cestonaro  Copyright (c) 2011, Vlad Voicu  Copyright (c) 2011, Jan Kaluza  Copyright (c) 2011, Tobias Markmann  Copyright (c) 2011, Soren Dreijer  Copyright (c) 2012, Vitaly Takmazov  Copyright (c) 2012, Pavol Babincak  All rights reserved.  Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:  Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.  Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.  Neither the name of their organizations nor the names of the contributors may be used to endorse or promote products derived from this software without specific prior written permission.  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.  --- END OF BSD LICENSE  --- START OF SIMPLIFIED BSD LICENSE  Copyright (c) 2012 Isode Limited, London, England.  Copyright (c) 2012 Yoann Blein.  Copyright (c) 2012 Mateusz Piekos.  Copyright (c) 2012 Catalin Badea. @@ -724,35 +725,51 @@ ordinary General Public License).    To apply these terms, attach the following notices to the library.  It is  safest to attach them to the start of each source file to most effectively  convey the exclusion of warranty; and each file should have at least the  "copyright" line and a pointer to where the full notice is found.      <one line to give the library's name and a brief idea of what it does.>      Copyright (C) <year>  <name of author>      This library is free software; you can redistribute it and/or      modify it under the terms of the GNU Lesser General Public      License as published by the Free Software Foundation; either      version 2.1 of the License, or (at your option) any later version.      This library is distributed in the hope that it will be useful,      but WITHOUT ANY WARRANTY; without even the implied warranty of      MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU      Lesser General Public License for more details.      You should have received a copy of the GNU Lesser General Public      License along with this library; if not, write to the Free Software      Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA  Also add information on how to contact you by electronic and paper mail.  You should also get your employer (if you work as a programmer) or your  school, if any, to sign a "copyright disclaimer" for the library, if  necessary.  Here is a sample; alter the names:    Yoyodyne, Inc., hereby disclaims all copyright interest in the    library `Frob' (a library for tweaking knobs) written by James Random Hacker.    <signature of Ty Coon>, 1 April 1990    Ty Coon, President of Vice  That's all there is to it! + + +========= +Trolltech +========= + +Demo code from http://git.forwardbias.in/?p=lineeditclearbutton.git with license: + +/**************************************************************************** +** +** Copyright (c) 2007 Trolltech ASA <info@trolltech.com> +** +** Use, modification and distribution is allowed without limitation, +** warranty, liability or support of any kind. +** +****************************************************************************/ diff --git a/Swift/QtUI/QtClosableLineEdit.cpp b/Swift/QtUI/QtClosableLineEdit.cpp new file mode 100644 index 0000000..512194b --- /dev/null +++ b/Swift/QtUI/QtClosableLineEdit.cpp @@ -0,0 +1,59 @@ +/* + * Copyright (c) 2014 Kevin Smith and Remko Tronçon + * Licensed under the GNU General Public License v3. + * See Documentation/Licenses/GPLv3.txt for more information. + */ + +/* Contains demo Trolltech code from http://git.forwardbias.in/?p=lineeditclearbutton.git with license: */ +/**************************************************************************** +** +** Copyright (c) 2007 Trolltech ASA <info@trolltech.com> +** +** Use, modification and distribution is allowed without limitation, +** warranty, liability or support of any kind. +** +****************************************************************************/ + +#include <Swift/QtUI/QtClosableLineEdit.h> +#include <QApplication> +#include <QToolButton> +#include <QStyle> +#include <QKeyEvent> + +namespace Swift { + +const int QtClosableLineEdit::clearButtonPadding = 2; + +QtClosableLineEdit::QtClosableLineEdit(QWidget *parent) : QLineEdit(parent) { +	clearButton = new QToolButton(this); +	clearButton->setIcon(style()->standardIcon(QStyle::SP_TitleBarCloseButton)); +	clearButton->setIconSize(QSize(16,16)); +	clearButton->setCursor(Qt::ArrowCursor); +	clearButton->setStyleSheet("QToolButton { border: none; padding: 0px; }"); +	clearButton->hide(); +	connect(clearButton, SIGNAL(clicked()), this, SLOT(handleCloseButtonClicked())); +	connect(this, SIGNAL(textChanged(const QString&)), this, SLOT(updateCloseButton(const QString&))); +	int frameWidth = style()->pixelMetric(QStyle::PM_DefaultFrameWidth); +	setStyleSheet(QString("QLineEdit { padding-right: %1px; } ").arg(clearButton->sizeHint().width() + frameWidth + 1)); +	QSize minimumSize = minimumSizeHint(); +	setMinimumSize(qMax(minimumSize.width(), clearButton->sizeHint().width() + frameWidth * 2 + clearButtonPadding), +								qMax(minimumSize.height(), clearButton->sizeHint().height() + frameWidth * 2 + clearButtonPadding)); +} + +void QtClosableLineEdit::resizeEvent(QResizeEvent *) { +	QSize size = clearButton->sizeHint(); +	int frameWidth = style()->pixelMetric(QStyle::PM_DefaultFrameWidth); +	clearButton->move(rect().right() - frameWidth - size.width(), (rect().bottom() + 1 - size.height())/2); +} + +void QtClosableLineEdit::updateCloseButton(const QString& text) { +	clearButton->setVisible(!text.isEmpty()); +} + +void QtClosableLineEdit::handleCloseButtonClicked() { +	clear(); +	QApplication::postEvent(this, new QKeyEvent(QEvent::KeyPress, Qt::Key_Escape, Qt::NoModifier)); +	QApplication::postEvent(this, new QKeyEvent(QEvent::KeyRelease, Qt::Key_Escape, Qt::NoModifier)); +} + +} diff --git a/Swift/QtUI/QtClosableLineEdit.h b/Swift/QtUI/QtClosableLineEdit.h new file mode 100644 index 0000000..91b4f0e --- /dev/null +++ b/Swift/QtUI/QtClosableLineEdit.h @@ -0,0 +1,43 @@ +/* + * Copyright (c) 2014 Kevin Smith and Remko Tronçon + * Licensed under the GNU General Public License v3. + * See Documentation/Licenses/GPLv3.txt for more information. + */ + +/* Contains demo Trolltech code from http://git.forwardbias.in/?p=lineeditclearbutton.git with license: */ +/**************************************************************************** +** +** Copyright (c) 2007 Trolltech ASA <info@trolltech.com> +** +** Use, modification and distribution is allowed without limitation, +** warranty, liability or support of any kind. +** +****************************************************************************/ + +#pragma once + +#include <QLineEdit> + +class QToolButton; + +namespace Swift { + +class QtClosableLineEdit : public QLineEdit +{ +	Q_OBJECT +	public: +		QtClosableLineEdit(QWidget *parent = 0); + +	protected: +		void resizeEvent(QResizeEvent *); + +	private slots: +		void updateCloseButton(const QString &text); +		void handleCloseButtonClicked(); + +	private: +		static const int clearButtonPadding; +		QToolButton *clearButton; +}; + +} diff --git a/Swift/QtUI/Roster/QtFilterWidget.cpp b/Swift/QtUI/Roster/QtFilterWidget.cpp index 2f08981..a4c9449 100644 --- a/Swift/QtUI/Roster/QtFilterWidget.cpp +++ b/Swift/QtUI/Roster/QtFilterWidget.cpp @@ -1,62 +1,69 @@  /* + * Copyright (c) 2014 Kevin Smith and Remko Tronçon + * Licensed under the GNU General Public License v3. + * See Documentation/Licenses/GPLv3.txt for more information. + */ + +/*   * Copyright (c) 2013 Tobias Markmann   * Licensed under the simplified BSD license.   * See Documentation/Licenses/BSD-simplified.txt for more information.   */ -#include <QLayout> -#include <QVBoxLayout> -#include <QKeyEvent>  #include <QEvent> +#include <QKeyEvent> +#include <QLayout>  #include <QString> -#include <QEvent> +#include <QVBoxLayout> +  #include <Swift/Controllers/UIEvents/RequestChatUIEvent.h>  #include <Swift/Controllers/UIEvents/UIEventStream.h> +#include <Swift/QtUI/QtClosableLineEdit.h>  #include <Swift/QtUI/QtSwiftUtil.h>  #include <Swift/QtUI/Roster/QtFilterWidget.h>  namespace Swift {  QtFilterWidget::QtFilterWidget(QWidget* parent, QtTreeWidget* treeView, UIEventStream* eventStream, QBoxLayout* layout) : QWidget(parent), treeView_(treeView), eventStream_(eventStream), fuzzyRosterFilter_(0), isModifierSinglePressed_(false) {  	int targetIndex = layout->indexOf(treeView);  	QVBoxLayout* vboxLayout = new QVBoxLayout(this);  	vboxLayout->setSpacing(0);  	vboxLayout->setContentsMargins(0,0,0,0); -	filterLineEdit_ = new QLineEdit(this); +	filterLineEdit_ = new QtClosableLineEdit(this);  	filterLineEdit_->hide();  	vboxLayout->addWidget(filterLineEdit_);  	vboxLayout->addWidget(treeView);  	setLayout(vboxLayout);  	layout->insertWidget(targetIndex, this);  	filterLineEdit_->installEventFilter(this);  	treeView->installEventFilter(this);  	sourceModel_ = treeView_->model();  }  QtFilterWidget::~QtFilterWidget() {  }  bool QtFilterWidget::eventFilter(QObject*, QEvent* event) {  	if (event->type() == QEvent::KeyPress ||  		event->type() == QEvent::KeyRelease ||  		// InputMethodQuery got introduced in Qt 5.  #if QT_VERSION >= 0x050000  		event->type() == QEvent::InputMethodQuery ||  #endif  		event->type() == QEvent::InputMethod) {  		event->ignore();  		QKeyEvent* keyEvent = dynamic_cast<QKeyEvent*>(event);  		if (keyEvent) {  			if (keyEvent->key() == Qt::Key_Up || keyEvent->key() == Qt::Key_Down) {  				return false;  			} else if ((keyEvent->key() == Qt::Key_Left || keyEvent->key() == Qt::Key_Right) && filterLineEdit_->text().isEmpty()) {  				return false;  			} else if (keyEvent->key() == Qt::Key_Alt && event->type() == QEvent::KeyPress) {  				isModifierSinglePressed_ = true;  			} else if (keyEvent->key() == Qt::Key_Alt && event->type() == QEvent::KeyRelease && isModifierSinglePressed_) { diff --git a/Swift/QtUI/Roster/QtFilterWidget.h b/Swift/QtUI/Roster/QtFilterWidget.h index 94ebc2a..3e17566 100644 --- a/Swift/QtUI/Roster/QtFilterWidget.h +++ b/Swift/QtUI/Roster/QtFilterWidget.h @@ -1,50 +1,48 @@  /*   * Copyright (c) 2013 Tobias Markmann   * Licensed under the simplified BSD license.   * See Documentation/Licenses/BSD-simplified.txt for more information.   */  #pragma once  #include <vector>  #include <QBoxLayout> -#include <QLineEdit>  #include <QWidget>  #include <Swift/Controllers/Roster/RosterFilter.h>  #include <Swift/Controllers/Roster/FuzzyRosterFilter.h>  #include <Swift/QtUI/Roster/QtTreeWidget.h>  namespace Swift { -  class UIEventStream; - +class QtClosableLineEdit;  class QtFilterWidget : public QWidget {  	Q_OBJECT  	public:  		QtFilterWidget(QWidget* parent, QtTreeWidget* treeView, UIEventStream* eventStream, QBoxLayout* layout = 0);  		virtual ~QtFilterWidget();  	protected:  		bool eventFilter(QObject*, QEvent* event);  	private:  		void popAllFilters();  		void pushAllFilters();  		void updateRosterFilters();  		void updateSearchFilter();  	private: -		QLineEdit* filterLineEdit_; +		QtClosableLineEdit* filterLineEdit_;  		QtTreeWidget* treeView_;  		UIEventStream* eventStream_;  		std::vector<RosterFilter*> filters_;  		QAbstractItemModel* sourceModel_;  		FuzzyRosterFilter* fuzzyRosterFilter_;  		bool isModifierSinglePressed_;  };  } diff --git a/Swift/QtUI/SConscript b/Swift/QtUI/SConscript index 06b04fa..53dbea9 100644 --- a/Swift/QtUI/SConscript +++ b/Swift/QtUI/SConscript @@ -98,70 +98,71 @@ sources = [      "QtBlockListEditorWindow.cpp",      "QtNameWidget.cpp",      "QtSettingsProvider.cpp",      "QtStatusWidget.cpp",      "QtScaledAvatarCache.cpp",      "QtSwift.cpp",      "QtURIHandler.cpp",      "QtChatWindow.cpp",      "QtChatView.cpp",      "QtWebKitChatView.cpp",      "QtPlainChatView.cpp",      "QtChatTheme.cpp",      "QtChatTabs.cpp",      "QtSoundPlayer.cpp",      "QtSystemTray.cpp",      "QtCachedImageScaler.cpp",      "QtTabbable.cpp",      "QtTabWidget.cpp",      "QtTextEdit.cpp",      "QtXMLConsoleWidget.cpp",      "QtHistoryWindow.cpp",      "QtFileTransferListWidget.cpp",      "QtFileTransferListItemModel.cpp",      "QtAdHocCommandWindow.cpp",      "QtUtilities.cpp",      "QtBookmarkDetailWindow.cpp",      "QtAddBookmarkWindow.cpp",      "QtEditBookmarkWindow.cpp",      "QtContactEditWindow.cpp",      "QtContactEditWidget.cpp",      "QtSingleWindow.cpp",      "QtHighlightEditorWidget.cpp",      "QtHighlightRulesItemModel.cpp",      "QtHighlightRuleWidget.cpp",      "QtColorToolButton.cpp", +    "QtClosableLineEdit.cpp",      "ChatSnippet.cpp",      "MessageSnippet.cpp",      "SystemMessageSnippet.cpp",      "QtElidingLabel.cpp",      "QtFormWidget.cpp",      "QtFormResultItemModel.cpp",      "QtLineEdit.cpp",      "QtJoinMUCWindow.cpp",      "QtConnectionSettingsWindow.cpp",      "Roster/RosterModel.cpp",      "Roster/QtTreeWidget.cpp",  #    "Roster/QtTreeWidgetItem.cpp",      "Roster/RosterDelegate.cpp",      "Roster/GroupItemDelegate.cpp",      "Roster/DelegateCommons.cpp",      "Roster/QtFilterWidget.cpp",      "Roster/QtRosterWidget.cpp",      "Roster/QtOccupantListWidget.cpp",      "Roster/RosterTooltip.cpp",      "EventViewer/EventModel.cpp",      "EventViewer/EventDelegate.cpp",      "EventViewer/TwoLineDelegate.cpp",      "EventViewer/QtEventWindow.cpp",      "EventViewer/QtEvent.cpp",      "ChatList/QtChatListWindow.cpp",      "ChatList/ChatListModel.cpp",      "ChatList/ChatListDelegate.cpp",      "ChatList/ChatListMUCItem.cpp",      "ChatList/ChatListRecentItem.cpp",      "ChatList/ChatListWhiteboardItem.cpp",      "MUCSearch/QtMUCSearchWindow.cpp",      "MUCSearch/MUCSearchModel.cpp",      "MUCSearch/MUCSearchRoomItem.cpp",      "MUCSearch/MUCSearchEmptyItem.cpp",      "MUCSearch/MUCSearchDelegate.cpp", | 
 Swift
 Swift