fix: 优化颜色标注完善机制;修复在 Qt5 下运行崩溃的问题;修复调整颜色 S 和 V 通道无效的问题;
This commit is contained in:
parent
1bd978e2b2
commit
3dc1ab0ee8
|
@ -40,7 +40,7 @@ qsizetype QHexCursor::selectionLength(qsizetype index) const {
|
|||
|
||||
qsizetype QHexCursor::currentSelectionLength() const {
|
||||
if (hasPreviewSelection() && m_preMode != SelectionRemove) {
|
||||
return qAbs(m_position - m_selection);
|
||||
return qAbs(m_position - m_selection + 1);
|
||||
}
|
||||
|
||||
qsizetype len = 0;
|
||||
|
@ -82,6 +82,23 @@ bool QHexCursor::isLineSelected(qsizetype line) const {
|
|||
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 {
|
||||
return hasPreviewSelection() || hasInternalSelection();
|
||||
}
|
||||
|
@ -210,10 +227,9 @@ bool QHexCursor::hasPreviewSelection() const {
|
|||
|
||||
bool QHexCursor::isLineSelected(const QHexSelection &sel,
|
||||
qsizetype line) const {
|
||||
auto first = std::min(sel.begin.line, sel.end.line);
|
||||
auto last = std::max(sel.begin.line, sel.end.line);
|
||||
Q_ASSERT(sel.isNormalized());
|
||||
|
||||
if ((line >= first) && (line <= last))
|
||||
if ((line >= sel.begin.line) && (line <= sel.end.line))
|
||||
return true;
|
||||
|
||||
return false;
|
||||
|
@ -223,7 +239,7 @@ QHexSelection QHexCursor::previewSelection() const {
|
|||
QHexSelection sel;
|
||||
sel.begin = m_position;
|
||||
sel.end = m_selection;
|
||||
return sel;
|
||||
return sel.normalized();
|
||||
}
|
||||
|
||||
void QHexCursor::setPreviewSelectionMode(SelectionMode mode) {
|
||||
|
@ -235,7 +251,7 @@ QHexCursor::SelectionMode QHexCursor::previewSelectionMode() const {
|
|||
}
|
||||
|
||||
void QHexCursor::mergePreviewSelection() {
|
||||
auto ss = QHexSelection(m_position, m_selection).normalized();
|
||||
auto ss = previewSelection();
|
||||
switch (m_preMode) {
|
||||
case SelectionNormal:
|
||||
if (m_sels.isEmpty()) {
|
||||
|
|
|
@ -15,7 +15,7 @@ struct QHexPosition {
|
|||
quint8 lineWidth = 0;
|
||||
int nibbleindex = -1;
|
||||
|
||||
QHexPosition() = default;
|
||||
inline QHexPosition() = default;
|
||||
inline qsizetype offset() const {
|
||||
return static_cast<qsizetype>(line * lineWidth) + column;
|
||||
}
|
||||
|
@ -61,15 +61,15 @@ struct QHexPosition {
|
|||
Q_DECLARE_METATYPE(QHexPosition)
|
||||
|
||||
struct QHexSelection : QHexRegionObject<QHexPosition, QHexSelection> {
|
||||
QHexSelection() { setAdjusted(true); };
|
||||
inline QHexSelection() = default;
|
||||
|
||||
explicit QHexSelection(const QHexPosition &begin, const QHexPosition &end) {
|
||||
setAdjusted(true);
|
||||
inline explicit QHexSelection(const QHexPosition &begin,
|
||||
const QHexPosition &end) {
|
||||
this->begin = begin;
|
||||
this->end = end;
|
||||
}
|
||||
|
||||
bool isLineSelected(qsizetype line) const {
|
||||
inline bool isLineSelected(qsizetype line) const {
|
||||
Q_ASSERT(isNormalized());
|
||||
if (this->begin.line == line || this->end.line == line) {
|
||||
return true;
|
||||
|
@ -118,6 +118,7 @@ public:
|
|||
bool atEnd() const;
|
||||
|
||||
bool isLineSelected(qsizetype line) const;
|
||||
bool isSelected(const QHexPosition &pos) const;
|
||||
bool hasSelection() const;
|
||||
bool hasInternalSelection() const;
|
||||
|
||||
|
|
|
@ -5,6 +5,8 @@
|
|||
#include "commands/meta/metaremoveposcommand.h"
|
||||
#include "commands/meta/metareplacecommand.h"
|
||||
|
||||
#include <cmath>
|
||||
|
||||
#include <QtAlgorithms>
|
||||
#include <QtConcurrent/QtConcurrentMap>
|
||||
|
||||
|
@ -162,35 +164,26 @@ QHexLineMetadata QHexMetadata::gets(qsizetype line) {
|
|||
return ret;
|
||||
}
|
||||
|
||||
QPair<qsizetype, qsizetype> QHexMetadata::getRealMetaRange(qsizetype begin,
|
||||
qsizetype end) {
|
||||
QVector<QHexMetadata::MetaInfo> QHexMetadata::getRealMetaRange(qsizetype begin,
|
||||
qsizetype end) {
|
||||
Q_ASSERT(begin <= end);
|
||||
|
||||
using QHexRegionGadget = QHexRegionGadget<qsizetype>;
|
||||
|
||||
QList<QHexRegionGadget> items;
|
||||
QVector<MetaInfo> ret;
|
||||
MetaInfo g(begin, end);
|
||||
for (auto &meta : m_metadata) {
|
||||
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 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);
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
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; }
|
||||
|
||||
/*==================================*/
|
||||
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 {
|
||||
if (!this->lineHasMetadata(line))
|
||||
return QString();
|
||||
|
||||
QString s;
|
||||
|
||||
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;
|
||||
// Ensure it meets contrast ratio criteria
|
||||
double contrastRatio =
|
||||
calculateContrastRatio(backgroundColor, invertedColor);
|
||||
if (contrastRatio >= 4.5) {
|
||||
return invertedColor;
|
||||
}
|
||||
|
||||
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 {
|
||||
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,
|
||||
const QColor &bgcolor) {
|
||||
return this->metadata(begin, end, fgcolor, bgcolor, QString());
|
||||
|
@ -393,7 +421,7 @@ void QHexMetadata::addMetaLines(const QHexMetadataItem &mi) {
|
|||
if (row == lastRow) {
|
||||
Q_ASSERT(m_lineWidth > 0);
|
||||
const int lastChar = mi.end % m_lineWidth;
|
||||
length = lastChar - start;
|
||||
length = lastChar - start + 1;
|
||||
} else {
|
||||
// fix the bug by wingsummer
|
||||
if (firstRow != lastRow)
|
||||
|
|
|
@ -115,12 +115,32 @@ class QHexMetadata : public QObject {
|
|||
Q_OBJECT
|
||||
|
||||
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:
|
||||
explicit QHexMetadata(QUndoStack *undo, QObject *parent = nullptr);
|
||||
QHexLineMetadata get(qsizetype line) const;
|
||||
QString comments(qsizetype line, qsizetype column) const;
|
||||
bool lineHasMetadata(qsizetype line) const; // modified by wingsummer
|
||||
|
||||
qsizetype size() const;
|
||||
|
@ -152,15 +172,27 @@ public:
|
|||
|
||||
std::optional<QHexMetadataItem> get(qsizetype offset);
|
||||
QHexLineMetadata gets(qsizetype line);
|
||||
QPair<qsizetype, qsizetype> getRealMetaRange(qsizetype begin,
|
||||
qsizetype end);
|
||||
QVector<MetaInfo> getRealMetaRange(qsizetype begin, qsizetype end);
|
||||
|
||||
void applyMetas(const QVector<QHexMetadataItem> &metas);
|
||||
|
||||
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 setLineWidth(quint8 width);
|
||||
|
||||
|
|
|
@ -1,51 +1,58 @@
|
|||
#ifndef QHEXREGIONOBJECT_H
|
||||
#define QHEXREGIONOBJECT_H
|
||||
|
||||
#include <type_traits>
|
||||
#include <utility>
|
||||
|
||||
namespace REQUIRE_CHECK {
|
||||
|
||||
struct NO_OP {};
|
||||
|
||||
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, typename = void>
|
||||
struct has_greater_equal : std::false_type {};
|
||||
|
||||
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>
|
||||
struct GreatThanExists {
|
||||
enum { value = sizeof(optest(*(T *)(0) > *(Arg *)(0))) == sizeof(char) };
|
||||
};
|
||||
template <typename T, typename Arg = T>
|
||||
struct LessThanExists {
|
||||
enum { value = sizeof(optest(*(T *)(0) < *(Arg *)(0))) == sizeof(char) };
|
||||
};
|
||||
template <typename T, typename Arg = T>
|
||||
struct GreatEqualThanExists {
|
||||
enum { value = sizeof(optest(*(T *)(0) >= *(Arg *)(0))) == sizeof(char) };
|
||||
};
|
||||
template <typename T, typename Arg = T>
|
||||
struct LessEqualThanExists {
|
||||
enum { value = sizeof(optest(*(T *)(0) <= *(Arg *)(0))) == sizeof(char) };
|
||||
};
|
||||
template <typename T, typename Arg = T>
|
||||
struct EqualExists {
|
||||
enum { value = sizeof(optest(*(T *)(0) == *(Arg *)(0))) == sizeof(char) };
|
||||
};
|
||||
template <typename T, typename Arg = T>
|
||||
struct NotEqualExists {
|
||||
enum { value = sizeof(optest(*(T *)(0) != *(Arg *)(0))) == sizeof(char) };
|
||||
};
|
||||
// Repeat for other operators
|
||||
template <typename, typename = void>
|
||||
struct has_greater : std::false_type {};
|
||||
|
||||
template <typename T>
|
||||
struct has_greater<T,
|
||||
std::void_t<decltype(std::declval<T>() > std::declval<T>())>>
|
||||
: std::true_type {};
|
||||
|
||||
template <typename, typename = void>
|
||||
struct has_less_equal : std::false_type {};
|
||||
|
||||
template <typename T>
|
||||
struct has_less_equal<
|
||||
T, std::void_t<decltype(std::declval<T>() <= std::declval<T>())>>
|
||||
: std::true_type {};
|
||||
|
||||
template <typename, typename = void>
|
||||
struct has_less : std::false_type {};
|
||||
|
||||
template <typename T>
|
||||
struct has_less<T, std::void_t<decltype(std::declval<T>() < std::declval<T>())>>
|
||||
: 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
|
||||
|
||||
|
@ -54,156 +61,23 @@ struct NotEqualExists {
|
|||
|
||||
#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>
|
||||
struct QHexRegionObject {
|
||||
static_assert(REQUIRE_CHECK::GreatThanExists<T>::value,
|
||||
static_assert(REQUIRE_CHECK::has_greater<T>::value,
|
||||
"Operator > is required");
|
||||
static_assert(REQUIRE_CHECK::LessThanExists<T>::value,
|
||||
"Operator < is required");
|
||||
static_assert(REQUIRE_CHECK::GreatEqualThanExists<T>::value,
|
||||
static_assert(REQUIRE_CHECK::has_less<T>::value, "Operator < is required");
|
||||
static_assert(REQUIRE_CHECK::has_greater_equal<T>::value,
|
||||
"Operator >= is required");
|
||||
static_assert(REQUIRE_CHECK::LessEqualThanExists<T>::value,
|
||||
static_assert(REQUIRE_CHECK::has_less_equal<T>::value,
|
||||
"Operator <= is required");
|
||||
static_assert(REQUIRE_CHECK::EqualExists<T>::value,
|
||||
static_assert(REQUIRE_CHECK::has_equal<T>::value,
|
||||
"Operator == is required");
|
||||
static_assert(REQUIRE_CHECK::NotEqualExists<T>::value,
|
||||
static_assert(REQUIRE_CHECK::has_not_equal<T>::value,
|
||||
"Operator != is required");
|
||||
|
||||
using Super = QHexRegionObject<T, P>;
|
||||
|
||||
private:
|
||||
bool _adjusted = false;
|
||||
|
||||
bool _valid = true;
|
||||
|
||||
T next(const T &obj) const {
|
||||
|
@ -241,6 +115,12 @@ public:
|
|||
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 {
|
||||
Q_ASSERT(isValid());
|
||||
return end >= begin;
|
||||
|
@ -260,13 +140,15 @@ public:
|
|||
static_assert(std::is_base_of_v<QHexRegionObject<T, P>, P>);
|
||||
Q_ASSERT(isValid());
|
||||
Q_ASSERT(isNormalized());
|
||||
if (_adjusted) {
|
||||
return !(next(sel.end) < this->begin ||
|
||||
sel.begin > next(this->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) {
|
||||
static_assert(std::is_base_of_v<QHexRegionObject<T, P>, P>);
|
||||
Q_ASSERT(isValid());
|
||||
|
@ -278,18 +160,10 @@ public:
|
|||
if (locker) {
|
||||
locker->lock();
|
||||
}
|
||||
if (_adjusted) {
|
||||
if (this->begin < s.end) {
|
||||
this->begin = qMax(this->begin, next(s.begin));
|
||||
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);
|
||||
}
|
||||
|
||||
this->begin = qMax(this->begin, s.begin);
|
||||
this->end = qMin(this->end, s.end);
|
||||
|
||||
if (locker) {
|
||||
locker->unlock();
|
||||
}
|
||||
|
@ -312,9 +186,7 @@ public:
|
|||
if (sel.end >= this->begin) {
|
||||
if (sel.end < this->end) {
|
||||
this->begin = sel.end;
|
||||
if (_adjusted) {
|
||||
++this->begin;
|
||||
}
|
||||
++this->begin;
|
||||
} else {
|
||||
// makes it invalid, delete later
|
||||
_valid = false;
|
||||
|
@ -322,23 +194,23 @@ public:
|
|||
result = true;
|
||||
}
|
||||
} else if (sel.begin > this->begin && sel.begin < this->end) {
|
||||
auto oldend = this->end;
|
||||
|
||||
this->end = sel.begin;
|
||||
if (_adjusted) {
|
||||
--this->end;
|
||||
}
|
||||
--this->end;
|
||||
result = true;
|
||||
|
||||
if (sel.end < this->end) {
|
||||
if (sel.end < oldend) {
|
||||
// break into two ranges
|
||||
P sel;
|
||||
sel.begin = sel.end;
|
||||
sel.end = this->end;
|
||||
P s;
|
||||
s.begin = sel.end;
|
||||
s.end = oldend;
|
||||
|
||||
if (locker) {
|
||||
locker->unlock();
|
||||
}
|
||||
|
||||
return sel;
|
||||
return s.normalized();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -352,22 +224,19 @@ public:
|
|||
mergeRegion(const P &sel, QMutex *locker = nullptr) {
|
||||
Q_ASSERT(isValid());
|
||||
Q_ASSERT(isNormalized());
|
||||
if (isIntersected(sel)) {
|
||||
if (canMerge(sel)) {
|
||||
if (locker) {
|
||||
locker->lock();
|
||||
}
|
||||
if (_adjusted) {
|
||||
if (this->begin < sel.end) {
|
||||
this->begin = qMin(this->begin, next(sel.begin));
|
||||
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));
|
||||
}
|
||||
|
||||
if (this->begin < sel.end) {
|
||||
this->begin = qMin(this->begin, next(sel.begin));
|
||||
this->end = qMax(next(this->end), sel.end);
|
||||
} else {
|
||||
this->begin = qMin(this->begin, sel.begin);
|
||||
this->end = qMax(this->end, sel.end);
|
||||
this->begin = qMin(next(this->begin), sel.begin);
|
||||
this->end = qMax(this->end, next(sel.end));
|
||||
}
|
||||
|
||||
if (locker) {
|
||||
locker->unlock();
|
||||
}
|
||||
|
@ -376,17 +245,9 @@ public:
|
|||
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 operator<(const Super &item) const { return begin < item.begin; }
|
||||
};
|
||||
|
||||
#include <QtConcurrent/QtConcurrentMap>
|
||||
|
@ -442,7 +303,12 @@ public:
|
|||
auto region = std::get<std::optional<P>>(res);
|
||||
idx = std::distance(this->begin(), p);
|
||||
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;
|
||||
}
|
||||
|
@ -455,10 +321,12 @@ public:
|
|||
auto m = this->takeAt(idx);
|
||||
mergeAdd(m, locker);
|
||||
} 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;
|
||||
|
|
|
@ -15,6 +15,8 @@
|
|||
|
||||
#define HEX_UNPRINTABLE_CHAR '.'
|
||||
|
||||
constexpr qreal CONTRASTING_COLOR_BORDER = 0.35;
|
||||
|
||||
/*===================================*/
|
||||
// added by wingsummer
|
||||
|
||||
|
@ -407,14 +409,36 @@ void QHexRenderer::applyMetadata(QTextCursor &textcursor, qsizetype line,
|
|||
const QHexLineMetadata &linemetadata = metadata->gets(line);
|
||||
for (auto &mi : linemetadata) {
|
||||
QTextCharFormat charformat;
|
||||
|
||||
QColor bg, fg;
|
||||
if (m_document->metabgVisible() && mi.background.isValid() &&
|
||||
mi.background.rgba())
|
||||
mi.background.alpha()) {
|
||||
charformat.setBackground(mi.background);
|
||||
bg = mi.background;
|
||||
}
|
||||
if (m_document->metafgVisible() && mi.foreground.isValid() &&
|
||||
mi.foreground.rgba())
|
||||
mi.foreground.alpha()) {
|
||||
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.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.movePosition(
|
||||
|
@ -437,7 +461,7 @@ void QHexRenderer::applySelection(QTextCursor &textcursor, qsizetype line,
|
|||
|
||||
if (m_cursor->hasPreviewSelection()) {
|
||||
applySelection(
|
||||
m_cursor->previewSelection().normalized(), textcursor, line, factor,
|
||||
m_cursor->previewSelection(), textcursor, line, factor,
|
||||
m_cursor->previewSelectionMode() == QHexCursor::SelectionRemove,
|
||||
m_cursor->previewSelectionMode() == QHexCursor::SelectionNormal &&
|
||||
m_cursor->hasInternalSelection());
|
||||
|
@ -452,9 +476,6 @@ void QHexRenderer::applySelection(const QHexSelection &selection,
|
|||
return;
|
||||
}
|
||||
|
||||
const QHexPosition &startsel = selection.begin;
|
||||
const QHexPosition &endsel = selection.end;
|
||||
|
||||
QTextCharFormat charfmt;
|
||||
charfmt.setBackground(strikeOut || hasSelection
|
||||
? m_selBackgroundColor.darker()
|
||||
|
@ -469,31 +490,83 @@ void QHexRenderer::applySelection(const QHexSelection &selection,
|
|||
charfmt_meta.setFontUnderline(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) {
|
||||
auto selbegin = startsel.offset();
|
||||
auto len = endsel.column - startsel.column + 1;
|
||||
auto selend = selbegin + len;
|
||||
begin = startsel.column;
|
||||
end = endsel.column;
|
||||
} 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) {
|
||||
auto begin = meta.first - startsel.lineWidth * startsel.line;
|
||||
auto mlen = meta.second - meta.first;
|
||||
applySelection(metas, textcursor, line * startsel.lineWidth, begin, end,
|
||||
factor, strikeOut, hasSelection);
|
||||
}
|
||||
|
||||
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,
|
||||
(begin - startsel.column) * factor);
|
||||
if (factor == Hex)
|
||||
textcursor.movePosition(QTextCursor::Left,
|
||||
QTextCursor::KeepAnchor, 1);
|
||||
blen * factor);
|
||||
|
||||
textcursor.mergeCharFormat(charfmt);
|
||||
len -= (begin - startsel.column);
|
||||
textcursor.clearSelection();
|
||||
|
||||
if (factor == Hex)
|
||||
textcursor.movePosition(QTextCursor::Right,
|
||||
QTextCursor::MoveAnchor, 1);
|
||||
totallen -= blen;
|
||||
|
||||
textcursor.movePosition(QTextCursor::Right, QTextCursor::KeepAnchor,
|
||||
mlen * factor);
|
||||
|
@ -502,45 +575,65 @@ void QHexRenderer::applySelection(const QHexSelection &selection,
|
|||
textcursor.movePosition(QTextCursor::Left,
|
||||
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.clearSelection();
|
||||
totallen -= mlen;
|
||||
|
||||
len -= mlen;
|
||||
if (len > 0) {
|
||||
if (factor == Hex)
|
||||
if (totallen > 0) {
|
||||
if (factor == Hex) {
|
||||
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);
|
||||
|
||||
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,
|
||||
len * factor);
|
||||
totallen * factor);
|
||||
if (factor == Hex)
|
||||
textcursor.movePosition(QTextCursor::Left,
|
||||
QTextCursor::KeepAnchor, 1);
|
||||
|
||||
textcursor.mergeCharFormat(charfmt);
|
||||
textcursor.clearSelection();
|
||||
}
|
||||
} else {
|
||||
if (line == startsel.line)
|
||||
textcursor.setPosition(startsel.column * factor);
|
||||
else
|
||||
textcursor.setPosition(0);
|
||||
|
||||
if (line == endsel.line)
|
||||
textcursor.movePosition(QTextCursor::Right, QTextCursor::KeepAnchor,
|
||||
((endsel.column + 1) * factor));
|
||||
else
|
||||
textcursor.movePosition(QTextCursor::EndOfLine,
|
||||
QTextCursor::KeepAnchor);
|
||||
|
||||
textcursor.setPosition(lineStart * factor);
|
||||
textcursor.movePosition(QTextCursor::Right, QTextCursor::KeepAnchor,
|
||||
totallen * factor);
|
||||
if (factor == Hex)
|
||||
textcursor.movePosition(QTextCursor::Left, QTextCursor::KeepAnchor,
|
||||
1);
|
||||
textcursor.mergeCharFormat(charfmt);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -126,6 +126,10 @@ private:
|
|||
void applySelection(const QHexSelection &selection, QTextCursor &textcursor,
|
||||
qsizetype line, Factor factor, bool strikeOut,
|
||||
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,
|
||||
Factor factor); // added by wingsummer
|
||||
|
|
|
@ -232,8 +232,38 @@ bool QHexView::event(QEvent *e) {
|
|||
|
||||
QPoint abspos = absolutePosition(helpevent->pos());
|
||||
if (m_renderer->hitTest(abspos, &position, this->firstVisibleLine())) {
|
||||
QString comments = m_document->metadata()->comments(
|
||||
position.line, position.column);
|
||||
QString comments;
|
||||
|
||||
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())
|
||||
QToolTip::showText(helpevent->globalPos(), comments, this);
|
||||
|
@ -344,7 +374,7 @@ QByteArray QHexView::selectedBytes(qsizetype index) 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());
|
||||
}
|
||||
|
||||
|
|
|
@ -29,6 +29,12 @@ Ribbon::Ribbon(QWidget *parent) : QTabWidget(parent) {
|
|||
setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Preferred);
|
||||
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);
|
||||
hideBtn->setObjectName(QStringLiteral("RIBBON_HIDE_BTN"));
|
||||
hideBtn->setCheckable(true);
|
||||
|
|
|
@ -44,13 +44,14 @@ void RibbonButtonGroup::addButton(QToolButton *button) {
|
|||
}
|
||||
|
||||
button->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Preferred);
|
||||
|
||||
auto font = button->font();
|
||||
QFontMetrics fm(font);
|
||||
button->setIconSize(QSize(32, 32));
|
||||
button->setAutoRaise(true);
|
||||
button->setToolButtonStyle(Qt::ToolButtonTextUnderIcon);
|
||||
|
||||
#if QT_VERSION > QT_VERSION_CHECK(6, 6, 0)
|
||||
button->setMinimumWidth(32 + 30); // Icon size + padding
|
||||
#endif
|
||||
|
||||
_buttons << button;
|
||||
ui->horizontalLayout->addWidget(button);
|
||||
|
||||
|
|
|
@ -3578,18 +3578,20 @@ bool QDocumentCursorHandle::movePosition(int count,
|
|||
auto txt = m_doc->line(line).text().left(offset);
|
||||
auto len = txt.length();
|
||||
qsizetype index = 0;
|
||||
if (txt.back().isSpace()) {
|
||||
for (qsizetype i = len - 1; i >= 0; --i) {
|
||||
if (!txt.at(i).isSpace()) {
|
||||
index = i + 1;
|
||||
break;
|
||||
if (!txt.isEmpty()) {
|
||||
if (txt.back().isSpace()) {
|
||||
for (qsizetype i = len - 1; i >= 0; --i) {
|
||||
if (!txt.at(i).isSpace()) {
|
||||
index = i + 1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
for (qsizetype i = len - 1; i >= 0; --i) {
|
||||
if (!txt.at(i).isLetterOrNumber()) {
|
||||
index = i + 1;
|
||||
break;
|
||||
} else {
|
||||
for (qsizetype i = len - 1; i >= 0; --i) {
|
||||
if (!txt.at(i).isLetterOrNumber()) {
|
||||
index = i + 1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -46,8 +46,6 @@
|
|||
to the user
|
||||
*/
|
||||
|
||||
QCE_AUTO_REGISTER(QFoldPanel)
|
||||
|
||||
/*!
|
||||
\brief Constructor
|
||||
*/
|
||||
|
|
|
@ -50,4 +50,6 @@ private:
|
|||
QList<int> m_lines;
|
||||
};
|
||||
|
||||
QCE_AUTO_REGISTER(QFoldPanel)
|
||||
|
||||
#endif // _QFOLD_PANEL_H_
|
||||
|
|
|
@ -43,8 +43,6 @@
|
|||
\see QEditorInterface
|
||||
*/
|
||||
|
||||
QCE_AUTO_REGISTER(QLineChangePanel)
|
||||
|
||||
/*!
|
||||
\brief Constructor
|
||||
*/
|
||||
|
|
|
@ -44,8 +44,8 @@ public:
|
|||
|
||||
protected:
|
||||
virtual void paint(QPainter *p, QEditor *e);
|
||||
|
||||
private:
|
||||
};
|
||||
|
||||
QCE_AUTO_REGISTER(QLineChangePanel)
|
||||
|
||||
#endif // _QLINE_CHANGE_PANEL_H_
|
||||
|
|
|
@ -45,8 +45,6 @@
|
|||
\brief A specific panel in charge of drawing line marks of an editor
|
||||
*/
|
||||
|
||||
QCE_AUTO_REGISTER(QLineMarkPanel)
|
||||
|
||||
/*!
|
||||
\brief Constructor
|
||||
*/
|
||||
|
@ -83,8 +81,8 @@ void QLineMarkPanel::paint(QPainter *p, QEditor *e) {
|
|||
pageBottom = e->viewport()->height(),
|
||||
contentsY = e->verticalOffset();
|
||||
|
||||
QString txt;
|
||||
const QFontMetrics sfm(fontMetrics());
|
||||
// QString txt;
|
||||
// const QFontMetrics sfm(fontMetrics());
|
||||
QLineMarksInfoCenter *mic = QLineMarksInfoCenter::instance();
|
||||
|
||||
n = d->lineNumber(contentsY);
|
||||
|
|
|
@ -55,4 +55,6 @@ private:
|
|||
QList<int> m_lines;
|
||||
};
|
||||
|
||||
QCE_AUTO_REGISTER(QLineMarkPanel)
|
||||
|
||||
#endif // _QLINE_MARK_PANEL_H_
|
||||
|
|
|
@ -40,8 +40,6 @@
|
|||
\brief A specific panel in charge of drawing line numbers of an editor
|
||||
*/
|
||||
|
||||
QCE_AUTO_REGISTER(QLineNumberPanel)
|
||||
|
||||
/*!
|
||||
\brief Constructor
|
||||
*/
|
||||
|
|
|
@ -55,4 +55,6 @@ protected:
|
|||
int _fixWidth = 0;
|
||||
};
|
||||
|
||||
QCE_AUTO_REGISTER(QLineNumberPanel)
|
||||
|
||||
#endif // _QLINE_NUMBER_PANEL_H_
|
||||
|
|
|
@ -53,7 +53,7 @@ QHash<QString, QPanelCreator *> &QPanel::creators() {
|
|||
|
||||
QPanel *QPanel::panel(const QString &id, QWidget *p) {
|
||||
if (!creators().contains(id))
|
||||
return 0;
|
||||
return nullptr;
|
||||
|
||||
return creators().value(id)->panel(p);
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
||||
|
@ -217,7 +217,7 @@ QList<WingHex::PluginPage *> TestPlugin::registeredPages() const {
|
|||
return _plgps;
|
||||
}
|
||||
|
||||
QList<WingHex::WingEditorViewWidget *>
|
||||
QList<QSharedPointer<WingHex::WingEditorViewWidget::Creator>>
|
||||
TestPlugin::registeredEditorViewWidgets() const {
|
||||
return _evws;
|
||||
}
|
||||
|
|
|
@ -64,7 +64,7 @@ public:
|
|||
virtual QHash<WingHex::SettingPage *, bool>
|
||||
registeredSettingPages() const override;
|
||||
virtual QList<WingHex::PluginPage *> registeredPages() const override;
|
||||
virtual QList<WingHex::WingEditorViewWidget *>
|
||||
virtual QList<QSharedPointer<WingHex::WingEditorViewWidget::Creator>>
|
||||
registeredEditorViewWidgets() const override;
|
||||
virtual QHash<QString, ScriptFnInfo> registeredScriptFns() const override;
|
||||
|
||||
|
@ -90,7 +90,7 @@ private:
|
|||
QList<WingHex::WingDockWidgetInfo> _winfo;
|
||||
QList<WingHex::WingRibbonToolBoxInfo> _rtbinfo;
|
||||
QHash<WingHex::SettingPage *, bool> _setpages;
|
||||
QList<WingHex::WingEditorViewWidget *> _evws;
|
||||
QList<QSharedPointer<WingHex::WingEditorViewWidget::Creator>> _evws;
|
||||
QList<WingHex::PluginPage *> _plgps;
|
||||
};
|
||||
|
||||
|
|
|
@ -10,19 +10,19 @@ TestWingEditorViewWidget::TestWingEditorViewWidget(QWidget *parent)
|
|||
layout->addWidget(lbl);
|
||||
}
|
||||
|
||||
QIcon TestWingEditorViewWidget::icon() const {
|
||||
QIcon TestWingEditorViewWidget::Creator::icon() const {
|
||||
return QIcon(QStringLiteral(":/images/TestPlugin/images/btn.png"));
|
||||
}
|
||||
|
||||
QString TestWingEditorViewWidget::name() const {
|
||||
QString TestWingEditorViewWidget::Creator::name() const {
|
||||
return tr("TestWingEditorView");
|
||||
}
|
||||
|
||||
QString TestWingEditorViewWidget::id() const {
|
||||
QString TestWingEditorViewWidget::Creator::id() const {
|
||||
return QStringLiteral("TestWingEditorView");
|
||||
}
|
||||
|
||||
void TestWingEditorViewWidget::toggled(bool isVisible) {}
|
||||
void TestWingEditorViewWidget::toggled(bool isVisible) { Q_UNUSED(isVisible); }
|
||||
|
||||
WingHex::WingEditorViewWidget *TestWingEditorViewWidget::clone() {
|
||||
return nullptr;
|
||||
|
|
|
@ -7,14 +7,27 @@
|
|||
|
||||
class TestWingEditorViewWidget : public WingHex::WingEditorViewWidget {
|
||||
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:
|
||||
explicit TestWingEditorViewWidget(QWidget *parent = nullptr);
|
||||
|
||||
// WingEditorViewWidget interface
|
||||
public:
|
||||
virtual QIcon icon() const override;
|
||||
virtual QString name() const override;
|
||||
virtual QString id() const override;
|
||||
|
||||
public slots:
|
||||
virtual void toggled(bool isVisible) override;
|
||||
|
|
|
@ -442,7 +442,7 @@
|
|||
<translation>编码</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../../src/control/editorview.cpp" line="258"/>
|
||||
<location filename="../../src/control/editorview.cpp" line="242"/>
|
||||
<source>Untitled</source>
|
||||
<translation>未命名</translation>
|
||||
</message>
|
||||
|
@ -943,8 +943,8 @@
|
|||
<location filename="../../src/dialog/mainwindow.cpp" line="886"/>
|
||||
<location filename="../../src/dialog/mainwindow.cpp" line="954"/>
|
||||
<location filename="../../src/dialog/mainwindow.cpp" line="1026"/>
|
||||
<location filename="../../src/dialog/mainwindow.cpp" line="2114"/>
|
||||
<location filename="../../src/dialog/mainwindow.cpp" line="2299"/>
|
||||
<location filename="../../src/dialog/mainwindow.cpp" line="2115"/>
|
||||
<location filename="../../src/dialog/mainwindow.cpp" line="2300"/>
|
||||
<source>CopyToClipBoard</source>
|
||||
<translation>数据已拷贝到粘贴板</translation>
|
||||
</message>
|
||||
|
@ -984,8 +984,8 @@
|
|||
<message>
|
||||
<location filename="../../src/dialog/mainwindow.cpp" line="726"/>
|
||||
<location filename="../../src/dialog/mainwindow.cpp" line="1291"/>
|
||||
<location filename="../../src/dialog/mainwindow.cpp" line="2377"/>
|
||||
<location filename="../../src/dialog/mainwindow.cpp" line="2385"/>
|
||||
<location filename="../../src/dialog/mainwindow.cpp" line="2378"/>
|
||||
<location filename="../../src/dialog/mainwindow.cpp" line="2386"/>
|
||||
<source>BookMark</source>
|
||||
<translation>书签</translation>
|
||||
</message>
|
||||
|
@ -1172,7 +1172,7 @@
|
|||
</message>
|
||||
<message>
|
||||
<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>
|
||||
<translation>填充</translation>
|
||||
</message>
|
||||
|
@ -1480,7 +1480,7 @@
|
|||
</message>
|
||||
<message>
|
||||
<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>
|
||||
<translation>保存布局</translation>
|
||||
</message>
|
||||
|
@ -1565,8 +1565,8 @@
|
|||
<translation>插件 %1 包含重复 ID (%2),该 ID 已被插件 %3 注册</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../../src/dialog/mainwindow.cpp" line="1803"/>
|
||||
<location filename="../../src/dialog/mainwindow.cpp" line="1854"/>
|
||||
<location filename="../../src/dialog/mainwindow.cpp" line="1804"/>
|
||||
<location filename="../../src/dialog/mainwindow.cpp" line="1855"/>
|
||||
<source>ChooseFile</source>
|
||||
<translation>选择文件</translation>
|
||||
</message>
|
||||
|
@ -1576,29 +1576,29 @@
|
|||
<location filename="../../src/dialog/mainwindow.cpp" line="1073"/>
|
||||
<location filename="../../src/dialog/mainwindow.cpp" line="1083"/>
|
||||
<location filename="../../src/dialog/mainwindow.cpp" line="1145"/>
|
||||
<location filename="../../src/dialog/mainwindow.cpp" line="1809"/>
|
||||
<location filename="../../src/dialog/mainwindow.cpp" line="1813"/>
|
||||
<location filename="../../src/dialog/mainwindow.cpp" line="1836"/>
|
||||
<location filename="../../src/dialog/mainwindow.cpp" line="1840"/>
|
||||
<location filename="../../src/dialog/mainwindow.cpp" line="1861"/>
|
||||
<location filename="../../src/dialog/mainwindow.cpp" line="1865"/>
|
||||
<location filename="../../src/dialog/mainwindow.cpp" line="1885"/>
|
||||
<location filename="../../src/dialog/mainwindow.cpp" line="1891"/>
|
||||
<location filename="../../src/dialog/mainwindow.cpp" line="1895"/>
|
||||
<location filename="../../src/dialog/mainwindow.cpp" line="1920"/>
|
||||
<location filename="../../src/dialog/mainwindow.cpp" line="1946"/>
|
||||
<location filename="../../src/dialog/mainwindow.cpp" line="2009"/>
|
||||
<location filename="../../src/dialog/mainwindow.cpp" line="2048"/>
|
||||
<location filename="../../src/dialog/mainwindow.cpp" line="2965"/>
|
||||
<location filename="../../src/dialog/mainwindow.cpp" line="3197"/>
|
||||
<location filename="../../src/dialog/mainwindow.cpp" line="1810"/>
|
||||
<location filename="../../src/dialog/mainwindow.cpp" line="1814"/>
|
||||
<location filename="../../src/dialog/mainwindow.cpp" line="1837"/>
|
||||
<location filename="../../src/dialog/mainwindow.cpp" line="1841"/>
|
||||
<location filename="../../src/dialog/mainwindow.cpp" line="1862"/>
|
||||
<location filename="../../src/dialog/mainwindow.cpp" line="1866"/>
|
||||
<location filename="../../src/dialog/mainwindow.cpp" line="1886"/>
|
||||
<location filename="../../src/dialog/mainwindow.cpp" line="1892"/>
|
||||
<location filename="../../src/dialog/mainwindow.cpp" line="1896"/>
|
||||
<location filename="../../src/dialog/mainwindow.cpp" line="1921"/>
|
||||
<location filename="../../src/dialog/mainwindow.cpp" line="1947"/>
|
||||
<location filename="../../src/dialog/mainwindow.cpp" line="2010"/>
|
||||
<location filename="../../src/dialog/mainwindow.cpp" line="2049"/>
|
||||
<location filename="../../src/dialog/mainwindow.cpp" line="2966"/>
|
||||
<location filename="../../src/dialog/mainwindow.cpp" line="3198"/>
|
||||
<source>Error</source>
|
||||
<translation>错误</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../../src/dialog/mainwindow.cpp" line="1809"/>
|
||||
<location filename="../../src/dialog/mainwindow.cpp" line="1836"/>
|
||||
<location filename="../../src/dialog/mainwindow.cpp" line="1861"/>
|
||||
<location filename="../../src/dialog/mainwindow.cpp" line="1891"/>
|
||||
<location filename="../../src/dialog/mainwindow.cpp" line="1810"/>
|
||||
<location filename="../../src/dialog/mainwindow.cpp" line="1837"/>
|
||||
<location filename="../../src/dialog/mainwindow.cpp" line="1862"/>
|
||||
<location filename="../../src/dialog/mainwindow.cpp" line="1892"/>
|
||||
<source>FileNotExist</source>
|
||||
<translation>文件不存在!</translation>
|
||||
</message>
|
||||
|
@ -1608,31 +1608,31 @@
|
|||
<location filename="../../src/dialog/mainwindow.cpp" line="1074"/>
|
||||
<location filename="../../src/dialog/mainwindow.cpp" line="1084"/>
|
||||
<location filename="../../src/dialog/mainwindow.cpp" line="1146"/>
|
||||
<location filename="../../src/dialog/mainwindow.cpp" line="1813"/>
|
||||
<location filename="../../src/dialog/mainwindow.cpp" line="1840"/>
|
||||
<location filename="../../src/dialog/mainwindow.cpp" line="1865"/>
|
||||
<location filename="../../src/dialog/mainwindow.cpp" line="1895"/>
|
||||
<location filename="../../src/dialog/mainwindow.cpp" line="1946"/>
|
||||
<location filename="../../src/dialog/mainwindow.cpp" line="1814"/>
|
||||
<location filename="../../src/dialog/mainwindow.cpp" line="1841"/>
|
||||
<location filename="../../src/dialog/mainwindow.cpp" line="1866"/>
|
||||
<location filename="../../src/dialog/mainwindow.cpp" line="1896"/>
|
||||
<location filename="../../src/dialog/mainwindow.cpp" line="1947"/>
|
||||
<source>FilePermission</source>
|
||||
<translation>因文件权限无法继续!</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../../src/dialog/mainwindow.cpp" line="1854"/>
|
||||
<location filename="../../src/dialog/mainwindow.cpp" line="1855"/>
|
||||
<source>ProjectFile (*.wingpro)</source>
|
||||
<translation>项目文件 (*.wingpro)</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../../src/dialog/mainwindow.cpp" line="1885"/>
|
||||
<location filename="../../src/dialog/mainwindow.cpp" line="1886"/>
|
||||
<source>Root Required!</source>
|
||||
<translation>需要管理员权限继续操作!</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../../src/dialog/mainwindow.cpp" line="1916"/>
|
||||
<location filename="../../src/dialog/mainwindow.cpp" line="1917"/>
|
||||
<source>ReloadSuccessfully</source>
|
||||
<translation>文件重新加载成功!</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../../src/dialog/mainwindow.cpp" line="1920"/>
|
||||
<location filename="../../src/dialog/mainwindow.cpp" line="1921"/>
|
||||
<source>ReloadUnSuccessfully</source>
|
||||
<translation>文件重新加载失败!</translation>
|
||||
</message>
|
||||
|
@ -1641,49 +1641,49 @@
|
|||
<location filename="../../src/dialog/mainwindow.cpp" line="967"/>
|
||||
<location filename="../../src/dialog/mainwindow.cpp" line="1040"/>
|
||||
<location filename="../../src/dialog/mainwindow.cpp" line="1137"/>
|
||||
<location filename="../../src/dialog/mainwindow.cpp" line="1976"/>
|
||||
<location filename="../../src/dialog/mainwindow.cpp" line="2059"/>
|
||||
<location filename="../../src/dialog/mainwindow.cpp" line="2605"/>
|
||||
<location filename="../../src/dialog/mainwindow.cpp" line="1977"/>
|
||||
<location filename="../../src/dialog/mainwindow.cpp" line="2060"/>
|
||||
<location filename="../../src/dialog/mainwindow.cpp" line="2606"/>
|
||||
<source>ChooseSaveFile</source>
|
||||
<translation>请选择保存文件路径:</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../../src/dialog/mainwindow.cpp" line="2145"/>
|
||||
<location filename="../../src/dialog/mainwindow.cpp" line="2146"/>
|
||||
<source>NoMoreClone</source>
|
||||
<translation>克隆已到上限,无法继续操作!</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../../src/dialog/mainwindow.cpp" line="2187"/>
|
||||
<location filename="../../src/dialog/mainwindow.cpp" line="2188"/>
|
||||
<source>FindFininishBusy</source>
|
||||
<translation>查找任务繁忙,请勿重复查找!</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../../src/dialog/mainwindow.cpp" line="2191"/>
|
||||
<location filename="../../src/dialog/mainwindow.cpp" line="2192"/>
|
||||
<source>MayTooMuchFindResult</source>
|
||||
<translation>搜索数量已到达上限,结果可能不全,建议请按区段搜索。</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../../src/dialog/mainwindow.cpp" line="2824"/>
|
||||
<location filename="../../src/dialog/mainwindow.cpp" line="2825"/>
|
||||
<source>SaveLayoutSuccess</source>
|
||||
<translation>保存布局成功</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../../src/dialog/mainwindow.cpp" line="2827"/>
|
||||
<location filename="../../src/dialog/mainwindow.cpp" line="2828"/>
|
||||
<source>SaveLayoutError</source>
|
||||
<translation>保存布局失败</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../../src/dialog/mainwindow.cpp" line="3512"/>
|
||||
<location filename="../../src/dialog/mainwindow.cpp" line="3513"/>
|
||||
<source>ConfirmSave</source>
|
||||
<translation>正在关闭未保存的文件或工作区,你确定保存吗?</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../../src/dialog/mainwindow.cpp" line="3531"/>
|
||||
<location filename="../../src/dialog/mainwindow.cpp" line="3532"/>
|
||||
<source>Column %1</source>
|
||||
<translation>列 %1</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../../src/dialog/mainwindow.cpp" line="3579"/>
|
||||
<location filename="../../src/dialog/mainwindow.cpp" line="3580"/>
|
||||
<source>ConfirmAPPSave</source>
|
||||
<translation>你尝试关闭程序,但仍存在未保存的文件或工作区,你确定保存这些更改吗?</translation>
|
||||
</message>
|
||||
|
@ -1692,21 +1692,21 @@
|
|||
<location filename="../../src/dialog/mainwindow.cpp" line="990"/>
|
||||
<location filename="../../src/dialog/mainwindow.cpp" line="1116"/>
|
||||
<location filename="../../src/dialog/mainwindow.cpp" line="1153"/>
|
||||
<location filename="../../src/dialog/mainwindow.cpp" line="1967"/>
|
||||
<location filename="../../src/dialog/mainwindow.cpp" line="1988"/>
|
||||
<location filename="../../src/dialog/mainwindow.cpp" line="1968"/>
|
||||
<location filename="../../src/dialog/mainwindow.cpp" line="1989"/>
|
||||
<source>SaveSuccessfully</source>
|
||||
<translation>保存成功!</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../../src/dialog/mainwindow.cpp" line="1962"/>
|
||||
<location filename="../../src/dialog/mainwindow.cpp" line="1993"/>
|
||||
<location filename="../../src/dialog/mainwindow.cpp" line="1963"/>
|
||||
<location filename="../../src/dialog/mainwindow.cpp" line="1994"/>
|
||||
<source>SaveWSError</source>
|
||||
<translation>保存工作区错误!</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../../src/dialog/mainwindow.cpp" line="1950"/>
|
||||
<location filename="../../src/dialog/mainwindow.cpp" line="1997"/>
|
||||
<location filename="../../src/dialog/mainwindow.cpp" line="2036"/>
|
||||
<location filename="../../src/dialog/mainwindow.cpp" line="1951"/>
|
||||
<location filename="../../src/dialog/mainwindow.cpp" line="1998"/>
|
||||
<location filename="../../src/dialog/mainwindow.cpp" line="2037"/>
|
||||
<source>Warn</source>
|
||||
<translation>警告</translation>
|
||||
</message>
|
||||
|
@ -1716,173 +1716,173 @@
|
|||
<translation>脚本对象</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../../src/dialog/mainwindow.cpp" line="1950"/>
|
||||
<location filename="../../src/dialog/mainwindow.cpp" line="1997"/>
|
||||
<location filename="../../src/dialog/mainwindow.cpp" line="2036"/>
|
||||
<location filename="../../src/dialog/mainwindow.cpp" line="1951"/>
|
||||
<location filename="../../src/dialog/mainwindow.cpp" line="1998"/>
|
||||
<location filename="../../src/dialog/mainwindow.cpp" line="2037"/>
|
||||
<source>SourceChanged</source>
|
||||
<translation>局部打开原始文件更改!</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../../src/dialog/mainwindow.cpp" line="1957"/>
|
||||
<location filename="../../src/dialog/mainwindow.cpp" line="2004"/>
|
||||
<location filename="../../src/dialog/mainwindow.cpp" line="1958"/>
|
||||
<location filename="../../src/dialog/mainwindow.cpp" line="2005"/>
|
||||
<source>SaveSourceFileError</source>
|
||||
<translation>由于原文件更改,保存文件失败!</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../../src/dialog/mainwindow.cpp" line="2009"/>
|
||||
<location filename="../../src/dialog/mainwindow.cpp" line="2010"/>
|
||||
<source>SaveUnSuccessfully</source>
|
||||
<translation>保存失败!</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../../src/dialog/mainwindow.cpp" line="2022"/>
|
||||
<location filename="../../src/dialog/mainwindow.cpp" line="2023"/>
|
||||
<source>ChooseExportFile</source>
|
||||
<translation>请选择导出文件路径:</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../../src/dialog/mainwindow.cpp" line="2032"/>
|
||||
<location filename="../../src/dialog/mainwindow.cpp" line="2033"/>
|
||||
<source>ExportSuccessfully</source>
|
||||
<translation>导出成功!</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../../src/dialog/mainwindow.cpp" line="2043"/>
|
||||
<location filename="../../src/dialog/mainwindow.cpp" line="2044"/>
|
||||
<source>ExportSourceFileError</source>
|
||||
<translation>由于原文件更改,导出文件失败!</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../../src/dialog/mainwindow.cpp" line="2048"/>
|
||||
<location filename="../../src/dialog/mainwindow.cpp" line="2049"/>
|
||||
<source>ExportUnSuccessfully</source>
|
||||
<translation>导出失败!</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../../src/dialog/mainwindow.cpp" line="2070"/>
|
||||
<location filename="../../src/dialog/mainwindow.cpp" line="2071"/>
|
||||
<source>SaveSelSuccess</source>
|
||||
<translation>保存选区字节成功!</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../../src/dialog/mainwindow.cpp" line="2073"/>
|
||||
<location filename="../../src/dialog/mainwindow.cpp" line="2074"/>
|
||||
<source>SaveSelError</source>
|
||||
<translation>保存选区字节失败,因文件不具有可写权限!</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../../src/dialog/mainwindow.cpp" line="2100"/>
|
||||
<location filename="../../src/dialog/mainwindow.cpp" line="2285"/>
|
||||
<location filename="../../src/dialog/mainwindow.cpp" line="2101"/>
|
||||
<location filename="../../src/dialog/mainwindow.cpp" line="2286"/>
|
||||
<source>CutToClipBoard</source>
|
||||
<translation>数据已剪切到粘贴板!</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../../src/dialog/mainwindow.cpp" line="2103"/>
|
||||
<location filename="../../src/dialog/mainwindow.cpp" line="2288"/>
|
||||
<location filename="../../src/dialog/mainwindow.cpp" line="2104"/>
|
||||
<location filename="../../src/dialog/mainwindow.cpp" line="2289"/>
|
||||
<source>UnCutToClipBoard</source>
|
||||
<translation>由于保持大小限制,数据剪切到粘贴板失败!</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../../src/dialog/mainwindow.cpp" line="2117"/>
|
||||
<location filename="../../src/dialog/mainwindow.cpp" line="2302"/>
|
||||
<location filename="../../src/dialog/mainwindow.cpp" line="2118"/>
|
||||
<location filename="../../src/dialog/mainwindow.cpp" line="2303"/>
|
||||
<source>UnCopyToClipBoard</source>
|
||||
<translation>由于保持大小限制,数据剪切到复制板失败!</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../../src/dialog/mainwindow.cpp" line="2183"/>
|
||||
<location filename="../../src/dialog/mainwindow.cpp" line="2184"/>
|
||||
<source>FindFininish</source>
|
||||
<translation>查找结果完毕!</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../../src/dialog/mainwindow.cpp" line="2320"/>
|
||||
<location filename="../../src/dialog/mainwindow.cpp" line="2321"/>
|
||||
<source>PleaseInputFill</source>
|
||||
<translation>请输入填充字节值</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../../src/dialog/mainwindow.cpp" line="2339"/>
|
||||
<location filename="../../src/dialog/mainwindow.cpp" line="2340"/>
|
||||
<source>FillInputError</source>
|
||||
<translation>填充字节输入错误</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../../src/dialog/mainwindow.cpp" line="2377"/>
|
||||
<location filename="../../src/dialog/mainwindow.cpp" line="2385"/>
|
||||
<location filename="../../src/dialog/mainwindow.cpp" line="2378"/>
|
||||
<location filename="../../src/dialog/mainwindow.cpp" line="2386"/>
|
||||
<source>InputComment</source>
|
||||
<translation>请输入批注:</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../../src/dialog/mainwindow.cpp" line="2440"/>
|
||||
<location filename="../../src/dialog/mainwindow.cpp" line="2481"/>
|
||||
<location filename="../../src/dialog/mainwindow.cpp" line="3053"/>
|
||||
<location filename="../../src/dialog/mainwindow.cpp" line="2441"/>
|
||||
<location filename="../../src/dialog/mainwindow.cpp" line="2482"/>
|
||||
<location filename="../../src/dialog/mainwindow.cpp" line="3054"/>
|
||||
<source>NoSelection</source>
|
||||
<translation>没有选区,无法继续的操作!</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../../src/dialog/mainwindow.cpp" line="2477"/>
|
||||
<location filename="../../src/dialog/mainwindow.cpp" line="2478"/>
|
||||
<source>NoMetaData</source>
|
||||
<translation>无可编辑标记</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../../src/dialog/mainwindow.cpp" line="2592"/>
|
||||
<location filename="../../src/dialog/mainwindow.cpp" line="2601"/>
|
||||
<location filename="../../src/dialog/mainwindow.cpp" line="2593"/>
|
||||
<location filename="../../src/dialog/mainwindow.cpp" line="2602"/>
|
||||
<source>EmptyFindResult</source>
|
||||
<translation>没有可导出的搜索结果!</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../../src/dialog/mainwindow.cpp" line="2646"/>
|
||||
<location filename="../../src/dialog/mainwindow.cpp" line="2647"/>
|
||||
<source>SaveFindResult</source>
|
||||
<translation>导出搜索结果成功!</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../../src/dialog/mainwindow.cpp" line="2650"/>
|
||||
<location filename="../../src/dialog/mainwindow.cpp" line="2651"/>
|
||||
<source>SaveFindResultError</source>
|
||||
<translation>导出结果失败!</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../../src/dialog/mainwindow.cpp" line="2789"/>
|
||||
<location filename="../../src/dialog/mainwindow.cpp" line="2790"/>
|
||||
<source>TooManyBytesDecode</source>
|
||||
<translation>超出解码字节限制……</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../../src/dialog/mainwindow.cpp" line="2836"/>
|
||||
<location filename="../../src/dialog/mainwindow.cpp" line="2837"/>
|
||||
<source>ExportLogError</source>
|
||||
<translation>导出日志失败!</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../../src/dialog/mainwindow.cpp" line="2839"/>
|
||||
<location filename="../../src/dialog/mainwindow.cpp" line="2840"/>
|
||||
<source>ExportLogSuccess</source>
|
||||
<translation>导出日志成功,路径:</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../../src/dialog/mainwindow.cpp" line="2847"/>
|
||||
<location filename="../../src/dialog/mainwindow.cpp" line="2848"/>
|
||||
<source>ClearLogSuccess</source>
|
||||
<translation>清空日志成功!</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../../src/dialog/mainwindow.cpp" line="2903"/>
|
||||
<location filename="../../src/dialog/mainwindow.cpp" line="2904"/>
|
||||
<source>BadNetwork</source>
|
||||
<translation>无法与远程服务器的更新检查建立连接,请检查网络。</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../../src/dialog/mainwindow.cpp" line="2908"/>
|
||||
<location filename="../../src/dialog/mainwindow.cpp" line="2909"/>
|
||||
<source>NewestVersion</source>
|
||||
<translation>当前软件为最新版本</translation>
|
||||
</message>
|
||||
<message>
|
||||
<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>
|
||||
<translation>你使用的软件为老版本,建议到 Github 和 Gitee 的仓库发行版下载更新。</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../../src/dialog/mainwindow.cpp" line="2911"/>
|
||||
<location filename="../../src/dialog/mainwindow.cpp" line="2912"/>
|
||||
<source>CheckingUpdate</source>
|
||||
<translation>检查更新中……</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../../src/dialog/mainwindow.cpp" line="2966"/>
|
||||
<location filename="../../src/dialog/mainwindow.cpp" line="2967"/>
|
||||
<source>Too much opened files</source>
|
||||
<translation>打开的文件过多,无法继续操作!</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../../src/dialog/mainwindow.cpp" line="3124"/>
|
||||
<location filename="../../src/dialog/mainwindow.cpp" line="3125"/>
|
||||
<source>CopyLimit</source>
|
||||
<translation>拷贝字节超出限制</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../../src/dialog/mainwindow.cpp" line="3198"/>
|
||||
<location filename="../../src/dialog/mainwindow.cpp" line="3199"/>
|
||||
<source>ErrOpenFileBelow</source>
|
||||
<translation>打开文件出现错误(由于权限不足),如下为打开错误的文件:</translation>
|
||||
</message>
|
||||
|
@ -1938,7 +1938,7 @@
|
|||
<translation>标注</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../../src/dialog/metadialog.cpp" line="102"/>
|
||||
<location filename="../../src/dialog/metadialog.cpp" line="104"/>
|
||||
<source>NoChoose</source>
|
||||
<translation>开启选项但未设置,如不想设置请关闭!</translation>
|
||||
</message>
|
||||
|
@ -2570,7 +2570,7 @@ Do you wish to keep up to date by reloading the file?</source>
|
|||
<context>
|
||||
<name>QFoldPanel</name>
|
||||
<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>
|
||||
<translation>折叠面板</translation>
|
||||
</message>
|
||||
|
@ -2601,6 +2601,24 @@ Do you wish to keep up to date by reloading the file?</source>
|
|||
<translation>跳转(&G)</translation>
|
||||
</message>
|
||||
</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>
|
||||
<name>QJsonModel</name>
|
||||
<message>
|
||||
|
@ -2636,7 +2654,7 @@ Do you wish to keep up to date by reloading the file?</source>
|
|||
<context>
|
||||
<name>QLineChangePanel</name>
|
||||
<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>
|
||||
<translation>行修改指示面板</translation>
|
||||
</message>
|
||||
|
@ -2644,7 +2662,7 @@ Do you wish to keep up to date by reloading the file?</source>
|
|||
<context>
|
||||
<name>QLineNumberPanel</name>
|
||||
<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>
|
||||
<translation>行号面板</translation>
|
||||
</message>
|
||||
|
@ -5132,12 +5150,12 @@ Do you wish to keep up to date by reloading the file?</source>
|
|||
<context>
|
||||
<name>ShowTextDialog</name>
|
||||
<message>
|
||||
<location filename="../../src/dialog/showtextdialog.cpp" line="169"/>
|
||||
<location filename="../../src/dialog/showtextdialog.cpp" line="170"/>
|
||||
<source>General</source>
|
||||
<translation>基本</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../../src/dialog/showtextdialog.cpp" line="171"/>
|
||||
<location filename="../../src/dialog/showtextdialog.cpp" line="172"/>
|
||||
<source>Copy</source>
|
||||
<translation>复制</translation>
|
||||
</message>
|
||||
|
@ -5147,57 +5165,57 @@ Do you wish to keep up to date by reloading the file?</source>
|
|||
<translation>文本浏览</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../../src/dialog/showtextdialog.cpp" line="93"/>
|
||||
<location filename="../../src/dialog/showtextdialog.cpp" line="94"/>
|
||||
<source>TooHugeFile</source>
|
||||
<translation>文件内容过大</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../../src/dialog/showtextdialog.cpp" line="103"/>
|
||||
<location filename="../../src/dialog/showtextdialog.cpp" line="104"/>
|
||||
<source>Loading</source>
|
||||
<translation>加载中</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../../src/dialog/showtextdialog.cpp" line="103"/>
|
||||
<location filename="../../src/dialog/showtextdialog.cpp" line="104"/>
|
||||
<source>Cancel</source>
|
||||
<translation>取消</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../../src/dialog/showtextdialog.cpp" line="162"/>
|
||||
<location filename="../../src/dialog/showtextdialog.cpp" line="163"/>
|
||||
<source>Edit</source>
|
||||
<translation>编辑</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../../src/dialog/showtextdialog.cpp" line="163"/>
|
||||
<location filename="../../src/dialog/showtextdialog.cpp" line="164"/>
|
||||
<source>View</source>
|
||||
<translation>视图</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../../src/dialog/showtextdialog.cpp" line="175"/>
|
||||
<location filename="../../src/dialog/showtextdialog.cpp" line="176"/>
|
||||
<source>Find</source>
|
||||
<translation>查找</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../../src/dialog/showtextdialog.cpp" line="179"/>
|
||||
<location filename="../../src/dialog/showtextdialog.cpp" line="180"/>
|
||||
<source>Goto</source>
|
||||
<translation>跳转</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../../src/dialog/showtextdialog.cpp" line="184"/>
|
||||
<location filename="../../src/dialog/showtextdialog.cpp" line="185"/>
|
||||
<source>Encoding</source>
|
||||
<translation>编码</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../../src/dialog/showtextdialog.cpp" line="195"/>
|
||||
<location filename="../../src/dialog/showtextdialog.cpp" line="196"/>
|
||||
<source>Display</source>
|
||||
<translation>显示</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../../src/dialog/showtextdialog.cpp" line="214"/>
|
||||
<location filename="../../src/dialog/showtextdialog.cpp" line="215"/>
|
||||
<source>Scale</source>
|
||||
<translation>缩放</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../../src/dialog/showtextdialog.cpp" line="216"/>
|
||||
<location filename="../../src/dialog/showtextdialog.cpp" line="217"/>
|
||||
<source>ResetScale</source>
|
||||
<translation>重置缩放</translation>
|
||||
</message>
|
||||
|
|
|
@ -130,37 +130,21 @@ EditorView::EditorView(QWidget *parent)
|
|||
applySettings();
|
||||
}
|
||||
|
||||
EditorView::~EditorView() {
|
||||
for (auto &w : m_others) {
|
||||
m_stack->removeWidget(w);
|
||||
w->setParent(nullptr);
|
||||
}
|
||||
}
|
||||
EditorView::~EditorView() {}
|
||||
|
||||
void EditorView::registerView(WingEditorViewWidget *view) {
|
||||
void EditorView::registerView(const QString &id, WingEditorViewWidget *view) {
|
||||
Q_ASSERT(view);
|
||||
m_others << view;
|
||||
m_others.insert(id, view);
|
||||
m_stack->addWidget(view);
|
||||
}
|
||||
|
||||
void EditorView::switchView(qsizetype index) {
|
||||
if (index < 0) {
|
||||
void EditorView::switchView(const QString &id) {
|
||||
if (id.isEmpty()) {
|
||||
m_stack->setCurrentWidget(m_hexContainer);
|
||||
} else {
|
||||
m_stack->setCurrentWidget(m_others.at(index));
|
||||
}
|
||||
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));
|
||||
if (m_others.contains(id)) {
|
||||
m_stack->setCurrentWidget(m_others.value(id));
|
||||
}
|
||||
} 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; }
|
||||
|
||||
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); }
|
||||
|
||||
qsizetype EditorView::copyLimit() const { return m_hex->copyLimit(); }
|
||||
|
@ -600,20 +575,21 @@ bool EditorView::hasMeta() const {
|
|||
|
||||
void EditorView::applyPluginData(const QHash<QString, QByteArray> &data) {
|
||||
for (auto p = data.begin(); p != data.end(); p++) {
|
||||
auto plgw = std::find_if(m_others.begin(), m_others.end(),
|
||||
[=](const WingEditorViewWidget *editor) {
|
||||
return editor->id() == p.key();
|
||||
});
|
||||
if (plgw != m_others.end()) {
|
||||
(*plgw)->loadState(p.value());
|
||||
for (auto pw = m_others.constKeyValueBegin();
|
||||
pw != m_others.constKeyValueEnd(); ++pw) {
|
||||
if (pw->first == p.key()) {
|
||||
pw->second->loadState(p.value());
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
QHash<QString, QByteArray> EditorView::savePluginData() {
|
||||
QHash<QString, QByteArray> ret;
|
||||
for (auto &item : m_others) {
|
||||
ret.insert(item->id(), item->saveState());
|
||||
for (auto p = m_others.constKeyValueBegin();
|
||||
p != m_others.constKeyValueEnd(); ++p) {
|
||||
ret.insert(p->first, p->second->saveState());
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
@ -689,9 +665,11 @@ EditorView *EditorView::clone() {
|
|||
|
||||
ev->m_docType = DocumentType::Cloned;
|
||||
|
||||
for (auto &evw : m_others) {
|
||||
ev->m_others << evw->clone();
|
||||
for (auto p = m_others.constKeyValueBegin();
|
||||
p != m_others.constKeyValueEnd(); ++p) {
|
||||
ev->m_others.insert(p->first, p->second->clone());
|
||||
}
|
||||
|
||||
this->m_cloneChildren[cloneIndex] = ev;
|
||||
|
||||
connectDocSavedFlag(ev);
|
||||
|
|
|
@ -80,16 +80,13 @@ public:
|
|||
|
||||
DocumentType documentType() const;
|
||||
|
||||
WingEditorViewWidget *otherEditor(qsizetype index) const;
|
||||
|
||||
qsizetype copyLimit() const;
|
||||
|
||||
public slots:
|
||||
EditorView *clone();
|
||||
|
||||
void registerView(WingHex::WingEditorViewWidget *view);
|
||||
void switchView(qsizetype index);
|
||||
void switchView(WingEditorViewWidget *w);
|
||||
void registerView(const QString &id, WingHex::WingEditorViewWidget *view);
|
||||
void switchView(const QString &id);
|
||||
void registerQMenu(QMenu *menu);
|
||||
|
||||
FindError find(const FindDialog::Result &result);
|
||||
|
@ -149,8 +146,6 @@ private:
|
|||
void connectDocSavedFlag(EditorView *editor);
|
||||
|
||||
signals:
|
||||
void viewChanged(int index);
|
||||
|
||||
void sigFileSaved(QString filename, QString oldFileName);
|
||||
|
||||
void sigOnCutFile();
|
||||
|
@ -176,7 +171,7 @@ private:
|
|||
QHexView *m_hex = nullptr;
|
||||
QMenu *m_menu = nullptr;
|
||||
|
||||
QList<WingEditorViewWidget *> m_others;
|
||||
QHash<QString, WingEditorViewWidget *> m_others;
|
||||
QString m_fileName;
|
||||
bool m_isNewFile = true;
|
||||
QByteArray m_md5;
|
||||
|
|
|
@ -72,6 +72,7 @@ void HueColorPickerSlider::setColor(const QColor &newColor) {
|
|||
{359.0 / 360.0, redColor(colorS, colorV)}});
|
||||
|
||||
this->setValue(_color.hsvHue());
|
||||
emit colorChanged(newColor);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -47,6 +47,8 @@ void QColorPickerSlider::setRenderCheckerboard(bool renderCheckerboard) {
|
|||
}
|
||||
|
||||
void QColorPickerSlider::paintEvent(QPaintEvent *event) {
|
||||
Q_UNUSED(event);
|
||||
|
||||
QPainter painter(this);
|
||||
painter.setRenderHint(QPainter::Antialiasing);
|
||||
|
||||
|
|
|
@ -835,7 +835,7 @@ MainWindow::buildUpVisualDataDock(ads::CDockManager *dock,
|
|||
|
||||
auto efilter = new EventFilter(QEvent::DynamicPropertyChange, this);
|
||||
connect(efilter, &EventFilter::eventTriggered, this,
|
||||
[this](QObject *obj, QEvent *event) {
|
||||
[](QObject *obj, QEvent *event) {
|
||||
auto e = static_cast<QDynamicPropertyChangeEvent *>(event);
|
||||
constexpr auto ppname = "__TITLE__";
|
||||
if (e->propertyName() == QByteArray(ppname)) {
|
||||
|
@ -1446,7 +1446,7 @@ RibbonTabContent *MainWindow::buildViewPage(RibbonTabContent *tab) {
|
|||
if (editor == nullptr) {
|
||||
return;
|
||||
}
|
||||
editor->switchView(-1);
|
||||
editor->switchView({});
|
||||
}));
|
||||
m_toolBtneditors.insert(ToolButtonIndex::EDITOR_WINS,
|
||||
addPannelAction(pannel, QStringLiteral("win"),
|
||||
|
@ -1756,26 +1756,27 @@ void MainWindow::installPluginEditorWidgets() {
|
|||
auto menu = m_toolBtneditors.value(EDITOR_WINS)->menu();
|
||||
for (auto p = m_editorViewWidgets.begin(); p != m_editorViewWidgets.end();
|
||||
++p) {
|
||||
for (auto &w : p.value()) {
|
||||
for (auto &wctor : p.value()) {
|
||||
qApp->processEvents();
|
||||
if (names.contains(w->id())) {
|
||||
if (names.contains(wctor->id())) {
|
||||
log.critical(tr("Plugin %1 contains a duplicate ID (%2) that "
|
||||
"is already registered by plugin %3")
|
||||
.arg(p.key()->pluginName(), w->id(),
|
||||
names.value(w->id())->pluginName()));
|
||||
.arg(p.key()->pluginName(), wctor->id(),
|
||||
names.value(wctor->id())->pluginName()));
|
||||
continue;
|
||||
}
|
||||
|
||||
menu->addAction(newAction(w->icon(), w->name(), [this, w] {
|
||||
auto editor = currentEditor();
|
||||
if (editor == nullptr) {
|
||||
return;
|
||||
}
|
||||
editor->switchView(w);
|
||||
}));
|
||||
menu->addAction(
|
||||
newAction(wctor->icon(), wctor->name(), [this, wctor] {
|
||||
auto editor = currentEditor();
|
||||
if (editor == nullptr) {
|
||||
return;
|
||||
}
|
||||
editor->switchView(wctor->id());
|
||||
}));
|
||||
|
||||
names.insert(w->id(), p.key());
|
||||
m_editorViewWidgetsBuffer.append(w);
|
||||
names.insert(wctor->id(), p.key());
|
||||
m_editorViewWidgetsBuffer.append(wctor);
|
||||
}
|
||||
qApp->processEvents();
|
||||
}
|
||||
|
@ -2428,7 +2429,7 @@ void MainWindow::on_metadata() {
|
|||
meta->beginMarco(QStringLiteral("MetaData"));
|
||||
for (int i = 0; i < total; ++i) {
|
||||
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(),
|
||||
m.backGroundColor(), m.comment());
|
||||
}
|
||||
|
@ -2971,7 +2972,7 @@ bool MainWindow::newOpenFileSafeCheck() {
|
|||
|
||||
void MainWindow::registerEditorView(EditorView *editor) {
|
||||
for (auto &w : m_editorViewWidgetsBuffer) {
|
||||
editor->registerView(w);
|
||||
editor->registerView(w->id(), w->create(editor));
|
||||
}
|
||||
for (auto &m : m_hexContextMenu) {
|
||||
editor->registerQMenu(m);
|
||||
|
@ -3022,7 +3023,7 @@ void MainWindow::connectEditorView(EditorView *editor) {
|
|||
meta->beginMarco(QStringLiteral("OnMetaData"));
|
||||
for (int i = 0; i < total; ++i) {
|
||||
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(),
|
||||
m.backGroundColor(), m.comment());
|
||||
}
|
||||
|
|
|
@ -18,7 +18,6 @@
|
|||
#ifndef MAINWINDOW_H
|
||||
#define MAINWINDOW_H
|
||||
|
||||
#include "class/eventfilter.h"
|
||||
#include "dialog/splashdialog.h"
|
||||
#include "framelessmainwindow.h"
|
||||
|
||||
|
@ -284,7 +283,15 @@ private:
|
|||
QMenu *menu = nullptr) {
|
||||
Q_ASSERT(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->setToolTip(
|
||||
shortcut.isEmpty()
|
||||
|
@ -301,6 +308,9 @@ private:
|
|||
|
||||
a->setMenu(menu);
|
||||
if (menu) {
|
||||
#if QT_VERSION > QT_VERSION_CHECK(6, 6, 0)
|
||||
a->setArrowType(Qt::DownArrow);
|
||||
#endif
|
||||
a->setPopupMode(QToolButton::InstantPopup);
|
||||
}
|
||||
connect(a, &QToolButton::clicked, this, slot);
|
||||
|
@ -551,10 +561,12 @@ private:
|
|||
// for plugin system use
|
||||
QHash<QString, RibbonTabContent *> m_ribbonMaps;
|
||||
QList<QMenu *> m_hexContextMenu;
|
||||
QMap<IWingPlugin *, QList<WingEditorViewWidget *>> m_editorViewWidgets;
|
||||
QMap<IWingPlugin *, QList<QSharedPointer<WingEditorViewWidget::Creator>>>
|
||||
m_editorViewWidgets;
|
||||
QHash<SettingPage *, bool> m_settingPages;
|
||||
QList<PluginPage *> m_plgPages;
|
||||
QList<WingEditorViewWidget *> m_editorViewWidgetsBuffer;
|
||||
QList<QSharedPointer<WingEditorViewWidget::Creator>>
|
||||
m_editorViewWidgetsBuffer;
|
||||
|
||||
ads::CDockAreaWidget *m_leftViewArea = nullptr;
|
||||
ads::CDockAreaWidget *m_rightViewArea = nullptr; // 该值使用时必不为空
|
||||
|
|
|
@ -41,7 +41,7 @@ MetaDialog::MetaDialog(QWidget *parent)
|
|||
iforeground->setEnabled(false);
|
||||
layout->addWidget(iforeground);
|
||||
connect(iforeground, &HueColorPickerSlider::colorChanged, this,
|
||||
[=](QColor color) { _foreground = color; });
|
||||
[=](QColor color) { _foreground = color.toRgb(); });
|
||||
_foreground = iforeground->color();
|
||||
|
||||
layout->addSpacing(2);
|
||||
|
@ -56,7 +56,7 @@ MetaDialog::MetaDialog(QWidget *parent)
|
|||
ibackground->setEnabled(false);
|
||||
layout->addWidget(ibackground);
|
||||
connect(ibackground, &HueColorPickerSlider::colorChanged, this,
|
||||
[=](QColor color) { _background = color; });
|
||||
[=](QColor color) { _background = color.toRgb(); });
|
||||
_background = ibackground->color();
|
||||
|
||||
layout->addSpacing(2);
|
||||
|
@ -93,10 +93,12 @@ MetaDialog::MetaDialog(QWidget *parent)
|
|||
}
|
||||
|
||||
void MetaDialog::on_accept() {
|
||||
if ((cforeground->isChecked() &&
|
||||
(!_foreground.isValid() || _foreground.rgba() == 0)) ||
|
||||
if ((!cforeground->isChecked() && !cbackground->isChecked() &&
|
||||
!ccomment->isChecked()) ||
|
||||
(cforeground->isChecked() &&
|
||||
(!_foreground.isValid() || _foreground.alpha() == 0)) ||
|
||||
(cbackground->isChecked() &&
|
||||
(!_background.isValid() || _background.rgba() == 0)) ||
|
||||
(!_background.isValid() || _background.alpha() == 0)) ||
|
||||
(ccomment->isChecked() && m_comment->text().trimmed().length() == 0)) {
|
||||
Toast::toast(this->parentWidget(),
|
||||
NAMEICONRES(QStringLiteral("metadata")), tr("NoChoose"));
|
||||
|
|
|
@ -136,8 +136,17 @@ private:
|
|||
const QKeySequence &shortcut = QKeySequence(),
|
||||
QMenu *menu = nullptr) {
|
||||
Q_ASSERT(pannel);
|
||||
Q_ASSERT(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);
|
||||
setPannelActionToolTip(a, shortcut);
|
||||
|
||||
|
@ -149,6 +158,9 @@ private:
|
|||
|
||||
a->setMenu(menu);
|
||||
if (menu) {
|
||||
#if QT_VERSION > QT_VERSION_CHECK(6, 6, 0)
|
||||
a->setArrowType(Qt::DownArrow);
|
||||
#endif
|
||||
a->setPopupMode(QToolButton::InstantPopup);
|
||||
}
|
||||
connect(a, &QToolButton::clicked, this, slot);
|
||||
|
|
|
@ -73,6 +73,7 @@ void ShowTextDialog::load(QHexBuffer *buffer, const QString encoding,
|
|||
qsizetype offset, qsizetype size) {
|
||||
auto editor = m_edit->editor();
|
||||
editor->blockSignals(true);
|
||||
editor->setCodec(encoding);
|
||||
load(buffer, offset, size);
|
||||
editor->blockSignals(false);
|
||||
}
|
||||
|
|
|
@ -464,15 +464,24 @@ class WingEditorViewWidget : public QWidget {
|
|||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit WingEditorViewWidget(QWidget *parent = nullptr)
|
||||
: QWidget(parent) {}
|
||||
class Creator {
|
||||
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:
|
||||
virtual QIcon icon() const = 0;
|
||||
|
||||
virtual QString name() const = 0;
|
||||
|
||||
virtual QString id() const = 0;
|
||||
explicit WingEditorViewWidget(QWidget *parent = nullptr)
|
||||
: QWidget(parent) {}
|
||||
|
||||
signals:
|
||||
void docSaved(bool saved);
|
||||
|
@ -601,7 +610,8 @@ public:
|
|||
return {};
|
||||
}
|
||||
virtual QList<PluginPage *> registeredPages() const { return {}; }
|
||||
virtual QList<WingEditorViewWidget *> registeredEditorViewWidgets() const {
|
||||
virtual QList<QSharedPointer<WingEditorViewWidget::Creator>>
|
||||
registeredEditorViewWidgets() const {
|
||||
return {};
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue