Skip to content

Commit

Permalink
V1.2.4
Browse files Browse the repository at this point in the history
  • Loading branch information
gztss committed Jul 3, 2018
1 parent 76b51dc commit d25e464
Show file tree
Hide file tree
Showing 14 changed files with 203 additions and 542 deletions.
484 changes: 0 additions & 484 deletions SerialTool/Makefile

This file was deleted.

4 changes: 4 additions & 0 deletions SerialTool/include/terminalview.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,10 @@ class TerminalView : public QWidget
void setPaused(bool status);
void setHighlight(const QString &language);
void setTextCodec(const QString &name);
void setTabsInsertSpaces(bool enable);
void setTabWidth(int width);
void setAutoIndent(bool enable);
void setIndentationGuides(bool enable);
void saveText(const QString &fname);

signals:
Expand Down
4 changes: 4 additions & 0 deletions SerialTool/include/textedit.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@ class TextEdit : public QsciScintilla
void append(const QString &text);
void setFonts(QString fonts, int size, QColor color = Qt::black, QString style = "");
void setHighLight(const QString &language);
void setIndentationsUseTabs(bool enable);
void setTabWidth(int width);
void setAutoIndent(bool enable);
void setIndentationGuides(bool enable);

public slots:
void setWrap(bool wrap);
Expand Down
4 changes: 2 additions & 2 deletions SerialTool/include/version.h
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
#ifndef __VERSION_H
#define __VERSION_H

#define MAIN_VERSION 1.2.3
#define MAIN_VERSION 1.2.4

#define SOFTWARE_NAME "SerialTool"
#define COPYRIGHT "Copyleft 2017-2018, Wenliang Guan"

#define _STR_(s) #s
#define __STR(s) _STR_(s)

#define BUILD_VERSION _STR_(492de)
#define BUILD_VERSION _STR_(48b44)
#define SOFTWARE_VERSION __STR(MAIN_VERSION)

#endif
82 changes: 51 additions & 31 deletions SerialTool/language/serialtool_zh_CN.ts
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@
</message>
<message>
<location filename="../ui/mainwindow.ui" line="226"/>
<location filename="../source/mainwindow.cpp" line="282"/>
<location filename="../source/mainwindow.cpp" line="286"/>
<source>Save</source>
<translation>保存</translation>
</message>
Expand All @@ -205,7 +205,7 @@
</message>
<message>
<location filename="../ui/mainwindow.ui" line="247"/>
<location filename="../source/mainwindow.cpp" line="464"/>
<location filename="../source/mainwindow.cpp" line="468"/>
<source>Open Port</source>
<translation>打开端口</translation>
</message>
Expand All @@ -216,7 +216,7 @@
</message>
<message>
<location filename="../ui/mainwindow.ui" line="263"/>
<location filename="../source/mainwindow.cpp" line="373"/>
<location filename="../source/mainwindow.cpp" line="377"/>
<source>Pause Tx/Rx</source>
<translation>暂停发送/接收</translation>
</message>
Expand Down Expand Up @@ -279,7 +279,7 @@
<message>
<location filename="../ui/mainwindow.ui" line="375"/>
<location filename="../ui/mainwindow.ui" line="378"/>
<location filename="../source/mainwindow.cpp" line="307"/>
<location filename="../source/mainwindow.cpp" line="311"/>
<source>Open</source>
<translation>打开</translation>
</message>
Expand All @@ -299,37 +299,37 @@
<translation>置于顶层</translation>
</message>
<message>
<location filename="../source/mainwindow.cpp" line="283"/>
<location filename="../source/mainwindow.cpp" line="292"/>
<location filename="../source/mainwindow.cpp" line="287"/>
<location filename="../source/mainwindow.cpp" line="296"/>
<source>Portable Network Graphic Format (*.png)</source>
<translation>图像文件存储格式 (*.png)</translation>
</message>
<message>
<location filename="../source/mainwindow.cpp" line="284"/>
<location filename="../source/mainwindow.cpp" line="294"/>
<location filename="../source/mainwindow.cpp" line="288"/>
<location filename="../source/mainwindow.cpp" line="298"/>
<source>Bitmap (*.bmp)</source>
<translation>位图文件 (*.bmp)</translation>
</message>
<message>
<location filename="../source/mainwindow.cpp" line="285"/>
<location filename="../source/mainwindow.cpp" line="296"/>
<location filename="../source/mainwindow.cpp" line="308"/>
<location filename="../source/mainwindow.cpp" line="289"/>
<location filename="../source/mainwindow.cpp" line="300"/>
<location filename="../source/mainwindow.cpp" line="312"/>
<source>Wave Plain Text File (*.txt)</source>
<translation>波形纯文本文件 (*.txt)</translation>
</message>
<message>
<location filename="../source/mainwindow.cpp" line="286"/>
<location filename="../source/mainwindow.cpp" line="298"/>
<location filename="../source/mainwindow.cpp" line="290"/>
<location filename="../source/mainwindow.cpp" line="302"/>
<source>Terminal Text File (*.txt)</source>
<translation>终端文本文件 (*.txt)</translation>
</message>
<message>
<location filename="../source/mainwindow.cpp" line="366"/>
<location filename="../source/mainwindow.cpp" line="370"/>
<source>Start Tx/Rx</source>
<translation>开始发送/接收</translation>
</message>
<message>
<location filename="../source/mainwindow.cpp" line="443"/>
<location filename="../source/mainwindow.cpp" line="447"/>
<source>Close Port</source>
<translation>关闭端口</translation>
</message>
Expand Down Expand Up @@ -413,8 +413,8 @@
<translation>ASCII字符</translation>
</message>
<message>
<location filename="../ui/optionsbox.ui" line="414"/>
<location filename="../ui/optionsbox.ui" line="441"/>
<location filename="../ui/optionsbox.ui" line="467"/>
<location filename="../ui/optionsbox.ui" line="494"/>
<source>Color...</source>
<translation>颜色...</translation>
</message>
Expand All @@ -434,62 +434,82 @@
<translation>代码高亮</translation>
</message>
<message>
<location filename="../ui/optionsbox.ui" line="373"/>
<location filename="../ui/optionsbox.ui" line="293"/>
<source>Auto Indent</source>
<translation>自动缩进</translation>
</message>
<message>
<location filename="../ui/optionsbox.ui" line="300"/>
<source>Tab Size</source>
<translation>Tab宽度</translation>
</message>
<message>
<location filename="../ui/optionsbox.ui" line="310"/>
<source>Tabs Insert Spaces</source>
<translation>Tab插入空格</translation>
</message>
<message>
<location filename="../ui/optionsbox.ui" line="339"/>
<source>Indentation Guides</source>
<translation>缩进提示</translation>
</message>
<message>
<location filename="../ui/optionsbox.ui" line="426"/>
<source>Plot</source>
<translation>波形绘制</translation>
</message>
<message>
<location filename="../ui/optionsbox.ui" line="388"/>
<location filename="../ui/optionsbox.ui" line="441"/>
<source>Color</source>
<translation>颜色</translation>
</message>
<message>
<location filename="../ui/optionsbox.ui" line="394"/>
<location filename="../ui/optionsbox.ui" line="447"/>
<source>Background</source>
<translation>背景颜色</translation>
</message>
<message>
<location filename="../ui/optionsbox.ui" line="421"/>
<location filename="../ui/optionsbox.ui" line="474"/>
<source>Grid</source>
<translation>网格颜色</translation>
</message>
<message>
<location filename="../ui/optionsbox.ui" line="451"/>
<location filename="../ui/optionsbox.ui" line="504"/>
<source>Graphics Options</source>
<translation>图形选项</translation>
</message>
<message>
<location filename="../ui/optionsbox.ui" line="460"/>
<location filename="../ui/optionsbox.ui" line="513"/>
<source>Update Interval (ms)</source>
<translation>刷新时间(ms)</translation>
</message>
<message>
<location filename="../ui/optionsbox.ui" line="467"/>
<location filename="../ui/optionsbox.ui" line="520"/>
<source>Use Antialias</source>
<translation>抗锯齿</translation>
</message>
<message>
<location filename="../ui/optionsbox.ui" line="474"/>
<location filename="../ui/optionsbox.ui" line="527"/>
<source>Use OpenGL</source>
<translation>使用OpenGL</translation>
</message>
<message>
<location filename="../ui/optionsbox.ui" line="530"/>
<location filename="../ui/optionsbox.ui" line="583"/>
<source>Command</source>
<translation>命令</translation>
</message>
<message>
<location filename="../ui/optionsbox.ui" line="560"/>
<location filename="../ui/optionsbox.ui" line="613"/>
<source>New</source>
<translation>新建</translation>
</message>
<message>
<location filename="../ui/optionsbox.ui" line="567"/>
<location filename="../ui/optionsbox.ui" line="620"/>
<source>Edit</source>
<translation>编辑</translation>
</message>
<message>
<location filename="../ui/optionsbox.ui" line="574"/>
<location filename="../ui/optionsbox.ui" line="627"/>
<source> Delete</source>
<translation>删除</translation>
</message>
Expand Down Expand Up @@ -578,12 +598,12 @@
<translation>波特率</translation>
</message>
<message>
<location filename="../source/serialport.cpp" line="84"/>
<location filename="../source/serialport.cpp" line="94"/>
<source>Error</source>
<translation>错误</translation>
</message>
<message>
<location filename="../source/serialport.cpp" line="85"/>
<location filename="../source/serialport.cpp" line="95"/>
<source>Can not open the port!
Port may be occupied or configured incorrectly!</source>
<translation>无法打开端口!
Expand Down
Binary file modified SerialTool/language/zh_cn/serialtool.qm
Binary file not shown.
4 changes: 4 additions & 0 deletions SerialTool/resource/default.ini
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@ FontStyle=normal
FontSize=10
TerminalHighlight=Bash
TerminalTextCodec=GB-2312
TerminalIndentationGuides=false
TerminalTabsInsertSpaces=false
TerminalAutoIndent=true
TerminalTabWidth=4
PlotBackground=#053846
AxisColor=#9499a3
UpdateInterval=25
Expand Down
4 changes: 4 additions & 0 deletions SerialTool/source/mainwindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,10 @@ void MainWindow::loadSettings()
ui->terminal->setHighlight(m_config->value("TerminalHighlight").toString());
// text codec
ui->terminal->setTextCodec(m_config->value("TerminalTextCodec").toString());
ui->terminal->setTabsInsertSpaces(m_config->value("TerminalTabsInsertSpaces").toBool());
ui->terminal->setTabWidth(m_config->value("TerminalTabWidth").toInt());
ui->terminal->setAutoIndent(m_config->value("TerminalAutoIndent").toBool());
ui->terminal->setIndentationGuides(m_config->value("TerminalIndentationGuides").toBool());

// 语言设置
setLanguage(m_config->value("Language").toString());
Expand Down
8 changes: 8 additions & 0 deletions SerialTool/source/optionsbox.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,10 @@ void OptionsBox::setup()
ui->portTypeBox->setCurrentIndex(config->value("PortType").toInt());
language = config->value("Language").toString();
theme = config->value("Theme").toString();
ui->tabWidthBox->setValue(config->value("TerminalTabWidth").toInt());
ui->tabsInsertSpacesBox->setChecked(config->value("TerminalTabsInsertSpaces").toBool());
ui->autoIndentBox->setChecked(config->value("TerminalAutoIndent").toBool());
ui->indentationGuidesBox->setChecked(config->value("TerminalIndentationGuides").toBool());
config->endGroup();

if (!fontFamily.isEmpty()) {
Expand Down Expand Up @@ -162,6 +166,10 @@ void OptionsBox::processOptions(QAbstractButton *button)
config->setValue("PortType", QVariant(ui->portTypeBox->currentIndex()));
config->setValue("Language", QVariant(language));
config->setValue("Theme", QVariant(ui->themeBox->currentText()));
config->setValue("TerminalTabWidth", QVariant(ui->tabWidthBox->value()));
config->setValue("TerminalTabsInsertSpaces", QVariant(ui->tabsInsertSpacesBox->isChecked()));
config->setValue("TerminalAutoIndent", QVariant(ui->autoIndentBox->isChecked()));
config->setValue("TerminalIndentationGuides", QVariant(ui->indentationGuidesBox->isChecked()));
config->endGroup();
saveCommand(); // 保存命令
m_parent->loadSettings(); // 配置生效
Expand Down
20 changes: 20 additions & 0 deletions SerialTool/source/terminalview.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -413,3 +413,23 @@ void TerminalView::saveText(const QString &fname)
file.close();
}
}

void TerminalView::setTabsInsertSpaces(bool enable)
{
ui->textEditTx->setIndentationsUseTabs(!enable);
}

void TerminalView::setTabWidth(int width)
{
ui->textEditTx->setTabWidth(width);
}

void TerminalView::setAutoIndent(bool enable)
{
ui->textEditTx->setAutoIndent(enable);
}

void TerminalView::setIndentationGuides(bool enable)
{
ui->textEditTx->setIndentationGuides(enable);
}
30 changes: 29 additions & 1 deletion SerialTool/source/textedit.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,13 @@ TextEdit::TextEdit(QWidget *parent) : QsciScintilla(parent)
{
SendScintilla(SCI_SETCODEPAGE, SC_CP_UTF8);
SendScintilla(SCI_SETLAYOUTCACHE, SC_CACHE_DOCUMENT);

setTabIndents(true); // indent alignment
setAutoIndent(true);
setTabWidth(4);
setIndentationsUseTabs(false);
setIndentationGuides(false);

connect(this, &QsciScintilla::textChanged, this, &TextEdit::onTextChanged);
connect(verticalScrollBar(), &QScrollBar::rangeChanged, this, &TextEdit::onVScrollBarRangeChanged);
connect(verticalScrollBar(), &QScrollBar::valueChanged, this, &TextEdit::onVScrollBarValueChanged);
Expand Down Expand Up @@ -229,6 +236,7 @@ void TextEdit::highlightJSON()
// 下面设置各种语法元素前景色
SendScintilla(SCI_STYLESETFORE, QsciLexerJSON::Default, 0x38312A); // 默认
SendScintilla(SCI_STYLESETFORE, QsciLexerJSON::Keyword, 0x8B8B00); // 关键字

SendScintilla(SCI_STYLESETFORE, QsciLexerJSON::String, 0x6666D4); // 字符串
SendScintilla(SCI_STYLESETFORE, QsciLexerJSON::Operator, 0xB48246); // 运算符
SendScintilla(SCI_STYLESETFORE, QsciLexerJSON::Number, 0x006F7F); // 数字
Expand All @@ -249,8 +257,28 @@ void TextEdit::setHighLight(const QString &language)
highlightNone();
}
m_language = language;
SendScintilla(SCI_SETTABWIDTH, 4); // Tab宽度

// 当前行高亮
SendScintilla(SCI_SETCARETLINEVISIBLE, true);
SendScintilla(SCI_SETCARETLINEBACK, 0xE0E0E0);
}

void TextEdit::setIndentationsUseTabs(bool enable)
{
QsciScintilla::setIndentationsUseTabs(enable);
}

void TextEdit::setTabWidth(int width)
{
QsciScintilla::setTabWidth(width);
}

void TextEdit::setAutoIndent(bool enable)
{
QsciScintilla::setAutoIndent(enable);
}

void TextEdit::setIndentationGuides(bool enable)
{
QsciScintilla::setIndentationGuides(enable);
}
Loading

0 comments on commit d25e464

Please sign in to comment.