From 7c0cdd710f6ffab81a8cf4677bb3fb85867aa1f5 Mon Sep 17 00:00:00 2001 From: krepa098 Date: Mon, 1 Sep 2014 11:00:06 +0200 Subject: [PATCH 1/7] editable CroppingLabel --- widget/croppinglabel.cpp | 79 +++++++++++++++++++++++++++++++++++++++- widget/croppinglabel.h | 13 +++++++ 2 files changed, 91 insertions(+), 1 deletion(-) diff --git a/widget/croppinglabel.cpp b/widget/croppinglabel.cpp index f69e81c4c..bed2f023e 100644 --- a/widget/croppinglabel.cpp +++ b/widget/croppinglabel.cpp @@ -15,11 +15,36 @@ */ #include "croppinglabel.h" +#include CroppingLabel::CroppingLabel(QWidget* parent) : QLabel(parent) + , blockPaintEvents(false) + , editable(false) + , elideMode(Qt::ElideRight) { setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Preferred); + + textEdit = new QLineEdit(this); + textEdit->hide(); + + installEventFilter(this); + textEdit->installEventFilter(this); +} + +void CroppingLabel::setEditable(bool editable) +{ + this->editable = editable; + + if (editable) + setCursor(Qt::PointingHandCursor); + else + unsetCursor(); +} + +void CroppingLabel::setEdlideMode(Qt::TextElideMode elide) +{ + elideMode = elide; } void CroppingLabel::setText(const QString& text) @@ -31,6 +56,8 @@ void CroppingLabel::setText(const QString& text) void CroppingLabel::resizeEvent(QResizeEvent* ev) { setElidedText(); + textEdit->resize(ev->size()); + QLabel::resizeEvent(ev); } @@ -44,9 +71,50 @@ QSize CroppingLabel::minimumSizeHint() const return QSize(fontMetrics().width("..."), QLabel::minimumSizeHint().height()); } +void CroppingLabel::mouseReleaseEvent(QMouseEvent *e) +{ + if (editable) + { + blockPaintEvents = true; + textEdit->show(); + textEdit->setFocus(); + } + + QLabel::mouseReleaseEvent(e); +} + +bool CroppingLabel::eventFilter(QObject *obj, QEvent *e) +{ + // catch paint events if needed + if (obj == this) + { + if (e->type() == QEvent::Paint && blockPaintEvents) + return true; + } + + // events fired by the QLineEdit + if (obj == textEdit) + { + if (e->type() == QEvent::KeyPress) + { + QKeyEvent* keyEvent = static_cast(e); + if (keyEvent->key() == Qt::Key_Return) + hideTextEdit(true); + + if (keyEvent->key() == Qt::Key_Escape) + hideTextEdit(false); + } + + if (e->type() == QEvent::FocusOut) + hideTextEdit(true); + } + + return false; +} + void CroppingLabel::setElidedText() { - QString elidedText = fontMetrics().elidedText(origText, Qt::ElideRight, width()); + QString elidedText = fontMetrics().elidedText(origText, elideMode, width()); if (elidedText != origText) setToolTip(origText); else @@ -54,3 +122,12 @@ void CroppingLabel::setElidedText() QLabel::setText(elidedText); } + +void CroppingLabel::hideTextEdit(bool acceptText) +{ + if (acceptText) + setText(textEdit->text()); + + textEdit->hide(); + blockPaintEvents = false; +} diff --git a/widget/croppinglabel.h b/widget/croppinglabel.h index decc5ad19..25fa34df0 100644 --- a/widget/croppinglabel.h +++ b/widget/croppinglabel.h @@ -18,6 +18,7 @@ #define CROPPINGLABEL_H #include +#include class CroppingLabel : public QLabel { @@ -25,16 +26,28 @@ class CroppingLabel : public QLabel public: explicit CroppingLabel(QWidget *parent = 0); + void setEditable(bool editable); + void setEdlideMode(Qt::TextElideMode elide); + virtual void setText(const QString& text); virtual void resizeEvent(QResizeEvent *ev); virtual QSize sizeHint() const; virtual QSize minimumSizeHint() const; + virtual void mouseReleaseEvent(QMouseEvent *e); + virtual bool eventFilter(QObject *obj, QEvent *e); protected: void setElidedText(); + void acceptText(); + void rejectText(); + void hideTextEdit(bool acceptText); private: QString origText; + QLineEdit* textEdit; + bool blockPaintEvents; + bool editable; + Qt::TextElideMode elideMode; }; #endif // CROPPINGLABEL_H From 26c028f416fc1ee3131de2d05fd08f4c70d275dd Mon Sep 17 00:00:00 2001 From: krepa098 Date: Mon, 1 Sep 2014 11:08:02 +0200 Subject: [PATCH 2/7] removed ClickableLabel, EditableLabelWidget, ElideLabel, EscLineEdit, CopyableElideLabel --- mainwindow.ui | 20 ++--- qtox.pro | 10 --- widget/form/settingsform.h | 3 +- widget/tool/clickablelabel.cpp | 27 ------- widget/tool/clickablelabel.h | 36 --------- widget/tool/copyableelidelabel.cpp | 47 ----------- widget/tool/copyableelidelabel.h | 36 --------- widget/tool/editablelabelwidget.cpp | 117 ---------------------------- widget/tool/editablelabelwidget.h | 66 ---------------- widget/tool/elidelabel.cpp | 82 ------------------- widget/tool/elidelabel.h | 50 ------------ widget/tool/esclineedit.cpp | 34 -------- widget/tool/esclineedit.h | 36 --------- widget/widget.cpp | 7 +- 14 files changed, 16 insertions(+), 555 deletions(-) delete mode 100644 widget/tool/clickablelabel.cpp delete mode 100644 widget/tool/clickablelabel.h delete mode 100644 widget/tool/copyableelidelabel.cpp delete mode 100644 widget/tool/copyableelidelabel.h delete mode 100644 widget/tool/editablelabelwidget.cpp delete mode 100644 widget/tool/editablelabelwidget.h delete mode 100644 widget/tool/elidelabel.cpp delete mode 100644 widget/tool/elidelabel.h delete mode 100644 widget/tool/esclineedit.cpp delete mode 100644 widget/tool/esclineedit.h diff --git a/mainwindow.ui b/mainwindow.ui index 8622e3d68..7f9cd12c5 100644 --- a/mainwindow.ui +++ b/mainwindow.ui @@ -1482,7 +1482,7 @@ QSplitter:handle{ 0 - + true @@ -1920,7 +1920,7 @@ QSplitter:handle{ - + 1 @@ -2092,8 +2092,8 @@ QSplitter:handle{ 0 0 - 335 - 379 + 263 + 373 @@ -3228,7 +3228,7 @@ QSplitter:handle{ 0 0 716 - 24 + 23 @@ -3243,17 +3243,17 @@ QSplitter:handle{ - - EditableLabelWidget - QLabel -
widget/tool/editablelabelwidget.h
-
AdjustingScrollArea QScrollArea
widget/adjustingscrollarea.h
1
+ + CroppingLabel + QLabel +
widget/croppinglabel.h
+
diff --git a/qtox.pro b/qtox.pro index 6060257cc..8f87e7255 100644 --- a/qtox.pro +++ b/qtox.pro @@ -71,10 +71,6 @@ HEADERS += widget/form/addfriendform.h \ widget/form/settingsform.h \ widget/form/filesform.h \ widget/tool/chattextedit.h \ - widget/tool/copyableelidelabel.h \ - widget/tool/editablelabelwidget.h \ - widget/tool/elidelabel.h \ - widget/tool/esclineedit.h \ widget/tool/friendrequestdialog.h \ widget/filetransfertwidget.h \ widget/friendwidget.h \ @@ -91,7 +87,6 @@ HEADERS += widget/form/addfriendform.h \ widget/selfcamview.h \ widget/camera.h \ widget/netcamview.h \ - widget/tool/clickablelabel.h \ smileypack.h \ widget/emoticonswidget.h \ style.h \ @@ -106,10 +101,6 @@ SOURCES += \ widget/form/settingsform.cpp \ widget/form/filesform.cpp \ widget/tool/chattextedit.cpp \ - widget/tool/copyableelidelabel.cpp \ - widget/tool/editablelabelwidget.cpp \ - widget/tool/elidelabel.cpp \ - widget/tool/esclineedit.cpp \ widget/tool/friendrequestdialog.cpp \ widget/filetransfertwidget.cpp \ widget/friendwidget.cpp \ @@ -127,7 +118,6 @@ SOURCES += \ widget/selfcamview.cpp \ widget/camera.cpp \ widget/netcamview.cpp \ - widget/tool/clickablelabel.cpp \ smileypack.cpp \ widget/emoticonswidget.cpp \ style.cpp \ diff --git a/widget/form/settingsform.h b/widget/form/settingsform.h index 0c8f59ee4..83e6800b7 100644 --- a/widget/form/settingsform.h +++ b/widget/form/settingsform.h @@ -27,7 +27,6 @@ #include #include #include -#include "widget/tool/clickablelabel.h" #include "ui_mainwindow.h" #include "widget/selfcamview.h" @@ -54,7 +53,7 @@ private slots: private: QLabel headLabel, nameLabel, statusTextLabel, smileyPackLabel; QTextEdit id; - ClickableLabel idLabel; + QLabel idLabel; QPushButton videoTest; QCheckBox enableIPv6, useTranslations, makeToxPortable; QVBoxLayout layout, headLayout; diff --git a/widget/tool/clickablelabel.cpp b/widget/tool/clickablelabel.cpp deleted file mode 100644 index 9e61becff..000000000 --- a/widget/tool/clickablelabel.cpp +++ /dev/null @@ -1,27 +0,0 @@ -/* - Copyright (C) 2014 by Project Tox - - This file is part of qTox, a Qt-based graphical interface for Tox. - - This program is libre software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - This program 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 COPYING file for more details. -*/ - -#include "clickablelabel.h" - -ClickableLabel::ClickableLabel(QWidget *parent) : - QLabel(parent) -{ -} - -void ClickableLabel::mousePressEvent(QMouseEvent*) -{ - emit clicked(); -} diff --git a/widget/tool/clickablelabel.h b/widget/tool/clickablelabel.h deleted file mode 100644 index db475ee1c..000000000 --- a/widget/tool/clickablelabel.h +++ /dev/null @@ -1,36 +0,0 @@ -/* - Copyright (C) 2014 by Project Tox - - This file is part of qTox, a Qt-based graphical interface for Tox. - - This program is libre software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - This program 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 COPYING file for more details. -*/ - -#ifndef CLICKABLELABEL_H -#define CLICKABLELABEL_H - -#include - -class ClickableLabel : public QLabel -{ - Q_OBJECT -public: - explicit ClickableLabel(QWidget *parent = 0); - -signals: - void clicked(); - -protected: - void mousePressEvent ( QMouseEvent * event ); - -}; - -#endif // CLICKABLELABEL_H diff --git a/widget/tool/copyableelidelabel.cpp b/widget/tool/copyableelidelabel.cpp deleted file mode 100644 index ae05717ca..000000000 --- a/widget/tool/copyableelidelabel.cpp +++ /dev/null @@ -1,47 +0,0 @@ -/* - Copyright (C) 2013 by Maxim Biro - - This file is part of Tox Qt GUI. - - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - This program 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 COPYING file for more details. -*/ - -#include "copyableelidelabel.h" - -#include -#include -#include - -CopyableElideLabel::CopyableElideLabel(QWidget* parent) : - ElideLabel(parent) -{ - setContextMenuPolicy(Qt::CustomContextMenu); - connect(this, &CopyableElideLabel::customContextMenuRequested, this, &CopyableElideLabel::showContextMenu); - - actionCopy = new QAction(CopyableElideLabel::tr("Copy"), this); - connect(actionCopy, &QAction::triggered, [this]() { - QApplication::clipboard()->setText(text()); - }); -} - -void CopyableElideLabel::showContextMenu(const QPoint& pos) -{ - if (text().length() == 0) { - return; - } - - QPoint globalPos = mapToGlobal(pos); - - QMenu contextMenu; - contextMenu.addAction(actionCopy); - - contextMenu.exec(globalPos); -} diff --git a/widget/tool/copyableelidelabel.h b/widget/tool/copyableelidelabel.h deleted file mode 100644 index 69bc09382..000000000 --- a/widget/tool/copyableelidelabel.h +++ /dev/null @@ -1,36 +0,0 @@ -/* - Copyright (C) 2013 by Maxim Biro - - This file is part of Tox Qt GUI. - - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - This program 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 COPYING file for more details. -*/ - -#ifndef COPYABLEELIDELABEL_HPP -#define COPYABLEELIDELABEL_HPP - -#include "elidelabel.h" - -class CopyableElideLabel : public ElideLabel -{ - Q_OBJECT -public: - explicit CopyableElideLabel(QWidget* parent = 0); - -private: - QAction* actionCopy; - -private slots: - void showContextMenu(const QPoint& pos); - -}; - -#endif // COPYABLEELIDELABEL_HPP diff --git a/widget/tool/editablelabelwidget.cpp b/widget/tool/editablelabelwidget.cpp deleted file mode 100644 index a9c87f27a..000000000 --- a/widget/tool/editablelabelwidget.cpp +++ /dev/null @@ -1,117 +0,0 @@ -/* - Copyright (C) 2013 by Maxim Biro - - This file is part of Tox Qt GUI. - - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - This program 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 COPYING file for more details. -*/ - -#include "editablelabelwidget.h" - -#include -#include -#include -#include -#include - -ClickableCopyableElideLabel::ClickableCopyableElideLabel(QWidget* parent) : - CopyableElideLabel(parent) -{ -} - -bool ClickableCopyableElideLabel::event(QEvent* event) -{ - if (event->type() == QEvent::MouseButtonRelease) { - QMouseEvent* mouseEvent = static_cast(event); - if (mouseEvent->button() == Qt::LeftButton) { - emit clicked(); - } - } else if (event->type() == QEvent::Enter) { - QApplication::setOverrideCursor(QCursor(Qt::PointingHandCursor)); - } else if (event->type() == QEvent::Leave) { - QApplication::restoreOverrideCursor(); - } - - return CopyableElideLabel::event(event); -} - -EditableLabelWidget::EditableLabelWidget(QWidget* parent) : - QStackedWidget(parent), isSubmitting(false) -{ - label = new ClickableCopyableElideLabel(this); - - connect(label, &ClickableCopyableElideLabel::clicked, this, &EditableLabelWidget::onLabelClicked); - - lineEdit = new EscLineEdit(this); - lineEdit->setSizePolicy(QSizePolicy::Ignored, QSizePolicy::Ignored); - lineEdit->setMinimumHeight(label->fontMetrics().lineSpacing() + LINE_SPACING_OFFSET); - - // Set dark background for >windows - //QColor toxDarkAsMySoul(28,28,28); - //QPalette darkPal; - //darkPal.setColor(QPalette::Window, toxDarkAsMySoul); - //darkPal.setColor(QPalette::Base, toxDarkAsMySoul); - //lineEdit->setPalette(darkPal); - - connect(lineEdit, &EscLineEdit::editingFinished, this, &EditableLabelWidget::onLabelChangeSubmited); - connect(lineEdit, &EscLineEdit::escPressed, this, &EditableLabelWidget::onLabelChangeCancelled); - - addWidget(label); - addWidget(lineEdit); - - setCurrentWidget(label); -} - -void EditableLabelWidget::setText(const QString& text) -{ - label->setText(text); - lineEdit->setText(text); -} - -QString EditableLabelWidget::text() -{ - return label->text(); -} - -void EditableLabelWidget::onLabelChangeSubmited() -{ - if (isSubmitting) { - return; - } - isSubmitting = true; - - QString oldText = label->text(); - QString newText = lineEdit->text(); - // `lineEdit->clearFocus()` triggers `onLabelChangeSubmited()`, we use `isSubmitting` as a workaround - lineEdit->clearFocus(); - setCurrentWidget(label); - - if (oldText != newText) { - label->setText(newText); - emit textChanged(newText, oldText); - } - - isSubmitting = false; -} - -void EditableLabelWidget::onLabelChangeCancelled() -{ - // order of calls matters, since clearFocus() triggers EditableLabelWidget::onLabelChangeSubmited() - lineEdit->setText(label->text()); - lineEdit->clearFocus(); - setCurrentWidget(label); -} - -void EditableLabelWidget::onLabelClicked() -{ - setCurrentWidget(lineEdit); - lineEdit->setFocus(); -} diff --git a/widget/tool/editablelabelwidget.h b/widget/tool/editablelabelwidget.h deleted file mode 100644 index 17772f8c4..000000000 --- a/widget/tool/editablelabelwidget.h +++ /dev/null @@ -1,66 +0,0 @@ -/* - Copyright (C) 2013 by Maxim Biro - - This file is part of Tox Qt GUI. - - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - This program 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 COPYING file for more details. -*/ - -#ifndef EDITABLELABELWIDGET_HPP -#define EDITABLELABELWIDGET_HPP - -#include "copyableelidelabel.h" -#include "esclineedit.h" - -#include -#include - -class ClickableCopyableElideLabel : public CopyableElideLabel -{ - Q_OBJECT -public: - explicit ClickableCopyableElideLabel(QWidget* parent = 0); - -protected: - bool event(QEvent* event) Q_DECL_OVERRIDE; - -signals: - void clicked(); - -}; - -class EditableLabelWidget : public QStackedWidget -{ - Q_OBJECT -public: - explicit EditableLabelWidget(QWidget* parent = 0); - - ClickableCopyableElideLabel* label; - EscLineEdit* lineEdit; - - void setText(const QString& text); - QString text(); - -private: - static const int LINE_SPACING_OFFSET = 2; - bool isSubmitting; - -private slots: - void onLabelChangeSubmited(); - void onLabelChangeCancelled(); - void onLabelClicked(); - -signals: - void textChanged(QString newText, QString oldText); - -}; - -#endif // EDITABLELABELWIDGET_HPP diff --git a/widget/tool/elidelabel.cpp b/widget/tool/elidelabel.cpp deleted file mode 100644 index 239400f49..000000000 --- a/widget/tool/elidelabel.cpp +++ /dev/null @@ -1,82 +0,0 @@ -/* - Copyright (C) 2013 by Maxim Biro - - This file is part of Tox Qt GUI. - - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - This program 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 COPYING file for more details. -*/ - -#include "elidelabel.h" - -#include -#include - -ElideLabel::ElideLabel(QWidget *parent) : - QLabel(parent), _textElide(false), _textElideMode(Qt::ElideNone), _showToolTipOnElide(false) -{ -} - -void ElideLabel::paintEvent(QPaintEvent *event) -{ - QFrame::paintEvent(event); - QPainter p(this); - QFontMetrics metrics(font()); - if ((metrics.width(text()) > contentsRect().width()) && textElide()) { - QString elidedText = fontMetrics().elidedText(text(), textElideMode(), rect().width()); - p.drawText(rect(), alignment(), elidedText); - } else { - QLabel::paintEvent(event); - } -} - -bool ElideLabel::event(QEvent *event) -{ - if (event->type() == QEvent::ToolTip) { - QFontMetrics metrics(font()); - if ((metrics.width(text()) > contentsRect().width()) && textElide() && showToolTipOnElide()) { - setToolTip(text()); - } else { - setToolTip(""); - } - } - - return QLabel::event(event); -} - -void ElideLabel::setTextElide(bool set) -{ - _textElide = set; -} - -bool ElideLabel::textElide() const -{ - return _textElide; -} - -void ElideLabel::setTextElideMode(Qt::TextElideMode mode) -{ - _textElideMode = mode; -} - -Qt::TextElideMode ElideLabel::textElideMode() const -{ - return _textElideMode; -} - -void ElideLabel::setShowToolTipOnElide(bool show) -{ - _showToolTipOnElide = show; -} - -bool ElideLabel::showToolTipOnElide() -{ - return _showToolTipOnElide; -} diff --git a/widget/tool/elidelabel.h b/widget/tool/elidelabel.h deleted file mode 100644 index 5dd309001..000000000 --- a/widget/tool/elidelabel.h +++ /dev/null @@ -1,50 +0,0 @@ -/* - Copyright (C) 2013 by Maxim Biro - - This file is part of Tox Qt GUI. - - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - This program 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 COPYING file for more details. -*/ - -#ifndef ELIDELABEL_HPP -#define ELIDELABEL_HPP - -#include - -class ElideLabel : public QLabel -{ - Q_OBJECT -public: - explicit ElideLabel(QWidget *parent = 0); - - void setTextElide(bool set); - bool textElide() const; - - void setTextElideMode(Qt::TextElideMode mode); - Qt::TextElideMode textElideMode() const; - - void setShowToolTipOnElide(bool show); - bool showToolTipOnElide(); - -protected: - void paintEvent(QPaintEvent *event) Q_DECL_OVERRIDE; - bool event(QEvent *e) Q_DECL_OVERRIDE; - -private: - bool _textElide; - Qt::TextElideMode _textElideMode; - - bool _showToolTipOnElide; - - -}; - -#endif // ELIDELABEL_HPP diff --git a/widget/tool/esclineedit.cpp b/widget/tool/esclineedit.cpp deleted file mode 100644 index 1a6adc373..000000000 --- a/widget/tool/esclineedit.cpp +++ /dev/null @@ -1,34 +0,0 @@ -/* - Copyright (C) 2013 by Maxim Biro - - This file is part of Tox Qt GUI. - - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - This program 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 COPYING file for more details. -*/ - -#include "esclineedit.h" - -#include -#include - -EscLineEdit::EscLineEdit(QWidget* parent) : - QLineEdit(parent) -{ -} - -void EscLineEdit::keyPressEvent(QKeyEvent* event) -{ - if (event->key() == Qt::Key_Escape && event->modifiers() == Qt::NoModifier) { - emit escPressed(); - } else { - QLineEdit::keyPressEvent(event); - } -} diff --git a/widget/tool/esclineedit.h b/widget/tool/esclineedit.h deleted file mode 100644 index 75eac7315..000000000 --- a/widget/tool/esclineedit.h +++ /dev/null @@ -1,36 +0,0 @@ -/* - Copyright (C) 2013 by Maxim Biro - - This file is part of Tox Qt GUI. - - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - This program 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 COPYING file for more details. -*/ - -#ifndef ESCLINEEDIT_HPP -#define ESCLINEEDIT_HPP - -#include - -class EscLineEdit : public QLineEdit -{ - Q_OBJECT -public: - explicit EscLineEdit(QWidget* parent); - -protected: - void keyPressEvent(QKeyEvent* event) Q_DECL_OVERRIDE; - -signals: - void escPressed(); - -}; - -#endif // ESCLINEEDIT_HPP diff --git a/widget/widget.cpp b/widget/widget.cpp index 851502df0..3b46fd62e 100644 --- a/widget/widget.cpp +++ b/widget/widget.cpp @@ -115,11 +115,14 @@ Widget::Widget(QWidget *parent) ui->friendList->setWidget(contactListWidget); ui->friendList->setLayoutDirection(Qt::RightToLeft); + ui->nameLabel->setEditable(true); + ui->statusLabel->setEditable(true); + // delay setting username and message until Core inits //ui->nameLabel->setText(core->getUsername()); - ui->nameLabel->label->setStyleSheet("QLabel { color : white; font-size: 11pt; font-weight:bold;}"); + ui->nameLabel->setStyleSheet("QLabel { color : white; font-size: 11pt; font-weight:bold;}"); //ui->statusLabel->setText(core->getStatusMessage()); - ui->statusLabel->label->setStyleSheet("QLabel { color : white; font-size: 8pt;}"); + ui->statusLabel->setStyleSheet("QLabel { color : white; font-size: 8pt;}"); ui->statusButton->setStyleSheet(Style::get(":/ui/statusButton/statusButton.css")); From 1cd954ba42b4d91df182246997476c1caf47a249 Mon Sep 17 00:00:00 2001 From: krepa098 Date: Mon, 1 Sep 2014 11:16:41 +0200 Subject: [PATCH 3/7] compatibility with old widgets --- widget/croppinglabel.cpp | 19 ++++++++++++++----- widget/croppinglabel.h | 5 +++++ widget/form/settingsform.h | 3 ++- 3 files changed, 21 insertions(+), 6 deletions(-) diff --git a/widget/croppinglabel.cpp b/widget/croppinglabel.cpp index bed2f023e..47b324d1e 100644 --- a/widget/croppinglabel.cpp +++ b/widget/croppinglabel.cpp @@ -74,11 +74,9 @@ QSize CroppingLabel::minimumSizeHint() const void CroppingLabel::mouseReleaseEvent(QMouseEvent *e) { if (editable) - { - blockPaintEvents = true; - textEdit->show(); - textEdit->setFocus(); - } + showTextEdit(); + + emit clicked(); QLabel::mouseReleaseEvent(e); } @@ -126,8 +124,19 @@ void CroppingLabel::setElidedText() void CroppingLabel::hideTextEdit(bool acceptText) { if (acceptText) + { + emit textChanged(textEdit->text(), origText); setText(textEdit->text()); + } textEdit->hide(); blockPaintEvents = false; } + +void CroppingLabel::showTextEdit() +{ + blockPaintEvents = true; + textEdit->show(); + textEdit->setFocus(); + textEdit->setText(origText); +} diff --git a/widget/croppinglabel.h b/widget/croppinglabel.h index 25fa34df0..17f5666c0 100644 --- a/widget/croppinglabel.h +++ b/widget/croppinglabel.h @@ -36,11 +36,16 @@ public: virtual void mouseReleaseEvent(QMouseEvent *e); virtual bool eventFilter(QObject *obj, QEvent *e); +signals: + void textChanged(QString newText, QString oldText); + void clicked(); + protected: void setElidedText(); void acceptText(); void rejectText(); void hideTextEdit(bool acceptText); + void showTextEdit(); private: QString origText; diff --git a/widget/form/settingsform.h b/widget/form/settingsform.h index 83e6800b7..81851e8a9 100644 --- a/widget/form/settingsform.h +++ b/widget/form/settingsform.h @@ -29,6 +29,7 @@ #include #include "ui_mainwindow.h" #include "widget/selfcamview.h" +#include "widget/croppinglabel.h" class SettingsForm : public QObject { @@ -53,7 +54,7 @@ private slots: private: QLabel headLabel, nameLabel, statusTextLabel, smileyPackLabel; QTextEdit id; - QLabel idLabel; + CroppingLabel idLabel; QPushButton videoTest; QCheckBox enableIPv6, useTranslations, makeToxPortable; QVBoxLayout layout, headLayout; From 7e6c4f51298e16b7b6179e5ba95f91f227c964bd Mon Sep 17 00:00:00 2001 From: krepa098 Date: Mon, 1 Sep 2014 12:27:41 +0200 Subject: [PATCH 4/7] cleanup --- widget/croppinglabel.h | 2 -- 1 file changed, 2 deletions(-) diff --git a/widget/croppinglabel.h b/widget/croppinglabel.h index 17f5666c0..aeca082b1 100644 --- a/widget/croppinglabel.h +++ b/widget/croppinglabel.h @@ -42,8 +42,6 @@ signals: protected: void setElidedText(); - void acceptText(); - void rejectText(); void hideTextEdit(bool acceptText); void showTextEdit(); From 24971f50e99aac4dcf8934f63f7c2201094c83c6 Mon Sep 17 00:00:00 2001 From: apprb Date: Mon, 1 Sep 2014 18:55:07 +0700 Subject: [PATCH 5/7] fix #243 : Smileys are broken --- widget/form/chatform.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/widget/form/chatform.cpp b/widget/form/chatform.cpp index 1e3b4cd16..50f09f5a2 100644 --- a/widget/form/chatform.cpp +++ b/widget/form/chatform.cpp @@ -218,8 +218,6 @@ void ChatForm::addMessage(QString author, QString message, QString date) void ChatForm::addMessage(QLabel* author, QLabel* message, QLabel* date) { - message->setText(SmileyPack::getInstance().smileyfied(message->text())); - QScrollBar* scroll = chatArea->verticalScrollBar(); lockSliderToBottom = scroll && scroll->value() == scroll->maximum(); author->setAlignment(Qt::AlignTop | Qt::AlignRight); @@ -262,6 +260,7 @@ void ChatForm::addMessage(QLabel* author, QLabel* message, QLabel* date) finalMessage += "
"; } message->setText(finalMessage.left(finalMessage.length()-4)); + message->setText(SmileyPack::getInstance().smileyfied(message->text())); message->setTextFormat(Qt::RichText); mainChatLayout->addWidget(author, curRow, 0); From f845bfb756667943a20fa3e798025dafc80fde2e Mon Sep 17 00:00:00 2001 From: krepa098 Date: Mon, 1 Sep 2014 18:03:31 +0200 Subject: [PATCH 6/7] xD smiley --- smileys/default/emoticons.xml | 6 +++ smileys/default/laugh_closed_eyes.png | Bin 0 -> 1461 bytes smileys/default/raw.svg | 54 +++++++++++++++++++++++--- 3 files changed, 55 insertions(+), 5 deletions(-) create mode 100644 smileys/default/laugh_closed_eyes.png diff --git a/smileys/default/emoticons.xml b/smileys/default/emoticons.xml index f978d55d5..d1fe8c715 100644 --- a/smileys/default/emoticons.xml +++ b/smileys/default/emoticons.xml @@ -76,4 +76,10 @@ D: + + 😆 + xD + XD + + diff --git a/smileys/default/laugh_closed_eyes.png b/smileys/default/laugh_closed_eyes.png new file mode 100644 index 0000000000000000000000000000000000000000..fc294a5106f5684698476f0d86d83876e49789d7 GIT binary patch literal 1461 zcmV;m1xosfP)V=- zLvm$dbY)~9W^ZyJbZBKDaa3=3AaHVTYGq?|E+9#6b8u;LWn>^?c_4IXWgsF>Wp-t9 zAZ=-GWFaCTb8TsCWqBZQVPk7946eMW00010bVXQnLvL_-a%pF1bO1v`AVG9=a%p09 zbZKvHElzK4LvL+uWpZO_VQe61baZe!FE3+qWnpw_c4cF4ZEbIEb1rXkXD@7NV`Xl0 zWpgiLc`a^ZFEcJMFX6H#GynhuTS-JgR7i=vmw!xEWf;dl@8z5u_uRwHFoOg&@CRCC zW7Q~EWD92&Qfslb6m-~_39h!bSYx_b!_6&SYib6KEz#9X+a#v3VL4V*11U?VOu_hd zbz!D-y};#gpZ>Uj_r`_pMf1D8|Geit@8|jPzR!7%5)mSmQYsO69GIzTBmr0!J%Ahd zK}0S^yw`t$l~OLdMu};V@3WZmSUSFWv#`%iCKjNrn}PFP_`Q6fsySm1r8& zWu}w5s}wVB&ZI#Zr`8TA-iGI=Q?z@$EDx80abTs?Vk4Ggr3JV)7h#VM8LD?H@NL^m zpLc*~MC8{A!Ahw_BbMJP%9y@t1?py?quPHIDJthr?*I=5dp?#irIcZns zRVz@X1-MLuI;E684y@~}&rB!vX2Tm!n~Sh#rjx4cygoXoL*7 z)(&`hHP^29Gh0OZYyftRlDus6V5qwn%67vAcXR-EFO*loR}G=_X>%Yi8{Mu^0wbX| z4e|?fF@hH=1=suG(R^550*AhVAuBx0?}sDb!;5dhqL<-ZC(KS9zpgMB!!*bTP(Y$- z(0=tej&Q|czy}BG1Ktn%U`-B`u7!A4plEF02fGeH?_W?}4C`J1movP9!+w~ylzxww z)EHn{Rt78A9 zZinxF3Gej?Yo?}YB#jpQU^(u9j@t27Pp0I1pma@OOr*KV#A+Hz6O{abqJc&$n`P0{ z*3H2GhX_?$Hv^VMj|RBUci{sZ5V%4+4?qDf1&TpNCXr?Rr9 z3_RP~%DL0WIsN(HV{^gR2@xUQ#hHdmM4AJmWj~TIBThOyJ7ua`n)Qf$vdK2Kr!*rC zl}NmcGa`Zp;PFyjRYTd68G-7Rkp^$C_VV=7CG@y26HQ+RuwcP_9O`!pbNwOnRW*1$ zUaA2`H+4B3Ts?c}hIRfX + + + @@ -841,5 +850,40 @@ d="m 137.06672,1013.3344 c 0.25114,-1.6566 2.15608,-5.1205 7.23695,-5.1205 5.08089,0 6.93799,3.9294 6.55424,5.1205 -0.13763,0.4272 -0.47655,0.8569 -1.31761,0.4379 -1.70599,-0.8499 -2.65516,-1.2076 -5.57799,-1.2572 -2.92284,-0.05 -4.14543,1.2631 -5.36636,1.7495 -1.22092,0.4865 -1.61867,-0.3403 -1.52923,-0.9302 z" style="fill:#ffffff;stroke:#000000;stroke-width:0.76466024;stroke-linecap:round;stroke-linejoin:miter;stroke-opacity:1" /> + + + + + + + From 532b8cec838baeefb781d0bfec600190bd1478cd Mon Sep 17 00:00:00 2001 From: "Tux3 / Mlkj / !Lev.uXFMLA" Date: Mon, 1 Sep 2014 20:33:04 +0200 Subject: [PATCH 7/7] Add Jenkins build config --- qtox.pro | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/qtox.pro b/qtox.pro index 8f87e7255..8bedf38f1 100644 --- a/qtox.pro +++ b/qtox.pro @@ -36,7 +36,11 @@ TRANSLATIONS = translations/de.ts \ RESOURCES += res.qrc -INCLUDEPATH += libs/include +contains(JENKINS,YES) { + INCLUDEPATH += ./libs/include/ +} else { + INCLUDEPATH += libs/include +} # Rules for Windows, Mac OSX, and Linux win32 { @@ -52,6 +56,10 @@ win32 { } else { LIBS += -L$$PWD/libs/lib/ -ltoxcore -ltoxav -lvpx -lopenal -lopencv_core -lopencv_highgui } + + contains(JENKINS, YES) { + LIBS = ./libs/lib/libtoxav.a ./libs/lib/libvpx.a ./libs/lib/libopus.a ./libs/lib/libtoxcore.a ./libs/lib/libsodium.a -lopencv_core -lopencv_highgui -lopenal + } }