fix: 优化颜色标注完善机制;修复在 Qt5 下运行崩溃的问题;修复调整颜色 S 和 V 通道无效的问题;

This commit is contained in:
寂静的羽夏 2025-01-09 13:09:00 +08:00
parent 1bd978e2b2
commit 3dc1ab0ee8
35 changed files with 705 additions and 581 deletions

View File

@ -40,7 +40,7 @@ qsizetype QHexCursor::selectionLength(qsizetype index) const {
qsizetype QHexCursor::currentSelectionLength() const { qsizetype QHexCursor::currentSelectionLength() const {
if (hasPreviewSelection() && m_preMode != SelectionRemove) { if (hasPreviewSelection() && m_preMode != SelectionRemove) {
return qAbs(m_position - m_selection); return qAbs(m_position - m_selection + 1);
} }
qsizetype len = 0; qsizetype len = 0;
@ -82,6 +82,23 @@ bool QHexCursor::isLineSelected(qsizetype line) const {
return false; return false;
} }
bool QHexCursor::isSelected(const QHexPosition &pos) const {
if (!this->hasSelection())
return false;
if (previewSelection().contains(pos)) {
return true;
}
for (auto &sel : m_sels) {
if (sel.contains(pos)) {
return true;
}
}
return false;
}
bool QHexCursor::hasSelection() const { bool QHexCursor::hasSelection() const {
return hasPreviewSelection() || hasInternalSelection(); return hasPreviewSelection() || hasInternalSelection();
} }
@ -210,10 +227,9 @@ bool QHexCursor::hasPreviewSelection() const {
bool QHexCursor::isLineSelected(const QHexSelection &sel, bool QHexCursor::isLineSelected(const QHexSelection &sel,
qsizetype line) const { qsizetype line) const {
auto first = std::min(sel.begin.line, sel.end.line); Q_ASSERT(sel.isNormalized());
auto last = std::max(sel.begin.line, sel.end.line);
if ((line >= first) && (line <= last)) if ((line >= sel.begin.line) && (line <= sel.end.line))
return true; return true;
return false; return false;
@ -223,7 +239,7 @@ QHexSelection QHexCursor::previewSelection() const {
QHexSelection sel; QHexSelection sel;
sel.begin = m_position; sel.begin = m_position;
sel.end = m_selection; sel.end = m_selection;
return sel; return sel.normalized();
} }
void QHexCursor::setPreviewSelectionMode(SelectionMode mode) { void QHexCursor::setPreviewSelectionMode(SelectionMode mode) {
@ -235,7 +251,7 @@ QHexCursor::SelectionMode QHexCursor::previewSelectionMode() const {
} }
void QHexCursor::mergePreviewSelection() { void QHexCursor::mergePreviewSelection() {
auto ss = QHexSelection(m_position, m_selection).normalized(); auto ss = previewSelection();
switch (m_preMode) { switch (m_preMode) {
case SelectionNormal: case SelectionNormal:
if (m_sels.isEmpty()) { if (m_sels.isEmpty()) {

View File

@ -15,7 +15,7 @@ struct QHexPosition {
quint8 lineWidth = 0; quint8 lineWidth = 0;
int nibbleindex = -1; int nibbleindex = -1;
QHexPosition() = default; inline QHexPosition() = default;
inline qsizetype offset() const { inline qsizetype offset() const {
return static_cast<qsizetype>(line * lineWidth) + column; return static_cast<qsizetype>(line * lineWidth) + column;
} }
@ -61,15 +61,15 @@ struct QHexPosition {
Q_DECLARE_METATYPE(QHexPosition) Q_DECLARE_METATYPE(QHexPosition)
struct QHexSelection : QHexRegionObject<QHexPosition, QHexSelection> { struct QHexSelection : QHexRegionObject<QHexPosition, QHexSelection> {
QHexSelection() { setAdjusted(true); }; inline QHexSelection() = default;
explicit QHexSelection(const QHexPosition &begin, const QHexPosition &end) { inline explicit QHexSelection(const QHexPosition &begin,
setAdjusted(true); const QHexPosition &end) {
this->begin = begin; this->begin = begin;
this->end = end; this->end = end;
} }
bool isLineSelected(qsizetype line) const { inline bool isLineSelected(qsizetype line) const {
Q_ASSERT(isNormalized()); Q_ASSERT(isNormalized());
if (this->begin.line == line || this->end.line == line) { if (this->begin.line == line || this->end.line == line) {
return true; return true;
@ -118,6 +118,7 @@ public:
bool atEnd() const; bool atEnd() const;
bool isLineSelected(qsizetype line) const; bool isLineSelected(qsizetype line) const;
bool isSelected(const QHexPosition &pos) const;
bool hasSelection() const; bool hasSelection() const;
bool hasInternalSelection() const; bool hasInternalSelection() const;

View File

@ -5,6 +5,8 @@
#include "commands/meta/metaremoveposcommand.h" #include "commands/meta/metaremoveposcommand.h"
#include "commands/meta/metareplacecommand.h" #include "commands/meta/metareplacecommand.h"
#include <cmath>
#include <QtAlgorithms> #include <QtAlgorithms>
#include <QtConcurrent/QtConcurrentMap> #include <QtConcurrent/QtConcurrentMap>
@ -162,35 +164,26 @@ QHexLineMetadata QHexMetadata::gets(qsizetype line) {
return ret; return ret;
} }
QPair<qsizetype, qsizetype> QHexMetadata::getRealMetaRange(qsizetype begin, QVector<QHexMetadata::MetaInfo> QHexMetadata::getRealMetaRange(qsizetype begin,
qsizetype end) { qsizetype end) {
Q_ASSERT(begin <= end); Q_ASSERT(begin <= end);
using QHexRegionGadget = QHexRegionGadget<qsizetype>; QVector<MetaInfo> ret;
MetaInfo g(begin, end);
QList<QHexRegionGadget> items;
for (auto &meta : m_metadata) { for (auto &meta : m_metadata) {
if (!(end < meta.begin || begin > meta.end)) { if (!(end < meta.begin || begin > meta.end)) {
items.append(QHexRegionGadget(meta.begin, meta.end)); auto m = MetaInfo(meta.begin, meta.end, meta.foreground,
meta.background, meta.comment);
if (m.intersect(g)) {
ret.insert(std::distance(ret.constBegin(),
std::upper_bound(ret.constBegin(),
ret.constEnd(), m)),
m);
}
} }
} }
if (items.isEmpty()) { return ret;
return qMakePair(-1, -1);
} else {
auto pitem = items.first();
for (auto meta = std::next(items.constBegin());
meta != items.constEnd(); ++meta) {
pitem.mergeRegion(*meta);
}
QHexRegionGadget g(begin, end);
auto ret = g.intersect(pitem);
if (!ret) {
return qMakePair(-1, -1);
}
return qMakePair(g.begin, g.end);
}
} }
void QHexMetadata::applyMetas(const QVector<QHexMetadataItem> &metas) { void QHexMetadata::applyMetas(const QVector<QHexMetadataItem> &metas) {
@ -201,31 +194,29 @@ void QHexMetadata::applyMetas(const QVector<QHexMetadataItem> &metas) {
bool QHexMetadata::hasMetadata() { return m_metadata.count() > 0; } bool QHexMetadata::hasMetadata() { return m_metadata.count() > 0; }
/*==================================*/ QColor QHexMetadata::generateContrastingColor(const QColor &backgroundColor) {
// Invert RGB values
QColor invertedColor(255 - backgroundColor.red(),
255 - backgroundColor.green(),
255 - backgroundColor.blue());
QString QHexMetadata::comments(qsizetype line, qsizetype column) const { // Ensure it meets contrast ratio criteria
if (!this->lineHasMetadata(line)) double contrastRatio =
return QString(); calculateContrastRatio(backgroundColor, invertedColor);
if (contrastRatio >= 4.5) {
QString s; return invertedColor;
const auto &linemetadata = this->get(line);
for (auto &mi : linemetadata) {
if (!(mi.start <= column && column < mi.start + mi.length))
continue;
if (mi.comment.isEmpty())
continue;
if (!s.isEmpty())
s += "\n";
s += mi.comment;
} }
return s; // If contrast is still too low, adjust brightness or saturation
int luminance = (backgroundColor.red() + backgroundColor.green() +
backgroundColor.blue()) /
3;
return (luminance < 128) ? QColor(255, 255, 255)
: QColor(0, 0, 0); // Use black or white
} }
/*==================================*/
bool QHexMetadata::lineHasMetadata(qsizetype line) const { bool QHexMetadata::lineHasMetadata(qsizetype line) const {
return m_linemeta.contains(line); return m_linemeta.contains(line);
} }
@ -329,6 +320,43 @@ void QHexMetadata::removeAdjust(qsizetype offset, qsizetype length) {
} }
} }
bool QHexMetadata::areColorsContrast(const QColor &color1,
const QColor &color2) {
return calculateContrastRatio(color1, color2) >= 4.5;
}
double QHexMetadata::calculateLuminance(const QColor &color) {
// Normalize RGB values to [0, 1]
double r = color.redF();
double g = color.greenF();
double b = color.blueF();
// Apply gamma correction
auto gammaCorrect = [](double value) {
return (value <= 0.03928) ? (value / 12.92)
: std::pow((value + 0.055) / 1.055, 2.4);
};
r = gammaCorrect(r);
g = gammaCorrect(g);
b = gammaCorrect(b);
// Calculate relative luminance
return 0.2126 * r + 0.7152 * g + 0.0722 * b;
}
double QHexMetadata::calculateContrastRatio(const QColor &color1,
const QColor &color2) {
double luminance1 = calculateLuminance(color1);
double luminance2 = calculateLuminance(color2);
// Ensure luminance1 is the lighter one
if (luminance1 < luminance2)
std::swap(luminance1, luminance2);
return (luminance1 + 0.05) / (luminance2 + 0.05);
}
bool QHexMetadata::color(qsizetype begin, qsizetype end, const QColor &fgcolor, bool QHexMetadata::color(qsizetype begin, qsizetype end, const QColor &fgcolor,
const QColor &bgcolor) { const QColor &bgcolor) {
return this->metadata(begin, end, fgcolor, bgcolor, QString()); return this->metadata(begin, end, fgcolor, bgcolor, QString());
@ -393,7 +421,7 @@ void QHexMetadata::addMetaLines(const QHexMetadataItem &mi) {
if (row == lastRow) { if (row == lastRow) {
Q_ASSERT(m_lineWidth > 0); Q_ASSERT(m_lineWidth > 0);
const int lastChar = mi.end % m_lineWidth; const int lastChar = mi.end % m_lineWidth;
length = lastChar - start; length = lastChar - start + 1;
} else { } else {
// fix the bug by wingsummer // fix the bug by wingsummer
if (firstRow != lastRow) if (firstRow != lastRow)

View File

@ -115,12 +115,32 @@ class QHexMetadata : public QObject {
Q_OBJECT Q_OBJECT
public: public:
enum class MetaOpError { Error = -2 }; struct MetaInfo : QHexRegionObject<qsizetype, MetaInfo> {
QColor foreground;
QColor background;
QString comment;
explicit MetaInfo() {
this->begin = -1;
this->end = -1;
}
explicit MetaInfo(qsizetype begin, qsizetype end) {
this->begin = begin;
this->end = end;
}
explicit MetaInfo(qsizetype begin, qsizetype end, QColor foreground,
QColor background, QString comment)
: foreground(foreground), background(background), comment(comment) {
this->begin = begin;
this->end = end;
}
};
public: public:
explicit QHexMetadata(QUndoStack *undo, QObject *parent = nullptr); explicit QHexMetadata(QUndoStack *undo, QObject *parent = nullptr);
QHexLineMetadata get(qsizetype line) const; QHexLineMetadata get(qsizetype line) const;
QString comments(qsizetype line, qsizetype column) const;
bool lineHasMetadata(qsizetype line) const; // modified by wingsummer bool lineHasMetadata(qsizetype line) const; // modified by wingsummer
qsizetype size() const; qsizetype size() const;
@ -152,15 +172,27 @@ public:
std::optional<QHexMetadataItem> get(qsizetype offset); std::optional<QHexMetadataItem> get(qsizetype offset);
QHexLineMetadata gets(qsizetype line); QHexLineMetadata gets(qsizetype line);
QPair<qsizetype, qsizetype> getRealMetaRange(qsizetype begin, QVector<MetaInfo> getRealMetaRange(qsizetype begin, qsizetype end);
qsizetype end);
void applyMetas(const QVector<QHexMetadataItem> &metas); void applyMetas(const QVector<QHexMetadataItem> &metas);
bool hasMetadata(); bool hasMetadata();
public:
static QColor generateContrastingColor(const QColor &backgroundColor);
static bool areColorsContrast(const QColor &color1, const QColor &color2);
// Function to calculate relative luminance
static double calculateLuminance(const QColor &color);
// Function to calculate contrast ratio
static double calculateContrastRatio(const QColor &color1,
const QColor &color2);
/*============================*/ /*============================*/
public:
void clear(); void clear();
void setLineWidth(quint8 width); void setLineWidth(quint8 width);

View File

@ -1,51 +1,58 @@
#ifndef QHEXREGIONOBJECT_H #ifndef QHEXREGIONOBJECT_H
#define QHEXREGIONOBJECT_H #define QHEXREGIONOBJECT_H
#include <type_traits>
#include <utility>
namespace REQUIRE_CHECK { namespace REQUIRE_CHECK {
struct NO_OP {}; template <typename, typename = void>
struct has_greater_equal : std::false_type {};
template <typename T, typename Arg>
NO_OP &operator>(const T &, const Arg &);
template <typename T, typename Arg>
NO_OP &operator>=(const T &, const Arg &);
template <typename T, typename Arg>
NO_OP &operator<(const T &, const Arg &);
template <typename T, typename Arg>
NO_OP &operator<=(const T &, const Arg &);
template <typename T, typename Arg>
NO_OP &operator==(const T &, const Arg &);
template <typename T, typename Arg>
NO_OP &operator!=(const T &, const Arg &);
int optest(NO_OP const &);
template <typename T> template <typename T>
char optest(T const &); struct has_greater_equal<
T, std::void_t<decltype(std::declval<T>() >= std::declval<T>())>>
: std::true_type {};
template <typename T, typename Arg = T> // Repeat for other operators
struct GreatThanExists { template <typename, typename = void>
enum { value = sizeof(optest(*(T *)(0) > *(Arg *)(0))) == sizeof(char) }; struct has_greater : std::false_type {};
};
template <typename T, typename Arg = T> template <typename T>
struct LessThanExists { struct has_greater<T,
enum { value = sizeof(optest(*(T *)(0) < *(Arg *)(0))) == sizeof(char) }; std::void_t<decltype(std::declval<T>() > std::declval<T>())>>
}; : std::true_type {};
template <typename T, typename Arg = T>
struct GreatEqualThanExists { template <typename, typename = void>
enum { value = sizeof(optest(*(T *)(0) >= *(Arg *)(0))) == sizeof(char) }; struct has_less_equal : std::false_type {};
};
template <typename T, typename Arg = T> template <typename T>
struct LessEqualThanExists { struct has_less_equal<
enum { value = sizeof(optest(*(T *)(0) <= *(Arg *)(0))) == sizeof(char) }; T, std::void_t<decltype(std::declval<T>() <= std::declval<T>())>>
}; : std::true_type {};
template <typename T, typename Arg = T>
struct EqualExists { template <typename, typename = void>
enum { value = sizeof(optest(*(T *)(0) == *(Arg *)(0))) == sizeof(char) }; struct has_less : std::false_type {};
};
template <typename T, typename Arg = T> template <typename T>
struct NotEqualExists { struct has_less<T, std::void_t<decltype(std::declval<T>() < std::declval<T>())>>
enum { value = sizeof(optest(*(T *)(0) != *(Arg *)(0))) == sizeof(char) }; : std::true_type {};
};
template <typename T, typename = void>
struct has_equal : std::false_type {};
template <typename T>
struct has_equal<T,
std::void_t<decltype(std::declval<T>() == std::declval<T>())>>
: std::true_type {};
template <typename, typename = void>
struct has_not_equal : std::false_type {};
template <typename T>
struct has_not_equal<
T, std::void_t<decltype(std::declval<T>() != std::declval<T>())>>
: std::true_type {};
} // namespace REQUIRE_CHECK } // namespace REQUIRE_CHECK
@ -54,156 +61,23 @@ struct NotEqualExists {
#include <QMutex> #include <QMutex>
template <typename T>
struct QHexRegionGadget final {
static_assert(REQUIRE_CHECK::GreatThanExists<T>::value,
"Operator > is required");
static_assert(REQUIRE_CHECK::LessThanExists<T>::value,
"Operator < is required");
static_assert(REQUIRE_CHECK::GreatEqualThanExists<T>::value,
"Operator >= is required");
static_assert(REQUIRE_CHECK::LessEqualThanExists<T>::value,
"Operator <= is required");
static_assert(REQUIRE_CHECK::EqualExists<T>::value,
"Operator == is required");
static_assert(REQUIRE_CHECK::NotEqualExists<T>::value,
"Operator != is required");
bool _valid = true;
public:
T begin;
T end;
QHexRegionGadget() : begin(T()), end(T()) {}
explicit QHexRegionGadget(const T &begin, const T &end)
: begin(begin), end(end) {}
void normalize() {
Q_ASSERT(isValid());
if (end < begin) {
std::swap(begin, end);
}
}
qsizetype length() const {
Q_ASSERT(isValid());
return qAbs(end - begin) + 1;
}
bool contains(const QHexRegionGadget &sel) const {
Q_ASSERT(isValid());
Q_ASSERT(isNormalized());
return this->begin <= sel.begin && this->end >= sel.end;
}
bool isNormalized() const {
Q_ASSERT(isValid());
return end >= begin;
}
QHexRegionGadget normalized() const {
Q_ASSERT(isValid());
QHexRegionGadget sel = *this;
if (end < begin) {
std::swap(sel.begin, sel.end);
}
return sel;
}
bool isIntersected(const QHexRegionGadget &sel) const {
Q_ASSERT(isValid());
Q_ASSERT(isNormalized());
return !(sel.end < begin || sel.begin > end);
}
bool intersect(const QHexRegionGadget &sel) {
Q_ASSERT(isValid());
Q_ASSERT(isNormalized());
if (!isIntersected(sel)) {
_valid = false;
return false;
}
auto s = sel.normalized();
this->begin = qMax(this->begin, s.begin);
this->end = qMin(this->end, s.end);
return true;
}
Q_REQUIRED_RESULT std::variant<bool, QHexRegionGadget>
removeRegion(const QHexRegionGadget &sel) {
Q_ASSERT(isValid());
Q_ASSERT(isNormalized());
Q_ASSERT(sel.isNormalized());
std::variant<bool, QHexRegionGadget> result = false;
if (sel.begin <= this->begin) {
if (sel.end >= this->begin) {
if (sel.end < this->end) {
this->begin = sel.end;
} else {
// makes it invalid, delete later
_valid = false;
}
result = true;
}
} else if (sel.begin > this->begin && sel.begin < this->end) {
this->end = sel.begin;
result = true;
if (sel.end < this->end) {
// break into two ranges
QHexRegionGadget sel;
sel.begin = sel.end;
sel.end = this->end;
return sel;
}
}
return result;
}
std::variant<bool, std::optional<QHexRegionGadget>>
mergeRegion(const QHexRegionGadget &sel) {
Q_ASSERT(isValid());
Q_ASSERT(isNormalized());
if (isIntersected(sel)) {
this->begin = qMin(this->begin, sel.begin);
this->end = qMax(this->end, sel.end);
return true;
}
return false;
};
bool isValid() const { return _valid; }
};
template <typename T, typename P> template <typename T, typename P>
struct QHexRegionObject { struct QHexRegionObject {
static_assert(REQUIRE_CHECK::GreatThanExists<T>::value, static_assert(REQUIRE_CHECK::has_greater<T>::value,
"Operator > is required"); "Operator > is required");
static_assert(REQUIRE_CHECK::LessThanExists<T>::value, static_assert(REQUIRE_CHECK::has_less<T>::value, "Operator < is required");
"Operator < is required"); static_assert(REQUIRE_CHECK::has_greater_equal<T>::value,
static_assert(REQUIRE_CHECK::GreatEqualThanExists<T>::value,
"Operator >= is required"); "Operator >= is required");
static_assert(REQUIRE_CHECK::LessEqualThanExists<T>::value, static_assert(REQUIRE_CHECK::has_less_equal<T>::value,
"Operator <= is required"); "Operator <= is required");
static_assert(REQUIRE_CHECK::EqualExists<T>::value, static_assert(REQUIRE_CHECK::has_equal<T>::value,
"Operator == is required"); "Operator == is required");
static_assert(REQUIRE_CHECK::NotEqualExists<T>::value, static_assert(REQUIRE_CHECK::has_not_equal<T>::value,
"Operator != is required"); "Operator != is required");
using Super = QHexRegionObject<T, P>; using Super = QHexRegionObject<T, P>;
private: private:
bool _adjusted = false;
bool _valid = true; bool _valid = true;
T next(const T &obj) const { T next(const T &obj) const {
@ -241,6 +115,12 @@ public:
return this->begin <= sel.begin && this->end >= sel.end; return this->begin <= sel.begin && this->end >= sel.end;
} }
bool contains(const T &offset) const {
Q_ASSERT(isValid());
Q_ASSERT(isNormalized());
return this->begin <= offset && this->end >= offset;
}
bool isNormalized() const { bool isNormalized() const {
Q_ASSERT(isValid()); Q_ASSERT(isValid());
return end >= begin; return end >= begin;
@ -260,13 +140,15 @@ public:
static_assert(std::is_base_of_v<QHexRegionObject<T, P>, P>); static_assert(std::is_base_of_v<QHexRegionObject<T, P>, P>);
Q_ASSERT(isValid()); Q_ASSERT(isValid());
Q_ASSERT(isNormalized()); Q_ASSERT(isNormalized());
if (_adjusted) {
return !(next(sel.end) < this->begin ||
sel.begin > next(this->end));
}
return !(sel.end < begin || sel.begin > end); return !(sel.end < begin || sel.begin > end);
} }
bool canMerge(const P &sel) const {
Q_ASSERT(isValid());
Q_ASSERT(isNormalized());
return !(next(sel.end) < this->begin || sel.begin > next(this->end));
}
bool intersect(const P &sel, QMutex *locker = nullptr) { bool intersect(const P &sel, QMutex *locker = nullptr) {
static_assert(std::is_base_of_v<QHexRegionObject<T, P>, P>); static_assert(std::is_base_of_v<QHexRegionObject<T, P>, P>);
Q_ASSERT(isValid()); Q_ASSERT(isValid());
@ -278,18 +160,10 @@ public:
if (locker) { if (locker) {
locker->lock(); locker->lock();
} }
if (_adjusted) {
if (this->begin < s.end) { this->begin = qMax(this->begin, s.begin);
this->begin = qMax(this->begin, next(s.begin)); this->end = qMin(this->end, s.end);
this->end = qMin(next(this->end), s.end);
} else {
this->begin = qMax(next(this->begin), s.begin);
this->end = qMin(this->end, next(s.end));
}
} else {
this->begin = qMax(this->begin, s.begin);
this->end = qMin(this->end, s.end);
}
if (locker) { if (locker) {
locker->unlock(); locker->unlock();
} }
@ -312,9 +186,7 @@ public:
if (sel.end >= this->begin) { if (sel.end >= this->begin) {
if (sel.end < this->end) { if (sel.end < this->end) {
this->begin = sel.end; this->begin = sel.end;
if (_adjusted) { ++this->begin;
++this->begin;
}
} else { } else {
// makes it invalid, delete later // makes it invalid, delete later
_valid = false; _valid = false;
@ -322,23 +194,23 @@ public:
result = true; result = true;
} }
} else if (sel.begin > this->begin && sel.begin < this->end) { } else if (sel.begin > this->begin && sel.begin < this->end) {
auto oldend = this->end;
this->end = sel.begin; this->end = sel.begin;
if (_adjusted) { --this->end;
--this->end;
}
result = true; result = true;
if (sel.end < this->end) { if (sel.end < oldend) {
// break into two ranges // break into two ranges
P sel; P s;
sel.begin = sel.end; s.begin = sel.end;
sel.end = this->end; s.end = oldend;
if (locker) { if (locker) {
locker->unlock(); locker->unlock();
} }
return sel; return s.normalized();
} }
} }
@ -352,22 +224,19 @@ public:
mergeRegion(const P &sel, QMutex *locker = nullptr) { mergeRegion(const P &sel, QMutex *locker = nullptr) {
Q_ASSERT(isValid()); Q_ASSERT(isValid());
Q_ASSERT(isNormalized()); Q_ASSERT(isNormalized());
if (isIntersected(sel)) { if (canMerge(sel)) {
if (locker) { if (locker) {
locker->lock(); locker->lock();
} }
if (_adjusted) {
if (this->begin < sel.end) { if (this->begin < sel.end) {
this->begin = qMin(this->begin, next(sel.begin)); this->begin = qMin(this->begin, next(sel.begin));
this->end = qMax(next(this->end), sel.end); this->end = qMax(next(this->end), sel.end);
} else {
this->begin = qMin(next(this->begin), sel.begin);
this->end = qMax(this->end, next(sel.end));
}
} else { } else {
this->begin = qMin(this->begin, sel.begin); this->begin = qMin(next(this->begin), sel.begin);
this->end = qMax(this->end, sel.end); this->end = qMax(this->end, next(sel.end));
} }
if (locker) { if (locker) {
locker->unlock(); locker->unlock();
} }
@ -376,17 +245,9 @@ public:
return false; return false;
}; };
bool adjusted() const {
Q_ASSERT(isValid());
return _adjusted;
};
void setAdjusted(bool newAdjusted) {
Q_ASSERT(isValid());
_adjusted = newAdjusted;
};
bool isValid() const { return _valid; } bool isValid() const { return _valid; }
bool operator<(const Super &item) const { return begin < item.begin; }
}; };
#include <QtConcurrent/QtConcurrentMap> #include <QtConcurrent/QtConcurrentMap>
@ -442,7 +303,12 @@ public:
auto region = std::get<std::optional<P>>(res); auto region = std::get<std::optional<P>>(res);
idx = std::distance(this->begin(), p); idx = std::distance(this->begin(), p);
if (region.has_value()) { if (region.has_value()) {
this->append(region.value()); auto v = region.value();
this->insert(
std::distance(this->constBegin(),
std::upper_bound(this->constBegin(),
this->constEnd(), v)),
v);
} }
break; break;
} }
@ -455,10 +321,12 @@ public:
auto m = this->takeAt(idx); auto m = this->takeAt(idx);
mergeAdd(m, locker); mergeAdd(m, locker);
} else { } else {
this->append(sel); this->insert(
std::distance(this->constBegin(),
std::upper_bound(this->constBegin(),
this->constEnd(), sel)),
sel);
} }
} else {
this->append(sel);
} }
return idx; return idx;

View File

@ -15,6 +15,8 @@
#define HEX_UNPRINTABLE_CHAR '.' #define HEX_UNPRINTABLE_CHAR '.'
constexpr qreal CONTRASTING_COLOR_BORDER = 0.35;
/*===================================*/ /*===================================*/
// added by wingsummer // added by wingsummer
@ -407,14 +409,36 @@ void QHexRenderer::applyMetadata(QTextCursor &textcursor, qsizetype line,
const QHexLineMetadata &linemetadata = metadata->gets(line); const QHexLineMetadata &linemetadata = metadata->gets(line);
for (auto &mi : linemetadata) { for (auto &mi : linemetadata) {
QTextCharFormat charformat; QTextCharFormat charformat;
QColor bg, fg;
if (m_document->metabgVisible() && mi.background.isValid() && if (m_document->metabgVisible() && mi.background.isValid() &&
mi.background.rgba()) mi.background.alpha()) {
charformat.setBackground(mi.background); charformat.setBackground(mi.background);
bg = mi.background;
}
if (m_document->metafgVisible() && mi.foreground.isValid() && if (m_document->metafgVisible() && mi.foreground.isValid() &&
mi.foreground.rgba()) mi.foreground.alpha()) {
charformat.setForeground(mi.foreground); charformat.setForeground(mi.foreground);
if (m_document->metaCommentVisible() && !mi.comment.isEmpty()) fg = mi.foreground;
}
if (m_document->metaCommentVisible() && !mi.comment.isEmpty()) {
charformat.setUnderlineStyle(QTextCharFormat::SingleUnderline); charformat.setUnderlineStyle(QTextCharFormat::SingleUnderline);
charformat.setToolTip(mi.comment);
}
if (!bg.isValid()) {
bg = m_bytesBackground;
}
if (!fg.isValid()) {
fg = m_bytesColor;
}
if (!QHexMetadata::areColorsContrast(bg, fg)) {
charformat.setFontWeight(QFont::Bold);
charformat.setTextOutline(
QPen(QHexMetadata::generateContrastingColor(bg),
CONTRASTING_COLOR_BORDER, Qt::SolidLine));
}
textcursor.setPosition(int(mi.start * factor)); textcursor.setPosition(int(mi.start * factor));
textcursor.movePosition( textcursor.movePosition(
@ -437,7 +461,7 @@ void QHexRenderer::applySelection(QTextCursor &textcursor, qsizetype line,
if (m_cursor->hasPreviewSelection()) { if (m_cursor->hasPreviewSelection()) {
applySelection( applySelection(
m_cursor->previewSelection().normalized(), textcursor, line, factor, m_cursor->previewSelection(), textcursor, line, factor,
m_cursor->previewSelectionMode() == QHexCursor::SelectionRemove, m_cursor->previewSelectionMode() == QHexCursor::SelectionRemove,
m_cursor->previewSelectionMode() == QHexCursor::SelectionNormal && m_cursor->previewSelectionMode() == QHexCursor::SelectionNormal &&
m_cursor->hasInternalSelection()); m_cursor->hasInternalSelection());
@ -452,9 +476,6 @@ void QHexRenderer::applySelection(const QHexSelection &selection,
return; return;
} }
const QHexPosition &startsel = selection.begin;
const QHexPosition &endsel = selection.end;
QTextCharFormat charfmt; QTextCharFormat charfmt;
charfmt.setBackground(strikeOut || hasSelection charfmt.setBackground(strikeOut || hasSelection
? m_selBackgroundColor.darker() ? m_selBackgroundColor.darker()
@ -469,31 +490,83 @@ void QHexRenderer::applySelection(const QHexSelection &selection,
charfmt_meta.setFontUnderline(true); charfmt_meta.setFontUnderline(true);
charfmt_meta.setFontItalic(true); charfmt_meta.setFontItalic(true);
const QHexPosition &startsel = selection.begin;
const QHexPosition &endsel = selection.end;
QHexSelection lineSel;
lineSel.begin.line = line;
lineSel.begin.lineWidth = startsel.lineWidth;
lineSel.begin.column = 0;
lineSel.begin.nibbleindex = 0;
lineSel.end = lineSel.begin;
lineSel.end.column = startsel.lineWidth - 1;
QVector<QHexMetadata::MetaInfo> metas;
if (lineSel.isIntersected(selection)) {
lineSel.intersect(selection);
metas = m_document->metadata()->getRealMetaRange(lineSel.begin.offset(),
lineSel.end.offset());
}
qsizetype begin;
qsizetype end;
if (startsel.line == endsel.line) { if (startsel.line == endsel.line) {
auto selbegin = startsel.offset(); begin = startsel.column;
auto len = endsel.column - startsel.column + 1; end = endsel.column;
auto selend = selbegin + len; } else {
if (line == startsel.line)
begin = startsel.column;
else
begin = 0;
auto meta = m_document->metadata()->getRealMetaRange(selbegin, selend); if (line == endsel.line)
end = endsel.column;
else
end = startsel.lineWidth - 1;
}
if (meta.first >= 0) { applySelection(metas, textcursor, line * startsel.lineWidth, begin, end,
auto begin = meta.first - startsel.lineWidth * startsel.line; factor, strikeOut, hasSelection);
auto mlen = meta.second - meta.first; }
textcursor.setPosition(startsel.column * factor); void QHexRenderer::applySelection(const QVector<QHexMetadata::MetaInfo> &metas,
QTextCursor &textcursor,
qsizetype startLineOffset,
qsizetype lineStart, qsizetype lineEnd,
Factor factor, bool strikeOut,
bool hasSelection) const {
auto totallen = lineEnd - lineStart + 1;
QTextCharFormat charfmt;
charfmt.setBackground(strikeOut || hasSelection
? m_selBackgroundColor.darker()
: m_selBackgroundColor);
charfmt.setForeground(strikeOut ? m_selectionColor.darker()
: m_selectionColor);
charfmt.setFontStrikeOut(strikeOut);
charfmt.setFontItalic(strikeOut);
if (!metas.isEmpty()) {
auto fmtBegin = lineStart;
for (int i = 0; i < metas.size(); ++i) {
QTextCharFormat charfmt_meta = charfmt;
charfmt_meta.setFontWeight(QFont::Bold);
charfmt_meta.setFontItalic(true);
auto mi = metas.at(i);
auto begin = mi.begin - startLineOffset;
auto mlen = mi.end - mi.begin + 1;
auto blen = begin - fmtBegin;
textcursor.setPosition(fmtBegin * factor);
textcursor.movePosition(QTextCursor::Right, QTextCursor::KeepAnchor, textcursor.movePosition(QTextCursor::Right, QTextCursor::KeepAnchor,
(begin - startsel.column) * factor); blen * factor);
if (factor == Hex)
textcursor.movePosition(QTextCursor::Left,
QTextCursor::KeepAnchor, 1);
textcursor.mergeCharFormat(charfmt); textcursor.mergeCharFormat(charfmt);
len -= (begin - startsel.column);
textcursor.clearSelection(); textcursor.clearSelection();
totallen -= blen;
if (factor == Hex)
textcursor.movePosition(QTextCursor::Right,
QTextCursor::MoveAnchor, 1);
textcursor.movePosition(QTextCursor::Right, QTextCursor::KeepAnchor, textcursor.movePosition(QTextCursor::Right, QTextCursor::KeepAnchor,
mlen * factor); mlen * factor);
@ -502,45 +575,65 @@ void QHexRenderer::applySelection(const QHexSelection &selection,
textcursor.movePosition(QTextCursor::Left, textcursor.movePosition(QTextCursor::Left,
QTextCursor::KeepAnchor, 1); QTextCursor::KeepAnchor, 1);
if (!strikeOut) {
QColor fg, bg = charfmt.background().color();
if (m_document->metafgVisible() && mi.foreground.isValid() &&
mi.foreground.alpha()) {
fg = mi.foreground.darker();
charfmt_meta.setForeground(fg);
}
if (m_document->metaCommentVisible() && !mi.comment.isEmpty()) {
charfmt_meta.setUnderlineStyle(
QTextCharFormat::SingleUnderline);
}
if (!fg.isValid()) {
fg = m_selectionColor;
}
if (!QHexMetadata::areColorsContrast(bg, fg)) {
charfmt_meta.setFontWeight(QFont::Bold);
charfmt_meta.setTextOutline(
QPen(QHexMetadata::generateContrastingColor(bg),
CONTRASTING_COLOR_BORDER, Qt::SolidLine));
}
}
textcursor.mergeCharFormat(charfmt_meta); textcursor.mergeCharFormat(charfmt_meta);
textcursor.clearSelection(); textcursor.clearSelection();
totallen -= mlen;
len -= mlen; if (totallen > 0) {
if (len > 0) { if (factor == Hex) {
if (factor == Hex)
textcursor.movePosition(QTextCursor::Right, textcursor.movePosition(QTextCursor::Right,
QTextCursor::MoveAnchor, 1);
textcursor.movePosition(QTextCursor::Right,
QTextCursor::KeepAnchor, len * factor);
if (factor == Hex)
textcursor.movePosition(QTextCursor::Left,
QTextCursor::KeepAnchor, 1); QTextCursor::KeepAnchor, 1);
textcursor.mergeCharFormat(charfmt);
textcursor.mergeCharFormat(charfmt); textcursor.clearSelection();
}
} }
} else {
textcursor.setPosition(startsel.column * factor); fmtBegin = mi.end - startLineOffset + 1;
}
if (totallen > 0) {
textcursor.movePosition(QTextCursor::Right, QTextCursor::KeepAnchor, textcursor.movePosition(QTextCursor::Right, QTextCursor::KeepAnchor,
len * factor); totallen * factor);
if (factor == Hex) if (factor == Hex)
textcursor.movePosition(QTextCursor::Left, textcursor.movePosition(QTextCursor::Left,
QTextCursor::KeepAnchor, 1); QTextCursor::KeepAnchor, 1);
textcursor.mergeCharFormat(charfmt); textcursor.mergeCharFormat(charfmt);
textcursor.clearSelection();
} }
} else { } else {
if (line == startsel.line) textcursor.setPosition(lineStart * factor);
textcursor.setPosition(startsel.column * factor); textcursor.movePosition(QTextCursor::Right, QTextCursor::KeepAnchor,
else totallen * factor);
textcursor.setPosition(0); if (factor == Hex)
textcursor.movePosition(QTextCursor::Left, QTextCursor::KeepAnchor,
if (line == endsel.line) 1);
textcursor.movePosition(QTextCursor::Right, QTextCursor::KeepAnchor,
((endsel.column + 1) * factor));
else
textcursor.movePosition(QTextCursor::EndOfLine,
QTextCursor::KeepAnchor);
textcursor.mergeCharFormat(charfmt); textcursor.mergeCharFormat(charfmt);
} }
} }

View File

@ -126,6 +126,10 @@ private:
void applySelection(const QHexSelection &selection, QTextCursor &textcursor, void applySelection(const QHexSelection &selection, QTextCursor &textcursor,
qsizetype line, Factor factor, bool strikeOut, qsizetype line, Factor factor, bool strikeOut,
bool hasSelection) const; bool hasSelection) const;
void applySelection(const QVector<QHexMetadata::MetaInfo> &metas,
QTextCursor &textcursor, qsizetype startLine,
qsizetype lineStart, qsizetype lineEnd, Factor factor,
bool strikeOut, bool hasSelection) const;
void applyBookMark(QTextCursor &textcursor, qsizetype line, void applyBookMark(QTextCursor &textcursor, qsizetype line,
Factor factor); // added by wingsummer Factor factor); // added by wingsummer

View File

@ -232,8 +232,38 @@ bool QHexView::event(QEvent *e) {
QPoint abspos = absolutePosition(helpevent->pos()); QPoint abspos = absolutePosition(helpevent->pos());
if (m_renderer->hitTest(abspos, &position, this->firstVisibleLine())) { if (m_renderer->hitTest(abspos, &position, this->firstVisibleLine())) {
QString comments = m_document->metadata()->comments( QString comments;
position.line, position.column);
auto mi = m_document->metadata()->get(position.offset());
if (mi.has_value()) {
QTextStream ss(&comments);
if (mi->foreground.isValid() && mi->foreground.alpha()) {
auto color = mi->foreground.name();
auto bcolor =
QHexMetadata::generateContrastingColor(mi->foreground)
.name();
ss << QStringLiteral("<p>") << tr("Foreground:")
<< QStringLiteral("<b><a style=\"color:") << color
<< QStringLiteral(";background-color:") << bcolor
<< QStringLiteral("\">") << color
<< QStringLiteral("</a></b></p>");
}
if (mi->background.isValid() && mi->background.alpha()) {
auto color = mi->background.name();
auto bcolor =
QHexMetadata::generateContrastingColor(mi->background)
.name();
ss << QStringLiteral("<p>") << tr("Background:")
<< QStringLiteral("<b><a style=\"color:") << color
<< QStringLiteral(";background-color:") << bcolor
<< QStringLiteral("\">") << color
<< QStringLiteral("</a></b></p>");
}
if (!mi->comment.isEmpty()) {
ss << tr("Comment:") << mi->comment;
}
}
if (!comments.isEmpty()) if (!comments.isEmpty())
QToolTip::showText(helpevent->globalPos(), comments, this); QToolTip::showText(helpevent->globalPos(), comments, this);
@ -344,7 +374,7 @@ QByteArray QHexView::selectedBytes(qsizetype index) const {
} }
QByteArray QHexView::previewSelectedBytes() const { QByteArray QHexView::previewSelectedBytes() const {
auto sel = m_cursor->previewSelection().normalized(); auto sel = m_cursor->previewSelection();
return m_document->read(sel.begin.offset(), sel.length()); return m_document->read(sel.begin.offset(), sel.length());
} }

View File

@ -29,6 +29,12 @@ Ribbon::Ribbon(QWidget *parent) : QTabWidget(parent) {
setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Preferred); setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Preferred);
setAcceptDrops(true); setAcceptDrops(true);
#if QT_VERSION > QT_VERSION_CHECK(6, 6, 0)
setStyleSheet("QToolButton::down-arrow { width:10px; height:10px; "
"subcontrol-position:right center; "
"subcontrol-origin:content; left: -2px;}");
#endif
auto hideBtn = new QToolButton(this); auto hideBtn = new QToolButton(this);
hideBtn->setObjectName(QStringLiteral("RIBBON_HIDE_BTN")); hideBtn->setObjectName(QStringLiteral("RIBBON_HIDE_BTN"));
hideBtn->setCheckable(true); hideBtn->setCheckable(true);

View File

@ -44,13 +44,14 @@ void RibbonButtonGroup::addButton(QToolButton *button) {
} }
button->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Preferred); button->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Preferred);
auto font = button->font();
QFontMetrics fm(font);
button->setIconSize(QSize(32, 32)); button->setIconSize(QSize(32, 32));
button->setAutoRaise(true); button->setAutoRaise(true);
button->setToolButtonStyle(Qt::ToolButtonTextUnderIcon); button->setToolButtonStyle(Qt::ToolButtonTextUnderIcon);
#if QT_VERSION > QT_VERSION_CHECK(6, 6, 0)
button->setMinimumWidth(32 + 30); // Icon size + padding
#endif
_buttons << button; _buttons << button;
ui->horizontalLayout->addWidget(button); ui->horizontalLayout->addWidget(button);

View File

@ -3578,18 +3578,20 @@ bool QDocumentCursorHandle::movePosition(int count,
auto txt = m_doc->line(line).text().left(offset); auto txt = m_doc->line(line).text().left(offset);
auto len = txt.length(); auto len = txt.length();
qsizetype index = 0; qsizetype index = 0;
if (txt.back().isSpace()) { if (!txt.isEmpty()) {
for (qsizetype i = len - 1; i >= 0; --i) { if (txt.back().isSpace()) {
if (!txt.at(i).isSpace()) { for (qsizetype i = len - 1; i >= 0; --i) {
index = i + 1; if (!txt.at(i).isSpace()) {
break; index = i + 1;
break;
}
} }
} } else {
} else { for (qsizetype i = len - 1; i >= 0; --i) {
for (qsizetype i = len - 1; i >= 0; --i) { if (!txt.at(i).isLetterOrNumber()) {
if (!txt.at(i).isLetterOrNumber()) { index = i + 1;
index = i + 1; break;
break; }
} }
} }
} }

View File

@ -46,8 +46,6 @@
to the user to the user
*/ */
QCE_AUTO_REGISTER(QFoldPanel)
/*! /*!
\brief Constructor \brief Constructor
*/ */

View File

@ -50,4 +50,6 @@ private:
QList<int> m_lines; QList<int> m_lines;
}; };
QCE_AUTO_REGISTER(QFoldPanel)
#endif // _QFOLD_PANEL_H_ #endif // _QFOLD_PANEL_H_

View File

@ -43,8 +43,6 @@
\see QEditorInterface \see QEditorInterface
*/ */
QCE_AUTO_REGISTER(QLineChangePanel)
/*! /*!
\brief Constructor \brief Constructor
*/ */

View File

@ -44,8 +44,8 @@ public:
protected: protected:
virtual void paint(QPainter *p, QEditor *e); virtual void paint(QPainter *p, QEditor *e);
private:
}; };
QCE_AUTO_REGISTER(QLineChangePanel)
#endif // _QLINE_CHANGE_PANEL_H_ #endif // _QLINE_CHANGE_PANEL_H_

View File

@ -45,8 +45,6 @@
\brief A specific panel in charge of drawing line marks of an editor \brief A specific panel in charge of drawing line marks of an editor
*/ */
QCE_AUTO_REGISTER(QLineMarkPanel)
/*! /*!
\brief Constructor \brief Constructor
*/ */
@ -83,8 +81,8 @@ void QLineMarkPanel::paint(QPainter *p, QEditor *e) {
pageBottom = e->viewport()->height(), pageBottom = e->viewport()->height(),
contentsY = e->verticalOffset(); contentsY = e->verticalOffset();
QString txt; // QString txt;
const QFontMetrics sfm(fontMetrics()); // const QFontMetrics sfm(fontMetrics());
QLineMarksInfoCenter *mic = QLineMarksInfoCenter::instance(); QLineMarksInfoCenter *mic = QLineMarksInfoCenter::instance();
n = d->lineNumber(contentsY); n = d->lineNumber(contentsY);

View File

@ -55,4 +55,6 @@ private:
QList<int> m_lines; QList<int> m_lines;
}; };
QCE_AUTO_REGISTER(QLineMarkPanel)
#endif // _QLINE_MARK_PANEL_H_ #endif // _QLINE_MARK_PANEL_H_

View File

@ -40,8 +40,6 @@
\brief A specific panel in charge of drawing line numbers of an editor \brief A specific panel in charge of drawing line numbers of an editor
*/ */
QCE_AUTO_REGISTER(QLineNumberPanel)
/*! /*!
\brief Constructor \brief Constructor
*/ */

View File

@ -55,4 +55,6 @@ protected:
int _fixWidth = 0; int _fixWidth = 0;
}; };
QCE_AUTO_REGISTER(QLineNumberPanel)
#endif // _QLINE_NUMBER_PANEL_H_ #endif // _QLINE_NUMBER_PANEL_H_

View File

@ -53,7 +53,7 @@ QHash<QString, QPanelCreator *> &QPanel::creators() {
QPanel *QPanel::panel(const QString &id, QWidget *p) { QPanel *QPanel::panel(const QString &id, QWidget *p) {
if (!creators().contains(id)) if (!creators().contains(id))
return 0; return nullptr;
return creators().value(id)->panel(p); return creators().value(id)->panel(p);
} }

View File

@ -147,7 +147,7 @@ bool TestPlugin::init(const std::unique_ptr<QSettings> &set) {
} }
{ {
auto ev = new TestWingEditorViewWidget; auto ev = QSharedPointer<TestWingEditorViewWidget::Creator>::create();
_evws.append(ev); _evws.append(ev);
} }
@ -217,7 +217,7 @@ QList<WingHex::PluginPage *> TestPlugin::registeredPages() const {
return _plgps; return _plgps;
} }
QList<WingHex::WingEditorViewWidget *> QList<QSharedPointer<WingHex::WingEditorViewWidget::Creator>>
TestPlugin::registeredEditorViewWidgets() const { TestPlugin::registeredEditorViewWidgets() const {
return _evws; return _evws;
} }

View File

@ -64,7 +64,7 @@ public:
virtual QHash<WingHex::SettingPage *, bool> virtual QHash<WingHex::SettingPage *, bool>
registeredSettingPages() const override; registeredSettingPages() const override;
virtual QList<WingHex::PluginPage *> registeredPages() const override; virtual QList<WingHex::PluginPage *> registeredPages() const override;
virtual QList<WingHex::WingEditorViewWidget *> virtual QList<QSharedPointer<WingHex::WingEditorViewWidget::Creator>>
registeredEditorViewWidgets() const override; registeredEditorViewWidgets() const override;
virtual QHash<QString, ScriptFnInfo> registeredScriptFns() const override; virtual QHash<QString, ScriptFnInfo> registeredScriptFns() const override;
@ -90,7 +90,7 @@ private:
QList<WingHex::WingDockWidgetInfo> _winfo; QList<WingHex::WingDockWidgetInfo> _winfo;
QList<WingHex::WingRibbonToolBoxInfo> _rtbinfo; QList<WingHex::WingRibbonToolBoxInfo> _rtbinfo;
QHash<WingHex::SettingPage *, bool> _setpages; QHash<WingHex::SettingPage *, bool> _setpages;
QList<WingHex::WingEditorViewWidget *> _evws; QList<QSharedPointer<WingHex::WingEditorViewWidget::Creator>> _evws;
QList<WingHex::PluginPage *> _plgps; QList<WingHex::PluginPage *> _plgps;
}; };

View File

@ -10,19 +10,19 @@ TestWingEditorViewWidget::TestWingEditorViewWidget(QWidget *parent)
layout->addWidget(lbl); layout->addWidget(lbl);
} }
QIcon TestWingEditorViewWidget::icon() const { QIcon TestWingEditorViewWidget::Creator::icon() const {
return QIcon(QStringLiteral(":/images/TestPlugin/images/btn.png")); return QIcon(QStringLiteral(":/images/TestPlugin/images/btn.png"));
} }
QString TestWingEditorViewWidget::name() const { QString TestWingEditorViewWidget::Creator::name() const {
return tr("TestWingEditorView"); return tr("TestWingEditorView");
} }
QString TestWingEditorViewWidget::id() const { QString TestWingEditorViewWidget::Creator::id() const {
return QStringLiteral("TestWingEditorView"); return QStringLiteral("TestWingEditorView");
} }
void TestWingEditorViewWidget::toggled(bool isVisible) {} void TestWingEditorViewWidget::toggled(bool isVisible) { Q_UNUSED(isVisible); }
WingHex::WingEditorViewWidget *TestWingEditorViewWidget::clone() { WingHex::WingEditorViewWidget *TestWingEditorViewWidget::clone() {
return nullptr; return nullptr;

View File

@ -7,14 +7,27 @@
class TestWingEditorViewWidget : public WingHex::WingEditorViewWidget { class TestWingEditorViewWidget : public WingHex::WingEditorViewWidget {
Q_OBJECT Q_OBJECT
public:
class Creator : public WingHex::WingEditorViewWidget::Creator {
public:
Creator() : WingHex::WingEditorViewWidget::Creator() {}
public:
virtual QIcon icon() const override;
virtual QString name() const override;
virtual QString id() const override;
public:
virtual WingEditorViewWidget *create(QWidget *parent) const override {
return new TestWingEditorViewWidget(parent);
}
};
public: public:
explicit TestWingEditorViewWidget(QWidget *parent = nullptr); explicit TestWingEditorViewWidget(QWidget *parent = nullptr);
// WingEditorViewWidget interface // WingEditorViewWidget interface
public:
virtual QIcon icon() const override;
virtual QString name() const override;
virtual QString id() const override;
public slots: public slots:
virtual void toggled(bool isVisible) override; virtual void toggled(bool isVisible) override;

View File

@ -442,7 +442,7 @@
<translation></translation> <translation></translation>
</message> </message>
<message> <message>
<location filename="../../src/control/editorview.cpp" line="258"/> <location filename="../../src/control/editorview.cpp" line="242"/>
<source>Untitled</source> <source>Untitled</source>
<translation></translation> <translation></translation>
</message> </message>
@ -943,8 +943,8 @@
<location filename="../../src/dialog/mainwindow.cpp" line="886"/> <location filename="../../src/dialog/mainwindow.cpp" line="886"/>
<location filename="../../src/dialog/mainwindow.cpp" line="954"/> <location filename="../../src/dialog/mainwindow.cpp" line="954"/>
<location filename="../../src/dialog/mainwindow.cpp" line="1026"/> <location filename="../../src/dialog/mainwindow.cpp" line="1026"/>
<location filename="../../src/dialog/mainwindow.cpp" line="2114"/> <location filename="../../src/dialog/mainwindow.cpp" line="2115"/>
<location filename="../../src/dialog/mainwindow.cpp" line="2299"/> <location filename="../../src/dialog/mainwindow.cpp" line="2300"/>
<source>CopyToClipBoard</source> <source>CopyToClipBoard</source>
<translation></translation> <translation></translation>
</message> </message>
@ -984,8 +984,8 @@
<message> <message>
<location filename="../../src/dialog/mainwindow.cpp" line="726"/> <location filename="../../src/dialog/mainwindow.cpp" line="726"/>
<location filename="../../src/dialog/mainwindow.cpp" line="1291"/> <location filename="../../src/dialog/mainwindow.cpp" line="1291"/>
<location filename="../../src/dialog/mainwindow.cpp" line="2377"/> <location filename="../../src/dialog/mainwindow.cpp" line="2378"/>
<location filename="../../src/dialog/mainwindow.cpp" line="2385"/> <location filename="../../src/dialog/mainwindow.cpp" line="2386"/>
<source>BookMark</source> <source>BookMark</source>
<translation></translation> <translation></translation>
</message> </message>
@ -1172,7 +1172,7 @@
</message> </message>
<message> <message>
<location filename="../../src/dialog/mainwindow.cpp" line="1281"/> <location filename="../../src/dialog/mainwindow.cpp" line="1281"/>
<location filename="../../src/dialog/mainwindow.cpp" line="2320"/> <location filename="../../src/dialog/mainwindow.cpp" line="2321"/>
<source>Fill</source> <source>Fill</source>
<translation></translation> <translation></translation>
</message> </message>
@ -1480,7 +1480,7 @@
</message> </message>
<message> <message>
<location filename="../../src/dialog/mainwindow.cpp" line="1549"/> <location filename="../../src/dialog/mainwindow.cpp" line="1549"/>
<location filename="../../src/dialog/mainwindow.cpp" line="2816"/> <location filename="../../src/dialog/mainwindow.cpp" line="2817"/>
<source>SaveLayout</source> <source>SaveLayout</source>
<translation></translation> <translation></translation>
</message> </message>
@ -1565,8 +1565,8 @@
<translation> %1 ID (%2) ID %3 </translation> <translation> %1 ID (%2) ID %3 </translation>
</message> </message>
<message> <message>
<location filename="../../src/dialog/mainwindow.cpp" line="1803"/> <location filename="../../src/dialog/mainwindow.cpp" line="1804"/>
<location filename="../../src/dialog/mainwindow.cpp" line="1854"/> <location filename="../../src/dialog/mainwindow.cpp" line="1855"/>
<source>ChooseFile</source> <source>ChooseFile</source>
<translation></translation> <translation></translation>
</message> </message>
@ -1576,29 +1576,29 @@
<location filename="../../src/dialog/mainwindow.cpp" line="1073"/> <location filename="../../src/dialog/mainwindow.cpp" line="1073"/>
<location filename="../../src/dialog/mainwindow.cpp" line="1083"/> <location filename="../../src/dialog/mainwindow.cpp" line="1083"/>
<location filename="../../src/dialog/mainwindow.cpp" line="1145"/> <location filename="../../src/dialog/mainwindow.cpp" line="1145"/>
<location filename="../../src/dialog/mainwindow.cpp" line="1809"/> <location filename="../../src/dialog/mainwindow.cpp" line="1810"/>
<location filename="../../src/dialog/mainwindow.cpp" line="1813"/> <location filename="../../src/dialog/mainwindow.cpp" line="1814"/>
<location filename="../../src/dialog/mainwindow.cpp" line="1836"/> <location filename="../../src/dialog/mainwindow.cpp" line="1837"/>
<location filename="../../src/dialog/mainwindow.cpp" line="1840"/> <location filename="../../src/dialog/mainwindow.cpp" line="1841"/>
<location filename="../../src/dialog/mainwindow.cpp" line="1861"/> <location filename="../../src/dialog/mainwindow.cpp" line="1862"/>
<location filename="../../src/dialog/mainwindow.cpp" line="1865"/> <location filename="../../src/dialog/mainwindow.cpp" line="1866"/>
<location filename="../../src/dialog/mainwindow.cpp" line="1885"/> <location filename="../../src/dialog/mainwindow.cpp" line="1886"/>
<location filename="../../src/dialog/mainwindow.cpp" line="1891"/> <location filename="../../src/dialog/mainwindow.cpp" line="1892"/>
<location filename="../../src/dialog/mainwindow.cpp" line="1895"/> <location filename="../../src/dialog/mainwindow.cpp" line="1896"/>
<location filename="../../src/dialog/mainwindow.cpp" line="1920"/> <location filename="../../src/dialog/mainwindow.cpp" line="1921"/>
<location filename="../../src/dialog/mainwindow.cpp" line="1946"/> <location filename="../../src/dialog/mainwindow.cpp" line="1947"/>
<location filename="../../src/dialog/mainwindow.cpp" line="2009"/> <location filename="../../src/dialog/mainwindow.cpp" line="2010"/>
<location filename="../../src/dialog/mainwindow.cpp" line="2048"/> <location filename="../../src/dialog/mainwindow.cpp" line="2049"/>
<location filename="../../src/dialog/mainwindow.cpp" line="2965"/> <location filename="../../src/dialog/mainwindow.cpp" line="2966"/>
<location filename="../../src/dialog/mainwindow.cpp" line="3197"/> <location filename="../../src/dialog/mainwindow.cpp" line="3198"/>
<source>Error</source> <source>Error</source>
<translation></translation> <translation></translation>
</message> </message>
<message> <message>
<location filename="../../src/dialog/mainwindow.cpp" line="1809"/> <location filename="../../src/dialog/mainwindow.cpp" line="1810"/>
<location filename="../../src/dialog/mainwindow.cpp" line="1836"/> <location filename="../../src/dialog/mainwindow.cpp" line="1837"/>
<location filename="../../src/dialog/mainwindow.cpp" line="1861"/> <location filename="../../src/dialog/mainwindow.cpp" line="1862"/>
<location filename="../../src/dialog/mainwindow.cpp" line="1891"/> <location filename="../../src/dialog/mainwindow.cpp" line="1892"/>
<source>FileNotExist</source> <source>FileNotExist</source>
<translation></translation> <translation></translation>
</message> </message>
@ -1608,31 +1608,31 @@
<location filename="../../src/dialog/mainwindow.cpp" line="1074"/> <location filename="../../src/dialog/mainwindow.cpp" line="1074"/>
<location filename="../../src/dialog/mainwindow.cpp" line="1084"/> <location filename="../../src/dialog/mainwindow.cpp" line="1084"/>
<location filename="../../src/dialog/mainwindow.cpp" line="1146"/> <location filename="../../src/dialog/mainwindow.cpp" line="1146"/>
<location filename="../../src/dialog/mainwindow.cpp" line="1813"/> <location filename="../../src/dialog/mainwindow.cpp" line="1814"/>
<location filename="../../src/dialog/mainwindow.cpp" line="1840"/> <location filename="../../src/dialog/mainwindow.cpp" line="1841"/>
<location filename="../../src/dialog/mainwindow.cpp" line="1865"/> <location filename="../../src/dialog/mainwindow.cpp" line="1866"/>
<location filename="../../src/dialog/mainwindow.cpp" line="1895"/> <location filename="../../src/dialog/mainwindow.cpp" line="1896"/>
<location filename="../../src/dialog/mainwindow.cpp" line="1946"/> <location filename="../../src/dialog/mainwindow.cpp" line="1947"/>
<source>FilePermission</source> <source>FilePermission</source>
<translation></translation> <translation></translation>
</message> </message>
<message> <message>
<location filename="../../src/dialog/mainwindow.cpp" line="1854"/> <location filename="../../src/dialog/mainwindow.cpp" line="1855"/>
<source>ProjectFile (*.wingpro)</source> <source>ProjectFile (*.wingpro)</source>
<translation> (*.wingpro)</translation> <translation> (*.wingpro)</translation>
</message> </message>
<message> <message>
<location filename="../../src/dialog/mainwindow.cpp" line="1885"/> <location filename="../../src/dialog/mainwindow.cpp" line="1886"/>
<source>Root Required!</source> <source>Root Required!</source>
<translation></translation> <translation></translation>
</message> </message>
<message> <message>
<location filename="../../src/dialog/mainwindow.cpp" line="1916"/> <location filename="../../src/dialog/mainwindow.cpp" line="1917"/>
<source>ReloadSuccessfully</source> <source>ReloadSuccessfully</source>
<translation></translation> <translation></translation>
</message> </message>
<message> <message>
<location filename="../../src/dialog/mainwindow.cpp" line="1920"/> <location filename="../../src/dialog/mainwindow.cpp" line="1921"/>
<source>ReloadUnSuccessfully</source> <source>ReloadUnSuccessfully</source>
<translation></translation> <translation></translation>
</message> </message>
@ -1641,49 +1641,49 @@
<location filename="../../src/dialog/mainwindow.cpp" line="967"/> <location filename="../../src/dialog/mainwindow.cpp" line="967"/>
<location filename="../../src/dialog/mainwindow.cpp" line="1040"/> <location filename="../../src/dialog/mainwindow.cpp" line="1040"/>
<location filename="../../src/dialog/mainwindow.cpp" line="1137"/> <location filename="../../src/dialog/mainwindow.cpp" line="1137"/>
<location filename="../../src/dialog/mainwindow.cpp" line="1976"/> <location filename="../../src/dialog/mainwindow.cpp" line="1977"/>
<location filename="../../src/dialog/mainwindow.cpp" line="2059"/> <location filename="../../src/dialog/mainwindow.cpp" line="2060"/>
<location filename="../../src/dialog/mainwindow.cpp" line="2605"/> <location filename="../../src/dialog/mainwindow.cpp" line="2606"/>
<source>ChooseSaveFile</source> <source>ChooseSaveFile</source>
<translation></translation> <translation></translation>
</message> </message>
<message> <message>
<location filename="../../src/dialog/mainwindow.cpp" line="2145"/> <location filename="../../src/dialog/mainwindow.cpp" line="2146"/>
<source>NoMoreClone</source> <source>NoMoreClone</source>
<translation></translation> <translation></translation>
</message> </message>
<message> <message>
<location filename="../../src/dialog/mainwindow.cpp" line="2187"/> <location filename="../../src/dialog/mainwindow.cpp" line="2188"/>
<source>FindFininishBusy</source> <source>FindFininishBusy</source>
<translation></translation> <translation></translation>
</message> </message>
<message> <message>
<location filename="../../src/dialog/mainwindow.cpp" line="2191"/> <location filename="../../src/dialog/mainwindow.cpp" line="2192"/>
<source>MayTooMuchFindResult</source> <source>MayTooMuchFindResult</source>
<translation></translation> <translation></translation>
</message> </message>
<message> <message>
<location filename="../../src/dialog/mainwindow.cpp" line="2824"/> <location filename="../../src/dialog/mainwindow.cpp" line="2825"/>
<source>SaveLayoutSuccess</source> <source>SaveLayoutSuccess</source>
<translation></translation> <translation></translation>
</message> </message>
<message> <message>
<location filename="../../src/dialog/mainwindow.cpp" line="2827"/> <location filename="../../src/dialog/mainwindow.cpp" line="2828"/>
<source>SaveLayoutError</source> <source>SaveLayoutError</source>
<translation></translation> <translation></translation>
</message> </message>
<message> <message>
<location filename="../../src/dialog/mainwindow.cpp" line="3512"/> <location filename="../../src/dialog/mainwindow.cpp" line="3513"/>
<source>ConfirmSave</source> <source>ConfirmSave</source>
<translation></translation> <translation></translation>
</message> </message>
<message> <message>
<location filename="../../src/dialog/mainwindow.cpp" line="3531"/> <location filename="../../src/dialog/mainwindow.cpp" line="3532"/>
<source>Column %1</source> <source>Column %1</source>
<translation> %1</translation> <translation> %1</translation>
</message> </message>
<message> <message>
<location filename="../../src/dialog/mainwindow.cpp" line="3579"/> <location filename="../../src/dialog/mainwindow.cpp" line="3580"/>
<source>ConfirmAPPSave</source> <source>ConfirmAPPSave</source>
<translation></translation> <translation></translation>
</message> </message>
@ -1692,21 +1692,21 @@
<location filename="../../src/dialog/mainwindow.cpp" line="990"/> <location filename="../../src/dialog/mainwindow.cpp" line="990"/>
<location filename="../../src/dialog/mainwindow.cpp" line="1116"/> <location filename="../../src/dialog/mainwindow.cpp" line="1116"/>
<location filename="../../src/dialog/mainwindow.cpp" line="1153"/> <location filename="../../src/dialog/mainwindow.cpp" line="1153"/>
<location filename="../../src/dialog/mainwindow.cpp" line="1967"/> <location filename="../../src/dialog/mainwindow.cpp" line="1968"/>
<location filename="../../src/dialog/mainwindow.cpp" line="1988"/> <location filename="../../src/dialog/mainwindow.cpp" line="1989"/>
<source>SaveSuccessfully</source> <source>SaveSuccessfully</source>
<translation></translation> <translation></translation>
</message> </message>
<message> <message>
<location filename="../../src/dialog/mainwindow.cpp" line="1962"/> <location filename="../../src/dialog/mainwindow.cpp" line="1963"/>
<location filename="../../src/dialog/mainwindow.cpp" line="1993"/> <location filename="../../src/dialog/mainwindow.cpp" line="1994"/>
<source>SaveWSError</source> <source>SaveWSError</source>
<translation></translation> <translation></translation>
</message> </message>
<message> <message>
<location filename="../../src/dialog/mainwindow.cpp" line="1950"/> <location filename="../../src/dialog/mainwindow.cpp" line="1951"/>
<location filename="../../src/dialog/mainwindow.cpp" line="1997"/> <location filename="../../src/dialog/mainwindow.cpp" line="1998"/>
<location filename="../../src/dialog/mainwindow.cpp" line="2036"/> <location filename="../../src/dialog/mainwindow.cpp" line="2037"/>
<source>Warn</source> <source>Warn</source>
<translation></translation> <translation></translation>
</message> </message>
@ -1716,173 +1716,173 @@
<translation></translation> <translation></translation>
</message> </message>
<message> <message>
<location filename="../../src/dialog/mainwindow.cpp" line="1950"/> <location filename="../../src/dialog/mainwindow.cpp" line="1951"/>
<location filename="../../src/dialog/mainwindow.cpp" line="1997"/> <location filename="../../src/dialog/mainwindow.cpp" line="1998"/>
<location filename="../../src/dialog/mainwindow.cpp" line="2036"/> <location filename="../../src/dialog/mainwindow.cpp" line="2037"/>
<source>SourceChanged</source> <source>SourceChanged</source>
<translation></translation> <translation></translation>
</message> </message>
<message> <message>
<location filename="../../src/dialog/mainwindow.cpp" line="1957"/> <location filename="../../src/dialog/mainwindow.cpp" line="1958"/>
<location filename="../../src/dialog/mainwindow.cpp" line="2004"/> <location filename="../../src/dialog/mainwindow.cpp" line="2005"/>
<source>SaveSourceFileError</source> <source>SaveSourceFileError</source>
<translation></translation> <translation></translation>
</message> </message>
<message> <message>
<location filename="../../src/dialog/mainwindow.cpp" line="2009"/> <location filename="../../src/dialog/mainwindow.cpp" line="2010"/>
<source>SaveUnSuccessfully</source> <source>SaveUnSuccessfully</source>
<translation></translation> <translation></translation>
</message> </message>
<message> <message>
<location filename="../../src/dialog/mainwindow.cpp" line="2022"/> <location filename="../../src/dialog/mainwindow.cpp" line="2023"/>
<source>ChooseExportFile</source> <source>ChooseExportFile</source>
<translation></translation> <translation></translation>
</message> </message>
<message> <message>
<location filename="../../src/dialog/mainwindow.cpp" line="2032"/> <location filename="../../src/dialog/mainwindow.cpp" line="2033"/>
<source>ExportSuccessfully</source> <source>ExportSuccessfully</source>
<translation></translation> <translation></translation>
</message> </message>
<message> <message>
<location filename="../../src/dialog/mainwindow.cpp" line="2043"/> <location filename="../../src/dialog/mainwindow.cpp" line="2044"/>
<source>ExportSourceFileError</source> <source>ExportSourceFileError</source>
<translation></translation> <translation></translation>
</message> </message>
<message> <message>
<location filename="../../src/dialog/mainwindow.cpp" line="2048"/> <location filename="../../src/dialog/mainwindow.cpp" line="2049"/>
<source>ExportUnSuccessfully</source> <source>ExportUnSuccessfully</source>
<translation></translation> <translation></translation>
</message> </message>
<message> <message>
<location filename="../../src/dialog/mainwindow.cpp" line="2070"/> <location filename="../../src/dialog/mainwindow.cpp" line="2071"/>
<source>SaveSelSuccess</source> <source>SaveSelSuccess</source>
<translation></translation> <translation></translation>
</message> </message>
<message> <message>
<location filename="../../src/dialog/mainwindow.cpp" line="2073"/> <location filename="../../src/dialog/mainwindow.cpp" line="2074"/>
<source>SaveSelError</source> <source>SaveSelError</source>
<translation></translation> <translation></translation>
</message> </message>
<message> <message>
<location filename="../../src/dialog/mainwindow.cpp" line="2100"/> <location filename="../../src/dialog/mainwindow.cpp" line="2101"/>
<location filename="../../src/dialog/mainwindow.cpp" line="2285"/> <location filename="../../src/dialog/mainwindow.cpp" line="2286"/>
<source>CutToClipBoard</source> <source>CutToClipBoard</source>
<translation></translation> <translation></translation>
</message> </message>
<message> <message>
<location filename="../../src/dialog/mainwindow.cpp" line="2103"/> <location filename="../../src/dialog/mainwindow.cpp" line="2104"/>
<location filename="../../src/dialog/mainwindow.cpp" line="2288"/> <location filename="../../src/dialog/mainwindow.cpp" line="2289"/>
<source>UnCutToClipBoard</source> <source>UnCutToClipBoard</source>
<translation></translation> <translation></translation>
</message> </message>
<message> <message>
<location filename="../../src/dialog/mainwindow.cpp" line="2117"/> <location filename="../../src/dialog/mainwindow.cpp" line="2118"/>
<location filename="../../src/dialog/mainwindow.cpp" line="2302"/> <location filename="../../src/dialog/mainwindow.cpp" line="2303"/>
<source>UnCopyToClipBoard</source> <source>UnCopyToClipBoard</source>
<translation></translation> <translation></translation>
</message> </message>
<message> <message>
<location filename="../../src/dialog/mainwindow.cpp" line="2183"/> <location filename="../../src/dialog/mainwindow.cpp" line="2184"/>
<source>FindFininish</source> <source>FindFininish</source>
<translation></translation> <translation></translation>
</message> </message>
<message> <message>
<location filename="../../src/dialog/mainwindow.cpp" line="2320"/> <location filename="../../src/dialog/mainwindow.cpp" line="2321"/>
<source>PleaseInputFill</source> <source>PleaseInputFill</source>
<translation></translation> <translation></translation>
</message> </message>
<message> <message>
<location filename="../../src/dialog/mainwindow.cpp" line="2339"/> <location filename="../../src/dialog/mainwindow.cpp" line="2340"/>
<source>FillInputError</source> <source>FillInputError</source>
<translation></translation> <translation></translation>
</message> </message>
<message> <message>
<location filename="../../src/dialog/mainwindow.cpp" line="2377"/> <location filename="../../src/dialog/mainwindow.cpp" line="2378"/>
<location filename="../../src/dialog/mainwindow.cpp" line="2385"/> <location filename="../../src/dialog/mainwindow.cpp" line="2386"/>
<source>InputComment</source> <source>InputComment</source>
<translation></translation> <translation></translation>
</message> </message>
<message> <message>
<location filename="../../src/dialog/mainwindow.cpp" line="2440"/> <location filename="../../src/dialog/mainwindow.cpp" line="2441"/>
<location filename="../../src/dialog/mainwindow.cpp" line="2481"/> <location filename="../../src/dialog/mainwindow.cpp" line="2482"/>
<location filename="../../src/dialog/mainwindow.cpp" line="3053"/> <location filename="../../src/dialog/mainwindow.cpp" line="3054"/>
<source>NoSelection</source> <source>NoSelection</source>
<translation></translation> <translation></translation>
</message> </message>
<message> <message>
<location filename="../../src/dialog/mainwindow.cpp" line="2477"/> <location filename="../../src/dialog/mainwindow.cpp" line="2478"/>
<source>NoMetaData</source> <source>NoMetaData</source>
<translation></translation> <translation></translation>
</message> </message>
<message> <message>
<location filename="../../src/dialog/mainwindow.cpp" line="2592"/> <location filename="../../src/dialog/mainwindow.cpp" line="2593"/>
<location filename="../../src/dialog/mainwindow.cpp" line="2601"/> <location filename="../../src/dialog/mainwindow.cpp" line="2602"/>
<source>EmptyFindResult</source> <source>EmptyFindResult</source>
<translation></translation> <translation></translation>
</message> </message>
<message> <message>
<location filename="../../src/dialog/mainwindow.cpp" line="2646"/> <location filename="../../src/dialog/mainwindow.cpp" line="2647"/>
<source>SaveFindResult</source> <source>SaveFindResult</source>
<translation></translation> <translation></translation>
</message> </message>
<message> <message>
<location filename="../../src/dialog/mainwindow.cpp" line="2650"/> <location filename="../../src/dialog/mainwindow.cpp" line="2651"/>
<source>SaveFindResultError</source> <source>SaveFindResultError</source>
<translation></translation> <translation></translation>
</message> </message>
<message> <message>
<location filename="../../src/dialog/mainwindow.cpp" line="2789"/> <location filename="../../src/dialog/mainwindow.cpp" line="2790"/>
<source>TooManyBytesDecode</source> <source>TooManyBytesDecode</source>
<translation></translation> <translation></translation>
</message> </message>
<message> <message>
<location filename="../../src/dialog/mainwindow.cpp" line="2836"/> <location filename="../../src/dialog/mainwindow.cpp" line="2837"/>
<source>ExportLogError</source> <source>ExportLogError</source>
<translation></translation> <translation></translation>
</message> </message>
<message> <message>
<location filename="../../src/dialog/mainwindow.cpp" line="2839"/> <location filename="../../src/dialog/mainwindow.cpp" line="2840"/>
<source>ExportLogSuccess</source> <source>ExportLogSuccess</source>
<translation></translation> <translation></translation>
</message> </message>
<message> <message>
<location filename="../../src/dialog/mainwindow.cpp" line="2847"/> <location filename="../../src/dialog/mainwindow.cpp" line="2848"/>
<source>ClearLogSuccess</source> <source>ClearLogSuccess</source>
<translation></translation> <translation></translation>
</message> </message>
<message> <message>
<location filename="../../src/dialog/mainwindow.cpp" line="2903"/> <location filename="../../src/dialog/mainwindow.cpp" line="2904"/>
<source>BadNetwork</source> <source>BadNetwork</source>
<translation></translation> <translation></translation>
</message> </message>
<message> <message>
<location filename="../../src/dialog/mainwindow.cpp" line="2908"/> <location filename="../../src/dialog/mainwindow.cpp" line="2909"/>
<source>NewestVersion</source> <source>NewestVersion</source>
<translation></translation> <translation></translation>
</message> </message>
<message> <message>
<location filename="../../src/dialog/mainwindow.cpp" line="314"/> <location filename="../../src/dialog/mainwindow.cpp" line="314"/>
<location filename="../../src/dialog/mainwindow.cpp" line="2905"/> <location filename="../../src/dialog/mainwindow.cpp" line="2906"/>
<source>OlderVersion</source> <source>OlderVersion</source>
<translation>使 Github Gitee </translation> <translation>使 Github Gitee </translation>
</message> </message>
<message> <message>
<location filename="../../src/dialog/mainwindow.cpp" line="2911"/> <location filename="../../src/dialog/mainwindow.cpp" line="2912"/>
<source>CheckingUpdate</source> <source>CheckingUpdate</source>
<translation></translation> <translation></translation>
</message> </message>
<message> <message>
<location filename="../../src/dialog/mainwindow.cpp" line="2966"/> <location filename="../../src/dialog/mainwindow.cpp" line="2967"/>
<source>Too much opened files</source> <source>Too much opened files</source>
<translation></translation> <translation></translation>
</message> </message>
<message> <message>
<location filename="../../src/dialog/mainwindow.cpp" line="3124"/> <location filename="../../src/dialog/mainwindow.cpp" line="3125"/>
<source>CopyLimit</source> <source>CopyLimit</source>
<translation></translation> <translation></translation>
</message> </message>
<message> <message>
<location filename="../../src/dialog/mainwindow.cpp" line="3198"/> <location filename="../../src/dialog/mainwindow.cpp" line="3199"/>
<source>ErrOpenFileBelow</source> <source>ErrOpenFileBelow</source>
<translation></translation> <translation></translation>
</message> </message>
@ -1938,7 +1938,7 @@
<translation></translation> <translation></translation>
</message> </message>
<message> <message>
<location filename="../../src/dialog/metadialog.cpp" line="102"/> <location filename="../../src/dialog/metadialog.cpp" line="104"/>
<source>NoChoose</source> <source>NoChoose</source>
<translation></translation> <translation></translation>
</message> </message>
@ -2570,7 +2570,7 @@ Do you wish to keep up to date by reloading the file?</source>
<context> <context>
<name>QFoldPanel</name> <name>QFoldPanel</name>
<message> <message>
<location filename="../../3rdparty/qcodeedit2/lib/widgets/qfoldpanel.cpp" line="66"/> <location filename="../../3rdparty/qcodeedit2/lib/widgets/qfoldpanel.cpp" line="64"/>
<source>Fold Panel</source> <source>Fold Panel</source>
<translation></translation> <translation></translation>
</message> </message>
@ -2601,6 +2601,24 @@ Do you wish to keep up to date by reloading the file?</source>
<translation>&amp;G</translation> <translation>&amp;G</translation>
</message> </message>
</context> </context>
<context>
<name>QHexView</name>
<message>
<location filename="../../3rdparty/QHexView/qhexview.cpp" line="246"/>
<source>Foreground:</source>
<translation></translation>
</message>
<message>
<location filename="../../3rdparty/QHexView/qhexview.cpp" line="257"/>
<source>Background:</source>
<translation></translation>
</message>
<message>
<location filename="../../3rdparty/QHexView/qhexview.cpp" line="264"/>
<source>Comment:</source>
<translation></translation>
</message>
</context>
<context> <context>
<name>QJsonModel</name> <name>QJsonModel</name>
<message> <message>
@ -2636,7 +2654,7 @@ Do you wish to keep up to date by reloading the file?</source>
<context> <context>
<name>QLineChangePanel</name> <name>QLineChangePanel</name>
<message> <message>
<location filename="../../3rdparty/qcodeedit2/lib/widgets/qlinechangepanel.cpp" line="63"/> <location filename="../../3rdparty/qcodeedit2/lib/widgets/qlinechangepanel.cpp" line="61"/>
<source>Line Change Panel</source> <source>Line Change Panel</source>
<translation></translation> <translation></translation>
</message> </message>
@ -2644,7 +2662,7 @@ Do you wish to keep up to date by reloading the file?</source>
<context> <context>
<name>QLineNumberPanel</name> <name>QLineNumberPanel</name>
<message> <message>
<location filename="../../3rdparty/qcodeedit2/lib/widgets/qlinenumberpanel.cpp" line="65"/> <location filename="../../3rdparty/qcodeedit2/lib/widgets/qlinenumberpanel.cpp" line="63"/>
<source>Line Number Panel</source> <source>Line Number Panel</source>
<translation></translation> <translation></translation>
</message> </message>
@ -5132,12 +5150,12 @@ Do you wish to keep up to date by reloading the file?</source>
<context> <context>
<name>ShowTextDialog</name> <name>ShowTextDialog</name>
<message> <message>
<location filename="../../src/dialog/showtextdialog.cpp" line="169"/> <location filename="../../src/dialog/showtextdialog.cpp" line="170"/>
<source>General</source> <source>General</source>
<translation></translation> <translation></translation>
</message> </message>
<message> <message>
<location filename="../../src/dialog/showtextdialog.cpp" line="171"/> <location filename="../../src/dialog/showtextdialog.cpp" line="172"/>
<source>Copy</source> <source>Copy</source>
<translation></translation> <translation></translation>
</message> </message>
@ -5147,57 +5165,57 @@ Do you wish to keep up to date by reloading the file?</source>
<translation></translation> <translation></translation>
</message> </message>
<message> <message>
<location filename="../../src/dialog/showtextdialog.cpp" line="93"/> <location filename="../../src/dialog/showtextdialog.cpp" line="94"/>
<source>TooHugeFile</source> <source>TooHugeFile</source>
<translation></translation> <translation></translation>
</message> </message>
<message> <message>
<location filename="../../src/dialog/showtextdialog.cpp" line="103"/> <location filename="../../src/dialog/showtextdialog.cpp" line="104"/>
<source>Loading</source> <source>Loading</source>
<translation></translation> <translation></translation>
</message> </message>
<message> <message>
<location filename="../../src/dialog/showtextdialog.cpp" line="103"/> <location filename="../../src/dialog/showtextdialog.cpp" line="104"/>
<source>Cancel</source> <source>Cancel</source>
<translation></translation> <translation></translation>
</message> </message>
<message> <message>
<location filename="../../src/dialog/showtextdialog.cpp" line="162"/> <location filename="../../src/dialog/showtextdialog.cpp" line="163"/>
<source>Edit</source> <source>Edit</source>
<translation></translation> <translation></translation>
</message> </message>
<message> <message>
<location filename="../../src/dialog/showtextdialog.cpp" line="163"/> <location filename="../../src/dialog/showtextdialog.cpp" line="164"/>
<source>View</source> <source>View</source>
<translation></translation> <translation></translation>
</message> </message>
<message> <message>
<location filename="../../src/dialog/showtextdialog.cpp" line="175"/> <location filename="../../src/dialog/showtextdialog.cpp" line="176"/>
<source>Find</source> <source>Find</source>
<translation></translation> <translation></translation>
</message> </message>
<message> <message>
<location filename="../../src/dialog/showtextdialog.cpp" line="179"/> <location filename="../../src/dialog/showtextdialog.cpp" line="180"/>
<source>Goto</source> <source>Goto</source>
<translation></translation> <translation></translation>
</message> </message>
<message> <message>
<location filename="../../src/dialog/showtextdialog.cpp" line="184"/> <location filename="../../src/dialog/showtextdialog.cpp" line="185"/>
<source>Encoding</source> <source>Encoding</source>
<translation></translation> <translation></translation>
</message> </message>
<message> <message>
<location filename="../../src/dialog/showtextdialog.cpp" line="195"/> <location filename="../../src/dialog/showtextdialog.cpp" line="196"/>
<source>Display</source> <source>Display</source>
<translation></translation> <translation></translation>
</message> </message>
<message> <message>
<location filename="../../src/dialog/showtextdialog.cpp" line="214"/> <location filename="../../src/dialog/showtextdialog.cpp" line="215"/>
<source>Scale</source> <source>Scale</source>
<translation></translation> <translation></translation>
</message> </message>
<message> <message>
<location filename="../../src/dialog/showtextdialog.cpp" line="216"/> <location filename="../../src/dialog/showtextdialog.cpp" line="217"/>
<source>ResetScale</source> <source>ResetScale</source>
<translation></translation> <translation></translation>
</message> </message>

View File

@ -130,37 +130,21 @@ EditorView::EditorView(QWidget *parent)
applySettings(); applySettings();
} }
EditorView::~EditorView() { EditorView::~EditorView() {}
for (auto &w : m_others) {
m_stack->removeWidget(w);
w->setParent(nullptr);
}
}
void EditorView::registerView(WingEditorViewWidget *view) { void EditorView::registerView(const QString &id, WingEditorViewWidget *view) {
Q_ASSERT(view); Q_ASSERT(view);
m_others << view; m_others.insert(id, view);
m_stack->addWidget(view); m_stack->addWidget(view);
} }
void EditorView::switchView(qsizetype index) { void EditorView::switchView(const QString &id) {
if (index < 0) { if (id.isEmpty()) {
m_stack->setCurrentWidget(m_hexContainer); m_stack->setCurrentWidget(m_hexContainer);
} else { } else {
m_stack->setCurrentWidget(m_others.at(index)); if (m_others.contains(id)) {
} m_stack->setCurrentWidget(m_others.value(id));
emit viewChanged(index);
}
void EditorView::switchView(WingEditorViewWidget *w) {
if (w) {
if (m_others.contains(w)) {
m_stack->setCurrentWidget(w);
emit viewChanged(m_others.indexOf(w));
} }
} else {
m_stack->setCurrentWidget(m_hexContainer);
emit viewChanged(-1);
} }
} }
@ -545,15 +529,6 @@ QHexView *EditorView::hexEditor() const { return m_hex; }
EditorView::DocumentType EditorView::documentType() const { return m_docType; } EditorView::DocumentType EditorView::documentType() const { return m_docType; }
WingEditorViewWidget *EditorView::otherEditor(qsizetype index) const {
if (index < 0 ||
index >= std::numeric_limits<decltype(m_others)::size_type>::max() ||
index >= m_others.size()) {
return nullptr;
}
return m_others.at(index);
}
void EditorView::setCopyLimit(qsizetype sizeMB) { m_hex->setCopyLimit(sizeMB); } void EditorView::setCopyLimit(qsizetype sizeMB) { m_hex->setCopyLimit(sizeMB); }
qsizetype EditorView::copyLimit() const { return m_hex->copyLimit(); } qsizetype EditorView::copyLimit() const { return m_hex->copyLimit(); }
@ -600,20 +575,21 @@ bool EditorView::hasMeta() const {
void EditorView::applyPluginData(const QHash<QString, QByteArray> &data) { void EditorView::applyPluginData(const QHash<QString, QByteArray> &data) {
for (auto p = data.begin(); p != data.end(); p++) { for (auto p = data.begin(); p != data.end(); p++) {
auto plgw = std::find_if(m_others.begin(), m_others.end(), for (auto pw = m_others.constKeyValueBegin();
[=](const WingEditorViewWidget *editor) { pw != m_others.constKeyValueEnd(); ++pw) {
return editor->id() == p.key(); if (pw->first == p.key()) {
}); pw->second->loadState(p.value());
if (plgw != m_others.end()) { break;
(*plgw)->loadState(p.value()); }
} }
} }
} }
QHash<QString, QByteArray> EditorView::savePluginData() { QHash<QString, QByteArray> EditorView::savePluginData() {
QHash<QString, QByteArray> ret; QHash<QString, QByteArray> ret;
for (auto &item : m_others) { for (auto p = m_others.constKeyValueBegin();
ret.insert(item->id(), item->saveState()); p != m_others.constKeyValueEnd(); ++p) {
ret.insert(p->first, p->second->saveState());
} }
return ret; return ret;
} }
@ -689,9 +665,11 @@ EditorView *EditorView::clone() {
ev->m_docType = DocumentType::Cloned; ev->m_docType = DocumentType::Cloned;
for (auto &evw : m_others) { for (auto p = m_others.constKeyValueBegin();
ev->m_others << evw->clone(); p != m_others.constKeyValueEnd(); ++p) {
ev->m_others.insert(p->first, p->second->clone());
} }
this->m_cloneChildren[cloneIndex] = ev; this->m_cloneChildren[cloneIndex] = ev;
connectDocSavedFlag(ev); connectDocSavedFlag(ev);

View File

@ -80,16 +80,13 @@ public:
DocumentType documentType() const; DocumentType documentType() const;
WingEditorViewWidget *otherEditor(qsizetype index) const;
qsizetype copyLimit() const; qsizetype copyLimit() const;
public slots: public slots:
EditorView *clone(); EditorView *clone();
void registerView(WingHex::WingEditorViewWidget *view); void registerView(const QString &id, WingHex::WingEditorViewWidget *view);
void switchView(qsizetype index); void switchView(const QString &id);
void switchView(WingEditorViewWidget *w);
void registerQMenu(QMenu *menu); void registerQMenu(QMenu *menu);
FindError find(const FindDialog::Result &result); FindError find(const FindDialog::Result &result);
@ -149,8 +146,6 @@ private:
void connectDocSavedFlag(EditorView *editor); void connectDocSavedFlag(EditorView *editor);
signals: signals:
void viewChanged(int index);
void sigFileSaved(QString filename, QString oldFileName); void sigFileSaved(QString filename, QString oldFileName);
void sigOnCutFile(); void sigOnCutFile();
@ -176,7 +171,7 @@ private:
QHexView *m_hex = nullptr; QHexView *m_hex = nullptr;
QMenu *m_menu = nullptr; QMenu *m_menu = nullptr;
QList<WingEditorViewWidget *> m_others; QHash<QString, WingEditorViewWidget *> m_others;
QString m_fileName; QString m_fileName;
bool m_isNewFile = true; bool m_isNewFile = true;
QByteArray m_md5; QByteArray m_md5;

View File

@ -72,6 +72,7 @@ void HueColorPickerSlider::setColor(const QColor &newColor) {
{359.0 / 360.0, redColor(colorS, colorV)}}); {359.0 / 360.0, redColor(colorS, colorV)}});
this->setValue(_color.hsvHue()); this->setValue(_color.hsvHue());
emit colorChanged(newColor);
} }
} }

View File

@ -47,6 +47,8 @@ void QColorPickerSlider::setRenderCheckerboard(bool renderCheckerboard) {
} }
void QColorPickerSlider::paintEvent(QPaintEvent *event) { void QColorPickerSlider::paintEvent(QPaintEvent *event) {
Q_UNUSED(event);
QPainter painter(this); QPainter painter(this);
painter.setRenderHint(QPainter::Antialiasing); painter.setRenderHint(QPainter::Antialiasing);

View File

@ -835,7 +835,7 @@ MainWindow::buildUpVisualDataDock(ads::CDockManager *dock,
auto efilter = new EventFilter(QEvent::DynamicPropertyChange, this); auto efilter = new EventFilter(QEvent::DynamicPropertyChange, this);
connect(efilter, &EventFilter::eventTriggered, this, connect(efilter, &EventFilter::eventTriggered, this,
[this](QObject *obj, QEvent *event) { [](QObject *obj, QEvent *event) {
auto e = static_cast<QDynamicPropertyChangeEvent *>(event); auto e = static_cast<QDynamicPropertyChangeEvent *>(event);
constexpr auto ppname = "__TITLE__"; constexpr auto ppname = "__TITLE__";
if (e->propertyName() == QByteArray(ppname)) { if (e->propertyName() == QByteArray(ppname)) {
@ -1446,7 +1446,7 @@ RibbonTabContent *MainWindow::buildViewPage(RibbonTabContent *tab) {
if (editor == nullptr) { if (editor == nullptr) {
return; return;
} }
editor->switchView(-1); editor->switchView({});
})); }));
m_toolBtneditors.insert(ToolButtonIndex::EDITOR_WINS, m_toolBtneditors.insert(ToolButtonIndex::EDITOR_WINS,
addPannelAction(pannel, QStringLiteral("win"), addPannelAction(pannel, QStringLiteral("win"),
@ -1756,26 +1756,27 @@ void MainWindow::installPluginEditorWidgets() {
auto menu = m_toolBtneditors.value(EDITOR_WINS)->menu(); auto menu = m_toolBtneditors.value(EDITOR_WINS)->menu();
for (auto p = m_editorViewWidgets.begin(); p != m_editorViewWidgets.end(); for (auto p = m_editorViewWidgets.begin(); p != m_editorViewWidgets.end();
++p) { ++p) {
for (auto &w : p.value()) { for (auto &wctor : p.value()) {
qApp->processEvents(); qApp->processEvents();
if (names.contains(w->id())) { if (names.contains(wctor->id())) {
log.critical(tr("Plugin %1 contains a duplicate ID (%2) that " log.critical(tr("Plugin %1 contains a duplicate ID (%2) that "
"is already registered by plugin %3") "is already registered by plugin %3")
.arg(p.key()->pluginName(), w->id(), .arg(p.key()->pluginName(), wctor->id(),
names.value(w->id())->pluginName())); names.value(wctor->id())->pluginName()));
continue; continue;
} }
menu->addAction(newAction(w->icon(), w->name(), [this, w] { menu->addAction(
auto editor = currentEditor(); newAction(wctor->icon(), wctor->name(), [this, wctor] {
if (editor == nullptr) { auto editor = currentEditor();
return; if (editor == nullptr) {
} return;
editor->switchView(w); }
})); editor->switchView(wctor->id());
}));
names.insert(w->id(), p.key()); names.insert(wctor->id(), p.key());
m_editorViewWidgetsBuffer.append(w); m_editorViewWidgetsBuffer.append(wctor);
} }
qApp->processEvents(); qApp->processEvents();
} }
@ -2428,7 +2429,7 @@ void MainWindow::on_metadata() {
meta->beginMarco(QStringLiteral("MetaData")); meta->beginMarco(QStringLiteral("MetaData"));
for (int i = 0; i < total; ++i) { for (int i = 0; i < total; ++i) {
auto begin = cur->selectionStart(i).offset(); auto begin = cur->selectionStart(i).offset();
auto end = cur->selectionEnd(i).offset() + 1; auto end = cur->selectionEnd(i).offset();
meta->Metadata(begin, end, m.foreGroundColor(), meta->Metadata(begin, end, m.foreGroundColor(),
m.backGroundColor(), m.comment()); m.backGroundColor(), m.comment());
} }
@ -2971,7 +2972,7 @@ bool MainWindow::newOpenFileSafeCheck() {
void MainWindow::registerEditorView(EditorView *editor) { void MainWindow::registerEditorView(EditorView *editor) {
for (auto &w : m_editorViewWidgetsBuffer) { for (auto &w : m_editorViewWidgetsBuffer) {
editor->registerView(w); editor->registerView(w->id(), w->create(editor));
} }
for (auto &m : m_hexContextMenu) { for (auto &m : m_hexContextMenu) {
editor->registerQMenu(m); editor->registerQMenu(m);
@ -3022,7 +3023,7 @@ void MainWindow::connectEditorView(EditorView *editor) {
meta->beginMarco(QStringLiteral("OnMetaData")); meta->beginMarco(QStringLiteral("OnMetaData"));
for (int i = 0; i < total; ++i) { for (int i = 0; i < total; ++i) {
auto begin = cur->selectionStart(i).offset(); auto begin = cur->selectionStart(i).offset();
auto end = cur->selectionEnd(i).offset() + 1; auto end = cur->selectionEnd(i).offset();
meta->Metadata(begin, end, m.foreGroundColor(), meta->Metadata(begin, end, m.foreGroundColor(),
m.backGroundColor(), m.comment()); m.backGroundColor(), m.comment());
} }

View File

@ -18,7 +18,6 @@
#ifndef MAINWINDOW_H #ifndef MAINWINDOW_H
#define MAINWINDOW_H #define MAINWINDOW_H
#include "class/eventfilter.h"
#include "dialog/splashdialog.h" #include "dialog/splashdialog.h"
#include "framelessmainwindow.h" #include "framelessmainwindow.h"
@ -284,7 +283,15 @@ private:
QMenu *menu = nullptr) { QMenu *menu = nullptr) {
Q_ASSERT(pannel); Q_ASSERT(pannel);
auto a = new QToolButton(pannel); auto a = new QToolButton(pannel);
a->setText(title); #if QT_VERSION <= QT_VERSION_CHECK(6, 6, 0)
if (menu) {
a->setText(title + QStringLiteral(""));
} else
#endif
{
a->setText(title);
}
a->setIcon(icon); a->setIcon(icon);
a->setToolTip( a->setToolTip(
shortcut.isEmpty() shortcut.isEmpty()
@ -301,6 +308,9 @@ private:
a->setMenu(menu); a->setMenu(menu);
if (menu) { if (menu) {
#if QT_VERSION > QT_VERSION_CHECK(6, 6, 0)
a->setArrowType(Qt::DownArrow);
#endif
a->setPopupMode(QToolButton::InstantPopup); a->setPopupMode(QToolButton::InstantPopup);
} }
connect(a, &QToolButton::clicked, this, slot); connect(a, &QToolButton::clicked, this, slot);
@ -551,10 +561,12 @@ private:
// for plugin system use // for plugin system use
QHash<QString, RibbonTabContent *> m_ribbonMaps; QHash<QString, RibbonTabContent *> m_ribbonMaps;
QList<QMenu *> m_hexContextMenu; QList<QMenu *> m_hexContextMenu;
QMap<IWingPlugin *, QList<WingEditorViewWidget *>> m_editorViewWidgets; QMap<IWingPlugin *, QList<QSharedPointer<WingEditorViewWidget::Creator>>>
m_editorViewWidgets;
QHash<SettingPage *, bool> m_settingPages; QHash<SettingPage *, bool> m_settingPages;
QList<PluginPage *> m_plgPages; QList<PluginPage *> m_plgPages;
QList<WingEditorViewWidget *> m_editorViewWidgetsBuffer; QList<QSharedPointer<WingEditorViewWidget::Creator>>
m_editorViewWidgetsBuffer;
ads::CDockAreaWidget *m_leftViewArea = nullptr; ads::CDockAreaWidget *m_leftViewArea = nullptr;
ads::CDockAreaWidget *m_rightViewArea = nullptr; // 该值使用时必不为空 ads::CDockAreaWidget *m_rightViewArea = nullptr; // 该值使用时必不为空

View File

@ -41,7 +41,7 @@ MetaDialog::MetaDialog(QWidget *parent)
iforeground->setEnabled(false); iforeground->setEnabled(false);
layout->addWidget(iforeground); layout->addWidget(iforeground);
connect(iforeground, &HueColorPickerSlider::colorChanged, this, connect(iforeground, &HueColorPickerSlider::colorChanged, this,
[=](QColor color) { _foreground = color; }); [=](QColor color) { _foreground = color.toRgb(); });
_foreground = iforeground->color(); _foreground = iforeground->color();
layout->addSpacing(2); layout->addSpacing(2);
@ -56,7 +56,7 @@ MetaDialog::MetaDialog(QWidget *parent)
ibackground->setEnabled(false); ibackground->setEnabled(false);
layout->addWidget(ibackground); layout->addWidget(ibackground);
connect(ibackground, &HueColorPickerSlider::colorChanged, this, connect(ibackground, &HueColorPickerSlider::colorChanged, this,
[=](QColor color) { _background = color; }); [=](QColor color) { _background = color.toRgb(); });
_background = ibackground->color(); _background = ibackground->color();
layout->addSpacing(2); layout->addSpacing(2);
@ -93,10 +93,12 @@ MetaDialog::MetaDialog(QWidget *parent)
} }
void MetaDialog::on_accept() { void MetaDialog::on_accept() {
if ((cforeground->isChecked() && if ((!cforeground->isChecked() && !cbackground->isChecked() &&
(!_foreground.isValid() || _foreground.rgba() == 0)) || !ccomment->isChecked()) ||
(cforeground->isChecked() &&
(!_foreground.isValid() || _foreground.alpha() == 0)) ||
(cbackground->isChecked() && (cbackground->isChecked() &&
(!_background.isValid() || _background.rgba() == 0)) || (!_background.isValid() || _background.alpha() == 0)) ||
(ccomment->isChecked() && m_comment->text().trimmed().length() == 0)) { (ccomment->isChecked() && m_comment->text().trimmed().length() == 0)) {
Toast::toast(this->parentWidget(), Toast::toast(this->parentWidget(),
NAMEICONRES(QStringLiteral("metadata")), tr("NoChoose")); NAMEICONRES(QStringLiteral("metadata")), tr("NoChoose"));

View File

@ -136,8 +136,17 @@ private:
const QKeySequence &shortcut = QKeySequence(), const QKeySequence &shortcut = QKeySequence(),
QMenu *menu = nullptr) { QMenu *menu = nullptr) {
Q_ASSERT(pannel); Q_ASSERT(pannel);
Q_ASSERT(pannel);
auto a = new QToolButton(pannel); auto a = new QToolButton(pannel);
a->setText(title); #if QT_VERSION <= QT_VERSION_CHECK(6, 6, 0)
if (menu) {
a->setText(title + QStringLiteral(""));
} else
#endif
{
a->setText(title);
}
a->setIcon(icon); a->setIcon(icon);
setPannelActionToolTip(a, shortcut); setPannelActionToolTip(a, shortcut);
@ -149,6 +158,9 @@ private:
a->setMenu(menu); a->setMenu(menu);
if (menu) { if (menu) {
#if QT_VERSION > QT_VERSION_CHECK(6, 6, 0)
a->setArrowType(Qt::DownArrow);
#endif
a->setPopupMode(QToolButton::InstantPopup); a->setPopupMode(QToolButton::InstantPopup);
} }
connect(a, &QToolButton::clicked, this, slot); connect(a, &QToolButton::clicked, this, slot);

View File

@ -73,6 +73,7 @@ void ShowTextDialog::load(QHexBuffer *buffer, const QString encoding,
qsizetype offset, qsizetype size) { qsizetype offset, qsizetype size) {
auto editor = m_edit->editor(); auto editor = m_edit->editor();
editor->blockSignals(true); editor->blockSignals(true);
editor->setCodec(encoding);
load(buffer, offset, size); load(buffer, offset, size);
editor->blockSignals(false); editor->blockSignals(false);
} }

View File

@ -464,15 +464,24 @@ class WingEditorViewWidget : public QWidget {
Q_OBJECT Q_OBJECT
public: public:
explicit WingEditorViewWidget(QWidget *parent = nullptr) class Creator {
: QWidget(parent) {} public:
Creator() = default;
public:
virtual QIcon icon() const = 0;
virtual QString name() const = 0;
virtual QString id() const = 0;
public:
virtual WingEditorViewWidget *create(QWidget *parent) const = 0;
};
public: public:
virtual QIcon icon() const = 0; explicit WingEditorViewWidget(QWidget *parent = nullptr)
: QWidget(parent) {}
virtual QString name() const = 0;
virtual QString id() const = 0;
signals: signals:
void docSaved(bool saved); void docSaved(bool saved);
@ -601,7 +610,8 @@ public:
return {}; return {};
} }
virtual QList<PluginPage *> registeredPages() const { return {}; } virtual QList<PluginPage *> registeredPages() const { return {}; }
virtual QList<WingEditorViewWidget *> registeredEditorViewWidgets() const { virtual QList<QSharedPointer<WingEditorViewWidget::Creator>>
registeredEditorViewWidgets() const {
return {}; return {};
} }