mirror of
https://github.com/qTox/qTox.git
synced 2024-03-22 14:00:36 +08:00
Fix circle related rebase bugs
This commit is contained in:
parent
3a30a038ef
commit
62873e9d71
|
@ -43,7 +43,7 @@ Group::Group(int GroupId, QString Name, bool IsAvGroupchat)
|
|||
Group::~Group()
|
||||
{
|
||||
delete chatForm;
|
||||
delete widget;
|
||||
widget->deleteLater();
|
||||
}
|
||||
|
||||
/*
|
||||
|
|
|
@ -31,13 +31,6 @@
|
|||
#include <QMenu>
|
||||
#include <cassert>
|
||||
|
||||
void maxCropLabel(CroppingLabel* label)
|
||||
{
|
||||
QFontMetrics metrics = label->fontMetrics();
|
||||
// Text width + padding. Without padding, we'll have elipses.
|
||||
label->setMaximumWidth(metrics.width(label->fullText()) + metrics.width("..."));
|
||||
}
|
||||
|
||||
QHash<int, CircleWidget*> CircleWidget::circleList;
|
||||
|
||||
CircleWidget::CircleWidget(FriendListWidget *parent, int id_)
|
||||
|
@ -85,9 +78,13 @@ CircleWidget::CircleWidget(FriendListWidget *parent, int id_)
|
|||
connect(nameLabel, &CroppingLabel::editFinished, [this](const QString &newName)
|
||||
{
|
||||
if (!newName.isEmpty())
|
||||
{
|
||||
emit renameRequested(newName);
|
||||
}
|
||||
emit renameRequested(this, newName);
|
||||
});
|
||||
|
||||
connect(nameLabel, &CroppingLabel::editRemoved, [this]()
|
||||
{
|
||||
if (isCompact())
|
||||
nameLabel->minimizeMaximumWidth();
|
||||
});
|
||||
|
||||
bool isNew = false;
|
||||
|
@ -150,12 +147,12 @@ void CircleWidget::setName(const QString &name)
|
|||
nameLabel->setText(name);
|
||||
Settings::getInstance().setCircleName(id, name);
|
||||
if (isCompact())
|
||||
maxCropLabel(nameLabel);
|
||||
nameLabel->minimizeMaximumWidth();
|
||||
}
|
||||
|
||||
void CircleWidget::renameCircle()
|
||||
{
|
||||
nameLabel->editStart();
|
||||
nameLabel->editBegin();
|
||||
nameLabel->setMaximumWidth(QWIDGETSIZE_MAX);
|
||||
}
|
||||
|
||||
|
@ -279,7 +276,7 @@ void CircleWidget::onCompactChanged(bool _compact)
|
|||
|
||||
if (property("compact").toBool())
|
||||
{
|
||||
maxCropLabel(nameLabel);
|
||||
nameLabel->minimizeMaximumWidth();
|
||||
|
||||
mainLayout = nullptr;
|
||||
|
||||
|
@ -335,7 +332,7 @@ void CircleWidget::contextMenuEvent(QContextMenuEvent *event)
|
|||
renameCircle();
|
||||
else if (selectedItem == removeAction)
|
||||
{
|
||||
FriendListWidget *friendList = static_cast<FriendListWidget*>(parentWidget());
|
||||
FriendListWidget* friendList = dynamic_cast<FriendListWidget*>(parentWidget());
|
||||
listLayout->moveFriendWidgets(friendList);
|
||||
|
||||
friendList->removeCircleWidget(this);
|
||||
|
@ -349,7 +346,7 @@ void CircleWidget::contextMenuEvent(QContextMenuEvent *event)
|
|||
}
|
||||
}
|
||||
|
||||
void CircleWidget::mousePressEvent(QMouseEvent *event)
|
||||
void CircleWidget::mouseReleaseEvent(QMouseEvent *event)
|
||||
{
|
||||
if (event->button() == Qt::LeftButton)
|
||||
setExpanded(!expanded);
|
||||
|
|
|
@ -25,7 +25,7 @@ class FriendListWidget;
|
|||
class FriendListLayout;
|
||||
class FriendWidget;
|
||||
|
||||
class CircleWidget : public GenericChatItemWidget
|
||||
class CircleWidget final : public GenericChatItemWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
|
@ -49,20 +49,17 @@ public:
|
|||
static CircleWidget* getFromID(int id);
|
||||
|
||||
signals:
|
||||
void renameRequested(const QString &newName);
|
||||
void renameRequested(CircleWidget* circleWidget, const QString &newName);
|
||||
|
||||
public slots:
|
||||
void onCompactChanged(bool compact);
|
||||
|
||||
protected:
|
||||
|
||||
void contextMenuEvent(QContextMenuEvent* event);
|
||||
|
||||
void mousePressEvent(QMouseEvent* event) override;
|
||||
|
||||
void dragEnterEvent(QDragEnterEvent* event) override;
|
||||
void dragLeaveEvent(QDragLeaveEvent* event) override;
|
||||
void dropEvent(QDropEvent* event) override;
|
||||
virtual void contextMenuEvent(QContextMenuEvent* event) final override;
|
||||
virtual void mouseReleaseEvent(QMouseEvent* event) final override;
|
||||
virtual void dragEnterEvent(QDragEnterEvent* event) final override;
|
||||
virtual void dragLeaveEvent(QDragLeaveEvent* event) final override;
|
||||
virtual void dropEvent(QDropEvent* event) final override;
|
||||
|
||||
private:
|
||||
void updateID(int index);
|
||||
|
|
|
@ -18,6 +18,7 @@
|
|||
*/
|
||||
|
||||
#include <QDebug>
|
||||
#include <QBoxLayout>
|
||||
#include <QScrollBar>
|
||||
#include <QFileDialog>
|
||||
#include <QMessageBox>
|
||||
|
|
|
@ -42,8 +42,8 @@ FriendListLayout::FriendListLayout(QWidget* parent)
|
|||
|
||||
void FriendListLayout::addFriendWidget(FriendWidget* w, Status s)
|
||||
{
|
||||
friendOfflineLayout.getLayout()->removeWidget(w);
|
||||
friendOnlineLayout.getLayout()->removeWidget(w);
|
||||
friendOfflineLayout.removeSortedWidget(w);
|
||||
friendOnlineLayout.removeSortedWidget(w);
|
||||
if (s == Status::Offline)
|
||||
{
|
||||
friendOfflineLayout.addSortedWidget(w);
|
||||
|
@ -64,7 +64,6 @@ void FriendListLayout::moveFriendWidgets(FriendListWidget* listWidget)
|
|||
while (friendOnlineLayout.getLayout()->count() != 0)
|
||||
{
|
||||
QWidget* getWidget = friendOnlineLayout.getLayout()->takeAt(0)->widget();
|
||||
assert(getWidget != nullptr);
|
||||
|
||||
FriendWidget* friendWidget = dynamic_cast<FriendWidget*>(getWidget);
|
||||
listWidget->moveWidget(friendWidget, FriendList::findFriend(friendWidget->friendId)->getStatus(), true);
|
||||
|
@ -72,7 +71,6 @@ void FriendListLayout::moveFriendWidgets(FriendListWidget* listWidget)
|
|||
while (friendOfflineLayout.getLayout()->count() != 0)
|
||||
{
|
||||
QWidget* getWidget = friendOfflineLayout.getLayout()->takeAt(0)->widget();
|
||||
assert(getWidget != nullptr);
|
||||
|
||||
FriendWidget* friendWidget = dynamic_cast<FriendWidget*>(getWidget);
|
||||
listWidget->moveWidget(friendWidget, FriendList::findFriend(friendWidget->friendId)->getStatus(), true);
|
||||
|
|
|
@ -60,7 +60,7 @@ void FriendListWidget::addGroupWidget(GroupWidget* widget)
|
|||
|
||||
// Only rename group if groups are visible.
|
||||
if (Widget::getInstance()->groupsVisible())
|
||||
widget->rename();
|
||||
widget->editName();
|
||||
}
|
||||
|
||||
void FriendListWidget::addFriendWidget(FriendWidget* w, Status s, int circleIndex)
|
||||
|
@ -116,17 +116,10 @@ void FriendListWidget::renameGroupWidget(GroupWidget* groupWidget, const QString
|
|||
groupLayout.removeSortedWidget(groupWidget);
|
||||
groupWidget->setName(newName);
|
||||
groupLayout.addSortedWidget(groupWidget);
|
||||
reDraw(); // Prevent artifacts.
|
||||
}
|
||||
|
||||
void FriendListWidget::renameCircleWidget(const QString &newName)
|
||||
void FriendListWidget::renameCircleWidget(CircleWidget* circleWidget, const QString &newName)
|
||||
{
|
||||
assert(sender() != nullptr);
|
||||
|
||||
CircleWidget* circleWidget = static_cast<CircleWidget*>(sender());
|
||||
assert(circleWidget != nullptr);
|
||||
|
||||
// Rename after removing so you can find it successfully.
|
||||
circleLayout.removeSortedWidget(circleWidget);
|
||||
circleWidget->setName(newName);
|
||||
circleLayout.addSortedWidget(circleWidget);
|
||||
|
@ -271,13 +264,10 @@ void FriendListWidget::dropEvent(QDropEvent* event)
|
|||
// Update old circle after moved.
|
||||
CircleWidget* circleWidget = CircleWidget::getFromID(Settings::getInstance().getFriendCircleID(f->getToxId()));
|
||||
|
||||
listLayout->addFriendWidget(widget, f->getStatus());
|
||||
moveWidget(widget, f->getStatus(), true);
|
||||
|
||||
if (circleWidget != nullptr)
|
||||
{
|
||||
// In case the status was changed while moving, update both.
|
||||
circleWidget->updateStatus();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -57,7 +57,7 @@ signals:
|
|||
|
||||
public slots:
|
||||
void renameGroupWidget(GroupWidget* groupWidget, const QString& newName);
|
||||
void renameCircleWidget(const QString& newName);
|
||||
void renameCircleWidget(CircleWidget* circleWidget, const QString& newName);
|
||||
void onGroupchatPositionChanged(bool top);
|
||||
void moveWidget(FriendWidget* w, Status s, bool add = false);
|
||||
|
||||
|
|
|
@ -57,6 +57,11 @@ FriendWidget::FriendWidget(int FriendId, QString id)
|
|||
|
||||
void FriendWidget::contextMenuEvent(QContextMenuEvent * event)
|
||||
{
|
||||
if (!active)
|
||||
setBackgroundRole(QPalette::Highlight);
|
||||
|
||||
installEventFilter(this); // Disable leave event.
|
||||
|
||||
QPoint pos = event->globalPos();
|
||||
ToxId id = FriendList::findFriend(friendId)->getToxId();
|
||||
QString dir = Settings::getInstance().getAutoAcceptDir(id);
|
||||
|
@ -90,7 +95,6 @@ void FriendWidget::contextMenuEvent(QContextMenuEvent * event)
|
|||
friendList = dynamic_cast<FriendListWidget*>(circleWidget->parentWidget());
|
||||
|
||||
assert(friendList != nullptr);
|
||||
friendList->reDraw();
|
||||
|
||||
QVector<CircleWidget*> circleVec = friendList->getAllCircles();
|
||||
QMap<QAction*, CircleWidget*> circleActions;
|
||||
|
@ -114,6 +118,12 @@ void FriendWidget::contextMenuEvent(QContextMenuEvent * event)
|
|||
QAction* removeFriendAction = menu.addAction(tr("Remove friend", "Menu to remove the friend from our friendlist"));
|
||||
|
||||
QAction* selectedItem = menu.exec(pos);
|
||||
|
||||
removeEventFilter(this);
|
||||
|
||||
if (!active)
|
||||
setBackgroundRole(QPalette::Window);
|
||||
|
||||
if (selectedItem)
|
||||
{
|
||||
if (selectedItem == copyId)
|
||||
|
@ -122,7 +132,7 @@ void FriendWidget::contextMenuEvent(QContextMenuEvent * event)
|
|||
return;
|
||||
} else if (selectedItem == setAlias)
|
||||
{
|
||||
nameLabel->editStart();
|
||||
nameLabel->editBegin();
|
||||
}
|
||||
else if (selectedItem == removeFriendAction)
|
||||
{
|
||||
|
@ -326,6 +336,4 @@ void FriendWidget::setAlias(const QString& _alias)
|
|||
f->setAlias(alias);
|
||||
Settings::getInstance().setFriendAlias(f->getToxId(), alias);
|
||||
Settings::getInstance().savePersonal();
|
||||
//hide();
|
||||
//show();
|
||||
}
|
||||
|
|
|
@ -22,14 +22,14 @@
|
|||
#include "src/persistence/settings.h"
|
||||
#include "maskablepixmapwidget.h"
|
||||
#include "src/widget/tool/croppinglabel.h"
|
||||
#include <QBoxLayout>
|
||||
#include <QMouseEvent>
|
||||
|
||||
GenericChatroomWidget::GenericChatroomWidget(QWidget *parent)
|
||||
: GenericChatItemWidget(parent), compact{Settings::getInstance().getCompactLayout()},
|
||||
active{false}
|
||||
: GenericChatItemWidget(parent), active{false}
|
||||
{
|
||||
// avatar
|
||||
if (compact)
|
||||
if (isCompact())
|
||||
avatar = new MaskablePixmapWidget(this, QSize(20,20), ":/img/avatar_mask.svg");
|
||||
else
|
||||
avatar = new MaskablePixmapWidget(this, QSize(40,40), ":/img/avatar_mask.svg");
|
||||
|
@ -39,23 +39,26 @@ GenericChatroomWidget::GenericChatroomWidget(QWidget *parent)
|
|||
statusMessageLabel->setTextFormat(Qt::PlainText);
|
||||
statusMessageLabel->setForegroundRole(QPalette::WindowText);
|
||||
|
||||
nameLabel->setTextFormat(Qt::PlainText);
|
||||
nameLabel->setForegroundRole(QPalette::WindowText);
|
||||
|
||||
setAutoFillBackground(true);
|
||||
reloadTheme();
|
||||
setCompact(compact);
|
||||
|
||||
compactChange(isCompact());
|
||||
}
|
||||
|
||||
void GenericChatroomWidget::setCompact(bool _compact)
|
||||
bool GenericChatroomWidget::eventFilter(QObject *, QEvent *)
|
||||
{
|
||||
compact = _compact;
|
||||
return true; // Disable all events.
|
||||
}
|
||||
|
||||
void GenericChatroomWidget::compactChange(bool _compact)
|
||||
{
|
||||
setCompact(_compact);
|
||||
|
||||
delete textLayout; // has to be first, deleted by layout
|
||||
delete mainLayout;
|
||||
|
||||
compact = _compact;
|
||||
|
||||
mainLayout = new QHBoxLayout;
|
||||
textLayout = new QVBoxLayout;
|
||||
|
||||
|
@ -67,7 +70,7 @@ void GenericChatroomWidget::setCompact(bool _compact)
|
|||
setLayoutDirection(Qt::LeftToRight); // parent might have set Qt::RightToLeft
|
||||
|
||||
// avatar
|
||||
if (compact)
|
||||
if (isCompact())
|
||||
{
|
||||
setFixedHeight(25);
|
||||
avatar->setSize(QSize(20,20));
|
||||
|
@ -162,17 +165,6 @@ void GenericChatroomWidget::reloadTheme()
|
|||
setPalette(p);
|
||||
}
|
||||
|
||||
bool GenericChatroomWidget::isCompact() const
|
||||
{
|
||||
return compact;
|
||||
}
|
||||
|
||||
void GenericChatroomWidget::mousePressEvent(QMouseEvent* event)
|
||||
{
|
||||
if (!active && event->button() == Qt::RightButton)
|
||||
setBackgroundRole(QPalette::Window);
|
||||
}
|
||||
|
||||
void GenericChatroomWidget::mouseReleaseEvent(QMouseEvent*)
|
||||
{
|
||||
emit chatroomWidgetClicked(this);
|
||||
|
@ -184,8 +176,9 @@ void GenericChatroomWidget::enterEvent(QEvent*)
|
|||
setBackgroundRole(QPalette::Highlight);
|
||||
}
|
||||
|
||||
void GenericChatroomWidget::leaveEvent(QEvent*)
|
||||
void GenericChatroomWidget::leaveEvent(QEvent* event)
|
||||
{
|
||||
if (!active)
|
||||
setBackgroundRole(QPalette::Window);
|
||||
QWidget::leaveEvent(event);
|
||||
}
|
||||
|
|
|
@ -21,11 +21,11 @@
|
|||
#define GENERICCHATROOMWIDGET_H
|
||||
|
||||
#include "genericchatitemwidget.h"
|
||||
#include <QBoxLayout>
|
||||
#include <QLabel>
|
||||
|
||||
class CroppingLabel;
|
||||
class MaskablePixmapWidget;
|
||||
class QVBoxLayout;
|
||||
class QHBoxLayout;
|
||||
|
||||
namespace Ui {
|
||||
class MainWindow;
|
||||
|
@ -37,34 +37,32 @@ class GenericChatroomWidget : public GenericChatItemWidget
|
|||
public:
|
||||
GenericChatroomWidget(QWidget *parent = 0);
|
||||
|
||||
virtual void setAsActiveChatroom(){;}
|
||||
virtual void setAsInactiveChatroom(){;}
|
||||
virtual void updateStatusLight(){;}
|
||||
virtual void setChatForm(Ui::MainWindow &){;}
|
||||
virtual void resetEventFlags(){;}
|
||||
virtual QString getStatusString(){return QString::null;}
|
||||
virtual void setAsActiveChatroom() = 0;
|
||||
virtual void setAsInactiveChatroom() = 0;
|
||||
virtual void updateStatusLight() = 0;
|
||||
virtual void setChatForm(Ui::MainWindow &) = 0;
|
||||
virtual void resetEventFlags() = 0;
|
||||
virtual QString getStatusString() = 0;
|
||||
|
||||
virtual bool eventFilter(QObject *, QEvent *) final override;
|
||||
|
||||
bool isActive();
|
||||
void setActive(bool active);
|
||||
|
||||
void setName(const QString& name);
|
||||
void setStatusMsg(const QString& status);
|
||||
|
||||
QString getStatusMsg() const;
|
||||
|
||||
void reloadTheme();
|
||||
|
||||
bool isCompact() const;
|
||||
void reloadTheme();
|
||||
|
||||
public slots:
|
||||
void setCompact(bool compact);
|
||||
void compactChange(bool compact);
|
||||
|
||||
signals:
|
||||
void chatroomWidgetClicked(GenericChatroomWidget* widget);
|
||||
|
||||
protected:
|
||||
virtual void mousePressEvent(QMouseEvent* event) override;
|
||||
virtual void mouseReleaseEvent (QMouseEvent* event) override;
|
||||
virtual void mouseReleaseEvent(QMouseEvent* event) override;
|
||||
virtual void enterEvent(QEvent* e) override;
|
||||
virtual void leaveEvent(QEvent* e) override;
|
||||
|
||||
|
@ -74,7 +72,7 @@ protected:
|
|||
QVBoxLayout* textLayout = nullptr;
|
||||
MaskablePixmapWidget* avatar;
|
||||
CroppingLabel* statusMessageLabel;
|
||||
bool compact, active;
|
||||
bool active;
|
||||
};
|
||||
|
||||
#endif // GENERICCHATROOMWIDGET_H
|
||||
|
|
|
@ -18,23 +18,18 @@
|
|||
*/
|
||||
|
||||
#include "groupwidget.h"
|
||||
#include "maskablepixmapwidget.h"
|
||||
#include "src/grouplist.h"
|
||||
#include "src/group.h"
|
||||
#include "src/persistence/settings.h"
|
||||
#include "form/groupchatform.h"
|
||||
#include "maskablepixmapwidget.h"
|
||||
#include "friendlistwidget.h"
|
||||
#include "src/widget/style.h"
|
||||
#include "src/core/core.h"
|
||||
#include "tool/croppinglabel.h"
|
||||
#include <QPalette>
|
||||
#include <QMenu>
|
||||
#include <QContextMenuEvent>
|
||||
#include <QMimeData>
|
||||
#include <QDragEnterEvent>
|
||||
#include <QInputDialog>
|
||||
|
||||
#include "ui_mainwindow.h"
|
||||
|
||||
#include <QMimeData>
|
||||
|
||||
GroupWidget::GroupWidget(int GroupId, QString Name)
|
||||
: groupId{GroupId}
|
||||
|
@ -44,11 +39,7 @@ GroupWidget::GroupWidget(int GroupId, QString Name)
|
|||
statusPic.setMargin(3);
|
||||
nameLabel->setText(Name);
|
||||
|
||||
Group* g = GroupList::findGroup(groupId);
|
||||
if (g)
|
||||
statusMessageLabel->setText(GroupWidget::tr("%1 users in chat").arg(g->getPeersCount()));
|
||||
else
|
||||
statusMessageLabel->setText(GroupWidget::tr("0 users in chat"));
|
||||
onUserListChanged();
|
||||
|
||||
setAcceptDrops(true);
|
||||
|
||||
|
@ -60,27 +51,27 @@ GroupWidget::GroupWidget(int GroupId, QString Name)
|
|||
emit renameRequested(this, newName);
|
||||
emit g->getChatForm()->groupTitleChanged(groupId, newName.left(128));
|
||||
}
|
||||
/* according to agilob:
|
||||
* “Moving mouse pointer over groupwidget results in CSS effect
|
||||
* mouse-over(?). Changing group title repaints only changed
|
||||
* element - title, the rest of the widget stays in the same CSS as it
|
||||
* was on mouse over. Repainting whole widget fixes style problem.”
|
||||
*/
|
||||
this->repaint();
|
||||
});
|
||||
}
|
||||
|
||||
void GroupWidget::contextMenuEvent(QContextMenuEvent * event)
|
||||
void GroupWidget::contextMenuEvent(QContextMenuEvent* event)
|
||||
{
|
||||
QPoint pos = event->globalPos();
|
||||
QMenu menu;
|
||||
if (!active)
|
||||
setBackgroundRole(QPalette::Highlight);
|
||||
|
||||
installEventFilter(this); // Disable leave event.
|
||||
|
||||
QMenu menu(this);
|
||||
QAction* setTitle = menu.addAction(tr("Set title..."));
|
||||
QAction* quitGroup = menu.addAction(tr("Quit group","Menu to quit a groupchat"));
|
||||
|
||||
FriendListWidget *friendList = static_cast<FriendListWidget*>(parentWidget());
|
||||
friendList->reDraw();
|
||||
QAction* selectedItem = menu.exec(event->globalPos());
|
||||
|
||||
removeEventFilter(this);
|
||||
|
||||
if (!active)
|
||||
setBackgroundRole(QPalette::Window);
|
||||
|
||||
QAction* selectedItem = menu.exec(pos);
|
||||
if (selectedItem)
|
||||
{
|
||||
if (selectedItem == quitGroup)
|
||||
|
@ -89,7 +80,7 @@ void GroupWidget::contextMenuEvent(QContextMenuEvent * event)
|
|||
}
|
||||
else if (selectedItem == setTitle)
|
||||
{
|
||||
nameLabel->editStart();
|
||||
editName();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -141,9 +132,9 @@ QString GroupWidget::getStatusString()
|
|||
return "New Message";
|
||||
}
|
||||
|
||||
void GroupWidget::rename()
|
||||
void GroupWidget::editName()
|
||||
{
|
||||
nameLabel->editStart();
|
||||
nameLabel->editBegin();
|
||||
}
|
||||
|
||||
void GroupWidget::setChatForm(Ui::MainWindow &ui)
|
||||
|
@ -163,14 +154,15 @@ void GroupWidget::dragEnterEvent(QDragEnterEvent *ev)
|
|||
{
|
||||
if (ev->mimeData()->hasFormat("friend"))
|
||||
ev->acceptProposedAction();
|
||||
setAttribute(Qt::WA_UnderMouse, true); // Simulate hover.
|
||||
Style::repolish(this);
|
||||
|
||||
if (!active)
|
||||
setBackgroundRole(QPalette::Highlight);
|
||||
}
|
||||
|
||||
void GroupWidget::dragLeaveEvent(QDragLeaveEvent *)
|
||||
{
|
||||
setAttribute(Qt::WA_UnderMouse, false);
|
||||
Style::repolish(this);
|
||||
if (!active)
|
||||
setBackgroundRole(QPalette::Window);
|
||||
}
|
||||
|
||||
void GroupWidget::dropEvent(QDropEvent *ev)
|
||||
|
@ -180,8 +172,8 @@ void GroupWidget::dropEvent(QDropEvent *ev)
|
|||
int friendId = ev->mimeData()->data("friend").toInt();
|
||||
Core::getInstance()->groupInviteFriend(friendId, groupId);
|
||||
|
||||
setAttribute(Qt::WA_UnderMouse, false);
|
||||
Style::repolish(this);
|
||||
if (!active)
|
||||
setBackgroundRole(QPalette::Window);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -22,12 +22,11 @@
|
|||
|
||||
#include "genericchatroomwidget.h"
|
||||
|
||||
class GroupWidget : public GenericChatroomWidget
|
||||
class GroupWidget final : public GenericChatroomWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
GroupWidget(int GroupId, QString Name);
|
||||
virtual void contextMenuEvent(QContextMenuEvent * event) final override;
|
||||
virtual void setAsInactiveChatroom() final override;
|
||||
virtual void setAsActiveChatroom() final override;
|
||||
virtual void updateStatusLight() final override;
|
||||
|
@ -36,7 +35,7 @@ public:
|
|||
virtual QString getStatusString() final override;
|
||||
void setName(const QString& name);
|
||||
void onUserListChanged();
|
||||
void rename();
|
||||
void editName();
|
||||
|
||||
signals:
|
||||
void groupWidgetClicked(GroupWidget* widget);
|
||||
|
@ -44,7 +43,7 @@ signals:
|
|||
void removeGroup(int groupId);
|
||||
|
||||
protected:
|
||||
// drag & drop
|
||||
virtual void contextMenuEvent(QContextMenuEvent * event) final override;
|
||||
virtual void dragEnterEvent(QDragEnterEvent* ev) override;
|
||||
virtual void dragLeaveEvent(QDragLeaveEvent* ev);
|
||||
virtual void dropEvent(QDropEvent* ev) override;
|
||||
|
|
|
@ -35,10 +35,10 @@ CroppingLabel::CroppingLabel(QWidget* parent)
|
|||
| Qt::ImhNoPredictiveText
|
||||
| Qt::ImhPreferLatin);
|
||||
|
||||
connect(textEdit, &QLineEdit::editingFinished, this, &CroppingLabel::finishTextEdit);
|
||||
connect(textEdit, &QLineEdit::editingFinished, this, &CroppingLabel::editingFinished);
|
||||
}
|
||||
|
||||
void CroppingLabel::editStart()
|
||||
void CroppingLabel::editBegin()
|
||||
{
|
||||
showTextEdit();
|
||||
textEdit->selectAll();
|
||||
|
@ -127,7 +127,14 @@ QString CroppingLabel::fullText()
|
|||
return origText;
|
||||
}
|
||||
|
||||
void CroppingLabel::finishTextEdit()
|
||||
void CroppingLabel::minimizeMaximumWidth()
|
||||
{
|
||||
// This function chooses the smallest possible maximum width.
|
||||
// Text width + padding. Without padding, we'll have elipses.
|
||||
setMaximumWidth(fontMetrics().width(origText) + fontMetrics().width("..."));
|
||||
}
|
||||
|
||||
void CroppingLabel::editingFinished()
|
||||
{
|
||||
QString newText = textEdit->text().trimmed().remove(QRegExp("[\\t\\n\\v\\f\\r\\x0000]"));
|
||||
if (origText != newText)
|
||||
|
@ -137,4 +144,5 @@ void CroppingLabel::finishTextEdit()
|
|||
|
||||
textEdit->hide();
|
||||
blockPaintEvents = false;
|
||||
emit editRemoved();
|
||||
}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
Copyright © 2014 by The qTox Project
|
||||
Copyright © 2014-2015 by The qTox Project
|
||||
|
||||
This file is part of qTox, a Qt-based graphical interface for Tox.
|
||||
|
||||
|
@ -30,16 +30,19 @@ class CroppingLabel : public QLabel
|
|||
public:
|
||||
explicit CroppingLabel(QWidget* parent = 0);
|
||||
|
||||
void editStart();
|
||||
void editBegin();
|
||||
void setEditable(bool editable);
|
||||
void setEdlideMode(Qt::TextElideMode elide);
|
||||
|
||||
void setText(const QString& text);
|
||||
QString fullText(); ///< Returns the un-cropped text
|
||||
|
||||
public slots:
|
||||
void minimizeMaximumWidth();
|
||||
|
||||
signals:
|
||||
void editFinished(QString newText);
|
||||
void textChanged(QString newText, QString oldText);
|
||||
void editFinished(const QString& newText);
|
||||
void editRemoved();
|
||||
void clicked();
|
||||
|
||||
protected:
|
||||
|
@ -53,7 +56,7 @@ protected:
|
|||
virtual void mouseReleaseEvent(QMouseEvent *e) final override;
|
||||
|
||||
private slots:
|
||||
void finishTextEdit();
|
||||
void editingFinished();
|
||||
|
||||
private:
|
||||
QString origText;
|
||||
|
|
|
@ -587,7 +587,7 @@ void Widget::addFriend(int friendId, const QString &userId)
|
|||
|
||||
Core* core = Nexus::getCore();
|
||||
connect(newfriend, &Friend::displayedNameChanged, this, &Widget::onFriendDisplayChanged);
|
||||
connect(settingsWidget, &SettingsWidget::compactToggled, newfriend->getFriendWidget(), &GenericChatroomWidget::setCompact);
|
||||
connect(settingsWidget, &SettingsWidget::compactToggled, newfriend->getFriendWidget(), &GenericChatroomWidget::compactChange);
|
||||
connect(newfriend->getFriendWidget(), SIGNAL(chatroomWidgetClicked(GenericChatroomWidget*)), this, SLOT(onChatroomWidgetClicked(GenericChatroomWidget*)));
|
||||
connect(newfriend->getFriendWidget(), SIGNAL(removeFriend(int)), this, SLOT(removeFriend(int)));
|
||||
connect(newfriend->getFriendWidget(), SIGNAL(copyFriendIdToClipboard(int)), this, SLOT(copyFriendIdToClipboard(int)));
|
||||
|
@ -1061,7 +1061,7 @@ Group *Widget::createGroup(int groupId)
|
|||
contactListWidget->addGroupWidget(newgroup->getGroupWidget());
|
||||
newgroup->getGroupWidget()->updateStatusLight();
|
||||
|
||||
connect(settingsWidget, &SettingsWidget::compactToggled, newgroup->getGroupWidget(), &GenericChatroomWidget::setCompact);
|
||||
connect(settingsWidget, &SettingsWidget::compactToggled, newgroup->getGroupWidget(), &GenericChatroomWidget::compactChange);
|
||||
connect(newgroup->getGroupWidget(), SIGNAL(chatroomWidgetClicked(GenericChatroomWidget*)), this, SLOT(onChatroomWidgetClicked(GenericChatroomWidget*)));
|
||||
connect(newgroup->getGroupWidget(), SIGNAL(removeGroup(int)), this, SLOT(removeGroup(int)));
|
||||
connect(newgroup->getGroupWidget(), SIGNAL(chatroomWidgetClicked(GenericChatroomWidget*)), newgroup->getChatForm(), SLOT(focusInput()));
|
||||
|
|
Loading…
Reference in New Issue
Block a user