1
0
mirror of https://github.com/qTox/qTox.git synced 2024-03-22 14:00:36 +08:00
This commit is contained in:
Bill Winslow 2014-09-01 13:46:05 -05:00
commit 7d3f98bc2a
20 changed files with 185 additions and 564 deletions

View File

@ -1482,7 +1482,7 @@ QSplitter:handle{
<number>0</number>
</property>
<item>
<widget class="EditableLabelWidget" name="nameLabel">
<widget class="CroppingLabel" name="nameLabel">
<property name="enabled">
<bool>true</bool>
</property>
@ -1920,7 +1920,7 @@ QSplitter:handle{
</widget>
</item>
<item>
<widget class="EditableLabelWidget" name="statusLabel">
<widget class="CroppingLabel" name="statusLabel">
<property name="sizePolicy">
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Preferred">
<horstretch>1</horstretch>
@ -2092,8 +2092,8 @@ QSplitter:handle{
<rect>
<x>0</x>
<y>0</y>
<width>335</width>
<height>379</height>
<width>263</width>
<height>373</height>
</rect>
</property>
<layout class="QVBoxLayout" name="verticalLayout_5"/>
@ -3228,7 +3228,7 @@ QSplitter:handle{
<x>0</x>
<y>0</y>
<width>716</width>
<height>24</height>
<height>23</height>
</rect>
</property>
</widget>
@ -3243,17 +3243,17 @@ QSplitter:handle{
</action>
</widget>
<customwidgets>
<customwidget>
<class>EditableLabelWidget</class>
<extends>QLabel</extends>
<header>widget/tool/editablelabelwidget.h</header>
</customwidget>
<customwidget>
<class>AdjustingScrollArea</class>
<extends>QScrollArea</extends>
<header>widget/adjustingscrollarea.h</header>
<container>1</container>
</customwidget>
<customwidget>
<class>CroppingLabel</class>
<extends>QLabel</extends>
<header>widget/croppinglabel.h</header>
</customwidget>
</customwidgets>
<resources>
<include location="res.qrc"/>

View File

@ -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
}
}
@ -71,10 +79,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 +95,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 +109,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 +126,6 @@ SOURCES += \
widget/selfcamview.cpp \
widget/camera.cpp \
widget/netcamview.cpp \
widget/tool/clickablelabel.cpp \
smileypack.cpp \
widget/emoticonswidget.cpp \
style.cpp \

View File

@ -76,4 +76,10 @@
<string>D:</string>
</emoticon>
<emoticon file="laugh_closed_eyes">
<string>😆</string>
<string>xD</string>
<string>XD</string>
</emoticon>
</messaging-emoticon-map>

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 KiB

View File

@ -220,6 +220,15 @@
x2="18.417803"
y2="219.33583"
gradientUnits="userSpaceOnUse" />
<filter
color-interpolation-filters="sRGB"
inkscape:collect="always"
id="filter3777-42-51">
<feGaussianBlur
inkscape:collect="always"
stdDeviation="0.20338983"
id="feGaussianBlur3779-6-09" />
</filter>
</defs>
<sodipodi:namedview
id="base"
@ -228,17 +237,17 @@
borderopacity="1.0"
inkscape:pageopacity="0.0"
inkscape:pageshadow="2"
inkscape:zoom="3.959798"
inkscape:cx="85.967272"
inkscape:cy="46.934585"
inkscape:zoom="2.8"
inkscape:cx="126.48175"
inkscape:cy="74.652167"
inkscape:document-units="px"
inkscape:current-layer="layer1"
showgrid="true"
gridtolerance="10"
inkscape:window-width="1920"
inkscape:window-height="1025"
inkscape:window-x="-3"
inkscape:window-y="-5"
inkscape:window-x="-2"
inkscape:window-y="-3"
inkscape:window-maximized="1"
showguides="true"
inkscape:guide-bbox="true">
@ -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" />
</g>
<g
id="laugh_closed_eyes"
inkscape:label="#g3182">
<path
transform="matrix(0.88628187,0,0,0.88628187,161.91268,791.71004)"
d="m 32,240 a 16,16 0 1 1 -32,0 16,16 0 1 1 32,0 z"
sodipodi:ry="16"
sodipodi:rx="16"
sodipodi:cy="240"
sodipodi:cx="16"
id="path2987-19-46"
style="fill:#ffcc00;fill-opacity:1;stroke:#000000;stroke-width:1.12830925;stroke-linecap:butt;stroke-linejoin:bevel;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;stroke-dashoffset:0;filter:url(#filter3777-42-51)"
sodipodi:type="arc" />
<path
sodipodi:nodetypes="czcc"
inkscape:connector-curvature="0"
id="path3809-7-7"
d="m 166.61105,1007.4713 c 0,0 2.81966,6.6964 9.46428,6.6964 6.64463,0 8.57143,-6.6964 8.57143,-6.6964 z"
style="fill:#ffffff;stroke:#000000;stroke-width:1;stroke-linecap:round;stroke-linejoin:miter;stroke-opacity:1" />
<path
inkscape:connector-curvature="0"
id="path3142"
d="m 167.85286,999.14099 5.21988,2.05271 -5.01109,1.8159"
style="fill:none;stroke:#000000;stroke-width:1.01681638px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1" />
<path
inkscape:connector-curvature="0"
id="path3142-8"
d="m 183.57572,999.08084 -5.21988,2.05276 5.01109,1.8159"
style="fill:none;stroke:#000000;stroke-width:1.01681638px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1" />
<path
inkscape:connector-curvature="0"
id="path4562-7"
d="m 168.16325,1009.489 15.08928,0 -1.50892,2.1996 -11.56846,0 z"
style="fill:#000000;stroke:none" />
</g>
</g>
</svg>

Before

Width:  |  Height:  |  Size: 38 KiB

After

Width:  |  Height:  |  Size: 40 KiB

View File

@ -15,11 +15,36 @@
*/
#include "croppinglabel.h"
#include <QResizeEvent>
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,48 @@ QSize CroppingLabel::minimumSizeHint() const
return QSize(fontMetrics().width("..."), QLabel::minimumSizeHint().height());
}
void CroppingLabel::mouseReleaseEvent(QMouseEvent *e)
{
if (editable)
showTextEdit();
emit clicked();
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<QKeyEvent*>(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 +120,23 @@ void CroppingLabel::setElidedText()
QLabel::setText(elidedText);
}
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);
}

View File

@ -18,6 +18,7 @@
#define CROPPINGLABEL_H
#include <QLabel>
#include <QLineEdit>
class CroppingLabel : public QLabel
{
@ -25,16 +26,31 @@ 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);
signals:
void textChanged(QString newText, QString oldText);
void clicked();
protected:
void setElidedText();
void hideTextEdit(bool acceptText);
void showTextEdit();
private:
QString origText;
QLineEdit* textEdit;
bool blockPaintEvents;
bool editable;
Qt::TextElideMode elideMode;
};
#endif // CROPPINGLABEL_H

View File

@ -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 += "<br>";
}
message->setText(finalMessage.left(finalMessage.length()-4));
message->setText(SmileyPack::getInstance().smileyfied(message->text()));
message->setTextFormat(Qt::RichText);
mainChatLayout->addWidget(author, curRow, 0);

View File

@ -27,9 +27,9 @@
#include <QPushButton>
#include <QTextEdit>
#include <QComboBox>
#include "widget/tool/clickablelabel.h"
#include "ui_mainwindow.h"
#include "widget/selfcamview.h"
#include "widget/croppinglabel.h"
class SettingsForm : public QObject
{
@ -54,7 +54,7 @@ private slots:
private:
QLabel headLabel, nameLabel, statusTextLabel, smileyPackLabel;
QTextEdit id;
ClickableLabel idLabel;
CroppingLabel idLabel;
QPushButton videoTest;
QCheckBox enableIPv6, useTranslations, makeToxPortable;
QVBoxLayout layout, headLayout;

View File

@ -1,27 +0,0 @@
/*
Copyright (C) 2014 by Project Tox <https://tox.im>
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();
}

View File

@ -1,36 +0,0 @@
/*
Copyright (C) 2014 by Project Tox <https://tox.im>
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 <QLabel>
class ClickableLabel : public QLabel
{
Q_OBJECT
public:
explicit ClickableLabel(QWidget *parent = 0);
signals:
void clicked();
protected:
void mousePressEvent ( QMouseEvent * event );
};
#endif // CLICKABLELABEL_H

View File

@ -1,47 +0,0 @@
/*
Copyright (C) 2013 by Maxim Biro <nurupo.contributions@gmail.com>
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 <QApplication>
#include <QMenu>
#include <QClipboard>
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);
}

View File

@ -1,36 +0,0 @@
/*
Copyright (C) 2013 by Maxim Biro <nurupo.contributions@gmail.com>
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

View File

@ -1,117 +0,0 @@
/*
Copyright (C) 2013 by Maxim Biro <nurupo.contributions@gmail.com>
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 <QApplication>
#include <QEvent>
#include <QFontMetrics>
#include <QMouseEvent>
#include <QVBoxLayout>
ClickableCopyableElideLabel::ClickableCopyableElideLabel(QWidget* parent) :
CopyableElideLabel(parent)
{
}
bool ClickableCopyableElideLabel::event(QEvent* event)
{
if (event->type() == QEvent::MouseButtonRelease) {
QMouseEvent* mouseEvent = static_cast<QMouseEvent*>(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();
}

View File

@ -1,66 +0,0 @@
/*
Copyright (C) 2013 by Maxim Biro <nurupo.contributions@gmail.com>
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 <QLineEdit>
#include <QStackedWidget>
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

View File

@ -1,82 +0,0 @@
/*
Copyright (C) 2013 by Maxim Biro <nurupo.contributions@gmail.com>
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 <QPainter>
#include <QEvent>
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;
}

View File

@ -1,50 +0,0 @@
/*
Copyright (C) 2013 by Maxim Biro <nurupo.contributions@gmail.com>
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 <QLabel>
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

View File

@ -1,34 +0,0 @@
/*
Copyright (C) 2013 by Maxim Biro <nurupo.contributions@gmail.com>
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 <QKeyEvent>
#include <QMouseEvent>
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);
}
}

View File

@ -1,36 +0,0 @@
/*
Copyright (C) 2013 by Maxim Biro <nurupo.contributions@gmail.com>
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 <QLineEdit>
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

View File

@ -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"));