Localize all UI strings
This commit is contained in:
parent
6920e0c123
commit
1a0b6b8dd0
6 changed files with 136 additions and 120 deletions
|
@ -4,6 +4,7 @@
|
|||
|
||||
#include "ArtConfigWindow.h"
|
||||
|
||||
#include <KLocalizedString>
|
||||
#include <QFile>
|
||||
#include <QFormLayout>
|
||||
#include <QGroupBox>
|
||||
|
@ -31,26 +32,26 @@ ArtConfigWindow::ArtConfigWindow(const QString& filename, QWidget* parent) : QDi
|
|||
formLayout->addWidget(galleryScrollArea);
|
||||
|
||||
m_newBannerEdit = new QLineEdit();
|
||||
formLayout->addRow(QStringLiteral("New Banner"), m_newBannerEdit);
|
||||
formLayout->addRow(i18nc("@label:textbox", "New Banner"), m_newBannerEdit);
|
||||
|
||||
m_commissionsOpen = new QCheckBox();
|
||||
formLayout->addRow(QStringLiteral("Commissions Open"), m_commissionsOpen);
|
||||
m_commissionsOpen = new QCheckBox();
|
||||
formLayout->addRow(i18nc("@option:check", "Commissions Open"), m_commissionsOpen);
|
||||
|
||||
auto bottomButtonLayout = new QHBoxLayout();
|
||||
formLayout->addRow(bottomButtonLayout);
|
||||
auto bottomButtonLayout = new QHBoxLayout();
|
||||
formLayout->addRow(bottomButtonLayout);
|
||||
|
||||
auto cancelButton = new QPushButton(QIcon::fromTheme(QStringLiteral("dialog-close")), QStringLiteral("Cancel"));
|
||||
connect(cancelButton, &QPushButton::clicked, this, &ArtConfigWindow::close);
|
||||
bottomButtonLayout->addWidget(cancelButton);
|
||||
bottomButtonLayout->addStretch(1);
|
||||
auto cancelButton = new QPushButton(QIcon::fromTheme(QStringLiteral("dialog-close")), i18nc("@action:button", "Cancel"));
|
||||
connect(cancelButton, &QPushButton::clicked, this, &ArtConfigWindow::close);
|
||||
bottomButtonLayout->addWidget(cancelButton);
|
||||
bottomButtonLayout->addStretch(1);
|
||||
|
||||
auto saveButton = new QPushButton(QIcon::fromTheme(QStringLiteral("dialog-ok")), QStringLiteral("Save"));
|
||||
connect(saveButton, &QPushButton::clicked, this, [this, filename] {
|
||||
saveData(filename);
|
||||
});
|
||||
bottomButtonLayout->addWidget(saveButton);
|
||||
auto saveButton = new QPushButton(QIcon::fromTheme(QStringLiteral("dialog-ok")), i18nc("@action:button", "Save"));
|
||||
connect(saveButton, &QPushButton::clicked, this, [this, filename] {
|
||||
saveData(filename);
|
||||
});
|
||||
bottomButtonLayout->addWidget(saveButton);
|
||||
|
||||
if(QFile::exists(filename)) {
|
||||
if(QFile::exists(filename)) {
|
||||
loadData(filename);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -5,17 +5,18 @@
|
|||
#include "ArtDetailWindow.h"
|
||||
#include "imagelabel.h"
|
||||
|
||||
#include <KLocalizedString>
|
||||
#include <QDateEdit>
|
||||
#include <QFile>
|
||||
#include <QFileInfo>
|
||||
#include <QFormLayout>
|
||||
#include <QGroupBox>
|
||||
#include <QHBoxLayout>
|
||||
#include <QJsonArray>
|
||||
#include <QJsonDocument>
|
||||
#include <QLineEdit>
|
||||
#include <QPushButton>
|
||||
#include <QTextEdit>
|
||||
#include <QHBoxLayout>
|
||||
|
||||
ArtDetailWindow::ArtDetailWindow(const QString& filename, const QString& assetDirectory, QWidget* parent) : QDialog(parent) {
|
||||
setMinimumWidth(800);
|
||||
|
@ -38,32 +39,32 @@ ArtDetailWindow::ArtDetailWindow(const QString& filename, const QString& assetDi
|
|||
QImage image;
|
||||
image.load(QStringLiteral("%1/%2.webp").arg(assetDirectory, withoutExtension));
|
||||
|
||||
auto previewBox = new QGroupBox(QStringLiteral("Preview"));
|
||||
mainLayout->addWidget(previewBox);
|
||||
auto previewBox = new QGroupBox(i18nc("@title:group", "Preview"));
|
||||
mainLayout->addWidget(previewBox);
|
||||
|
||||
auto previewLayout = new QVBoxLayout();
|
||||
previewBox->setLayout(previewLayout);
|
||||
auto previewLayout = new QVBoxLayout();
|
||||
previewBox->setLayout(previewLayout);
|
||||
|
||||
auto imageView = new ImageLabel();
|
||||
imageView->setPixmap(QPixmap::fromImage(image));
|
||||
previewLayout->addWidget(imageView);
|
||||
|
||||
m_titleEdit = new QLineEdit();
|
||||
formLayout->addRow(QStringLiteral("Title"), m_titleEdit);
|
||||
formLayout->addRow(i18nc("@label:textbox", "Title"), m_titleEdit);
|
||||
|
||||
m_knowExactDateBox = new QCheckBox();
|
||||
connect(m_knowExactDateBox, &QCheckBox::toggled, this, [this](bool checked) {
|
||||
if (checked) {
|
||||
m_knowExactDateBox = new QCheckBox();
|
||||
connect(m_knowExactDateBox, &QCheckBox::toggled, this, [this](bool checked) {
|
||||
if (checked) {
|
||||
m_dateEdit->setDisplayFormat(QStringLiteral("yyyy-MM-dd"));
|
||||
} else {
|
||||
m_dateEdit->setDisplayFormat(QStringLiteral("yyyy"));
|
||||
}
|
||||
});
|
||||
formLayout->addRow(QStringLiteral("Know Exact Date?"), m_knowExactDateBox);
|
||||
});
|
||||
formLayout->addRow(i18nc("@option:check", "Know Exact Date?"), m_knowExactDateBox);
|
||||
|
||||
m_dateEdit = new QDateEdit();
|
||||
m_dateEdit->setCalendarPopup(true);
|
||||
formLayout->addRow(QStringLiteral("Date"), m_dateEdit);
|
||||
m_dateEdit = new QDateEdit();
|
||||
m_dateEdit->setCalendarPopup(true);
|
||||
formLayout->addRow(QStringLiteral("Date"), m_dateEdit);
|
||||
|
||||
m_altTextEdit = new QTextEdit();
|
||||
m_altTextEdit->setAcceptRichText(false);
|
||||
|
@ -74,99 +75,101 @@ ArtDetailWindow::ArtDetailWindow(const QString& filename, const QString& assetDi
|
|||
formLayout->addRow(QStringLiteral("Description"), m_descriptionEdit);
|
||||
|
||||
m_nsfwBox = new QCheckBox();
|
||||
formLayout->addRow(QStringLiteral("Is NSFW?"), m_nsfwBox);
|
||||
formLayout->addRow(i18nc("@option:check", "Is NSFW?"), m_nsfwBox);
|
||||
|
||||
m_mastodonUrlEdit = new QLineEdit();
|
||||
formLayout->addRow(QStringLiteral("Mastodon URL"), m_mastodonUrlEdit);
|
||||
m_mastodonUrlEdit = new QLineEdit();
|
||||
formLayout->addRow(i18nc("@label:textbox", "Mastodon URL"), m_mastodonUrlEdit);
|
||||
|
||||
m_pixivUrlEdit = new QLineEdit();
|
||||
formLayout->addRow(QStringLiteral("Pixiv URL"), m_pixivUrlEdit);
|
||||
m_pixivUrlEdit = new QLineEdit();
|
||||
formLayout->addRow(i18nc("@label:textbox", "Pixiv URL"), m_pixivUrlEdit);
|
||||
|
||||
m_newgroundsUrlEdit = new QLineEdit();
|
||||
formLayout->addRow(QStringLiteral("Newgrounds URL"), m_newgroundsUrlEdit);
|
||||
m_newgroundsUrlEdit = new QLineEdit();
|
||||
formLayout->addRow(i18nc("@label:textbox", "Newgrounds URL"), m_newgroundsUrlEdit);
|
||||
|
||||
m_programEdit = new QLineEdit();
|
||||
formLayout->addRow(QStringLiteral("Program"), m_programEdit);
|
||||
m_programEdit = new QLineEdit();
|
||||
formLayout->addRow(i18nc("@label:textbox", "Program"), m_programEdit);
|
||||
|
||||
auto charactersLayout = new QVBoxLayout();
|
||||
formLayout->addRow(QStringLiteral("Characters"), charactersLayout);
|
||||
auto charactersLayout = new QVBoxLayout();
|
||||
formLayout->addRow(i18nc("@title:group", "Characters"), charactersLayout);
|
||||
|
||||
auto characterList = new QListView();
|
||||
m_characterListModel = new QStringListModel();
|
||||
characterList->setModel(m_characterListModel);
|
||||
auto characterList = new QListView();
|
||||
m_characterListModel = new QStringListModel();
|
||||
characterList->setModel(m_characterListModel);
|
||||
charactersLayout->addWidget(characterList);
|
||||
|
||||
auto characterButtonLayout = new QHBoxLayout();
|
||||
charactersLayout->addLayout(characterButtonLayout);
|
||||
|
||||
auto addCharacterButton = new QPushButton(QIcon::fromTheme(QStringLiteral("list-add")), QStringLiteral("Add"));
|
||||
connect(addCharacterButton, &QPushButton::clicked, this, [this] {
|
||||
auto tmp = m_characterListModel->stringList();;
|
||||
tmp.push_back(QStringLiteral("New Character"));
|
||||
auto addCharacterButton = new QPushButton(QIcon::fromTheme(QStringLiteral("list-add")), i18nc("@action:button", "Add"));
|
||||
connect(addCharacterButton, &QPushButton::clicked, this, [this] {
|
||||
auto tmp = m_characterListModel->stringList();
|
||||
;
|
||||
tmp.push_back(QStringLiteral("New Character"));
|
||||
m_characterListModel->setStringList(tmp);
|
||||
});
|
||||
characterButtonLayout->addWidget(addCharacterButton);
|
||||
characterButtonLayout->addStretch(1);
|
||||
});
|
||||
characterButtonLayout->addWidget(addCharacterButton);
|
||||
characterButtonLayout->addStretch(1);
|
||||
|
||||
auto removeCharacterButton = new QPushButton(QIcon::fromTheme(QStringLiteral("list-remove")), QStringLiteral("Remove"));
|
||||
connect(removeCharacterButton, &QPushButton::clicked, this, [this, characterList] {
|
||||
if(characterList->selectionModel()->hasSelection()) {
|
||||
const QString toRemove = characterList->selectionModel()->selectedRows()[0].data().toString();
|
||||
auto removeCharacterButton = new QPushButton(QIcon::fromTheme(QStringLiteral("list-remove")), i18nc("@action:button", "Remove"));
|
||||
connect(removeCharacterButton, &QPushButton::clicked, this, [this, characterList] {
|
||||
if (characterList->selectionModel()->hasSelection()) {
|
||||
const QString toRemove = characterList->selectionModel()->selectedRows()[0].data().toString();
|
||||
|
||||
auto tmp = m_characterListModel->stringList();
|
||||
tmp.removeOne(toRemove);
|
||||
m_characterListModel->setStringList(tmp);
|
||||
}
|
||||
});
|
||||
characterButtonLayout->addWidget(removeCharacterButton);
|
||||
}
|
||||
});
|
||||
characterButtonLayout->addWidget(removeCharacterButton);
|
||||
|
||||
auto tagLayout = new QVBoxLayout();
|
||||
formLayout->addRow(QStringLiteral("Tags"), tagLayout);
|
||||
auto tagLayout = new QVBoxLayout();
|
||||
formLayout->addRow(i18nc("@title:group", "Tags"), tagLayout);
|
||||
|
||||
auto tagsList = new QListView();
|
||||
m_tagsListModel = new QStringListModel();
|
||||
tagsList->setModel(m_tagsListModel);
|
||||
auto tagsList = new QListView();
|
||||
m_tagsListModel = new QStringListModel();
|
||||
tagsList->setModel(m_tagsListModel);
|
||||
tagLayout->addWidget(tagsList);
|
||||
|
||||
auto tagButtonLayout = new QHBoxLayout();
|
||||
tagLayout->addLayout(tagButtonLayout);
|
||||
|
||||
auto addTagButton = new QPushButton(QIcon::fromTheme(QStringLiteral("list-add")), QStringLiteral("Add"));
|
||||
connect(addTagButton, &QPushButton::clicked, this, [this] {
|
||||
auto tmp = m_tagsListModel->stringList();;
|
||||
tmp.push_back(QStringLiteral("New Tag"));
|
||||
auto addTagButton = new QPushButton(QIcon::fromTheme(QStringLiteral("list-add")), i18nc("@action:button", "Add"));
|
||||
connect(addTagButton, &QPushButton::clicked, this, [this] {
|
||||
auto tmp = m_tagsListModel->stringList();
|
||||
;
|
||||
tmp.push_back(QStringLiteral("New Tag"));
|
||||
m_tagsListModel->setStringList(tmp);
|
||||
});
|
||||
tagButtonLayout->addWidget(addTagButton);
|
||||
tagButtonLayout->addStretch(1);
|
||||
});
|
||||
tagButtonLayout->addWidget(addTagButton);
|
||||
tagButtonLayout->addStretch(1);
|
||||
|
||||
auto removeTagButton = new QPushButton(QIcon::fromTheme(QStringLiteral("list-remove")), QStringLiteral("Remove"));
|
||||
connect(removeTagButton, &QPushButton::clicked, this, [this, tagsList] {
|
||||
if(tagsList->selectionModel()->hasSelection()) {
|
||||
const QString toRemove = tagsList->selectionModel()->selectedRows()[0].data().toString();
|
||||
auto removeTagButton = new QPushButton(QIcon::fromTheme(QStringLiteral("list-remove")), i18nc("@action:button", "Remove"));
|
||||
connect(removeTagButton, &QPushButton::clicked, this, [this, tagsList] {
|
||||
if (tagsList->selectionModel()->hasSelection()) {
|
||||
const QString toRemove = tagsList->selectionModel()->selectedRows()[0].data().toString();
|
||||
|
||||
auto tmp = m_tagsListModel->stringList();
|
||||
tmp.removeOne(toRemove);
|
||||
m_tagsListModel->setStringList(tmp);
|
||||
}
|
||||
});
|
||||
tagButtonLayout->addWidget(removeTagButton);
|
||||
}
|
||||
});
|
||||
tagButtonLayout->addWidget(removeTagButton);
|
||||
|
||||
auto bottomButtonLayout = new QHBoxLayout();
|
||||
auto bottomButtonLayout = new QHBoxLayout();
|
||||
formLayout->addRow(bottomButtonLayout);
|
||||
|
||||
auto cancelButton = new QPushButton(QIcon::fromTheme(QStringLiteral("dialog-close")), QStringLiteral("Cancel"));
|
||||
connect(cancelButton, &QPushButton::clicked, this, &ArtDetailWindow::close);
|
||||
bottomButtonLayout->addWidget(cancelButton);
|
||||
bottomButtonLayout->addStretch(1);
|
||||
auto cancelButton = new QPushButton(QIcon::fromTheme(QStringLiteral("dialog-close")), i18nc("@action:button", "Cancel"));
|
||||
connect(cancelButton, &QPushButton::clicked, this, &ArtDetailWindow::close);
|
||||
bottomButtonLayout->addWidget(cancelButton);
|
||||
bottomButtonLayout->addStretch(1);
|
||||
|
||||
auto saveButton = new QPushButton(QIcon::fromTheme(QStringLiteral("dialog-ok")), QStringLiteral("Save"));
|
||||
connect(saveButton, &QPushButton::clicked, this, [this, filename] {
|
||||
saveData(filename);
|
||||
});
|
||||
bottomButtonLayout->addWidget(saveButton);
|
||||
auto saveButton = new QPushButton(QIcon::fromTheme(QStringLiteral("dialog-ok")), i18nc("@action:button", "Save"));
|
||||
connect(saveButton, &QPushButton::clicked, this, [this, filename] {
|
||||
saveData(filename);
|
||||
});
|
||||
bottomButtonLayout->addWidget(saveButton);
|
||||
|
||||
if(QFile::exists(filename)) {
|
||||
if(QFile::exists(filename)) {
|
||||
loadData(filename);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -4,6 +4,7 @@
|
|||
|
||||
#include "ArtModel.h"
|
||||
|
||||
#include <KLocalizedString>
|
||||
#include <QDirIterator>
|
||||
#include <QFile>
|
||||
#include <QFileInfo>
|
||||
|
@ -53,11 +54,13 @@ ArtModel::ArtModel(const QString& definitionDirectory, const QString& assetDirec
|
|||
}
|
||||
|
||||
int ArtModel::rowCount(const QModelIndex &parent) const {
|
||||
return m_artPieces.size();
|
||||
Q_UNUSED(parent);
|
||||
return m_artPieces.size();
|
||||
}
|
||||
|
||||
int ArtModel::columnCount(const QModelIndex &parent) const {
|
||||
return 4;
|
||||
Q_UNUSED(parent);
|
||||
return 4;
|
||||
}
|
||||
|
||||
QVariant ArtModel::data(const QModelIndex &index, int role) const {
|
||||
|
@ -95,16 +98,16 @@ QVariant ArtModel::headerData(int section, Qt::Orientation orientation, int role
|
|||
if (orientation == Qt::Orientation::Horizontal && role == Qt::DisplayRole) {
|
||||
switch(section) {
|
||||
case 0:
|
||||
return QStringLiteral("Filename");
|
||||
case 1:
|
||||
return QStringLiteral("Image");
|
||||
case 2:
|
||||
return QStringLiteral("Title");
|
||||
case 3:
|
||||
return QStringLiteral("Has Alt Text");
|
||||
default:
|
||||
Q_UNREACHABLE();
|
||||
}
|
||||
return i18nc("@title:column", "Filename");
|
||||
case 1:
|
||||
return i18nc("@title:column", "Image");
|
||||
case 2:
|
||||
return i18nc("@title:column", "Title");
|
||||
case 3:
|
||||
return i18nc("@title:column", "Has Alt Text");
|
||||
default:
|
||||
Q_UNREACHABLE();
|
||||
}
|
||||
}
|
||||
|
||||
return QAbstractTableModel::headerData(section, orientation, role);
|
||||
|
|
|
@ -4,32 +4,33 @@
|
|||
|
||||
#include "MainWindow.h"
|
||||
|
||||
#include <QTableView>
|
||||
#include <KLocalizedString>
|
||||
#include <QHeaderView>
|
||||
#include <QMenuBar>
|
||||
#include <QTableView>
|
||||
|
||||
#include "ArtConfigWindow.h"
|
||||
#include "ArtDetailWindow.h"
|
||||
#include "ArtModel.h"
|
||||
|
||||
MainWindow::MainWindow(const QString& definitionDirectory, const QString& assetDirectory, const QString& dataDirectory) {
|
||||
setWindowTitle(QStringLiteral("Redai"));
|
||||
setMinimumSize(1280, 720);
|
||||
setWindowTitle(i18nc("@title:window", "Redai"));
|
||||
setMinimumSize(1280, 720);
|
||||
|
||||
auto menuBar = new QMenuBar();
|
||||
setMenuBar(menuBar);
|
||||
auto menuBar = new QMenuBar();
|
||||
setMenuBar(menuBar);
|
||||
|
||||
auto manageMenu = menuBar->addMenu(QStringLiteral("Manage"));
|
||||
auto manageMenu = menuBar->addMenu(i18nc("@title:menu Manage site", "Manage"));
|
||||
|
||||
auto editConfigAction = manageMenu->addAction(QStringLiteral("Edit Config..."));
|
||||
connect(editConfigAction, &QAction::triggered, this, [this, dataDirectory] {
|
||||
auto window = new ArtConfigWindow(QStringLiteral("%1/art-config.json").arg(dataDirectory), this);
|
||||
window->show();
|
||||
});
|
||||
auto editConfigAction = manageMenu->addAction(i18nc("@action:inmenu", "Edit Config..."));
|
||||
connect(editConfigAction, &QAction::triggered, this, [this, dataDirectory] {
|
||||
auto window = new ArtConfigWindow(QStringLiteral("%1/art-config.json").arg(dataDirectory), this);
|
||||
window->show();
|
||||
});
|
||||
|
||||
auto model = new ArtModel(definitionDirectory, assetDirectory);
|
||||
auto model = new ArtModel(definitionDirectory, assetDirectory);
|
||||
|
||||
auto pieceListView = new QTableView();
|
||||
auto pieceListView = new QTableView();
|
||||
pieceListView->setModel(model);
|
||||
pieceListView->setSelectionBehavior(QAbstractItemView::SelectionBehavior::SelectRows);
|
||||
pieceListView->setSelectionMode(QAbstractItemView::SingleSelection);
|
||||
|
|
|
@ -28,6 +28,8 @@ QPixmap ImageLabel::scaledPixmap() const {
|
|||
}
|
||||
|
||||
void ImageLabel::resizeEvent(QResizeEvent *e) {
|
||||
if (!pix.isNull())
|
||||
QLabel::setPixmap(scaledPixmap());
|
||||
Q_UNUSED(e);
|
||||
if (!pix.isNull()) {
|
||||
QLabel::setPixmap(scaledPixmap());
|
||||
}
|
||||
}
|
18
src/main.cpp
18
src/main.cpp
|
@ -2,6 +2,7 @@
|
|||
//
|
||||
// SPDX-License-Identifier: GPL-3.0-or-later
|
||||
|
||||
#include <KLocalizedString>
|
||||
#include <QApplication>
|
||||
#include <QCommandLineParser>
|
||||
#include <QDir>
|
||||
|
@ -9,15 +10,20 @@
|
|||
#include "MainWindow.h"
|
||||
|
||||
int main(int argc, char *argv[]) {
|
||||
QApplication app(argc, argv);
|
||||
QCoreApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
|
||||
QCoreApplication::setAttribute(Qt::AA_UseHighDpiPixmaps);
|
||||
|
||||
QCommandLineParser parser;
|
||||
parser.addPositionalArgument(QStringLiteral("site-path"), QCoreApplication::translate("main", "Site directory."));
|
||||
QApplication app(argc, argv);
|
||||
|
||||
parser.process(app);
|
||||
KLocalizedString::setApplicationDomain("redai");
|
||||
|
||||
const auto args = parser.positionalArguments();
|
||||
if (args.empty()) {
|
||||
QCommandLineParser parser;
|
||||
parser.addPositionalArgument(QStringLiteral("site-path"), i18nc("@info", "Site directory."));
|
||||
|
||||
parser.process(app);
|
||||
|
||||
const auto args = parser.positionalArguments();
|
||||
if (args.empty()) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue