13 changed files with 469 additions and 6 deletions
|
Before Width: | Height: | Size: 9.1 KiB After Width: | Height: | Size: 14 KiB |
|
After Width: | Height: | Size: 22 KiB |
@ -0,0 +1,118 @@
@@ -0,0 +1,118 @@
|
||||
///////////////////////////////////////////////////////////////////////////////////
|
||||
// Copyright (C) 2021 Jon Beniston, M7RCE //
|
||||
// //
|
||||
// This program is free software; you can redistribute it and/or modify //
|
||||
// it under the terms of the GNU General Public License as published by //
|
||||
// the Free Software Foundation as version 3 of the License, or //
|
||||
// (at your option) any later version. //
|
||||
// //
|
||||
// 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 General Public License V3 for more details. //
|
||||
// //
|
||||
// You should have received a copy of the GNU General Public License //
|
||||
// along with this program. If not, see <http://www.gnu.org/licenses/>. //
|
||||
///////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include <QDebug> |
||||
|
||||
#include "pagerdemodcharsetdialog.h" |
||||
|
||||
PagerDemodCharsetDialog::PagerDemodCharsetDialog(PagerDemodSettings *settings, |
||||
QWidget* parent) : |
||||
QDialog(parent), |
||||
m_settings(settings), |
||||
ui(new Ui::PagerDemodCharsetDialog) |
||||
{ |
||||
ui->setupUi(this); |
||||
if (settings->m_sevenbit.size() > 0) { |
||||
ui->preset->setCurrentIndex(2); // User
|
||||
} |
||||
ui->readingOrder->setCurrentIndex(settings->m_rightToLeft ? 1 : 0); |
||||
for (int i = 0; i < settings->m_sevenbit.size(); i++) { |
||||
addRow(settings->m_sevenbit[i], settings->m_unicode[i]); |
||||
} |
||||
connect(ui->table, &QTableWidget::cellChanged, this, &PagerDemodCharsetDialog::on_table_cellChanged); |
||||
} |
||||
|
||||
PagerDemodCharsetDialog::~PagerDemodCharsetDialog() |
||||
{ |
||||
delete ui; |
||||
} |
||||
|
||||
void PagerDemodCharsetDialog::accept() |
||||
{ |
||||
m_settings->m_sevenbit.clear(); |
||||
m_settings->m_unicode.clear(); |
||||
for (int i = 0; i < ui->table->rowCount(); i++) |
||||
{ |
||||
int sevenbit = ui->table->item(i, SEVENBIT_COL)->data(Qt::DisplayRole).toString().toInt(nullptr, 16); |
||||
int unicode = ui->table->item(i, UNICODE_COL)->data(Qt::DisplayRole).toString().toInt(nullptr, 16); |
||||
m_settings->m_sevenbit.append(sevenbit); |
||||
m_settings->m_unicode.append(unicode); |
||||
} |
||||
m_settings->m_rightToLeft = ui->readingOrder->currentIndex() == 1; |
||||
QDialog::accept(); |
||||
} |
||||
|
||||
void PagerDemodCharsetDialog::on_add_clicked() |
||||
{ |
||||
addRow(0, 0); |
||||
} |
||||
|
||||
void PagerDemodCharsetDialog::on_remove_clicked() |
||||
{ |
||||
QModelIndexList indexList = ui->table->selectionModel()->selectedRows(); |
||||
if (!indexList.isEmpty()) |
||||
{ |
||||
int row = indexList.at(0).row(); |
||||
ui->table->removeRow(row); |
||||
} |
||||
} |
||||
|
||||
void PagerDemodCharsetDialog::on_preset_currentIndexChanged(int index) |
||||
{ |
||||
ui->table->setRowCount(0); |
||||
ui->readingOrder->setCurrentIndex(0); |
||||
if (index == 1) |
||||
{ |
||||
// Hebrew
|
||||
for (int i = 0; i < 22; i++) { |
||||
addRow(96 + i, 0x05D0 + i); |
||||
} |
||||
ui->readingOrder->setCurrentIndex(1); |
||||
} |
||||
} |
||||
|
||||
void PagerDemodCharsetDialog::addRow(int sevenBit, int unicode) |
||||
{ |
||||
ui->table->setSortingEnabled(false); |
||||
ui->table->blockSignals(true); |
||||
int row = ui->table->rowCount(); |
||||
ui->table->setRowCount(row + 1); |
||||
QTableWidgetItem *sevenbitItem = new QTableWidgetItem(); |
||||
QTableWidgetItem *unicodeItem = new QTableWidgetItem(); |
||||
QTableWidgetItem *glyphItem = new QTableWidgetItem(); |
||||
ui->table->setItem(row, SEVENBIT_COL, sevenbitItem); |
||||
ui->table->setItem(row, UNICODE_COL, unicodeItem); |
||||
ui->table->setItem(row, GLYPH_COL, glyphItem); |
||||
sevenbitItem->setFlags(Qt::ItemIsEditable | sevenbitItem->flags()); |
||||
sevenbitItem->setData(Qt::DisplayRole, QString::number(sevenBit, 16)); |
||||
unicodeItem->setFlags(Qt::ItemIsEditable | unicodeItem->flags()); |
||||
unicodeItem->setData(Qt::DisplayRole, QString::number(unicode, 16)); |
||||
glyphItem->setFlags(glyphItem->flags() & ~Qt::ItemIsEditable); |
||||
glyphItem->setData(Qt::DisplayRole, QChar(unicode)); |
||||
ui->table->blockSignals(false); |
||||
ui->table->setSortingEnabled(true); |
||||
} |
||||
|
||||
void PagerDemodCharsetDialog::on_table_cellChanged(int row, int column) |
||||
{ |
||||
if (column == UNICODE_COL) |
||||
{ |
||||
// Update glyph to match entered unicode code point
|
||||
int unicode = ui->table->item(row, UNICODE_COL)->data(Qt::DisplayRole).toString().toInt(nullptr, 16); |
||||
ui->table->item(row, GLYPH_COL)->setData(Qt::DisplayRole, QChar(unicode)); |
||||
} |
||||
} |
||||
@ -0,0 +1,55 @@
@@ -0,0 +1,55 @@
|
||||
///////////////////////////////////////////////////////////////////////////////////
|
||||
// Copyright (C) 2021 Jon Beniston, M7RCE //
|
||||
// //
|
||||
// This program is free software; you can redistribute it and/or modify //
|
||||
// it under the terms of the GNU General Public License as published by //
|
||||
// the Free Software Foundation as version 3 of the License, or //
|
||||
// (at your option) any later version. //
|
||||
// //
|
||||
// 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 General Public License V3 for more details. //
|
||||
// //
|
||||
// You should have received a copy of the GNU General Public License //
|
||||
// along with this program. If not, see <http://www.gnu.org/licenses/>. //
|
||||
///////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef INCLUDE_PAGERDEMODCHARSETDIALOG_H |
||||
#define INCLUDE_PAGERDEMODCHARSETDIALOG_H |
||||
|
||||
#include <QHash> |
||||
#include <QNetworkRequest> |
||||
|
||||
#include "ui_pagerdemodcharsetdialog.h" |
||||
#include "pagerdemodsettings.h" |
||||
|
||||
class PagerDemodCharsetDialog : public QDialog { |
||||
Q_OBJECT |
||||
|
||||
public: |
||||
explicit PagerDemodCharsetDialog(PagerDemodSettings* settings, QWidget* parent = 0); |
||||
~PagerDemodCharsetDialog(); |
||||
|
||||
PagerDemodSettings *m_settings; |
||||
|
||||
private slots: |
||||
void accept(); |
||||
void on_add_clicked(); |
||||
void on_remove_clicked(); |
||||
void on_preset_currentIndexChanged(int index); |
||||
void on_table_cellChanged(int row, int column); |
||||
|
||||
private: |
||||
Ui::PagerDemodCharsetDialog* ui; |
||||
|
||||
enum Columns { |
||||
SEVENBIT_COL, |
||||
UNICODE_COL, |
||||
GLYPH_COL |
||||
}; |
||||
|
||||
void addRow(int sevenBit, int unicode); |
||||
}; |
||||
|
||||
#endif // INCLUDE_PAGERDEMODCHARSETDIALOG_H
|
||||
@ -0,0 +1,208 @@
@@ -0,0 +1,208 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?> |
||||
<ui version="4.0"> |
||||
<class>PagerDemodCharsetDialog</class> |
||||
<widget class="QDialog" name="PagerDemodCharsetDialog"> |
||||
<property name="geometry"> |
||||
<rect> |
||||
<x>0</x> |
||||
<y>0</y> |
||||
<width>403</width> |
||||
<height>561</height> |
||||
</rect> |
||||
</property> |
||||
<property name="font"> |
||||
<font> |
||||
<family>Liberation Sans</family> |
||||
<pointsize>9</pointsize> |
||||
</font> |
||||
</property> |
||||
<property name="windowTitle"> |
||||
<string>Set chararcter encoding</string> |
||||
</property> |
||||
<layout class="QVBoxLayout" name="verticalLayout"> |
||||
<item> |
||||
<layout class="QHBoxLayout" name="presetLayout"> |
||||
<item> |
||||
<widget class="QLabel" name="presetLabel"> |
||||
<property name="text"> |
||||
<string>Preset</string> |
||||
</property> |
||||
</widget> |
||||
</item> |
||||
<item> |
||||
<widget class="QComboBox" name="preset"> |
||||
<property name="toolTip"> |
||||
<string>Select a pre-defined character encoding</string> |
||||
</property> |
||||
<item> |
||||
<property name="text"> |
||||
<string>Latin</string> |
||||
</property> |
||||
</item> |
||||
<item> |
||||
<property name="text"> |
||||
<string>Hebrew</string> |
||||
</property> |
||||
</item> |
||||
<item> |
||||
<property name="text"> |
||||
<string>User</string> |
||||
</property> |
||||
</item> |
||||
</widget> |
||||
</item> |
||||
<item> |
||||
<spacer name="presetlSpacer"> |
||||
<property name="orientation"> |
||||
<enum>Qt::Horizontal</enum> |
||||
</property> |
||||
<property name="sizeHint" stdset="0"> |
||||
<size> |
||||
<width>40</width> |
||||
<height>20</height> |
||||
</size> |
||||
</property> |
||||
</spacer> |
||||
</item> |
||||
<item> |
||||
<widget class="QLabel" name="readingOrderLabel"> |
||||
<property name="text"> |
||||
<string>Reading Order</string> |
||||
</property> |
||||
</widget> |
||||
</item> |
||||
<item> |
||||
<widget class="QComboBox" name="readingOrder"> |
||||
<property name="minimumSize"> |
||||
<size> |
||||
<width>100</width> |
||||
<height>0</height> |
||||
</size> |
||||
</property> |
||||
<property name="toolTip"> |
||||
<string>Specify the order in which characters should be displayed</string> |
||||
</property> |
||||
<item> |
||||
<property name="text"> |
||||
<string>Left-to-right</string> |
||||
</property> |
||||
</item> |
||||
<item> |
||||
<property name="text"> |
||||
<string>Right-to-left</string> |
||||
</property> |
||||
</item> |
||||
</widget> |
||||
</item> |
||||
</layout> |
||||
</item> |
||||
<item> |
||||
<layout class="QHBoxLayout" name="tableLayout"> |
||||
<item> |
||||
<widget class="QTableWidget" name="table"> |
||||
<property name="selectionMode"> |
||||
<enum>QAbstractItemView::SingleSelection</enum> |
||||
</property> |
||||
<property name="selectionBehavior"> |
||||
<enum>QAbstractItemView::SelectRows</enum> |
||||
</property> |
||||
<column> |
||||
<property name="text"> |
||||
<string>7-bit</string> |
||||
</property> |
||||
</column> |
||||
<column> |
||||
<property name="text"> |
||||
<string>Unicode</string> |
||||
</property> |
||||
</column> |
||||
<column> |
||||
<property name="text"> |
||||
<string>Glyph</string> |
||||
</property> |
||||
</column> |
||||
</widget> |
||||
</item> |
||||
</layout> |
||||
</item> |
||||
<item> |
||||
<layout class="QHBoxLayout" name="buttonLayout"> |
||||
<item> |
||||
<widget class="QPushButton" name="add"> |
||||
<property name="text"> |
||||
<string>+</string> |
||||
</property> |
||||
</widget> |
||||
</item> |
||||
<item> |
||||
<widget class="QPushButton" name="remove"> |
||||
<property name="text"> |
||||
<string>-</string> |
||||
</property> |
||||
</widget> |
||||
</item> |
||||
<item> |
||||
<spacer name="buttonSpacer"> |
||||
<property name="orientation"> |
||||
<enum>Qt::Horizontal</enum> |
||||
</property> |
||||
<property name="sizeHint" stdset="0"> |
||||
<size> |
||||
<width>40</width> |
||||
<height>20</height> |
||||
</size> |
||||
</property> |
||||
</spacer> |
||||
</item> |
||||
</layout> |
||||
</item> |
||||
<item> |
||||
<widget class="QDialogButtonBox" name="buttonBox"> |
||||
<property name="orientation"> |
||||
<enum>Qt::Horizontal</enum> |
||||
</property> |
||||
<property name="standardButtons"> |
||||
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set> |
||||
</property> |
||||
</widget> |
||||
</item> |
||||
</layout> |
||||
</widget> |
||||
<resources> |
||||
<include location="../../../sdrgui/resources/res.qrc"/> |
||||
</resources> |
||||
<connections> |
||||
<connection> |
||||
<sender>buttonBox</sender> |
||||
<signal>accepted()</signal> |
||||
<receiver>PagerDemodCharsetDialog</receiver> |
||||
<slot>accept()</slot> |
||||
<hints> |
||||
<hint type="sourcelabel"> |
||||
<x>248</x> |
||||
<y>254</y> |
||||
</hint> |
||||
<hint type="destinationlabel"> |
||||
<x>157</x> |
||||
<y>274</y> |
||||
</hint> |
||||
</hints> |
||||
</connection> |
||||
<connection> |
||||
<sender>buttonBox</sender> |
||||
<signal>rejected()</signal> |
||||
<receiver>PagerDemodCharsetDialog</receiver> |
||||
<slot>reject()</slot> |
||||
<hints> |
||||
<hint type="sourcelabel"> |
||||
<x>316</x> |
||||
<y>260</y> |
||||
</hint> |
||||
<hint type="destinationlabel"> |
||||
<x>286</x> |
||||
<y>274</y> |
||||
</hint> |
||||
</hints> |
||||
</connection> |
||||
</connections> |
||||
</ui> |
||||
Loading…
Reference in new issue