mirror of
https://github.com/saitohirga/WSJT-X.git
synced 2024-11-14 08:01:49 -05:00
45b12e6028
Re-enabling the WSJT-X i18n facilities. This allows translation files to be created for languages that are automatically used to lookup translatable strings. To enable a new language the language name must be added to the CMakeLists.txt LANGUAGES list variable in BCP47 format (i.e. en_US, en_GB, pt_PT, ...). Do one build with the CMake option UPDATE_TRANSLATIONS enabled (do not leave it enabled as there is a danger of loosing existing translated texts), that will create a fresh translations/wsjtx_<lang>.ts file which should be immediately checked in with the CMakeLists.txt change. The .ts should then be updated by the translator using the Qt Linguist tool to add translations. Check in the updated .ts file to complete the initial translation process for that language. To aid translators their WIP .ts file may be tested by releasing (using the lrelease tool or from the Linguist menu) a .qm file and placing that .qm file in the current directory before starting WSJT-X. The translations will be used if the system locale matches the file name. If the system locale does not match the file name; the language may be overridden by setting the LANG environment variable. For example if a wsjtx_pt_PT.qm file is in the current directory WSJT-X will use it for translation lookups, regardless of the current system locale setting, if the LANG variable is set to pt_PT or pt-PT. On MS Windows from a command prompt: set LANG=pt_PT C:\WSJT\wsjtx\bin\wsjtx elsewhere: LANG=pt_PT wsjtx
75 lines
3.2 KiB
C++
75 lines
3.2 KiB
C++
#include "DecodeHighlightingListView.hpp"
|
|
|
|
#include <QAction>
|
|
#include <QColorDialog>
|
|
|
|
#include "models/DecodeHighlightingModel.hpp"
|
|
#include "MessageBox.hpp"
|
|
|
|
#include "moc_DecodeHighlightingListView.cpp"
|
|
|
|
DecodeHighlightingListView::DecodeHighlightingListView (QWidget * parent)
|
|
: QListView {parent}
|
|
{
|
|
auto * fg_colour_action = new QAction {tr ("&Foreground color ..."), this};
|
|
addAction (fg_colour_action);
|
|
connect (fg_colour_action, &QAction::triggered, [this] (bool /*checked*/) {
|
|
auto const& index = currentIndex ();
|
|
auto colour = QColorDialog::getColor (model ()->data (index, Qt::ForegroundRole).value<QBrush> ().color ()
|
|
, this
|
|
, tr ("Choose %1 Foreground Color")
|
|
.arg (model ()->data (index).toString ()));
|
|
if (colour.isValid ())
|
|
{
|
|
model ()->setData (index, QBrush {colour}, Qt::ForegroundRole);
|
|
}
|
|
});
|
|
|
|
auto * unset_fg_colour_action = new QAction {tr ("&Unset foreground color"), this};
|
|
addAction (unset_fg_colour_action);
|
|
connect (unset_fg_colour_action, &QAction::triggered, [this] (bool /*checked*/) {
|
|
model ()->setData (currentIndex (), QBrush {}, Qt::ForegroundRole);
|
|
});
|
|
|
|
auto * bg_colour_action = new QAction {tr ("&Background color ..."), this};
|
|
addAction (bg_colour_action);
|
|
connect (bg_colour_action, &QAction::triggered, [this] (bool /*checked*/) {
|
|
auto const& index = currentIndex ();
|
|
auto colour = QColorDialog::getColor (model ()->data (index, Qt::BackgroundRole).value<QBrush> ().color ()
|
|
, this
|
|
, tr ("Choose %1 Background Color")
|
|
.arg (model ()->data (index).toString ()));
|
|
if (colour.isValid ())
|
|
{
|
|
model ()->setData (index, QBrush {colour}, Qt::BackgroundRole);
|
|
}
|
|
});
|
|
|
|
auto * unset_bg_colour_action = new QAction {tr ("U&nset background color"), this};
|
|
addAction (unset_bg_colour_action);
|
|
connect (unset_bg_colour_action, &QAction::triggered, [this] (bool /*checked*/) {
|
|
model ()->setData (currentIndex (), QBrush {}, Qt::BackgroundRole);
|
|
});
|
|
|
|
auto * defaults_action = new QAction {tr ("&Reset this item to defaults"), this};
|
|
addAction (defaults_action);
|
|
connect (defaults_action, &QAction::triggered, [this] (bool /*checked*/) {
|
|
auto const& index = currentIndex ();
|
|
model ()->setData (index, model ()->data (index, DecodeHighlightingModel::EnabledDefaultRole).toBool () ? Qt::Checked : Qt::Unchecked, Qt::CheckStateRole);
|
|
model ()->setData (index, model ()->data (index, DecodeHighlightingModel::ForegroundDefaultRole), Qt::ForegroundRole);
|
|
model ()->setData (index, model ()->data (index, DecodeHighlightingModel::BackgroundDefaultRole), Qt::BackgroundRole);
|
|
});
|
|
}
|
|
|
|
QSize DecodeHighlightingListView::sizeHint () const
|
|
{
|
|
auto item_height = sizeHintForRow (0);
|
|
if (item_height >= 0)
|
|
{
|
|
// set the height hint to exactly the space required for all the
|
|
// items
|
|
return {width (), (model ()->rowCount () * (item_height + 2 * spacing ())) + 2 * frameWidth ()};
|
|
}
|
|
return QListView::sizeHint ();
|
|
}
|