Skip to content

Commit

Permalink
Prevent truncating the name of folders upon renaming them (#728)
Browse files Browse the repository at this point in the history
Fixes #647
  • Loading branch information
1250890838 authored Nov 22, 2024
1 parent 396a8d1 commit 57542f6
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 13 deletions.
16 changes: 7 additions & 9 deletions src/elidedlabel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,11 @@
#include <QResizeEvent>
#include <QTimer>

ElidedLabel::ElidedLabel(QWidget *parent, Qt::WindowFlags f) : QLabel(parent, f)
{
defaultType = Qt::ElideRight;
eliding = false;
original = "";
}
ElidedLabel::ElidedLabel(QWidget *parent, Qt::WindowFlags f) : ElidedLabel("", parent, f) { }

ElidedLabel::ElidedLabel(const QString &text, QWidget *parent, Qt::WindowFlags f)
: QLabel(text, parent, f)
: QLabel(text, parent, f), original(""), defaultType(Qt::ElideRight), eliding(false)
{
defaultType = Qt::ElideRight;
eliding = false;
setText(text);
}

Expand All @@ -24,6 +17,11 @@ void ElidedLabel::setType(const Qt::TextElideMode type)
elide();
}

QString ElidedLabel::text() const
{
return original;
}

void ElidedLabel::resizeEvent(QResizeEvent *event)
{
Q_UNUSED(event);
Expand Down
1 change: 1 addition & 0 deletions src/elidedlabel.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ class ElidedLabel : public QLabel
explicit ElidedLabel(const QString &text, QWidget *parent = nullptr,
Qt::WindowFlags f = Qt::WindowFlags());
void setType(const Qt::TextElideMode type);
QString text() const;

public slots:
void setText(const QString &text);
Expand Down
1 change: 0 additions & 1 deletion src/foldertreedelegateeditor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,6 @@ void FolderTreeDelegateEditor::updateDelegate()
{
auto displayName = m_index.data(NodeItem::Roles::DisplayText).toString();
QFontMetrics fm(m_titleFont);
displayName = fm.elidedText(displayName, Qt::ElideRight, m_label->contentsRect().width());
QString labelStyle;
QString folderIconStyle;

Expand Down
2 changes: 1 addition & 1 deletion src/labeledittype.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
#include <QBoxLayout>
#include <QDebug>

LabelEditType::LabelEditType(QWidget *parent) : QLabel(parent)
LabelEditType::LabelEditType(QWidget *parent) : ElidedLabel(parent)
{
setContentsMargins(0, 0, 0, 0);
m_editor = new QLineEdit(this);
Expand Down
4 changes: 2 additions & 2 deletions src/labeledittype.h
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
#ifndef LABELEDITTYPE_H
#define LABELEDITTYPE_H

#include <QLabel>
#include "elidedlabel.h"

class QLineEdit;
class LabelEditType : public QLabel
class LabelEditType : public ElidedLabel
{
Q_OBJECT
public:
Expand Down

0 comments on commit 57542f6

Please sign in to comment.