refreshUi and translate things

This commit is contained in:
Lukas Brübach 2025-02-02 07:56:02 +01:00
parent a69dfdc135
commit 72192f6392
4 changed files with 29 additions and 16 deletions

View file

@ -30,6 +30,11 @@ void BannerWidget::mousePressEvent(QMouseEvent *event)
emit buddyVisibilityChanged();
}
void BannerWidget::setText(const QString &text) const
{
bannerLabel->setText(text);
}
void BannerWidget::toggleBuddyVisibility() const
{
if (buddy) {

View file

@ -14,6 +14,7 @@ public:
Qt::Orientation orientation = Qt::Vertical,
int transparency = 80);
void mousePressEvent(QMouseEvent *event) override;
void setText(const QString &text) const;
void setBuddy(QWidget *_buddy)
{
buddy = _buddy;

View file

@ -15,22 +15,7 @@ VisualDeckStorageFolderDisplayWidget::VisualDeckStorageFolderDisplayWidget(
layout = new QVBoxLayout(this);
setLayout(layout);
QString bannerText = "Deck Storage";
QString deckPath = SettingsCache::instance().getDeckPath();
if (filePath != deckPath) {
QString relativePath = filePath;
if (filePath.startsWith(deckPath)) {
relativePath = filePath.mid(deckPath.length()); // Remove the deckPath prefix
if (relativePath.startsWith('/')) {
relativePath.remove(0, 1); // Remove leading '/' if it exists
}
}
bannerText = relativePath;
}
header = new BannerWidget(this, bannerText);
header = new BannerWidget(this, "");
layout->addWidget(header);
container = new QWidget(this);
@ -53,6 +38,27 @@ VisualDeckStorageFolderDisplayWidget::VisualDeckStorageFolderDisplayWidget(
createWidgetsForFiles();
createWidgetsForFolders();
refreshUi();
}
void VisualDeckStorageFolderDisplayWidget::refreshUi()
{
QString bannerText = tr("Deck Storage");
QString deckPath = SettingsCache::instance().getDeckPath();
if (filePath != deckPath) {
QString relativePath = filePath;
if (filePath.startsWith(deckPath)) {
relativePath = filePath.mid(deckPath.length()); // Remove the deckPath prefix
if (relativePath.startsWith('/')) {
relativePath.remove(0, 1); // Remove leading '/' if it exists
}
}
bannerText = relativePath;
}
header->setText(bannerText);
}
void VisualDeckStorageFolderDisplayWidget::createWidgetsForFiles()

View file

@ -15,6 +15,7 @@ public:
VisualDeckStorageFolderDisplayWidget(QWidget *parent,
VisualDeckStorageWidget *_visualDeckStorageWidget,
QString _filePath);
void refreshUi();
void createWidgetsForFiles();
void createWidgetsForFolders();
QStringList gatherAllTagsFromFlowWidget() const;