From f40d9525b06422f039c9bb47999e24c6633cea70 Mon Sep 17 00:00:00 2001 From: wingsummer <1326224942@qq.com> Date: Sun, 13 Jul 2025 22:06:34 +0800 Subject: [PATCH] =?UTF-8?q?refactor:=20=E9=87=8D=E6=9E=84=E5=8D=81?= =?UTF-8?q?=E5=85=AD=E8=BF=9B=E5=88=B6=E7=BC=96=E8=BE=91=E5=99=A8=E7=9A=84?= =?UTF-8?q?=E5=90=8E=E7=AB=AF=EF=BC=9B=E6=9B=B4=E6=9A=97=E9=BB=91=E7=9A=84?= =?UTF-8?q?=E6=9A=97=E8=89=B2=E4=B8=BB=E9=A2=98=EF=BC=9B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- 3rdparty/QHexView/QHexEdit2/chunks.cpp | 307 +++++---- 3rdparty/QHexView/QHexEdit2/chunks.h | 90 +-- .../QHexView/document/buffer/qfilebuffer.cpp | 20 +- 3rdparty/QHexView/document/qhexdocument.cpp | 30 +- 3rdparty/QHexView/document/qhexdocument.h | 32 +- TestPlugin/lang/TestPlugin_zh_CN.ts | 52 +- TestPlugin/testplugin.cpp | 79 +-- WingPlugin | 2 +- lang/zh_CN/winghex_zh_CN.ts | 648 +++++++++--------- lang/zh_TW/winghex_zh_TW.ts | 648 +++++++++--------- src/class/wingcstruct.cpp | 6 +- src/control/editorview.cpp | 22 +- src/control/editorview.h | 2 +- src/control/gotowidget.cpp | 129 +--- src/dialog/mainwindow.cpp | 24 +- theme/dark/stylesheet.qss | 92 +-- 16 files changed, 1075 insertions(+), 1108 deletions(-) diff --git a/3rdparty/QHexView/QHexEdit2/chunks.cpp b/3rdparty/QHexView/QHexEdit2/chunks.cpp index 6c94731..51fc8c1 100644 --- a/3rdparty/QHexView/QHexEdit2/chunks.cpp +++ b/3rdparty/QHexView/QHexEdit2/chunks.cpp @@ -1,25 +1,29 @@ -/*============================================================================== -** Copyright (C) 2024-2027 WingSummer -** -** This program is free software: you can redistribute it and/or modify it under -** the terms of the GNU Affero General Public License as published by the Free -** Software Foundation, version 3. -** -** This program is distributed in the hope that it will be useful, but WITHOUT -** ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS -** FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more -** details. -** -** You should have received a copy of the GNU Affero General Public License -** along with this program. If not, see . -** -** The original License is LGPL from Andres6936/QHexEdit. I have modified a lot -** so I decide to change the Open Source License. You can use the original -** library under LGPL. Thanks for Andres6936's efforts. -** ============================================================================= -*/ +/* + * QHexEdit is a Hex Editor Widget for the Qt Framework + * Copyright (C) 2010-2025 Winfried Simon + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, see + * https://www.gnu.org/licenses/ + */ #include "chunks.h" +#include + +#include + +#define NORMAL 0 +#define HIGHLIGHTED 1 #define BUFFER_SIZE 0x10000 #define CHUNK_SIZE 0x1000 @@ -29,38 +33,43 @@ // ***************************************** Constructors and file settings -Chunks::Chunks(QObject *parent) : QObject(parent) {} +Chunks::Chunks(QObject *parent) : QObject(parent) { + QBuffer *buf = new QBuffer(this); + setIODevice(buf); +} Chunks::Chunks(QIODevice *ioDevice, QObject *parent) : QObject(parent) { setIODevice(ioDevice); } -Chunks::~Chunks() {} - bool Chunks::setIODevice(QIODevice *ioDevice) { - if (ioDevice && ioDevice->isOpen()) { + _ioDevice = ioDevice; + bool ok = _ioDevice->open(QIODevice::ReadOnly); + if (ok) // Try to open IODevice + { ioDevice->setParent(this); - _size = ioDevice->size(); - _ioDevice = ioDevice; - } else { - return false; + _size = _ioDevice->size(); + _ioDevice->close(); + } else // Fallback is an empty buffer + { + QBuffer *buf = new QBuffer(this); + _ioDevice = buf; + _size = 0; } _chunks.clear(); - _pos = 0; - return true; + return ok; } // ***************************************** Getting data out of Chunks -QByteArray Chunks::data(qsizetype pos, qsizetype maxSize) { - qsizetype ioDelta = 0; - qsizetype chunkIdx = 0; +QByteArray Chunks::data(qint64 pos, qint64 maxSize) const { + qint64 ioDelta = 0; + int chunkIdx = 0; Chunk chunk; QByteArray buffer; // Do some checks and some arrangements - if (pos >= _size) return buffer; @@ -69,8 +78,10 @@ QByteArray Chunks::data(qsizetype pos, qsizetype maxSize) { else if ((pos + maxSize) > _size) maxSize = _size - pos; + _ioDevice->open(QIODevice::ReadOnly); + while (maxSize > 0) { - chunk.absPos = std::numeric_limits::max(); + chunk.absPos = LLONG_MAX; bool chunksLoopOngoing = true; while ((chunkIdx < _chunks.count()) && chunksLoopOngoing) { // In this section, we track changes before our required data and @@ -84,16 +95,16 @@ QByteArray Chunks::data(qsizetype pos, qsizetype maxSize) { else { chunkIdx += 1; qint64 count; - qint64 chunkOfs = qint64(pos - chunk.absPos); - if (maxSize > (chunk.data.size() - chunkOfs)) { - count = qint64(chunk.data.size()) - chunkOfs; - ioDelta += CHUNK_SIZE - quint64(chunk.data.size()); + qint64 chunkOfs = pos - chunk.absPos; + if (maxSize > ((qint64)chunk.data.size() - chunkOfs)) { + count = (qint64)chunk.data.size() - chunkOfs; + ioDelta += CHUNK_SIZE - chunk.data.size(); } else count = maxSize; if (count > 0) { - buffer += chunk.data.mid(int(chunkOfs), int(count)); + buffer += chunk.data.mid(chunkOfs, (int)count); maxSize -= count; - pos += quint64(count); + pos += count; } } } @@ -104,7 +115,7 @@ QByteArray Chunks::data(qsizetype pos, qsizetype maxSize) { qint64 byteCount; QByteArray readBuffer; - if (chunk.absPos - pos > qsizetype(maxSize)) + if ((chunk.absPos - pos) > maxSize) byteCount = maxSize; else byteCount = chunk.absPos - pos; @@ -113,134 +124,175 @@ QByteArray Chunks::data(qsizetype pos, qsizetype maxSize) { _ioDevice->seek(pos + ioDelta); readBuffer = _ioDevice->read(byteCount); buffer += readBuffer; - pos += quint64(readBuffer.size()); + pos += readBuffer.size(); } } - + _ioDevice->close(); return buffer; } -bool Chunks::write(QIODevice *iODevice, qsizetype pos, qsizetype count) { +bool Chunks::write(QIODevice *iODevice, qint64 pos, qint64 count) { if (count == -1) count = _size; - - bool ok = iODevice->isOpen() && iODevice->isWritable(); - if (ok) { - for (auto idx = pos; idx < qsizetype(count); idx += BUFFER_SIZE) { - QByteArray ba = data(idx, BUFFER_SIZE); - iODevice->write(ba); + if (iODevice->isOpen()) { + if (iODevice->isWritable()) { + for (qint64 idx = pos; idx < count; idx += BUFFER_SIZE) { + QByteArray ba = data(idx, BUFFER_SIZE); + iODevice->write(ba); + } + return true; } + return false; + } else { + bool ok = iODevice->open(QIODevice::WriteOnly); + if (ok) { + for (qint64 idx = pos; idx < count; idx += BUFFER_SIZE) { + QByteArray ba = data(idx, BUFFER_SIZE); + iODevice->write(ba); + } + iODevice->close(); + } + return ok; } - return ok; } // ***************************************** Search API -qsizetype Chunks::indexOf(const QByteArray &ba, qsizetype from) { - qsizetype result = -1; +qint64 Chunks::indexOf(const QByteArray &ba, qint64 from) const { + qint64 result = -1; QByteArray buffer; - for (auto pos = from; (pos < _size) && (result < 0); pos += BUFFER_SIZE) { + for (qint64 pos = from; (pos < _size) && (result < 0); pos += BUFFER_SIZE) { buffer = data(pos, BUFFER_SIZE + ba.size() - 1); int findPos = buffer.indexOf(ba); if (findPos >= 0) - result = pos + findPos; + result = pos + (qint64)findPos; } return result; } -qsizetype Chunks::lastIndexOf(const QByteArray &ba, qsizetype from) { +qint64 Chunks::lastIndexOf(const QByteArray &ba, qint64 from) const { qint64 result = -1; QByteArray buffer; - for (auto pos = from; (pos > 0) && (result < 0); pos -= BUFFER_SIZE) { - auto sPos = pos - BUFFER_SIZE - ba.size() + 1; - /*if (sPos < 0) - sPos = 0;*/ + for (qint64 pos = from; (pos > 0) && (result < 0); pos -= BUFFER_SIZE) { + qint64 sPos = pos - BUFFER_SIZE - (qint64)ba.size() + 1; + if (sPos < 0) + sPos = 0; buffer = data(sPos, pos - sPos); - auto findPos = buffer.lastIndexOf(ba); + int findPos = buffer.lastIndexOf(ba); if (findPos >= 0) - result = sPos + findPos; + result = sPos + (qint64)findPos; } return result; } // ***************************************** Char manipulations -bool Chunks::insert(qsizetype pos, char b) { - if (pos > _size) +bool Chunks::insert(qint64 pos, char b) { + return insert(pos, QByteArray(1, b)); +} + +bool Chunks::overwrite(qint64 pos, char b) { + return overwrite(pos, QByteArray(1, b)); +} + +bool Chunks::removeAt(qint64 pos) { return remove(pos, 1); } + +bool Chunks::insert(qint64 pos, const QByteArray &ba) { + if ((pos < 0) || (pos > _size)) return false; - qsizetype chunkIdx; - if (pos == _size) { + + if (ba.isEmpty()) { + return true; + } + + auto length = ba.length(); + int chunkIdx; + if (pos == _size) chunkIdx = getChunkIndex(pos - 1); - } else + else chunkIdx = getChunkIndex(pos); - auto posInBa = pos - _chunks[chunkIdx].absPos; - _chunks[chunkIdx].data.insert(int(posInBa), b); - _chunks[chunkIdx].dataChanged.insert(int(posInBa), char(1)); - for (auto idx = chunkIdx + 1; idx < _chunks.size(); idx++) - _chunks[idx].absPos += 1; - _size += 1; - _pos = pos; - return true; -} - -bool Chunks::overwrite(qsizetype pos, char b) { - if (pos >= _size) - return false; - auto chunkIdx = getChunkIndex(pos); - auto posInBa = pos - _chunks[chunkIdx].absPos; - _chunks[chunkIdx].data[int(posInBa)] = b; - _chunks[chunkIdx].dataChanged[int(posInBa)] = char(1); - _pos = pos; - return true; -} - -bool Chunks::removeAt(qsizetype pos) { - if (pos >= _size) - return false; - auto chunkIdx = getChunkIndex(pos); - auto posInBa = pos - _chunks[chunkIdx].absPos; - _chunks[chunkIdx].data.remove(int(posInBa), 1); - _chunks[chunkIdx].dataChanged.remove(int(posInBa), 1); + qint64 posInBa = pos - _chunks[chunkIdx].absPos; + _chunks[chunkIdx].data.insert(posInBa, ba); for (int idx = chunkIdx + 1; idx < _chunks.size(); idx++) - _chunks[idx].absPos -= 1; - _size -= 1; - _pos = pos; + _chunks[idx].absPos += length; + _size += length; + return true; +} + +bool Chunks::overwrite(qint64 pos, const QByteArray &ba) { + if ((pos < 0) || (pos >= _size)) + return false; + int chunkIdx = getChunkIndex(pos); + + auto &chunk = _chunks[chunkIdx]; + qint64 posInBa = pos - chunk.absPos; + + auto length = ba.length(); + auto clen = chunk.data.size(); + auto dist = length + posInBa - clen; + + if (dist <= 0) { + chunk.data.replace(posInBa, length, ba); + } else { + auto len = clen - posInBa; + chunk.data.replace(posInBa, len, ba.left(len)); + if (!overwrite(pos + clen, ba.right(dist))) { + return false; + } + } + + return true; +} + +bool Chunks::remove(qint64 pos, qint64 length) { + if ((pos < 0) || (pos >= _size)) + return false; + int chunkIdx = getChunkIndex(pos); + + auto &chunk = _chunks[chunkIdx]; + qint64 posInBa = pos - chunk.absPos; + + auto clen = chunk.data.size(); + auto dist = length + posInBa - clen; + + if (dist <= 0) { + chunk.data.remove(posInBa, length); + for (int idx = chunkIdx + 1; idx < _chunks.size(); idx++) + _chunks[idx].absPos += length; + _size -= length; + } else { + auto len = clen - posInBa; + chunk.data.remove(posInBa, len); + for (int idx = chunkIdx + 1; idx < _chunks.size(); idx++) + _chunks[idx].absPos -= len; + _size -= len; + + if (!remove(pos + clen, dist)) { + return false; + } + } + return true; } // ***************************************** Utility functions -char Chunks::operator[](qsizetype pos) { - auto d = data(pos, 1); - if (d.isEmpty()) - return '0'; - return d.at(0); -} +char Chunks::at(qint64 pos) const { return data(pos, 1).at(0); } -qsizetype Chunks::pos() { return _pos; } +char Chunks::operator[](qint64 pos) const { return this->at(pos); } -qsizetype Chunks::size() { return _size; } +qint64 Chunks::size() const { return _size; } -qsizetype Chunks::getChunkIndex(qsizetype absPos) { - // This routine checks, if there is already a copied chunk available. If so, +int Chunks::getChunkIndex(qint64 absPos) { + // This routine checks, if there is already a copied chunk available. If os, // it returns a reference to it. If there is no copied chunk available, // original data will be copied into a new chunk. - qsizetype foundIdx = -1; - qsizetype insertIdx = 0; - qsizetype ioDelta = 0; - - // fix the bug by wingsummer - if (absPos < 0) { - Chunk newChunk; - newChunk.data = QByteArray(CHUNK_SIZE, 0); - newChunk.absPos = 0; - newChunk.dataChanged = nullptr; - _chunks.insert(insertIdx, newChunk); - return insertIdx; - } + int foundIdx = -1; + int insertIdx = 0; + qint64 ioDelta = 0; for (int idx = 0; idx < _chunks.size(); idx++) { Chunk chunk = _chunks[idx]; @@ -259,14 +311,17 @@ qsizetype Chunks::getChunkIndex(qsizetype absPos) { if (foundIdx == -1) { Chunk newChunk; - qsizetype readAbsPos = absPos - ioDelta; - qsizetype readPos = (readAbsPos & READ_CHUNK_MASK); - _ioDevice->seek(qint64(readPos)); + qint64 readAbsPos = absPos - ioDelta; + qint64 readPos = (readAbsPos & READ_CHUNK_MASK); + _ioDevice->open(QIODevice::ReadOnly); + _ioDevice->seek(readPos); newChunk.data = _ioDevice->read(CHUNK_SIZE); + _ioDevice->close(); newChunk.absPos = absPos - (readAbsPos - readPos); - newChunk.dataChanged = QByteArray(newChunk.data.size(), char(0)); _chunks.insert(insertIdx, newChunk); foundIdx = insertIdx; } return foundIdx; } + +QIODevice *Chunks::ioDevice() const { return _ioDevice; } diff --git a/3rdparty/QHexView/QHexEdit2/chunks.h b/3rdparty/QHexView/QHexEdit2/chunks.h index 624f0ce..a1eac4d 100644 --- a/3rdparty/QHexView/QHexEdit2/chunks.h +++ b/3rdparty/QHexView/QHexEdit2/chunks.h @@ -1,23 +1,21 @@ -/*============================================================================== -** Copyright (C) 2024-2027 WingSummer -** -** This program is free software: you can redistribute it and/or modify it under -** the terms of the GNU Affero General Public License as published by the Free -** Software Foundation, version 3. -** -** This program is distributed in the hope that it will be useful, but WITHOUT -** ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS -** FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more -** details. -** -** You should have received a copy of the GNU Affero General Public License -** along with this program. If not, see . -** -** The original License is LGPL from Andres6936/QHexEdit. I have modified a lot -** so I decide to change the Open Source License. You can use the original -** library under LGPL. Thanks for Andres6936's efforts. -** ============================================================================= -*/ +/* + * QHexEdit is a Hex Editor Widget for the Qt Framework + * Copyright (C) 2010-2025 Winfried Simon + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, see + * https://www.gnu.org/licenses/ + */ #ifndef CHUNKS_H #define CHUNKS_H @@ -40,49 +38,59 @@ * */ -#include -#include +// I (wingsummer) made some modifications for supporting QByteArray +// manipulations, great thanks for Simsys's effort! + +#include +#include +#include struct Chunk { QByteArray data; - QByteArray dataChanged; - qsizetype absPos; + qint64 absPos; }; class Chunks : public QObject { Q_OBJECT + public: // Constructors and file settings - Chunks(QObject *parent = nullptr); - Chunks(QIODevice *ioDevice, QObject *parent); - - ~Chunks(); + explicit Chunks(QObject *parent); + explicit Chunks(QIODevice *ioDevice, QObject *parent); +public: + QIODevice *ioDevice() const; bool setIODevice(QIODevice *ioDevice); // Getting data out of Chunks - QByteArray data(qsizetype pos = 0, qsizetype maxSize = -1); - bool write(QIODevice *iODevice, qsizetype pos = 0, qsizetype count = -1); + QByteArray data(qint64 pos = 0, qint64 count = -1) const; + bool write(QIODevice *iODevice, qint64 pos = 0, qint64 count = -1); // Search API - qsizetype indexOf(const QByteArray &ba, qsizetype from); - qsizetype lastIndexOf(const QByteArray &ba, qsizetype from); + qint64 indexOf(const QByteArray &ba, qint64 from) const; + qint64 lastIndexOf(const QByteArray &ba, qint64 from) const; // Char manipulations - bool insert(qsizetype pos, char b); - bool overwrite(qsizetype pos, char b); - bool removeAt(qsizetype pos); + bool insert(qint64 pos, char b); + bool overwrite(qint64 pos, char b); + bool removeAt(qint64 pos); + + // QByteArray manipulations by wingsummer + bool insert(qint64 pos, const QByteArray &ba); + bool overwrite(qint64 pos, const QByteArray &ba); + bool remove(qint64 pos, qint64 length); // Utility functions - char operator[](qsizetype pos); - qsizetype pos(); - qsizetype size(); + char at(qint64 pos) const; // by wingsummer + char operator[](qint64 pos) const; + qint64 size() const; + +private: + int getChunkIndex(qint64 absPos); private: - qsizetype getChunkIndex(qsizetype absPos); QIODevice *_ioDevice; - qsizetype _pos; - qsizetype _size; + qint64 _size; QList _chunks; }; diff --git a/3rdparty/QHexView/document/buffer/qfilebuffer.cpp b/3rdparty/QHexView/document/buffer/qfilebuffer.cpp index 48ed8ef..8244731 100644 --- a/3rdparty/QHexView/document/buffer/qfilebuffer.cpp +++ b/3rdparty/QHexView/document/buffer/qfilebuffer.cpp @@ -18,28 +18,24 @@ #include "QHexEdit2/chunks.h" QFileBuffer::QFileBuffer(QObject *parent) : QHexBuffer(parent) { - _chunks = new Chunks(parent); + _chunks = new Chunks(this); } QFileBuffer::~QFileBuffer() {} uchar QFileBuffer::at(qsizetype idx) { - auto data = _chunks->data(idx, 1); - return uchar(data[0]); + auto data = _chunks->at(idx); + return uchar(data); } qsizetype QFileBuffer::length() const { return _chunks->size(); } void QFileBuffer::insert(qsizetype offset, const QByteArray &data) { - for (int i = 0; i < data.length(); i++) { - _chunks->insert(offset + i, data.at(i)); - } + _chunks->insert(offset, data); } void QFileBuffer::remove(qsizetype offset, qsizetype length) { - for (uint i = 0; i < uint(length); i++) { - _chunks->removeAt(offset + i); - } + _chunks->remove(offset, length); } QByteArray QFileBuffer::read(qsizetype offset, qsizetype length) { @@ -47,7 +43,11 @@ QByteArray QFileBuffer::read(qsizetype offset, qsizetype length) { } bool QFileBuffer::read(QIODevice *device) { - return _chunks->setIODevice(device); + auto d = _chunks->ioDevice(); + auto ret = _chunks->setIODevice(device); + d->setParent(nullptr); + d->deleteLater(); + return ret; } void QFileBuffer::write(QIODevice *device) { _chunks->write(device); } diff --git a/3rdparty/QHexView/document/qhexdocument.cpp b/3rdparty/QHexView/document/qhexdocument.cpp index 0df0683..51fa729 100644 --- a/3rdparty/QHexView/document/qhexdocument.cpp +++ b/3rdparty/QHexView/document/qhexdocument.cpp @@ -617,6 +617,7 @@ QHexDocument::QHexDocument(QHexBuffer *buffer, bool readonly) : QObject(nullptr), m_baseaddress(0), m_readonly(false), m_keepsize(false), m_islocked(false) { + buffer->setParent(this); m_buffer = buffer; m_areaindent = DEFAULT_AREA_IDENTATION; m_hexlinewidth = DEFAULT_HEX_LINE_LENGTH; @@ -874,28 +875,13 @@ qsizetype QHexDocument::findPreviousExt(qsizetype begin, return findPreviousExt(begin, patterns); } -QHexDocument *QHexDocument::fromLargeFile(const QString &filename, - bool readonly) { - - auto f = new QFile; - if (!filename.isEmpty()) { - f->setFileName(filename); - QHexBuffer *hexbuffer = new QFileBuffer(); - if (f->open(readonly ? QFile::ReadOnly : QFile::ReadWrite) && - hexbuffer->read(f)) { - return new QHexDocument(hexbuffer, - readonly); // modified by wingsummer - } else { - delete hexbuffer; - } - } else { - delete f; - return new QHexDocument(new QFileBuffer(), readonly); - } - - return nullptr; -} - QHexBuffer *QHexDocument::buffer() const { return m_buffer; } +void QHexDocument::setBuffer(QHexBuffer *buffer) { + if (buffer) { + m_buffer->deleteLater(); + m_buffer = buffer; + } +} + QUndoStack *QHexDocument::undoStack() const { return m_undostack; } diff --git a/3rdparty/QHexView/document/qhexdocument.h b/3rdparty/QHexView/document/qhexdocument.h index cee23d0..0e5d145 100644 --- a/3rdparty/QHexView/document/qhexdocument.h +++ b/3rdparty/QHexView/document/qhexdocument.h @@ -237,10 +237,9 @@ public: template static QHexDocument *fromMemory(const QByteArray &ba, bool readonly = false); - static QHexDocument *fromLargeFile(const QString &filename, - bool readonly = false); QHexBuffer *buffer() const; + void setBuffer(QHexBuffer *buffer); QUndoStack *undoStack() const; @@ -304,7 +303,6 @@ QHexDocument *QHexDocument::fromDevice(QIODevice *iodevice, bool readonly) { if (!iodevice->isOpen()) { needsclose = true; - iodevice->open(QIODevice::ReadOnly); } QHexBuffer *hexbuffer = new T(); @@ -314,6 +312,9 @@ QHexDocument *QHexDocument::fromDevice(QIODevice *iodevice, bool readonly) { return new QHexDocument(hexbuffer, readonly); } else { + if (needsclose) + iodevice->close(); + delete hexbuffer; } @@ -322,17 +323,24 @@ QHexDocument *QHexDocument::fromDevice(QIODevice *iodevice, bool readonly) { template QHexDocument *QHexDocument::fromFile(QString filename, bool readonly) { - QFile f; - QHexDocument *doc; - if (filename.length()) { - f.setFileName(filename); - f.open(QFile::ReadOnly); - doc = QHexDocument::fromDevice(&f, readonly); - f.close(); + auto f = new QFile; + if (!filename.isEmpty()) { + f->setFileName(filename); + QHexBuffer *hexbuffer = new T(); + if (f->open(readonly ? QFile::ReadOnly : QFile::ReadWrite)) { + f->close(); + if (hexbuffer->read(f)) { + // modified by wingsummer + return new QHexDocument(hexbuffer, readonly); + } + } else { + delete hexbuffer; + } } else { - doc = new QHexDocument(new T(), readonly); + delete f; + return new QHexDocument(new T(), readonly); } - return doc; + return nullptr; } template diff --git a/TestPlugin/lang/TestPlugin_zh_CN.ts b/TestPlugin/lang/TestPlugin_zh_CN.ts index b35a3a5..1a522c9 100644 --- a/TestPlugin/lang/TestPlugin_zh_CN.ts +++ b/TestPlugin/lang/TestPlugin_zh_CN.ts @@ -269,60 +269,60 @@ TestPlugin - + Test 测试 - - - - + + + + TestPlugin 测试插件 - + Button - 按钮 - - + Click 点击 - + A Test Plugin for WingHexExplorer2. 一个用来测试羽云十六进制编辑器2的插件 - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + InvalidParamsCount 无效参数个数 - - + + InvalidParam 非法参数 - + AllocArrayFailed 分配数组失败 diff --git a/TestPlugin/testplugin.cpp b/TestPlugin/testplugin.cpp index 378864b..ed64e47 100644 --- a/TestPlugin/testplugin.cpp +++ b/TestPlugin/testplugin.cpp @@ -58,7 +58,6 @@ bool TestPlugin::init(const std::unique_ptr &set) { _tform->setMaximumHeight(500); using TBInfo = WingHex::WingRibbonToolBoxInfo; - TBInfo::RibbonCatagories cats; auto tb = new QToolButton; // 这里有一个约定,对于含有图片的,前缀应为:/images/插件的 PUID @@ -74,61 +73,42 @@ bool TestPlugin::init(const std::unique_ptr &set) { } }); - { - WingHex::WingRibbonToolBoxInfo rtinfo; - rtinfo.catagory = cats.PLUGIN; + QIcon btnIcon(QStringLiteral(":/images/TestPlugin/images/btn.png")); + + _rtbinfo << createRibbonToolBox(WingHex::WingRibbonCatagories::PLUGIN, + createToolBox(tr("TestPlugin"), tb)); + + auto rtb = + createRibbonToolBox(QStringLiteral("TestPlugin"), tr("TestPlugin")); + for (int i = 0; i < 3; ++i) { TBInfo::Toolbox tbtb; - tbtb.name = tr("TestPlugin"); - tbtb.tools = {tb}; - rtinfo.toolboxs = {tbtb}; - _rtbinfo.append(rtinfo); - } - - { - WingHex::WingRibbonToolBoxInfo rtinfo; - rtinfo.catagory = QStringLiteral("TestPlugin"); - rtinfo.displayName = tr("TestPlugin"); - - QIcon btnIcon(QStringLiteral(":/images/TestPlugin/images/btn.png")); - for (int i = 0; i < 3; ++i) { - TBInfo::Toolbox tbtb; - tbtb.name = tr("TestPlugin") + QStringLiteral("(%1)").arg(i); - for (int y = 0; y < 5; ++y) { - auto tb = new QToolButton; - tb->setIcon(btnIcon); - tb->setText(tr("Button - ") + - QStringLiteral("(%1, %2)").arg(i).arg(y)); - connect(tb, &QToolButton::clicked, this, [this] { + tbtb.name = tr("TestPlugin") + QStringLiteral("(%1)").arg(i); + for (int y = 0; y < 5; ++y) { + tbtb.tools << createToolButton( + btnIcon, + tr("Button - ") + QStringLiteral("(%1, %2)").arg(i).arg(y), + this, [this] { auto tb = qobject_cast(sender()); msgInformation(nullptr, tr("Click"), tb->text()); }); - tbtb.tools.append(tb); - } - rtinfo.toolboxs.append(tbtb); } - _rtbinfo.append(rtinfo); + rtb.toolboxs.append(tbtb); } + _rtbinfo.append(rtb); - _setpages.append(new TestSettingPage( - QStringLiteral("Test1"), QStringLiteral("This is a Test1"), true)); + _setpages = {new TestSettingPage(QStringLiteral("Test1"), + QStringLiteral("This is a Test1"), true), + new TestSettingPage(QStringLiteral("Test2"), + QStringLiteral("This is a Test2"), false)}; - _setpages.append(new TestSettingPage( - QStringLiteral("Test2"), QStringLiteral("This is a Test2"), false)); + // DockWidget test + auto lbl = new QLabel(QStringLiteral("DockTest1")); + lbl->setAlignment(Qt::AlignCenter); + _winfo << WingHex::createWingDockWidget(QStringLiteral("DockTest1"), lbl, + Qt::LeftDockWidgetArea); - { - WingHex::WingDockWidgetInfo info; - auto lbl = new QLabel(QStringLiteral("DockTest1")); - lbl->setAlignment(Qt::AlignCenter); - info.widget = lbl; - info.widgetName = QStringLiteral("DockTest1"); - info.area = Qt::LeftDockWidgetArea; - _winfo.append(info); - } - - { - auto ev = QSharedPointer::create(); - _evws.append(ev); - } + auto ev = QSharedPointer::create(); + _evws.append(ev); _tmenu = new QMenu(QStringLiteral("TestPlugin")); auto micon = QIcon(QStringLiteral(":/images/TestPlugin/images/btn.png")); @@ -481,9 +461,8 @@ void TestPlugin::testCrash() { } WingHex::IWingPlugin::RegisteredEvents TestPlugin::registeredEvents() const { - RegisteredEvents evs; - evs.setFlag(RegisteredEvent::AppReady); - return evs; + return packupEvent(RegisteredEvent::AppReady, + RegisteredEvent::HexEditorViewPaint); } void TestPlugin::eventReady() { diff --git a/WingPlugin b/WingPlugin index 420ad38..3942f52 160000 --- a/WingPlugin +++ b/WingPlugin @@ -1 +1 @@ -Subproject commit 420ad38ba767c180c7edc726aa8641a631e24559 +Subproject commit 3942f52c8ee7e828ba56328106eb6c03ae14a623 diff --git a/lang/zh_CN/winghex_zh_CN.ts b/lang/zh_CN/winghex_zh_CN.ts index fd64ebb..e458137 100644 --- a/lang/zh_CN/winghex_zh_CN.ts +++ b/lang/zh_CN/winghex_zh_CN.ts @@ -450,72 +450,72 @@ EditorView - + Cut 剪切 - + CutHex 剪切(十六进制) - + Copy 复制 - + CopyHex 复制(十六进制) - + Paste 粘贴 - + PasteHex 粘贴(十六进制) - + Delete 删除 - + Find 查找 - + Goto 跳转 - + Fill 填充 - + MetaData 标注 - + BookMark 书签 - + Untitled 未命名 - + Not allowed operation in non-UI thread 该操作在非 UI 线程非法 @@ -900,19 +900,19 @@ 文件 - - + + View 视图 - + About 关于 - + WingHexExplorer 羽云十六进制编辑器 @@ -927,322 +927,322 @@ 选长: - + Edit 编辑 - + Script 脚本 - - - + + + Plugin 插件 - + Setting 设置 - - + + Log 日志 - + ExportFindResult 导出搜索结果 - + ClearFindResult 清空记录 - - + + FindResult 搜索结果 - - - - - - - + + + + + + + Copy 复制 - - - - - + + + + + CopyToClipBoard 数据已拷贝到粘贴板 - + LittleEndian 小端 - + BigEndian 大端 - + Number 数值 - - + + CheckSum 校验和 - - + + DeleteBookMark 删除书签 - - + + ClearBookMark 清空书签 - - - - + + + + BookMark 书签 - + DecodeText 解码字符串 - + ScriptConsole 脚本控制台 - - + + Basic 基础 - + New 新建 - + OpenF 打开文件 - + OpenWorkSpace 打开工作区 - + RecentFiles 最近打开 - - - + + + Reload 重新加载 - + Save 保存 - + SaveAs 另存为 - + ConvertWS 转为工作区 - + Export 导出 - + SaveSel 保存选区字节 - - - + + + General 基本 - + Undo 撤销 - + Redo 恢复 - + Cut 剪切 - + Paste 粘贴 - + Delete 删除 - + Clone 克隆 - + Lookup 查询 - + Find 查找 - + Goto 跳转 - - + + Encoding 编码 - + FileInfo 文件信息 - - + + Hex 十六进制 - + CutHex 剪切(十六进制) - + CopyHex 复制(十六进制) - + PasteHex 粘贴(十六进制) - - + + Fill 填充 - + FillZero 填充零 - - - - - + + + + + MetaData 标注 - + DeleteMetadata 删除标注 - + ClearMetadata 清空标注 - + MetaDataEdit 编辑标注 - + DeleteMetaData 删除标注 - + ClearMetaData 清空标注 - + Display 显示 - + ViewText 文本预览 - + Scale 缩放 @@ -1322,87 +1322,87 @@ 启动完毕 - + NoExtension 无扩展 - - + + ExportResult 导出结果 - + NothingToSave 没有保存的数据 - + OpenExt 打开 - 拓展 - + ResetScale 重置缩放 - + ShowMetafg 标注前景色 - + ShowMetabg 标注背景色 - + ShowMetaComment 批注 - + MetaShowAll 显示所有标注 - + MetaHideAll 隐藏所有标注 - + FileStatus 文件状态 - + InfoSave 是否保存 - + ReadOnly 可读写 - + SetLocked 启用/禁用锁定编辑 - + ErrUnLock 锁定编辑失败 - + SetOver 启用/禁用改变大小 @@ -1417,198 +1417,198 @@ 脚本引擎启动失败,将自动禁用该功能。 - + UnsignedHex 无符号 Hex - + BgScriptOutputHere 后台脚本执行将会在这里输出 - + SelectAll 全选 - - + + Clear 清空 - + AbortScript 终止脚本 - + BgScriptOutput 后台脚本输出 - + ErrUnOver 锁定文件大小失败 - + Window 窗体 - + Editor 编辑器 - + Tools 工具 - + HexEditorLayout 编辑器布局 - + SetBaseAddr 设置基址 - + addressBase 基址 - + inputAddressBase 请输入基址 - + WarnBigBaseAddress 基址过大,你得到的地址将会不正确! - + ErrBaseAddress 非法基址输入 - + SetColInfo 显示/隐藏地址栏 - + SetHeaderInfo 显示/隐藏表头 - + SetAsciiString 显示/隐藏解码字符串 - + Layout 布局 - + Fullscreen 全屏 - + Default 默认 - - - + + + LayoutRestoring... 恢复布局中... - + RestoreLayout 恢复布局 - - + + SaveLayout 保存布局 - - + + ExportLog 导出日志 - - + + ClearLog 清空日志 - + InsepctQt 监视 Qt - + ScriptEditor 脚本编辑器 - + Scripts 脚本仓库 - + PluginFunctions 插件功能 - + ScriptSetting 脚本设置 - + PluginSettings 插件设置 - + Info 信息 - + Software 软件 - + Sponsor 赞助 - + CheckUpdate 检查更新 - + Wiki 网页 Wiki @@ -1618,506 +1618,506 @@ - + UndoStack - + AboutQT 关于 QT - + SetPageIDEmptyTryUseName 设置页 ID 为空,尝试使用名称作为 ID - + SetPageDupNameIgnored 设置页重复的 ID 名称,已忽略加载 - + Plugin %1 contains a duplicate ID (%2) that is already registered by plugin %3 插件 %1 包含重复 ID (%2),该 ID 已被插件 %3 注册 - - + + ChooseFile 选择文件 - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + Error 错误 - - + + FileNotExist 文件不存在! - - - - - + + + + + FilePermission 因文件权限无法继续! - + ProjectFile (*.wingpro) 项目文件 (*.wingpro) - + ReloadSuccessfully 文件重新加载成功! - + ReloadUnSuccessfully 文件重新加载失败! - - - - + + + + ChooseSaveFile 请选择保存文件路径: - + PasteFailedNote 粘贴失败,请注意权限或者内容长度 - + NoMoreClone 克隆已到上限,无法继续操作! - + FindFininishBusy 查找任务繁忙,请勿重复查找! - + MayTooMuchFindResult 搜索数量已到达上限,结果可能不全,建议请按区段搜索。 - + SaveLayoutSuccess 保存布局成功 - + SaveLayoutError 保存布局失败 - + HasClonedView 该编辑页已被克隆编辑,如果关闭,相关联的页也会被关闭,你确认继续吗? - + [MetaAdd] - + FileCloseBigFile 大文件读取模式下目标文件被关闭,该标签将会被关闭。 - - + + ReloadNeededYesOrNo 目标文件被修改,是否重新加载? - + SaveWorkSpace 保存工作区 - + WingHexWorkSpace (*.wingpro) 羽云十六进制工作区 (*.wingpro) - + ConfirmSave 正在关闭未保存的文件或工作区,你确定保存吗? - + [Info] 【信息】 - + [Warn] 【警告】 - + [Error] 【错误】 - + ConfirmAPPSave 你尝试关闭程序,但仍存在未保存的文件或工作区,你确定保存这些更改吗? - - - + + + SaveSuccessfully 保存成功! - - + + SaveWSError 保存工作区错误! - - + + Warn 警告 - + Opening... 打开文件中... - + WorkSpaceOpening... 打开工作区中... - + Reloading... 重载文件中... - + Saving... 保存中... - + SaveNewFirst 请首先保存新建的文件 - + AlreadyWorkSpace 已经是工作区,无需转化 - + ConvWorkSpaceFailed 转化为工作区失败 - + ConvWorkSpaceSuccess 转化为工作区成功 - + SavingAs... 另存为中... - + SaveUnSuccessfully 保存失败! - + Exporting... 导出中... - + ChooseExportFile 请选择导出文件路径: - + ExportSuccessfully 导出成功! - + ExportUnSuccessfully 导出失败! - + SavingSel... 保存选中字节中... - + SaveSelSuccess 保存选区字节成功! - + SaveSelError 保存选区字节失败,因文件不具有可写权限! - - + + CutToClipBoard 数据已剪切到粘贴板! - - + + UnCutToClipBoard 由于保持大小限制,数据剪切到粘贴板失败! - - + + UnCopyToClipBoard 由于保持大小限制,数据剪切到复制板失败! - - + + Finding... 查找中... - + DeleteSuccess 删除成功 - + DeleteFailed 删除失败 - + FindFininish 查找结果完毕! - + PleaseInputFill 请输入填充字节值 - + FillInputTruncWarn 填充输入数值过大,将会被截断填充 - + FillInputError 填充字节输入错误 - - + + InputComment 请输入批注: - - + + BookmarkDelSuccess 删除书签成功 - + BookmarkDelNoItem 无书签可删除 - + BookmarkClearSuccess 书签清空完毕 - - - + + + NoSelection 没有选区,无法继续的操作! - + NoMetaData 无可编辑标记 - + PleaseClearSel 请清空选择 - + MetaDelSuccess 元数据删除成功 - + MetaDelNoItem 无元数据可删除 - + MetaClearSuccess 元数据清空完毕 - + FindResultExporting... 查找结果导出中... - - + + EmptyFindResult 没有可导出的搜索结果! - + SaveFindResult 导出搜索结果成功! - + SaveFindResultError 导出结果失败! - + TooManyBytesDecode 超出解码字节限制…… - + NoTextFileMayInvalid 该文件不是文本文件,以文本方式预览并不是一个好的方式,你确认继续吗? - + LayoutSaving... 布局保存中... - + PleaseInput 请输入 - + LogExporting... 日志导出中... - + ExportLogError 导出日志失败! - + ExportLogSuccess 导出日志成功,路径: - + ClearLogSuccess 清空日志成功! - + BadNetwork 无法与远程服务器的更新检查建立连接,请检查网络。 - + NewestVersion 当前软件为最新版本 - - + + OlderVersion 你使用的软件为老版本,建议到 Github 和 Gitee 的仓库发行版下载更新。 - + CheckingUpdate 检查更新中…… - + Too much opened files 打开的文件过多,无法继续操作! - + FilePermissionSure2Quit 因文件权限无法保存,你确认要退出吗? - + UnknownErrorSure2Quit 因未知错误无法保存,你确认要退出吗? - + WorkSpaceUnSavedSure2Quit 工作区文件无法保存,你确认要退出吗? - + CopyLimit 拷贝字节超出限制 - + ErrOpenFileBelow 打开文件出现错误(由于权限不足),如下为打开错误的文件: @@ -5497,31 +5497,31 @@ 提供基础的文件结构分析支持 - - - - - - - - - - - - - + + + + + + + + + + + + + InvalidParamsCount 非法参数个数 - - - - - - - - + + + + + + + + InvalidParam 非法参数 diff --git a/lang/zh_TW/winghex_zh_TW.ts b/lang/zh_TW/winghex_zh_TW.ts index 0ca10a2..77bcd62 100644 --- a/lang/zh_TW/winghex_zh_TW.ts +++ b/lang/zh_TW/winghex_zh_TW.ts @@ -450,72 +450,72 @@ EditorView - + Cut 剪切 - + CutHex 剪切(十六進制) - + Copy 複製 - + CopyHex 複製(十六進制) - + Paste 粘貼 - + PasteHex 粘貼(十六進制) - + Delete 刪除 - + Find 查找 - + Goto 跳轉 - + Fill 填充 - + MetaData 標注 - + BookMark 書簽 - + Untitled 未命名 - + Not allowed operation in non-UI thread 該操作在非 UI 線程非法 @@ -900,19 +900,19 @@ - - + + View 視圖 - + About 關於 - + WingHexExplorer 羽雲十六進制編輯器 @@ -927,322 +927,322 @@ 選長: - + Edit 編輯 - + Script 腳本 - - - + + + Plugin 插件 - + Setting 設置 - - + + Log 日誌 - + ExportFindResult 導出搜索結果 - + ClearFindResult 清空記錄 - - + + FindResult 搜索結果 - - - - - - - + + + + + + + Copy 複製 - - - - - + + + + + CopyToClipBoard 數據已拷貝到粘貼板 - + LittleEndian 小端 - + BigEndian 大端 - + Number 數值 - - + + CheckSum 校驗和 - - + + DeleteBookMark 刪除書簽 - - + + ClearBookMark 清空書簽 - - - - + + + + BookMark 書簽 - + DecodeText 解碼字串 - + ScriptConsole 腳本控制臺 - - + + Basic 基礎 - + New 新建 - + OpenF 打開檔 - + OpenWorkSpace 打開工作區 - + RecentFiles 最近打開 - - - + + + Reload 重新加載 - + Save 保存 - + SaveAs 另存為 - + ConvertWS 轉為工作區 - + Export 導出 - + SaveSel 保存選區位元組 - - - + + + General 基本 - + Undo 撤銷 - + Redo 恢復 - + Cut 剪切 - + Paste 粘貼 - + Delete 刪除 - + Clone 克隆 - + Lookup 查詢 - + Find 查找 - + Goto 跳轉 - - + + Encoding 編碼 - + FileInfo 檔資訊 - - + + Hex 十六進制 - + CutHex 剪切(十六進制) - + CopyHex 複製(十六進制) - + PasteHex 粘貼(十六進制) - - + + Fill 填充 - + FillZero 填充零 - - - - - + + + + + MetaData 標注 - + DeleteMetadata 刪除標注 - + ClearMetadata 清空標注 - + MetaDataEdit 編輯標注 - + DeleteMetaData 刪除標注 - + ClearMetaData 清空標注 - + Display 顯示 - + ViewText 文本預覽 - + Scale 縮放 @@ -1322,87 +1322,87 @@ 啟動完畢 - + NoExtension 無擴展 - - + + ExportResult 導出結果 - + NothingToSave 沒有保存的數據 - + OpenExt 打開 - 拓展 - + ResetScale 重置縮放 - + ShowMetafg 標注前景色 - + ShowMetabg 標注背景色 - + ShowMetaComment 批註 - + MetaShowAll 顯示所有標注 - + MetaHideAll 隱藏所有標注 - + FileStatus 檔狀態 - + InfoSave 是否保存 - + ReadOnly 可讀寫 - + SetLocked 啟用/禁用鎖定編輯 - + ErrUnLock 鎖定編輯失敗 - + SetOver 啟用/禁用改變大小 @@ -1417,198 +1417,198 @@ 腳本引擎啟動失敗,將自動禁用該功能。 - + UnsignedHex 無符號 Hex - + BgScriptOutputHere 後臺腳本執行將會在這裏輸出 - + SelectAll 全選 - - + + Clear 清空 - + AbortScript 終止腳本 - + BgScriptOutput 後臺腳本輸出 - + ErrUnOver 鎖定檔大小失敗 - + Window 窗體 - + Editor 編輯器 - + Tools 工具 - + HexEditorLayout 編輯器佈局 - + SetBaseAddr 設置基址 - + addressBase 基址 - + inputAddressBase 請輸入基址 - + WarnBigBaseAddress 基址過大,你得到的地址將會不正確! - + ErrBaseAddress 非法基址輸入 - + SetColInfo 顯示/隱藏地址欄 - + SetHeaderInfo 顯示/隱藏表頭 - + SetAsciiString 顯示/隱藏解碼字串 - + Layout 佈局 - + Fullscreen 全屏 - + Default 默認 - - - + + + LayoutRestoring... 恢復佈局中... - + RestoreLayout 恢復佈局 - - + + SaveLayout 保存佈局 - - + + ExportLog 導出日誌 - - + + ClearLog 清空日誌 - + InsepctQt 監視 Qt - + ScriptEditor 腳本編輯器 - + Scripts 腳本倉庫 - + PluginFunctions 插件功能 - + ScriptSetting 腳本設置 - + PluginSettings 插件設置 - + Info 資訊 - + Software 軟體 - + Sponsor 贊助 - + CheckUpdate 檢查更新 - + Wiki 網頁 Wiki @@ -1618,506 +1618,506 @@ - + UndoStack - + AboutQT 關於 QT - + SetPageIDEmptyTryUseName 設置頁 ID 為空,嘗試使用名稱作為 ID - + SetPageDupNameIgnored 設置頁重複的 ID 名稱,已忽略加載 - + Plugin %1 contains a duplicate ID (%2) that is already registered by plugin %3 插件 %1 包含重複 ID (%2),該 ID 已被插件 %3 註冊 - - + + ChooseFile 選擇檔 - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + Error 錯誤 - - + + FileNotExist 檔不存在! - - - - - + + + + + FilePermission 因檔許可權無法繼續! - + ProjectFile (*.wingpro) 專案檔 (*.wingpro) - + ReloadSuccessfully 檔重新加載成功! - + ReloadUnSuccessfully 檔重新加載失敗! - - - - + + + + ChooseSaveFile 請選擇保存檔路徑: - + PasteFailedNote 粘貼失敗,請注意許可權或者內容長度 - + NoMoreClone 克隆已到上限,無法繼續操作! - + FindFininishBusy 查找任務繁忙,請勿重複查找! - + MayTooMuchFindResult 搜索數量已到達上限,結果可能不全,建議請按區段搜索。 - + SaveLayoutSuccess 保存佈局成功 - + SaveLayoutError 保存佈局失敗 - + HasClonedView 該編輯頁已被克隆編輯,如果關閉,相關聯的頁也會被關閉,你確認繼續嗎? - + [MetaAdd] - + FileCloseBigFile 大檔讀取模式下目的檔案被關閉,該標籤將會被關閉。 - - + + ReloadNeededYesOrNo 目的檔案被修改,是否重新載入? - + SaveWorkSpace 保存工作區 - + WingHexWorkSpace (*.wingpro) 羽雲十六進制工作區 (*.wingpro) - + ConfirmSave 正在關閉未保存的檔或工作區,你確定保存嗎? - + [Info] 【資訊】 - + [Warn] 【警告】 - + [Error] 【錯誤】 - + ConfirmAPPSave 你嘗試關閉程式,但仍存在未保存的檔或工作區,你確定保存這些更改嗎? - - - + + + SaveSuccessfully 保存成功! - - + + SaveWSError 保存工作區錯誤! - - + + Warn 警告 - + Opening... 打開檔中... - + WorkSpaceOpening... 打開工作區中... - + Reloading... 重載檔中... - + Saving... 保存中... - + SaveNewFirst 請首先保存新建的檔 - + AlreadyWorkSpace 已經是工作區,無需轉化 - + ConvWorkSpaceFailed 轉化為工作區失敗 - + ConvWorkSpaceSuccess 轉化為工作區成功 - + SavingAs... 另存為中... - + SaveUnSuccessfully 保存失敗! - + Exporting... 導出中... - + ChooseExportFile 請選擇導出檔路徑: - + ExportSuccessfully 導出成功! - + ExportUnSuccessfully 導出失敗! - + SavingSel... 保存選中位元組中... - + SaveSelSuccess 保存選區位元組成功! - + SaveSelError 保存選區位元組失敗,因檔不具有可寫許可權! - - + + CutToClipBoard 數據已剪切到粘貼板! - - + + UnCutToClipBoard 由於保持大小限制,數據剪切到粘貼板失敗! - - + + UnCopyToClipBoard 由於保持大小限制,數據剪切到複製板失敗! - - + + Finding... 查找中... - + DeleteSuccess 刪除成功 - + DeleteFailed 刪除失敗 - + FindFininish 查找結果完畢! - + PleaseInputFill 請輸入填充位元組值 - + FillInputTruncWarn 填充輸入數值過大,將會被截斷填充 - + FillInputError 填充位元組輸入錯誤 - - + + InputComment 請輸入批註: - - + + BookmarkDelSuccess 刪除書簽成功 - + BookmarkDelNoItem 無書簽可刪除 - + BookmarkClearSuccess 書簽清空完畢 - - - + + + NoSelection 沒有選區,無法繼續的操作! - + NoMetaData 無可編輯標記 - + PleaseClearSel 請清空選擇 - + MetaDelSuccess 元數據刪除成功 - + MetaDelNoItem 無元數據可刪除 - + MetaClearSuccess 元數據清空完畢 - + FindResultExporting... 查找結果導出中... - - + + EmptyFindResult 沒有可導出的搜索結果! - + SaveFindResult 導出搜索結果成功! - + SaveFindResultError 導出結果失敗! - + TooManyBytesDecode 超出解碼位元組限制…… - + NoTextFileMayInvalid 該檔不是文本檔,以文本方式預覽並不是一個好的方式,你確認繼續嗎? - + LayoutSaving... 佈局保存中... - + PleaseInput 請輸入 - + LogExporting... 日誌導出中... - + ExportLogError 導出日誌失敗! - + ExportLogSuccess 導出日誌成功,路徑: - + ClearLogSuccess 清空日誌成功! - + BadNetwork 無法與遠程伺服器的更新檢查建立連接,請檢查網路。 - + NewestVersion 當前軟體為最新版本 - - + + OlderVersion 你使用的軟體為老版本,建議到 Github 和 Gitee 的倉庫發行版下載更新。 - + CheckingUpdate 檢查更新中…… - + Too much opened files 打開的檔過多,無法繼續操作! - + FilePermissionSure2Quit 因檔許可權無法保存,你確認要退出嗎? - + UnknownErrorSure2Quit 因未知錯誤無法保存,你確認要退出嗎? - + WorkSpaceUnSavedSure2Quit 工作區檔無法保存,你確認要退出嗎? - + CopyLimit 拷貝位元組超出限制 - + ErrOpenFileBelow 打開檔出現錯誤(由於許可權不足),如下為打開錯誤的檔: @@ -5497,31 +5497,31 @@ 提供基礎的檔結構分析支持 - - - - - - - - - - - - - + + + + + + + + + + + + + InvalidParamsCount 非法參數個數 - - - - - - - - + + + + + + + + InvalidParam 非法參數 diff --git a/src/class/wingcstruct.cpp b/src/class/wingcstruct.cpp index 350aa6e..7e7bb6a 100644 --- a/src/class/wingcstruct.cpp +++ b/src/class/wingcstruct.cpp @@ -50,10 +50,8 @@ QString WingCStruct::retranslate(const QString &str) { } WingCStruct::RegisteredEvents WingCStruct::registeredEvents() const { - RegisteredEvents evs; - evs.setFlag(RegisteredEvent::ScriptPragma); - evs.setFlag(RegisteredEvent::ScriptPragmaInit); - return evs; + return packupEvent(RegisteredEvent::ScriptPragma, + RegisteredEvent::ScriptPragmaInit); } QList WingCStruct::registeredSettingPages() const { diff --git a/src/control/editorview.cpp b/src/control/editorview.cpp index 3555d3b..e47f4dd 100644 --- a/src/control/editorview.cpp +++ b/src/control/editorview.cpp @@ -18,7 +18,6 @@ #include "editorview.h" #include "QHexView/document/buffer/qfilebuffer.h" -#include "QHexView/document/buffer/qmemorybuffer.h" #include "Qt-Advanced-Docking-System/src/DockWidgetTab.h" #include "class/logger.h" @@ -36,7 +35,6 @@ #include #endif -constexpr qsizetype FILE_MAX_BUFFER = 0x32000000; // 800MB constexpr auto CLONE_LIMIT = 3; constexpr auto VIEW_PROPERTY = "__VIEW__"; @@ -302,7 +300,7 @@ ErrFile EditorView::newFile(size_t index) { m_docType = DocumentType::File; m_isWorkSpace = false; m_isNewFile = true; - auto p = QHexDocument::fromMemory(QByteArray(), false); + auto p = QHexDocument::fromMemory(QByteArray(), false); p->setDocSaved(); m_hex->setDocument(QSharedPointer(p)); m_hex->cursor()->setInsertionMode(QHexCursor::InsertMode); @@ -323,11 +321,7 @@ ErrFile EditorView::openFile(const QString &filename) { auto readonly = !Utilities::fileCanWrite(filename); - auto *p = - info.size() > FILE_MAX_BUFFER - ? QHexDocument::fromLargeFile(filename, readonly) - : QHexDocument::fromFile(filename, readonly); - + auto *p = QHexDocument::fromFile(filename, readonly); if (Q_UNLIKELY(p == nullptr)) { return ErrFile::Permission; } @@ -380,9 +374,7 @@ ErrFile EditorView::openExtFile(const QString &ext, const QString &file) { } } - auto *p = (d->size() > FILE_MAX_BUFFER || d->size() < 0) - ? QHexDocument::fromDevice(d, readonly) - : QHexDocument::fromDevice(d, readonly); + auto *p = QHexDocument::fromDevice(d, readonly); if (Q_UNLIKELY(p == nullptr)) { return ErrFile::Error; @@ -580,9 +572,15 @@ ErrFile EditorView::save(const QString &workSpaceName, const QString &path, if (doc->saveTo(&file, !isExport)) { file.close(); - if (!isExport) { m_fileName = QFileInfo(fileName).absoluteFilePath(); + + if (isNewFile()) { + auto buffer = new QFileBuffer; + buffer->read(new QFile(fileName)); + doc->setBuffer(buffer); + } + m_isNewFile = false; m_docType = DocumentType::File; doc->setDocSaved(); diff --git a/src/control/editorview.h b/src/control/editorview.h index 9bdaeb0..8e36de3 100644 --- a/src/control/editorview.h +++ b/src/control/editorview.h @@ -361,7 +361,7 @@ private slots: WING_API bool moveTo(QObject *caller, qsizetype offset, bool clearSelection); WING_API bool select(QObject *caller, qsizetype offset, qsizetype length, - SelectionMode mode); + WingHex::SelectionMode mode); WING_API bool setInsertionMode(QObject *caller, bool isinsert); // metadata diff --git a/src/control/gotowidget.cpp b/src/control/gotowidget.cpp index bc0c411..5ab196a 100644 --- a/src/control/gotowidget.cpp +++ b/src/control/gotowidget.cpp @@ -76,25 +76,21 @@ public: if (ctx->IntegerConstant()) { auto r = parseIntegerConstant(ctx->IntegerConstant()->getText()); - if (std::holds_alternative(r)) { - lastAddr = std::get(r); - } else if (std::holds_alternative(r)) { - lastAddr = std::get(r); + if (r) { + lastAddr = r.value(); } else { lastPos = GotoWidget::SEEKPOS::Invaild; lastAddr = 0; } } else { auto r = visitAssignmentExpression(ctx->assignmentExpression()); - if (r.type() == typeid(quint64)) { - lastAddr = std::any_cast(r); - } else if (r.type() == typeid(qint64)) { + if (r.has_value()) { auto addr = std::any_cast(r); if (addr < 0) { lastPos = GotoWidget::SEEKPOS::Invaild; lastAddr = 0; } - lastAddr = quint64(addr); + lastAddr = addr; } else { lastPos = GotoWidget::SEEKPOS::Invaild; lastAddr = 0; @@ -105,7 +101,7 @@ public: } public: - quint64 lastAddr = 0; + qint64 lastAddr = 0; GotoWidget::SEEKPOS lastPos = GotoWidget::SEEKPOS::Invaild; public: @@ -117,10 +113,8 @@ public: if (ctx->IntegerConstant()) { auto r = parseIntegerConstant(ctx->IntegerConstant()->getText()); - if (std::holds_alternative(r)) { - return std::get(r); - } else if (std::holds_alternative(r)) { - return std::get(r); + if (r) { + return r.value(); } } else if (ctx->unaryExpression()) { return visitUnaryExpression(ctx->unaryExpression()); @@ -137,18 +131,7 @@ public: auto op = ctx->unaryOperator(); auto r = visitCastExpression(ctx->castExpression()); - if (r.type() == typeid(quint64)) { - auto v = std::any_cast(r); - if (op->Minus()) { - return -v; - } else if (op->Plus()) { - return +v; - } else if (op->Tilde()) { - return ~v; - } else { - return defaultResult(); - } - } else if (r.type() == typeid(qint64)) { + if (r.has_value()) { auto v = std::any_cast(r); if (op->Minus()) { return -v; @@ -170,13 +153,10 @@ public: return defaultResult(); } - qulonglong ret = 0; + qint64 ret = 0; for (auto &v : ctx->exclusiveOrExpression()) { auto r = visitExclusiveOrExpression(v); - if (r.type() == typeid(quint64)) { - auto rr = std::any_cast(r); - ret |= rr; - } else if (r.type() == typeid(qint64)) { + if (r.has_value()) { auto rr = std::any_cast(r); ret |= rr; } else { @@ -195,10 +175,8 @@ public: if (ctx->IntegerConstant()) { auto r = parseIntegerConstant(ctx->IntegerConstant()->getText()); - if (std::holds_alternative(r)) { - return std::get(r); - } else if (std::holds_alternative(r)) { - return std::get(r); + if (r) { + return r.value(); } } else if (ctx->inclusiveOrExpression()) { return visitInclusiveOrExpression(ctx->inclusiveOrExpression()); @@ -213,15 +191,12 @@ public: return defaultResult(); } - quint64 v = 0; + qint64 v = 0; for (auto &ex : ctx->andExpression()) { auto r = visitAndExpression(ex); - if (r.type() == typeid(qint64)) { + if (r.has_value()) { auto rv = std::any_cast(r); v ^= rv; - } else if (r.type() == typeid(quint64)) { - auto rv = std::any_cast(r); - v ^= rv; } else { return defaultResult(); } @@ -239,17 +214,14 @@ public: quint64 v = std::numeric_limits::max(); for (auto &ex : ctx->shiftExpression()) { auto r = visitShiftExpression(ex); - if (r.type() == typeid(qint64)) { + if (r.has_value()) { auto rv = std::any_cast(r); - v &= rv; - } else if (r.type() == typeid(quint64)) { - auto rv = std::any_cast(r); - v &= rv; + v &= quint64(rv); } else { return defaultResult(); } } - return v; + return qint64(v); } std::any @@ -261,12 +233,10 @@ public: auto data = ctx->additiveExpression(); auto total = data.size(); - quint64 ret = 0; + qint64 ret = 0; auto retv = visitAdditiveExpression(data.front()); - if (retv.type() == typeid(qint64)) { + if (retv.has_value()) { ret = std::any_cast(retv); - } else if (retv.type() == typeid(quint64)) { - ret = std::any_cast(retv); } else { return defaultResult(); } @@ -275,22 +245,16 @@ public: auto op = ctx->children[2 * i - 1]->getText(); auto r = visitAdditiveExpression(data.at(i)); if (op == "<<") { - if (r.type() == typeid(qint64)) { + if (r.has_value()) { auto rv = std::any_cast(r); ret <<= rv; - } else if (r.type() == typeid(quint64)) { - auto rv = std::any_cast(r); - ret <<= rv; } else { return defaultResult(); } } else if (op == ">>") { - if (r.type() == typeid(qint64)) { + if (r.has_value()) { auto rv = std::any_cast(r); ret >>= rv; - } else if (r.type() == typeid(quint64)) { - auto rv = std::any_cast(r); - ret >>= rv; } else { return defaultResult(); } @@ -311,12 +275,10 @@ public: auto data = ctx->multiplicativeExpression(); auto total = data.size(); - quint64 ret = 0; + qint64 ret = 0; auto retv = visitMultiplicativeExpression(data.front()); - if (retv.type() == typeid(qint64)) { + if (retv.has_value()) { ret = std::any_cast(retv); - } else if (retv.type() == typeid(quint64)) { - ret = std::any_cast(retv); } else { return defaultResult(); } @@ -324,7 +286,7 @@ public: for (size_t i = 1; i < total; i++) { auto r = visitMultiplicativeExpression(data.at(i)); auto op = ctx->children[2 * i - 1]->getText(); - if (r.type() == typeid(qint64)) { + if (r.has_value()) { auto rv = std::any_cast(r); if (op == "+") { ret += rv; @@ -333,15 +295,6 @@ public: } else { return defaultResult(); } - } else if (r.type() == typeid(quint64)) { - auto rv = std::any_cast(r); - if (op == "+") { - ret += rv; - } else if (op == "-") { - ret -= rv; - } else { - return defaultResult(); - } } else { return defaultResult(); } @@ -359,12 +312,10 @@ public: auto data = ctx->castExpression(); auto total = data.size(); - quint64 ret = 0; + qint64 ret = 0; auto retv = visitCastExpression(data.front()); - if (retv.type() == typeid(qint64)) { + if (retv.has_value()) { ret = std::any_cast(retv); - } else if (retv.type() == typeid(quint64)) { - ret = std::any_cast(retv); } else { return defaultResult(); } @@ -372,7 +323,7 @@ public: for (size_t i = 1; i < total; i++) { auto r = visitCastExpression(data.at(i)); auto op = ctx->children[2 * i - 1]->getText(); - if (r.type() == typeid(qint64)) { + if (r.has_value()) { auto rv = std::any_cast(r); if (op == "*") { ret *= rv; @@ -383,17 +334,6 @@ public: } else { return defaultResult(); } - } else if (r.type() == typeid(quint64)) { - auto rv = std::any_cast(r); - if (op == "*") { - ret *= rv; - } else if (op == "/") { - ret /= rv; - } else if (op == "%") { - ret %= rv; - } else { - return defaultResult(); - } } else { return defaultResult(); } @@ -410,10 +350,8 @@ public: if (ctx->IntegerConstant()) { auto r = parseIntegerConstant(ctx->IntegerConstant()->getText()); - if (std::holds_alternative(r)) { - return std::get(r); - } else if (std::holds_alternative(r)) { - return std::get(r); + if (r) { + return r.value(); } } else if (ctx->assignmentExpression()) { return visitAssignmentExpression(ctx->assignmentExpression()); @@ -423,8 +361,7 @@ public: } private: - std::variant - parseIntegerConstant(const std::string &text) { + std::optional parseIntegerConstant(const std::string &text) { Q_STATIC_ASSERT_X( QT_VERSION >= QT_VERSION_CHECK(6, 4, 0), "If you want to support Qt version lower than 6.4.0, You should " @@ -436,11 +373,7 @@ private: if (b) { return num; } else { - auto num = ct.toULongLong(&b, 0); - if (b) { - return num; - } - return {}; + return std::nullopt; } } }; diff --git a/src/dialog/mainwindow.cpp b/src/dialog/mainwindow.cpp index 7cf0090..f69b396 100644 --- a/src/dialog/mainwindow.cpp +++ b/src/dialog/mainwindow.cpp @@ -245,8 +245,8 @@ MainWindow::MainWindow(SplashDialog *splash) : FramelessMainWindow() { m_scriptConsole->setEnabled(false); // configure error, so disable all script feature - WingHex::WingRibbonToolBoxInfo::RibbonCatagories catagories; - m_ribbonMaps[catagories.SCRIPT]->setEnabled(false); + m_ribbonMaps[WingHex::WingRibbonCatagories::SCRIPT]->setEnabled( + false); } else { ScriptMachine::RegCallBacks callbacks; callbacks.getInputFn = [this]() -> QString { @@ -369,33 +369,35 @@ void MainWindow::buildUpRibbonBar() { loadCacheIcon(); - using RibbonCatagories = WingHex::WingRibbonToolBoxInfo::RibbonCatagories; - RibbonCatagories catagories; + using RibbonCatagories = WingHex::WingRibbonCatagories; - m_ribbonMaps[catagories.FILE] = buildFilePage(m_ribbon->addTab(tr("File"))); + m_ribbonMaps[RibbonCatagories::FILE] = + buildFilePage(m_ribbon->addTab(tr("File"))); qApp->processEvents(); - m_ribbonMaps[catagories.EDIT] = buildEditPage(m_ribbon->addTab(tr("Edit"))); + m_ribbonMaps[RibbonCatagories::EDIT] = + buildEditPage(m_ribbon->addTab(tr("Edit"))); qApp->processEvents(); - m_ribbonMaps[catagories.VIEW] = buildViewPage(m_ribbon->addTab(tr("View"))); + m_ribbonMaps[RibbonCatagories::VIEW] = + buildViewPage(m_ribbon->addTab(tr("View"))); qApp->processEvents(); auto &set = SettingManager::instance(); if (set.scriptEnabled()) { - m_ribbonMaps[catagories.SCRIPT] = + m_ribbonMaps[RibbonCatagories::SCRIPT] = buildScriptPage(m_ribbon->addTab(tr("Script"))); qApp->processEvents(); } if (set.enablePlugin()) { - m_ribbonMaps[catagories.PLUGIN] = + m_ribbonMaps[RibbonCatagories::PLUGIN] = buildPluginPage(m_ribbon->addTab(tr("Plugin"))); qApp->processEvents(); } - m_ribbonMaps[catagories.SETTING] = + m_ribbonMaps[RibbonCatagories::SETTING] = buildSettingPage(m_ribbon->addTab(tr("Setting"))); qApp->processEvents(); - m_ribbonMaps[catagories.ABOUT] = + m_ribbonMaps[RibbonCatagories::ABOUT] = buildAboutPage(m_ribbon->addTab(tr("About"))); qApp->processEvents(); diff --git a/theme/dark/stylesheet.qss b/theme/dark/stylesheet.qss index e09668e..fc16a29 100644 --- a/theme/dark/stylesheet.qss +++ b/theme/dark/stylesheet.qss @@ -45,8 +45,8 @@ QToolTip /* 0.2ex is the smallest value that's not ignored on Windows. */ border: 0.04em solid #eff0f1; background-image: none; - background-color: #31363b; - alternate-background-color: #31363b; + background-color: #202326; + alternate-background-color: #202326; color: #eff0f1; padding: 0.1em; opacity: 200; @@ -55,7 +55,7 @@ QToolTip QWidget { color: #eff0f1; - background-color: #31363b; + background-color: #202326; selection-background-color: #3daee9; selection-color: #eff0f1; background-clip: border; @@ -137,7 +137,7 @@ QWidget QWidget:disabled { color: #454545; - background-color: #31363b; + background-color: #202326; } QCheckBox @@ -181,7 +181,7 @@ QGroupBox::title top: -1.6em; subcontrol-origin: content; subcontrol-position: top center; - background: #31363b; + background: #202326; padding-left: 0.2em; padding-right: 0.2em; } @@ -343,7 +343,7 @@ QRadioButton::indicator:unchecked:disabled QMenuBar { - background-color: #31363b; + background-color: #202326; color: #eff0f1; } @@ -404,7 +404,7 @@ QMenu::item:selected QMenu::item:selected:disabled { - background-color: #31363b; + background-color: #202326; } QMenu::item:disabled @@ -476,9 +476,9 @@ QMenu::right-arrow:disabled QAbstractItemView { - alternate-background-color: #31363b; + alternate-background-color: #202326; color: #eff0f1; - border: 0.09em solid #31363b; + border: 0.09em solid #202326; border-radius: 0.09em; } @@ -513,7 +513,7 @@ QAbstractScrollArea */ QAbstractScrollArea::corner { - background: #31363b; + background: #202326; } /** @@ -735,7 +735,7 @@ QFrame[frameShape="6"] /* QFrame::StyledPanel == 0x0006 */ border-width: 0.04em; padding: 0.09em; border-style: solid; - border-color: #31363b; + border-color: #202326; background-color: #76797c; border-radius: 0.23em; } @@ -842,7 +842,7 @@ QDialog QToolBar QToolButton[popupMode="2"] QPushButton { color: #eff0f1; - background-color: #31363b; + background-color: #202326; border: 0.04em solid #76797c; padding: 0.23em; border-radius: 0.09em; @@ -872,7 +872,7 @@ QPushButton:closed QPushButton:disabled { - background-color: #31363b; + background-color: #202326; border-width: 0.04em; border-color: #76797c; border-style: solid; @@ -919,7 +919,7 @@ QPushButton:checked QPushButton:hover { - background-color: #31363b; + background-color: #202326; border: 0.04em solid #3daee9; color: #eff0f1; } @@ -958,12 +958,12 @@ QPlainTextEdit:hover:pressed, QAbstractView:hover:pressed, QTreeView:hover:pressed { - background-color: #31363b; + background-color: #202326; } QColumnView { - border: 0.04em transparent #31363b; + border: 0.04em transparent #202326; } QColumnViewGrip @@ -1365,7 +1365,7 @@ QTabBar::tab:top:only-one border-left: 0.04em solid #76797c; border-right: 0.04em solid #76797c; border-top: 0.09em solid #3daee9; - background-color: #31363b; + background-color: #202326; padding: 0.23em; min-width: 50px; border-radius: 0.09em; @@ -1376,7 +1376,7 @@ QTabBar::tab:top:only-one QTabBar::tab:top:!selected { color: #eff0f1; - background-color: #2c3034; + background-color: #1b1d20; border: 0.04em transparent black; border-right: 0.04em solid #76797c; border-bottom: 0.04em solid #76797c; @@ -1418,7 +1418,7 @@ QTabBar::tab:bottom:only-one border-left: 0.04em solid #76797c; border-right: 0.04em solid #76797c; border-bottom: 0.09em solid #3daee9; - background-color: #31363b; + background-color: #202326; padding: 0.23em; min-width: 50px; border-radius: 0.09em; @@ -1429,7 +1429,7 @@ QTabBar::tab:bottom:only-one QTabBar::tab:bottom:!selected { color: #eff0f1; - background-color: #2c3034; + background-color: #1b1d20; border: 0.04em transparent black; border-top: 0.04em solid #76797c; border-right: 0.04em solid #76797c; @@ -1471,7 +1471,7 @@ QTabBar::tab:left:only-one border-top: 0.09em solid #3daee9; border-bottom: 0.04em solid #76797c; border-left: 0.04em solid #76797c; - background-color: #31363b; + background-color: #202326; padding: 0.23em; min-height: 50px; border-radius: 0.09em; @@ -1482,7 +1482,7 @@ QTabBar::tab:left:only-one QTabBar::tab:left:!selected { color: #eff0f1; - background-color: #2c3034; + background-color: #1b1d20; border: 0.04em transparent black; border-top: 0.04em solid #76797c; border-right: 0.04em solid #76797c; @@ -1524,7 +1524,7 @@ QTabBar::tab:right:only-one border-top: 0.09em solid #3daee9; border-bottom: 0.04em solid #76797c; border-right: 0.04em solid #76797c; - background-color: #31363b; + background-color: #202326; padding: 0.23em; min-height: 50px; border-radius: 0.09em; @@ -1535,7 +1535,7 @@ QTabBar::tab:right:only-one QTabBar::tab:right:!selected { color: #eff0f1; - background-color: #2c3034; + background-color: #1b1d20; border: 0.04em transparent black; border-top: 0.04em solid #76797c; border-left: 0.04em solid #76797c; @@ -1594,7 +1594,7 @@ QTabBar[shape="7"]::tab:only-one { /* Need a dark color without alpha channel since it affects the text. */ color: #3daee9; - background-color: #31363b; + background-color: #202326; padding: 0.23em; } @@ -1624,7 +1624,7 @@ QTabBar[shape="6"]::tab:!selected, QTabBar[shape="7"]::tab:!selected { color: #eff0f1; - background-color: #2c3034; + background-color: #1b1d20; } /** @@ -1675,7 +1675,7 @@ QTabBar[shape="7"]::close-button QDockWidget { - background: #31363b; + background: #202326; /** * It doesn't seem possible to change the border of the * QDockWidget without changing the content margins. @@ -1899,7 +1899,7 @@ QSlider::groove:horizontal, QSlider::groove:vertical { background: #2c3034; - border: 0em solid #31363b; + border: 0em solid #202326; border-radius: 0.19em; } @@ -2003,14 +2003,14 @@ QDialog QToolBar QToolButton[hasMenu="false"][popupMode="2"] QToolButton[autoRaise="false"] { - background-color: #31363b; + background-color: #202326; border: 0.04em solid #76797c; border-radius: 0.09em; } QToolButton[autoRaise="true"] { - background-color: #31363b; + background-color: #202326; border: 0.04em solid transparent; } @@ -2164,7 +2164,7 @@ QToolButton::menu-button:pressed QTableView { border: 0em solid black; - gridline-color: #31363b; + gridline-color: #202326; background-color: #1d2023; } @@ -2220,7 +2220,7 @@ QAbstractItemView::item:selected:hover QHeaderView { - background-color: #31363b; + background-color: #202326; border: 0.04em transparent; border-radius: 0em; margin: 0em; @@ -2229,7 +2229,7 @@ QHeaderView QHeaderView::section { - background-color: #31363b; + background-color: #202326; border: 0.04em solid #76797c; color: #eff0f1; border-radius: 0em; @@ -2317,7 +2317,7 @@ QHeaderView::up-arrow QTableView QTableCornerButton::section { - background-color: #31363b; + background-color: #202326; border: 0.04em transparent #76797c; border-top: 0.04em solid #76797c; border-left: 0.04em solid #76797c; @@ -2357,7 +2357,7 @@ QToolBox::tab:hover QSplitter::handle { border: 0.09em solid #2c3034; - background: -0.5em solid #2c3034; + background: -0.5em solid #202326; max-width: 0em; max-height: 0em; } @@ -2372,7 +2372,7 @@ QProgressBar:horizontal, QProgressBar:vertical { background-color: #626568; - border: 0.9em solid #31363b; + border: 0.9em solid #202326; border-radius: 0.13em; padding: 0em; } @@ -2462,7 +2462,7 @@ QMessageBox QPushButton QWidget[isTitlebar="true"], QWidget[isTitlebar="true"] * { - background-color: #2c3034; + background-color: #1b1d20; } /** @@ -2542,7 +2542,7 @@ QFrame[frameShape][isWindow="true"][windowFrame="5"] ads--CAutoHideDockContainer #dockAreaAutoHideButton { qproperty-icon: url(:/dark/transparent.svg); - background: #31363b; + background: #202326; width: 1.2em; height: 1.2em; padding: 0em; @@ -2570,7 +2570,7 @@ ads--CAutoHideDockContainer #dockAreaAutoHideButton #floatingTitleCloseButton:pressed, #floatingTitleMaximizeButton:pressed { - background: #31363b; + background: #202326; } #tabCloseButton, @@ -2713,7 +2713,7 @@ ads--CDockWidgetTab { border: 0.04em solid #76797c; border-top: 0.09em solid #76797c; - background-color: #2c3034; + background-color: #1b1d20; padding: 0.1em; min-width: 30px; border-radius: 0.09em; @@ -2723,7 +2723,7 @@ ads--CDockWidgetTab ads--CDockWidgetTab[activeTab="true"][focused="true"] { - background-color: #31363b; + background-color: #202326; border-top: 0.09em solid #3de9e3; border-left: 0.04em solid #76797c; border-right: 0.04em solid #3de9e3; @@ -2732,7 +2732,7 @@ ads--CDockWidgetTab[activeTab="true"][focused="true"] ads--CDockWidgetTab[activeTab="true"] { - background-color: #31363b; + background-color: #202326; border-top: 0.09em solid #3daee9; border-left: 0.04em solid #76797c; border-right: 0.04em solid #76797c; @@ -2741,12 +2741,12 @@ ads--CDockWidgetTab[activeTab="true"] ads--CDockWidgetTab QLabel { - background-color: #2c3034; + background-color: #1b1d20; } ads--CDockWidgetTab[activeTab="true"] QLabel { - background-color: #31363b; + background-color: #202326; } ads--CDockContainerWidget > QSplitter{ @@ -2942,7 +2942,7 @@ RibbonButtonGroup QFrame[frameShape="5"]:hover border-width: 0.04em; padding: 0.09em; border-style: solid; - border-color: #31363b; + border-color: #202326; background-color: #76797c; border-radius: 0.23em; } @@ -2950,7 +2950,7 @@ RibbonButtonGroup QFrame[frameShape="5"]:hover QHexView { qproperty-bytesColor: #eff0f1; - qproperty-bytesBackground: #31363b; + qproperty-bytesBackground: #202326; qproperty-bytesAlterBackground: #2C3136; qproperty-selectionColor: #eff0f1; qproperty-selBackgroundColor: #3daee9;