diff --git a/DSView/src/appcore/appcontrol.cpp b/DSView/src/appcore/appcontrol.cpp index 7a0377fb..3d5a13e7 100644 --- a/DSView/src/appcore/appcontrol.cpp +++ b/DSView/src/appcore/appcontrol.cpp @@ -181,7 +181,7 @@ void AppControl::remove_font_form(IFontForm *form) void AppControl::update_font_forms() { for (auto f : _font_forms){ - f->update_font(); + f->UpdateFont(); } } diff --git a/DSView/src/appcore/mainframe.cpp b/DSView/src/appcore/mainframe.cpp index 2f2016e2..680bb0de 100644 --- a/DSView/src/appcore/mainframe.cpp +++ b/DSView/src/appcore/mainframe.cpp @@ -429,7 +429,7 @@ void MainFrame::readSettings() AppConfig &app = AppConfig::Instance(); if (app.frameOptions.language > 0){ - _mainWindow->switchLanguage(app.frameOptions.language); + _mainWindow->SwitchLanguage(app.frameOptions.language); } int left = app.frameOptions.left; diff --git a/DSView/src/appcore/mainwindow.cpp b/DSView/src/appcore/mainwindow.cpp index dcf006b0..ff7aa6bf 100644 --- a/DSView/src/appcore/mainwindow.cpp +++ b/DSView/src/appcore/mainwindow.cpp @@ -238,7 +238,7 @@ namespace appcore { // defaut language AppConfig &app = AppConfig::Instance(); - switchLanguage(app.frameOptions.language); + SwitchLanguage(app.frameOptions.language); switchTheme(app.frameOptions.style); retranslateUi(); @@ -1356,7 +1356,7 @@ namespace appcore { return false; } - void MainWindow::switchLanguage(int language) + void MainWindow::SwitchLanguage(int language) { if (language == 0) return; diff --git a/DSView/src/appcore/mainwindow.h b/DSView/src/appcore/mainwindow.h index fc4f7a3a..0f01636f 100644 --- a/DSView/src/appcore/mainwindow.h +++ b/DSView/src/appcore/mainwindow.h @@ -139,7 +139,7 @@ signals: public: //IMainForm - void switchLanguage(int language) override; + void SwitchLanguage(int language) override; bool able_to_close(); private: diff --git a/DSView/src/data/mathstack.h b/DSView/src/data/mathstack.h index 9e6e6be5..4864a6cd 100644 --- a/DSView/src/data/mathstack.h +++ b/DSView/src/data/mathstack.h @@ -29,18 +29,15 @@ #include "signaldata.h" namespace dsv{ - namespace appcore{ + namespace appcore{ class SigSession; } -} -using namespace dsv::appcore; - -namespace dsv{ namespace view{ class DsoSignal; class dslDial; } } +using namespace dsv::appcore; using namespace dsv::view; namespace dsv { diff --git a/DSView/src/decode/row.h b/DSView/src/decode/row.h index 66abbe69..cf09c795 100644 --- a/DSView/src/decode/row.h +++ b/DSView/src/decode/row.h @@ -23,7 +23,6 @@ #define DECODE_ROW_H #include - #include "annotation.h" struct srd_decoder; diff --git a/DSView/src/dialogs/decoderoptionsdlg.cpp b/DSView/src/dialogs/decoderoptionsdlg.cpp index e787c1c9..acccd61b 100644 --- a/DSView/src/dialogs/decoderoptionsdlg.cpp +++ b/DSView/src/dialogs/decoderoptionsdlg.cpp @@ -206,7 +206,7 @@ void DecoderOptionsDlg::load_options_view() confirm_button_box->addWidget(button_box, 0, Qt::AlignRight); form->addRow(confirm_button_box); - this->update_font(); + this->UpdateFont(); int real_content_width = _content_width; int content_height = _contentHeight; diff --git a/DSView/src/dialogs/deviceoptions.cpp b/DSView/src/dialogs/deviceoptions.cpp index e18096d1..8af806fd 100644 --- a/DSView/src/dialogs/deviceoptions.cpp +++ b/DSView/src/dialogs/deviceoptions.cpp @@ -398,7 +398,7 @@ void DeviceOptions::logic_probes(QVBoxLayout &layout) enable_all_probes->setMaximumWidth(bt_width); disable_all_probes->setMaximumWidth(bt_width); - this->update_font(); + this->UpdateFont(); contentHeight += enable_all_probes->sizeHint().height(); contentHeight += channel_line_height * row2 + 50; @@ -734,7 +734,7 @@ void DeviceOptions::analog_probes(QGridLayout &layout) layout.addWidget(tabWidget, 0, 0, 1, 1); - this->update_font(); + this->UpdateFont(); _groupHeight2 = tabWidget->sizeHint().height() + 10; _dynamic_panel->setFixedHeight(_groupHeight2); @@ -836,7 +836,7 @@ void DeviceOptions::build_dynamic_panel() int bb = 0; void DeviceOptions::try_resize_scroll() { - this->update_font(); + this->UpdateFont(); // content area height int contentHeight = _groupHeight1 + _groupHeight2 + 20; // +space diff --git a/DSView/src/dialogs/dsdialog.cpp b/DSView/src/dialogs/dsdialog.cpp index 24b0a1d6..98d7a7c0 100644 --- a/DSView/src/dialogs/dsdialog.cpp +++ b/DSView/src/dialogs/dsdialog.cpp @@ -129,7 +129,7 @@ int DSDialog::exec() connect(_base_button, SIGNAL(accepted()), this, SLOT(accept())); } - update_font(); + UpdateFont(); return QDialog::exec(); } @@ -175,20 +175,20 @@ void DSDialog::build_base(bool hasClose) _main_layout->setContentsMargins(10,5,10,10); } -void DSDialog::update_font() +void DSDialog::UpdateFont() { QFont font = this->font(); font.setPointSizeF(AppConfig::Instance().appOptions.fontSize); ui::set_form_font(this, font); if (_titlebar != NULL){ - _titlebar->update_font(); + _titlebar->UpdateFont(); } } void DSDialog::show() { - update_font(); + UpdateFont(); QWidget::show(); } diff --git a/DSView/src/dialogs/dsdialog.h b/DSView/src/dialogs/dsdialog.h index f7ce2323..afcda50c 100644 --- a/DSView/src/dialogs/dsdialog.h +++ b/DSView/src/dialogs/dsdialog.h @@ -67,7 +67,7 @@ public: void SetTitleSpace(int h); //IFontForm - void update_font() override; + void UpdateFont() override; void show(); diff --git a/DSView/src/dialogs/dsmessagebox.cpp b/DSView/src/dialogs/dsmessagebox.cpp index da05e2e8..7eca6413 100644 --- a/DSView/src/dialogs/dsmessagebox.cpp +++ b/DSView/src/dialogs/dsmessagebox.cpp @@ -136,7 +136,7 @@ int DSMessageBox::exec() ui::set_form_font(this, font); if (_titlebar != NULL){ - _titlebar->update_font(); + _titlebar->UpdateFont(); } return QDialog::exec(); diff --git a/DSView/src/dock/dsotriggerdock.cpp b/DSView/src/dock/dsotriggerdock.cpp index fd632ab5..bcdc8730 100644 --- a/DSView/src/dock/dsotriggerdock.cpp +++ b/DSView/src/dock/dsotriggerdock.cpp @@ -173,7 +173,7 @@ DsoTriggerDock::DsoTriggerDock(QWidget *parent, SigSession *session) : retranslateUi(); - update_font(); + UpdateFont(); } DsoTriggerDock::~DsoTriggerDock() @@ -488,7 +488,7 @@ void DsoTriggerDock::update_view() connect(_margin_slider, SIGNAL(valueChanged(int)), this, SLOT(margin_changed(int))); } -void DsoTriggerDock::update_font() +void DsoTriggerDock::UpdateFont() { QFont font = this->font(); font.setPointSizeF(AppConfig::Instance().appOptions.fontSize); diff --git a/DSView/src/dock/dsotriggerdock.h b/DSView/src/dock/dsotriggerdock.h index c76fe1fd..3ce9dfd4 100644 --- a/DSView/src/dock/dsotriggerdock.h +++ b/DSView/src/dock/dsotriggerdock.h @@ -63,7 +63,7 @@ private: bool check_trig_channel(); //IFontForm - void update_font() override; + void UpdateFont() override; signals: void set_trig_pos(int percent); diff --git a/DSView/src/dock/measuredock.cpp b/DSView/src/dock/measuredock.cpp index b9526303..c3340fb5 100644 --- a/DSView/src/dock/measuredock.cpp +++ b/DSView/src/dock/measuredock.cpp @@ -150,7 +150,7 @@ MeasureDock::MeasureDock(QWidget *parent, View &view, SigSession *session) : connect(_fen_checkBox, SIGNAL(stateChanged(int)), &_view, SLOT(set_measure_en(int))); connect(&_view, SIGNAL(measure_updated()), this, SLOT(measure_updated())); - update_font(); + UpdateFont(); } MeasureDock::~MeasureDock() @@ -827,7 +827,7 @@ void MeasureDock::del_cursor() _view.update(); } -void MeasureDock::update_font() +void MeasureDock::UpdateFont() { QFont font = this->font(); font.setPointSizeF(AppConfig::Instance().appOptions.fontSize); diff --git a/DSView/src/dock/measuredock.h b/DSView/src/dock/measuredock.h index b50fee85..5c841954 100644 --- a/DSView/src/dock/measuredock.h +++ b/DSView/src/dock/measuredock.h @@ -94,7 +94,7 @@ private: void reStyle(); //IFontForm - void update_font() override; + void UpdateFont() override; void build_dist_pannel(); void build_edge_pannel(); diff --git a/DSView/src/dock/protocoldock.cpp b/DSView/src/dock/protocoldock.cpp index c37b5a56..e079c350 100644 --- a/DSView/src/dock/protocoldock.cpp +++ b/DSView/src/dock/protocoldock.cpp @@ -226,7 +226,7 @@ ProtocolDock::ProtocolDock(QWidget *parent, view::View &view, SigSession *sessio connect(_pro_search_button, SIGNAL(clicked()), this, SLOT(show_protocol_select())); - update_font(); + UpdateFont(); } ProtocolDock::~ProtocolDock() @@ -1041,7 +1041,7 @@ bool ProtocolDock::protocol_sort_callback(const DecoderInfoItem *o1, const Decod } } - void ProtocolDock::update_font() + void ProtocolDock::UpdateFont() { QFont font = this->font(); font.setPointSizeF(AppConfig::Instance().appOptions.fontSize); @@ -1049,7 +1049,7 @@ bool ProtocolDock::protocol_sort_callback(const DecoderInfoItem *o1, const Decod _table_view->setFont(font); for(auto lay : _protocol_lay_items){ - lay->update_font(); + lay->UpdateFont(); } font.setPointSizeF(font.pointSizeF() + 1); diff --git a/DSView/src/dock/protocoldock.h b/DSView/src/dock/protocoldock.h index 006c6b90..dcd6cfe2 100644 --- a/DSView/src/dock/protocoldock.h +++ b/DSView/src/dock/protocoldock.h @@ -120,7 +120,7 @@ private: void update_deocder_item_name(void *trace_handel, const char *name) override; //IFontForm - void update_font() override; + void UpdateFont() override; signals: void protocol_updated(); diff --git a/DSView/src/dock/protocolitemlayer.cpp b/DSView/src/dock/protocolitemlayer.cpp index e5b3ef02..85eba075 100644 --- a/DSView/src/dock/protocolitemlayer.cpp +++ b/DSView/src/dock/protocolitemlayer.cpp @@ -73,7 +73,7 @@ ProtocolItemLayer::ProtocolItemLayer(QWidget *parent, QString protocolName, IPro connect(_set_button, SIGNAL(clicked()),this, SLOT(on_set_protocol())); connect(_format_combox, SIGNAL(currentIndexChanged(int)),this, SLOT(on_format_select_changed(int))); - update_font(); + UpdateFont(); } ProtocolItemLayer::~ProtocolItemLayer(){ diff --git a/DSView/src/dock/protocolitemlayer.h b/DSView/src/dock/protocolitemlayer.h index 38ad3eb7..1d2954c0 100644 --- a/DSView/src/dock/protocolitemlayer.h +++ b/DSView/src/dock/protocolitemlayer.h @@ -71,7 +71,7 @@ public: void set_label_name(QString name); - void update_font(); + void UpdateFont(); private slots: void on_set_protocol(); diff --git a/DSView/src/dock/searchdock.cpp b/DSView/src/dock/searchdock.cpp index 71ecfb99..90800e89 100644 --- a/DSView/src/dock/searchdock.cpp +++ b/DSView/src/dock/searchdock.cpp @@ -85,7 +85,7 @@ SearchDock::SearchDock(QWidget *parent, View &view, SigSession *session) : retranslateUi(); - update_font(); + UpdateFont(); connect(&_pre_button, SIGNAL(clicked()), this, SLOT(on_previous())); connect(&_nxt_button, SIGNAL(clicked()),this, SLOT(on_next())); @@ -254,7 +254,7 @@ void SearchDock::on_set() } } -void SearchDock::update_font() +void SearchDock::UpdateFont() { QFont font = this->font(); font.setPointSizeF(AppConfig::Instance().appOptions.fontSize); diff --git a/DSView/src/dock/searchdock.h b/DSView/src/dock/searchdock.h index 7d3e390d..61eac814 100644 --- a/DSView/src/dock/searchdock.h +++ b/DSView/src/dock/searchdock.h @@ -76,7 +76,7 @@ private: void reStyle(); //IFontForm - void update_font() override; + void UpdateFont() override; public slots: void on_previous(); diff --git a/DSView/src/dock/triggerdock.cpp b/DSView/src/dock/triggerdock.cpp index c999715d..81542b50 100644 --- a/DSView/src/dock/triggerdock.cpp +++ b/DSView/src/dock/triggerdock.cpp @@ -134,7 +134,7 @@ TriggerDock::TriggerDock(QWidget *parent, SigSession *session) : retranslateUi(); - update_font(); + UpdateFont(); } TriggerDock::~TriggerDock() @@ -1072,7 +1072,7 @@ void TriggerDock::on_serial_hex_changed() _is_serial_val_setting = false; } -void TriggerDock::update_font() +void TriggerDock::UpdateFont() { QFont font = this->font(); font.setPointSizeF(AppConfig::Instance().appOptions.fontSize); diff --git a/DSView/src/dock/triggerdock.h b/DSView/src/dock/triggerdock.h index 6285177a..305c1543 100644 --- a/DSView/src/dock/triggerdock.h +++ b/DSView/src/dock/triggerdock.h @@ -90,7 +90,7 @@ private: bool commit_trigger(); //IFontForm - void update_font() override; + void UpdateFont() override; private slots: void simple_trigger(); diff --git a/DSView/src/interface/icallbacks.h b/DSView/src/interface/icallbacks.h index 2cfed68f..db040596 100644 --- a/DSView/src/interface/icallbacks.h +++ b/DSView/src/interface/icallbacks.h @@ -59,11 +59,6 @@ public: virtual void OnDlgResult(bool bYes)=0; }; -class IMainForm{ -public: - virtual void switchLanguage(int language)=0; -}; - #define DSV_MSG_START_COLLECT_WORK_PREV 5001 #define DSV_MSG_START_COLLECT_WORK 5002 @@ -108,10 +103,4 @@ public: virtual void update_deocder_item_name(void *trace_handel, const char *name)=0; }; -class IFontForm -{ -public: - virtual void update_font()=0; -}; - #endif diff --git a/DSView/src/toolbars/filebar.cpp b/DSView/src/toolbars/filebar.cpp index 8d95c61d..bceaa14b 100644 --- a/DSView/src/toolbars/filebar.cpp +++ b/DSView/src/toolbars/filebar.cpp @@ -96,7 +96,7 @@ FileBar::FileBar(SigSession *session, QWidget *parent) : connect(_action_export, SIGNAL(triggered()), this, SIGNAL(sig_export())); connect(_action_capture, SIGNAL(triggered()), this, SLOT(on_actionCapture_triggered())); - update_font(); + UpdateFont(); } void FileBar::changeEvent(QEvent *event) @@ -256,7 +256,7 @@ void FileBar::update_view_status() _menu_session->setEnabled(bEnable && is_hardware); } -void FileBar::update_font() +void FileBar::UpdateFont() { QFont font = this->font(); font.setPointSizeF(AppConfig::Instance().appOptions.fontSize); diff --git a/DSView/src/toolbars/filebar.h b/DSView/src/toolbars/filebar.h index d958b6a3..09acd940 100644 --- a/DSView/src/toolbars/filebar.h +++ b/DSView/src/toolbars/filebar.h @@ -58,7 +58,7 @@ private: void reStyle(); //IFontForm - void update_font() override; + void UpdateFont() override; signals: void sig_load_file(QString); diff --git a/DSView/src/toolbars/logobar.cpp b/DSView/src/toolbars/logobar.cpp index 3bc831e9..18f05d3d 100644 --- a/DSView/src/toolbars/logobar.cpp +++ b/DSView/src/toolbars/logobar.cpp @@ -124,7 +124,7 @@ LogoBar::LogoBar(SigSession *session, QWidget *parent) : connect(_update, SIGNAL(triggered()), this, SLOT(on_action_update())); connect(_log, SIGNAL(triggered()), this, SLOT(on_action_setting_log())); - update_font(); + UpdateFont(); } void LogoBar::changeEvent(QEvent *event) @@ -188,7 +188,7 @@ void LogoBar::on_actionEn_triggered() QIcon(":/icons/English.svg"))); assert(_mainForm); - _mainForm->switchLanguage(LAN_EN); + _mainForm->SwitchLanguage(LAN_EN); } void LogoBar::on_actionCn_triggered() @@ -196,7 +196,7 @@ void LogoBar::on_actionCn_triggered() _language->setIcon(QIcon::fromTheme("file", QIcon(":/icons/Chinese.svg"))); assert(_mainForm); - _mainForm->switchLanguage(LAN_CN); + _mainForm->SwitchLanguage(LAN_CN); } void LogoBar::on_actionAbout_triggered() @@ -348,7 +348,7 @@ void LogoBar::on_clear_log_file() } } -void LogoBar::update_font() +void LogoBar::UpdateFont() { QFont font = this->font(); font.setPointSizeF(AppConfig::Instance().appOptions.fontSize); diff --git a/DSView/src/toolbars/logobar.h b/DSView/src/toolbars/logobar.h index 2372a0fc..9bb40270 100644 --- a/DSView/src/toolbars/logobar.h +++ b/DSView/src/toolbars/logobar.h @@ -65,7 +65,7 @@ private: void reStyle(); //IFontForm - void update_font() override; + void UpdateFont() override; signals: //post event message to open user help document, MainWindow class receive it diff --git a/DSView/src/toolbars/samplingbar.cpp b/DSView/src/toolbars/samplingbar.cpp index d53a9e58..1d3cdd35 100644 --- a/DSView/src/toolbars/samplingbar.cpp +++ b/DSView/src/toolbars/samplingbar.cpp @@ -130,7 +130,7 @@ namespace dsv _instant_action = addWidget(&_instant_button); update_view_status(); - update_font(); + UpdateFont(); connect(&_device_selector, SIGNAL(currentIndexChanged(int)), this, SLOT(on_device_selected())); connect(&_configure_button, SIGNAL(clicked()), this, SLOT(on_configure())); @@ -1257,7 +1257,7 @@ namespace dsv on_instant_stop(); } - void SamplingBar::update_font() + void SamplingBar::UpdateFont() { QFont font = this->font(); font.setPointSizeF(AppConfig::Instance().appOptions.fontSize); diff --git a/DSView/src/toolbars/samplingbar.h b/DSView/src/toolbars/samplingbar.h index cc6d338d..7e56aaed 100644 --- a/DSView/src/toolbars/samplingbar.h +++ b/DSView/src/toolbars/samplingbar.h @@ -129,7 +129,7 @@ namespace toolbars{ bool action_instant_stop(); //IFontForm - void update_font() override; + void UpdateFont() override; private slots: void on_collect_mode(); diff --git a/DSView/src/toolbars/titlebar.cpp b/DSView/src/toolbars/titlebar.cpp index 645045f9..beffbc08 100644 --- a/DSView/src/toolbars/titlebar.cpp +++ b/DSView/src/toolbars/titlebar.cpp @@ -93,7 +93,7 @@ TitleBar::TitleBar(bool top, QWidget *parent, bool hasClose) : setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed); - update_font(); + UpdateFont(); } TitleBar::~TitleBar(){ @@ -238,7 +238,7 @@ void TitleBar::mouseDoubleClickEvent(QMouseEvent *event) QWidget::mouseDoubleClickEvent(event); } -void TitleBar::update_font() +void TitleBar::UpdateFont() { QFont font = this->font(); font.setPointSizeF(AppConfig::Instance().appOptions.fontSize); diff --git a/DSView/src/toolbars/titlebar.h b/DSView/src/toolbars/titlebar.h index d941c5cc..20b67116 100644 --- a/DSView/src/toolbars/titlebar.h +++ b/DSView/src/toolbars/titlebar.h @@ -44,7 +44,7 @@ public: QString title(); //IFontForm - void update_font() override; + void UpdateFont() override; private: void changeEvent(QEvent *event); diff --git a/DSView/src/toolbars/trigbar.cpp b/DSView/src/toolbars/trigbar.cpp index 8c6d4cb7..722f7714 100644 --- a/DSView/src/toolbars/trigbar.cpp +++ b/DSView/src/toolbars/trigbar.cpp @@ -123,7 +123,7 @@ TrigBar::TrigBar(SigSession *session, QWidget *parent) : connect(_light_style, SIGNAL(triggered()), this, SLOT(on_actionLight_triggered())); connect(_action_dispalyOptions, SIGNAL(triggered()), this, SLOT(on_display_setting())); - update_font(); + UpdateFont(); } //语言变化 @@ -371,7 +371,7 @@ void TrigBar::update_checked_status() _search_button.setChecked(opt->searchDock); } -void TrigBar::update_font() +void TrigBar::UpdateFont() { QFont font = this->font(); font.setPointSizeF(AppConfig::Instance().appOptions.fontSize); diff --git a/DSView/src/toolbars/trigbar.h b/DSView/src/toolbars/trigbar.h index 8fba1278..0758ef26 100644 --- a/DSView/src/toolbars/trigbar.h +++ b/DSView/src/toolbars/trigbar.h @@ -64,7 +64,7 @@ private: void update_checked_status(); //IFontForm - void update_font() override; + void UpdateFont() override; signals: void sig_setTheme(QString style); diff --git a/DSView/src/ui/string_ids.h b/DSView/src/uicore/lang_page_ids.h similarity index 86% rename from DSView/src/ui/string_ids.h rename to DSView/src/uicore/lang_page_ids.h index 2fdd8819..2175e533 100644 --- a/DSView/src/ui/string_ids.h +++ b/DSView/src/uicore/lang_page_ids.h @@ -2,7 +2,7 @@ * This file is part of the DSView project. * DSView is based on PulseView. * - * Copyright (C) 2022 DreamSourceLab + * Copyright (C) 2023 DreamSourceLab * * 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 @@ -19,14 +19,17 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ -#ifndef STRING_IDS_H -#define STRING_IDS_H +#ifndef LANG_PAGE_IDS_H +#define LANG_PAGE_IDS_H +/** + * Language resource page code. +*/ #define STR_PAGE_MSG 1 #define STR_PAGE_TOOLBAR 2 #define STR_PAGE_DLG 3 #define STR_PAGE_DSL 100 #define STR_PAGE_DECODER 101 -#define IDS_MSG_LOG_LEVEL + #endif \ No newline at end of file diff --git a/DSView/src/uicore/langitemlist.cpp b/DSView/src/uicore/langitemlist.cpp new file mode 100644 index 00000000..4f9a6403 --- /dev/null +++ b/DSView/src/uicore/langitemlist.cpp @@ -0,0 +1,84 @@ +/* + * This file is part of the DSView project. + * DSView is based on PulseView. + * + * Copyright (C) 2023 DreamSourceLab + * + * 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; either version 2 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 for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#include "langitemlist.h" +#include +#include "langresource.h" + +LangItemList::LangItemList() +{ + +} + +LangItemList::~LangItemList() +{ + Clear(); +} + +void LangItemList::Clear() +{ + for(auto it = m_items.begin(); it != m_items.end(); it++) + { + delete (*it).setter; + } + m_items.clear(); +} + +void LangItemList::AddItem(int page_id, const char *key_id, const char *defaultStr, ILangSetter *setter) +{ + assert(key_id); + assert(defaultStr); + assert(setter); + + LangItemInfo item = {page_id, key_id, defaultStr, setter}; + m_items.push_back(item); +} + +void LangItemList::RemoveItemBySetterHandle(void *setterHandle) +{ + assert(setterHandle); + + for(auto it = m_items.begin(); it != m_items.end(); it++) + { + if ((*it).setter->GetControlHandle() == setterHandle){ + m_items.erase(it); + break; + } + } +} + +void LangItemList::LoadAllText() +{ + for(auto it = m_items.begin(); it != m_items.end(); it++) + { + int page_id = (*it).lang_page_id; + const char *key_id = (*it).key_id; + const char *def_str = (*it).default_str; + ILangSetter *setter = (*it).setter; + + const char *str = LangResource::Instance()->get_lang_text(page_id, key_id, def_str); + if (str == NULL){ + str = def_str; + } + + setter->SetLangText(str); + } +} \ No newline at end of file diff --git a/DSView/src/uicore/langitemlist.h b/DSView/src/uicore/langitemlist.h new file mode 100644 index 00000000..1a3346f2 --- /dev/null +++ b/DSView/src/uicore/langitemlist.h @@ -0,0 +1,55 @@ +/* + * This file is part of the DSView project. + * DSView is based on PulseView. + * + * Copyright (C) 2023 DreamSourceLab + * + * 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; either version 2 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 for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#ifndef LANG_ITEM_LIST_H +#define LANG_ITEM_LIST_H + +#include +#include "uitypes.h" +#include "lang_page_ids.h" + +struct LangItemInfo +{ + int lang_page_id; + const char *key_id; + const char *default_str; + ILangSetter *setter; +}; + +class LangItemList +{ +public: + LangItemList(); + ~LangItemList(); + + void Clear(); + + void AddItem(int page_id, const char *key_id, const char *defaultStr, ILangSetter *setter); + + void RemoveItemBySetterHandle(void *setterHandle); + + void LoadAllText(); + +private: + std::vector m_items; +}; + +#endif \ No newline at end of file diff --git a/DSView/src/ui/langresource.cpp b/DSView/src/uicore/langresource.cpp similarity index 100% rename from DSView/src/ui/langresource.cpp rename to DSView/src/uicore/langresource.cpp diff --git a/DSView/src/ui/langresource.h b/DSView/src/uicore/langresource.h similarity index 99% rename from DSView/src/ui/langresource.h rename to DSView/src/uicore/langresource.h index 63a079e6..19ec41ec 100644 --- a/DSView/src/ui/langresource.h +++ b/DSView/src/uicore/langresource.h @@ -27,7 +27,7 @@ #include #include #include -#include "string_ids.h" +#include "lang_page_ids.h" struct lang_key_item { diff --git a/DSView/src/uicore/uitypes.h b/DSView/src/uicore/uitypes.h new file mode 100644 index 00000000..fe3f9068 --- /dev/null +++ b/DSView/src/uicore/uitypes.h @@ -0,0 +1,55 @@ +/* + * This file is part of the DSView project. + * DSView is based on PulseView. + * + * Copyright (C) 2023 DreamSourceLab + * + * 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; either version 2 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 for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#ifndef UICORE_UI_TYPES_H +#define UICORE_UI_TYPES_H + +class ILangSetter +{ +public: + virtual void SetLangText(const char *szText)=0; + virtual void* GetControlHandle()=0; +}; + +class ILangForm +{ +public: + virtual void LoadLangText()=0; +}; + +class IFontForm +{ +public: + virtual void UpdateFont()=0; +}; + +class IMainForm +{ +public: + virtual void SwitchLanguage(int language)=0; + virtual void AddLangForm(ILangForm *form)=0; + virtual void RemoveLangForm(ILangForm *form)=0; + virtual void AddFontForm(IFontForm *form)=0; + virtual void RemoveFontForm(IFontForm *form)=0; + virtual void UpdateAllFontForm()=0; +}; + +#endif \ No newline at end of file diff --git a/DSView/src/view/devmode.cpp b/DSView/src/view/devmode.cpp index 7030e3cb..541a903c 100644 --- a/DSView/src/view/devmode.cpp +++ b/DSView/src/view/devmode.cpp @@ -89,7 +89,7 @@ DevMode::DevMode(QWidget *parent, SigSession *session) : layout->setStretch(1, 100); setLayout(layout); - update_font(); + UpdateFont(); connect(_close_button, SIGNAL(clicked()), this, SLOT(on_close())); } @@ -172,7 +172,7 @@ void DevMode::set_device() _bFile = true; } - update_font(); + UpdateFont(); update(); } @@ -231,7 +231,7 @@ void DevMode::on_mode_change() } } - update_font(); + UpdateFont(); } void DevMode::on_close() @@ -279,7 +279,7 @@ const struct dev_mode_name* DevMode::get_mode_name(int mode) assert(false); } -void DevMode::update_font() +void DevMode::UpdateFont() { QFont font = this->font(); font.setPointSizeF(AppConfig::Instance().appOptions.fontSize); diff --git a/DSView/src/view/devmode.h b/DSView/src/view/devmode.h index 5c4fa2d5..235ceed2 100644 --- a/DSView/src/view/devmode.h +++ b/DSView/src/view/devmode.h @@ -72,7 +72,7 @@ private: const struct dev_mode_name* get_mode_name(int mode); //IFontForm - void update_font() override; + void UpdateFont() override; public slots: void set_device(); diff --git a/DSView/src/view/view.cpp b/DSView/src/view/view.cpp index 622bad0f..a72b1eb0 100644 --- a/DSView/src/view/view.cpp +++ b/DSView/src/view/view.cpp @@ -1339,7 +1339,7 @@ int View::get_body_height() _time_viewport->update(); } - void View::update_font() + void View::UpdateFont() { headerWidth(); } diff --git a/DSView/src/view/view.h b/DSView/src/view/view.h index 4850306a..558d6a78 100644 --- a/DSView/src/view/view.h +++ b/DSView/src/view/view.h @@ -320,7 +320,7 @@ public: } //IFontForm - void update_font() override; + void UpdateFont() override; signals: void hover_point_changed(); diff --git a/DSView/src/view/viewport.cpp b/DSView/src/view/viewport.cpp index bff5723d..71267f23 100644 --- a/DSView/src/view/viewport.cpp +++ b/DSView/src/view/viewport.cpp @@ -106,7 +106,7 @@ Viewport::Viewport(View &parent, View_type type) : _xAction = xAction; setContextMenuPolicy(Qt::CustomContextMenu); - this->update_font(); + this->UpdateFont(); connect(&_trigger_timer, SIGNAL(timeout()),this, SLOT(on_trigger_timer())); connect(&_drag_timer, SIGNAL(timeout()),this, SLOT(on_drag_timer())); @@ -2001,7 +2001,7 @@ void Viewport::add_cursor_x() _view.show_xcursors(true); } -void Viewport::update_font() +void Viewport::UpdateFont() { QFont font = this->font(); font.setPointSizeF(AppConfig::Instance().appOptions.fontSize); diff --git a/DSView/src/view/viewport.h b/DSView/src/view/viewport.h index 5114acf9..c7525707 100644 --- a/DSView/src/view/viewport.h +++ b/DSView/src/view/viewport.h @@ -116,7 +116,7 @@ public: void update_lang(); //IFontForm - void update_font() override; + void UpdateFont() override; protected: bool event(QEvent *event) override;