Browse Source

Merge pull request #5489

Teemu Ikonen (1):
      fix(ui): tighten idealSize() for chatlog Timestamps
reviewable/pr5494/r1
Anthony Bilinski 7 years ago
parent
commit
55ef1e0370
No known key found for this signature in database
GPG Key ID: 2AA8E0DA1B31FB3C
  1. 9
      src/chatlog/content/text.h
  2. 8
      src/chatlog/content/timestamp.cpp
  3. 6
      src/chatlog/content/timestamp.h

9
src/chatlog/content/text.h

@ -70,7 +70,7 @@ protected:
void regenerate(); void regenerate();
void freeResources(); void freeResources();
QSizeF idealSize(); virtual QSizeF idealSize();
int cursorFromPos(QPointF scenePos, bool fuzzy = true) const; int cursorFromPos(QPointF scenePos, bool fuzzy = true) const;
int getSelectionEnd() const; int getSelectionEnd() const;
int getSelectionStart() const; int getSelectionStart() const;
@ -78,14 +78,16 @@ protected:
QString extractSanitizedText(int from, int to) const; QString extractSanitizedText(int from, int to) const;
QString extractImgTooltip(int pos) const; QString extractImgTooltip(int pos) const;
QTextDocument* doc = nullptr;
QSizeF size;
qreal width = 0.0;
private: private:
void selectText(QTextCursor& cursor, const std::pair<int, int>& point); void selectText(QTextCursor& cursor, const std::pair<int, int>& point);
QTextDocument* doc = nullptr;
QString text; QString text;
QString rawText; QString rawText;
QString selectedText; QString selectedText;
QSizeF size;
bool keepInMemory = false; bool keepInMemory = false;
bool elide = false; bool elide = false;
bool dirty = false; bool dirty = false;
@ -93,7 +95,6 @@ private:
int selectionEnd = -1; int selectionEnd = -1;
int selectionAnchor = -1; int selectionAnchor = -1;
qreal ascent = 0.0; qreal ascent = 0.0;
qreal width = 0.0;
QFont defFont; QFont defFont;
QString defStyleSheet; QString defStyleSheet;
QColor color; QColor color;

8
src/chatlog/content/timestamp.cpp

@ -29,3 +29,11 @@ QDateTime Timestamp::getTime()
{ {
return time; return time;
} }
QSizeF Timestamp::idealSize()
{
if (doc) {
return QSizeF(qMin(doc->idealWidth(), width), doc->size().height());
}
return size;
}

6
src/chatlog/content/timestamp.h

@ -22,6 +22,9 @@
#include "text.h" #include "text.h"
#include <QDateTime> #include <QDateTime>
#include <QTextDocument>
class QTextDocument;
class Timestamp : public Text class Timestamp : public Text
{ {
@ -30,6 +33,9 @@ public:
Timestamp(const QDateTime& time, const QString& format, const QFont& font); Timestamp(const QDateTime& time, const QString& format, const QFont& font);
QDateTime getTime(); QDateTime getTime();
protected:
QSizeF idealSize();
private: private:
QDateTime time; QDateTime time;
}; };

Loading…
Cancel
Save