2022-03-10 15:24:08 +01:00
|
|
|
/***************************************************************************
|
|
|
|
|
* Copyright (C) 2022 by Piotr Wilczynski - delwing@gmail.com *
|
2022-12-09 13:53:13 +00:00
|
|
|
* Copyright (C) 2022 by Stephen Lyons - slysven@virginmedia.com *
|
2022-03-10 15:24:08 +01:00
|
|
|
* *
|
|
|
|
|
* 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., *
|
|
|
|
|
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
|
|
|
|
|
***************************************************************************/
|
2022-12-09 13:53:13 +00:00
|
|
|
|
2022-03-10 15:24:08 +01:00
|
|
|
#include "dlgMapLabel.h"
|
2024-11-04 10:54:51 +04:00
|
|
|
#include "mudlet.h"
|
2022-12-09 13:53:13 +00:00
|
|
|
#include "utils.h"
|
2026-01-08 21:04:24 +01:00
|
|
|
#include <QColorDialog>
|
|
|
|
|
#include <QFileDialog>
|
|
|
|
|
#include <QFontDialog>
|
2024-11-04 10:54:51 +04:00
|
|
|
#include <QSettings>
|
2022-03-10 15:24:08 +01:00
|
|
|
|
2022-12-09 13:53:13 +00:00
|
|
|
static QString BUTTON_STYLESHEET = qsl("QPushButton { background-color: rgba(%1, %2, %3, %4); }");
|
2022-03-10 15:24:08 +01:00
|
|
|
|
2022-11-14 10:14:16 +01:00
|
|
|
dlgMapLabel::dlgMapLabel(QWidget* pParentWidget)
|
|
|
|
|
: QDialog(pParentWidget)
|
2022-03-10 15:24:08 +01:00
|
|
|
{
|
|
|
|
|
setupUi(this);
|
|
|
|
|
|
|
|
|
|
setAttribute(Qt::WA_DeleteOnClose);
|
2023-05-29 22:03:34 +03:00
|
|
|
//: Create label dialog title
|
|
|
|
|
setWindowTitle(tr("Create label"));
|
2022-03-10 15:24:08 +01:00
|
|
|
|
2022-08-27 10:47:01 +02:00
|
|
|
connect(comboBox_type, QOverload<int>::of(&QComboBox::currentIndexChanged), this, &dlgMapLabel::slot_updateControlsVisibility);
|
2022-03-10 15:24:08 +01:00
|
|
|
connect(comboBox_type, QOverload<int>::of(&QComboBox::currentIndexChanged), this, &dlgMapLabel::updated);
|
2022-08-27 10:47:01 +02:00
|
|
|
connect(toolButton_imagePick, &QToolButton::released, this, &dlgMapLabel::slot_pickFile);
|
2025-02-10 11:59:45 +00:00
|
|
|
#if QT_VERSION >= QT_VERSION_CHECK(6, 7, 0)
|
|
|
|
|
connect(checkBox_stretchImage, &QCheckBox::checkStateChanged, this, &dlgMapLabel::updated);
|
|
|
|
|
#else
|
2022-03-10 15:24:08 +01:00
|
|
|
connect(checkBox_stretchImage, &QCheckBox::stateChanged, this, &dlgMapLabel::updated);
|
2025-02-10 11:59:45 +00:00
|
|
|
#endif
|
2025-01-21 21:14:02 +00:00
|
|
|
connect(plainTextEdit_labelText, &QPlainTextEdit::textChanged, this, [&]() {
|
|
|
|
|
text = plainTextEdit_labelText->toPlainText();
|
2022-03-10 15:24:08 +01:00
|
|
|
emit updated();
|
|
|
|
|
});
|
2022-08-27 10:47:01 +02:00
|
|
|
connect(pushButton_bgColor, &QPushButton::released, this, &dlgMapLabel::slot_pickBgColor);
|
|
|
|
|
connect(pushButton_fgColor, &QPushButton::released, this, &dlgMapLabel::slot_pickFgColor);
|
Add: give map label text the ability to have an outline (#7598)
<!-- Keep the title short & concise so anyone non-technical can
understand it,
the title appears in PTB changelogs -->
#### Brief overview of PR changes/additions
Add an outline colour chooser to map label creation window in mapper.
Update createMapLabel Lua function to reflect this as well. Adds three
optional arguments to the end of createMapLabel( ..., outlineRed,
outlineGreen, outlineBlue), default to the same colour as foreground if
not specified.
Also, chosen colours weren't being saved from one dialog to the next
forcing unnecessary typing to replicate a colour scheme when creating
multiple labels, so fix this and allow chosen colours to also save
across Mudlet restarts as well.
#### Motivation for adding to Mudlet
Better user experience, more map design options, prettier maps.
#### Other info (issues closed, discussion etc)
- The outline width is only 1 pixel, but as fonts get smaller this
starts to become increasingly larger compared to the width of the small
font. Zoomed in fonts (or larger than 16 on my display) typically look
better.
- Based on this work I think it would be fairly trivial to add drop
shadows, mirroring and other text effects.

Zoomed in;

closes #2861
/claim #2861
2024-12-27 12:07:37 +04:00
|
|
|
connect(pushButton_outlineColor, &QPushButton::released, this, &dlgMapLabel::slot_pickOutlineColor);
|
2022-08-27 10:47:01 +02:00
|
|
|
connect(toolButton_fontPick, &QToolButton::released, this, &dlgMapLabel::slot_pickFont);
|
|
|
|
|
connect(pushButton_save, &QPushButton::released, this, &dlgMapLabel::slot_save);
|
2022-03-10 15:24:08 +01:00
|
|
|
connect(pushButton_cancel, &QPushButton::released, this, &dlgMapLabel::close);
|
2025-02-10 11:59:45 +00:00
|
|
|
connect(comboBox_position, QOverload<int>::of(&QComboBox::currentIndexChanged), this, &dlgMapLabel::updated);
|
|
|
|
|
#if QT_VERSION >= QT_VERSION_CHECK(6, 7, 0)
|
|
|
|
|
connect(checkBox_scaling, &QCheckBox::checkStateChanged, this, &dlgMapLabel::updated);
|
|
|
|
|
#else
|
|
|
|
|
connect(checkBox_scaling, &QCheckBox::stateChanged, this, &dlgMapLabel::updated);
|
|
|
|
|
#endif
|
2022-08-27 10:47:01 +02:00
|
|
|
connect(this, &dlgMapLabel::updated, this, &dlgMapLabel::slot_updateControls);
|
2022-03-10 15:24:08 +01:00
|
|
|
|
|
|
|
|
font = QApplication::font();
|
|
|
|
|
font.setStyle(QFont::StyleNormal);
|
2025-01-21 21:14:02 +00:00
|
|
|
text = plainTextEdit_labelText->placeholderText();
|
2026-01-19 07:31:50 +01:00
|
|
|
//: Tooltip for font display in map label dialog
|
|
|
|
|
lineEdit_font->setToolTip(tr("Font size is automatically calculated to fit the label"));
|
Add: give map label text the ability to have an outline (#7598)
<!-- Keep the title short & concise so anyone non-technical can
understand it,
the title appears in PTB changelogs -->
#### Brief overview of PR changes/additions
Add an outline colour chooser to map label creation window in mapper.
Update createMapLabel Lua function to reflect this as well. Adds three
optional arguments to the end of createMapLabel( ..., outlineRed,
outlineGreen, outlineBlue), default to the same colour as foreground if
not specified.
Also, chosen colours weren't being saved from one dialog to the next
forcing unnecessary typing to replicate a colour scheme when creating
multiple labels, so fix this and allow chosen colours to also save
across Mudlet restarts as well.
#### Motivation for adding to Mudlet
Better user experience, more map design options, prettier maps.
#### Other info (issues closed, discussion etc)
- The outline width is only 1 pixel, but as fonts get smaller this
starts to become increasingly larger compared to the width of the small
font. Zoomed in fonts (or larger than 16 on my display) typically look
better.
- Based on this work I think it would be fairly trivial to add drop
shadows, mirroring and other text effects.

Zoomed in;

closes #2861
/claim #2861
2024-12-27 12:07:37 +04:00
|
|
|
|
|
|
|
|
QSettings& settings = *mudlet::getQSettings();
|
|
|
|
|
fgColor = settings.value("fgColorDialogMapLabel", fgColor).value<QColor>();
|
|
|
|
|
bgColor = settings.value("bgColorDialogMapLabel", bgColor).value<QColor>();
|
|
|
|
|
outlineColor = settings.value("outlineColorDialogMapLabel", outlineColor).value<QColor>();
|
2022-08-27 10:47:01 +02:00
|
|
|
slot_updateControls();
|
|
|
|
|
slot_updateControlsVisibility();
|
2022-03-10 15:24:08 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool dlgMapLabel::isTextLabel()
|
|
|
|
|
{
|
|
|
|
|
return comboBox_type->currentIndex() == 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QString dlgMapLabel::getImagePath()
|
|
|
|
|
{
|
|
|
|
|
return imagePath;
|
|
|
|
|
}
|
|
|
|
|
|
2022-08-27 10:47:01 +02:00
|
|
|
void dlgMapLabel::slot_pickFgColor()
|
2022-03-10 15:24:08 +01:00
|
|
|
{
|
Add: give map label text the ability to have an outline (#7598)
<!-- Keep the title short & concise so anyone non-technical can
understand it,
the title appears in PTB changelogs -->
#### Brief overview of PR changes/additions
Add an outline colour chooser to map label creation window in mapper.
Update createMapLabel Lua function to reflect this as well. Adds three
optional arguments to the end of createMapLabel( ..., outlineRed,
outlineGreen, outlineBlue), default to the same colour as foreground if
not specified.
Also, chosen colours weren't being saved from one dialog to the next
forcing unnecessary typing to replicate a colour scheme when creating
multiple labels, so fix this and allow chosen colours to also save
across Mudlet restarts as well.
#### Motivation for adding to Mudlet
Better user experience, more map design options, prettier maps.
#### Other info (issues closed, discussion etc)
- The outline width is only 1 pixel, but as fonts get smaller this
starts to become increasingly larger compared to the width of the small
font. Zoomed in fonts (or larger than 16 on my display) typically look
better.
- Based on this work I think it would be fairly trivial to add drop
shadows, mirroring and other text effects.

Zoomed in;

closes #2861
/claim #2861
2024-12-27 12:07:37 +04:00
|
|
|
QSettings& settings = *mudlet::getQSettings();
|
2022-03-10 15:24:08 +01:00
|
|
|
fgColorDialog = new QColorDialog(this);
|
Add: give map label text the ability to have an outline (#7598)
<!-- Keep the title short & concise so anyone non-technical can
understand it,
the title appears in PTB changelogs -->
#### Brief overview of PR changes/additions
Add an outline colour chooser to map label creation window in mapper.
Update createMapLabel Lua function to reflect this as well. Adds three
optional arguments to the end of createMapLabel( ..., outlineRed,
outlineGreen, outlineBlue), default to the same colour as foreground if
not specified.
Also, chosen colours weren't being saved from one dialog to the next
forcing unnecessary typing to replicate a colour scheme when creating
multiple labels, so fix this and allow chosen colours to also save
across Mudlet restarts as well.
#### Motivation for adding to Mudlet
Better user experience, more map design options, prettier maps.
#### Other info (issues closed, discussion etc)
- The outline width is only 1 pixel, but as fonts get smaller this
starts to become increasingly larger compared to the width of the small
font. Zoomed in fonts (or larger than 16 on my display) typically look
better.
- Based on this work I think it would be fairly trivial to add drop
shadows, mirroring and other text effects.

Zoomed in;

closes #2861
/claim #2861
2024-12-27 12:07:37 +04:00
|
|
|
fgColorDialog->setCurrentColor(settings.value("fgColorDialogMapLabel", fgColor).value<QColor>());
|
2022-03-10 15:24:08 +01:00
|
|
|
fgColorDialog->setAttribute(Qt::WA_DeleteOnClose);
|
2023-05-29 22:03:34 +03:00
|
|
|
//: 2D mapper create label color dialog title
|
|
|
|
|
fgColorDialog->setWindowTitle(tr("Foreground color"));
|
2022-03-10 15:24:08 +01:00
|
|
|
fgColorDialog->setOption(QColorDialog::ShowAlphaChannel);
|
|
|
|
|
connect(fgColorDialog, &QColorDialog::currentColorChanged, this, [&](const QColor& color) {
|
|
|
|
|
fgColor = color;
|
Add: give map label text the ability to have an outline (#7598)
<!-- Keep the title short & concise so anyone non-technical can
understand it,
the title appears in PTB changelogs -->
#### Brief overview of PR changes/additions
Add an outline colour chooser to map label creation window in mapper.
Update createMapLabel Lua function to reflect this as well. Adds three
optional arguments to the end of createMapLabel( ..., outlineRed,
outlineGreen, outlineBlue), default to the same colour as foreground if
not specified.
Also, chosen colours weren't being saved from one dialog to the next
forcing unnecessary typing to replicate a colour scheme when creating
multiple labels, so fix this and allow chosen colours to also save
across Mudlet restarts as well.
#### Motivation for adding to Mudlet
Better user experience, more map design options, prettier maps.
#### Other info (issues closed, discussion etc)
- The outline width is only 1 pixel, but as fonts get smaller this
starts to become increasingly larger compared to the width of the small
font. Zoomed in fonts (or larger than 16 on my display) typically look
better.
- Based on this work I think it would be fairly trivial to add drop
shadows, mirroring and other text effects.

Zoomed in;

closes #2861
/claim #2861
2024-12-27 12:07:37 +04:00
|
|
|
settings.setValue("fgColorDialogMapLabel", fgColor);
|
2022-03-10 15:24:08 +01:00
|
|
|
emit updated();
|
|
|
|
|
});
|
|
|
|
|
auto originalColor = QColor(fgColor);
|
Add: give map label text the ability to have an outline (#7598)
<!-- Keep the title short & concise so anyone non-technical can
understand it,
the title appears in PTB changelogs -->
#### Brief overview of PR changes/additions
Add an outline colour chooser to map label creation window in mapper.
Update createMapLabel Lua function to reflect this as well. Adds three
optional arguments to the end of createMapLabel( ..., outlineRed,
outlineGreen, outlineBlue), default to the same colour as foreground if
not specified.
Also, chosen colours weren't being saved from one dialog to the next
forcing unnecessary typing to replicate a colour scheme when creating
multiple labels, so fix this and allow chosen colours to also save
across Mudlet restarts as well.
#### Motivation for adding to Mudlet
Better user experience, more map design options, prettier maps.
#### Other info (issues closed, discussion etc)
- The outline width is only 1 pixel, but as fonts get smaller this
starts to become increasingly larger compared to the width of the small
font. Zoomed in fonts (or larger than 16 on my display) typically look
better.
- Based on this work I think it would be fairly trivial to add drop
shadows, mirroring and other text effects.

Zoomed in;

closes #2861
/claim #2861
2024-12-27 12:07:37 +04:00
|
|
|
connect(fgColorDialog, &QColorDialog::rejected, this, [this, originalColor]() {
|
2022-03-10 15:24:08 +01:00
|
|
|
fgColor = originalColor;
|
|
|
|
|
emit updated();
|
|
|
|
|
});
|
|
|
|
|
fgColorDialog->show();
|
|
|
|
|
fgColorDialog->raise();
|
|
|
|
|
}
|
|
|
|
|
|
2022-08-27 10:47:01 +02:00
|
|
|
void dlgMapLabel::slot_pickBgColor()
|
2022-03-10 15:24:08 +01:00
|
|
|
{
|
Add: give map label text the ability to have an outline (#7598)
<!-- Keep the title short & concise so anyone non-technical can
understand it,
the title appears in PTB changelogs -->
#### Brief overview of PR changes/additions
Add an outline colour chooser to map label creation window in mapper.
Update createMapLabel Lua function to reflect this as well. Adds three
optional arguments to the end of createMapLabel( ..., outlineRed,
outlineGreen, outlineBlue), default to the same colour as foreground if
not specified.
Also, chosen colours weren't being saved from one dialog to the next
forcing unnecessary typing to replicate a colour scheme when creating
multiple labels, so fix this and allow chosen colours to also save
across Mudlet restarts as well.
#### Motivation for adding to Mudlet
Better user experience, more map design options, prettier maps.
#### Other info (issues closed, discussion etc)
- The outline width is only 1 pixel, but as fonts get smaller this
starts to become increasingly larger compared to the width of the small
font. Zoomed in fonts (or larger than 16 on my display) typically look
better.
- Based on this work I think it would be fairly trivial to add drop
shadows, mirroring and other text effects.

Zoomed in;

closes #2861
/claim #2861
2024-12-27 12:07:37 +04:00
|
|
|
QSettings& settings = *mudlet::getQSettings();
|
2022-03-10 15:24:08 +01:00
|
|
|
bgColorDialog = new QColorDialog(this);
|
Add: give map label text the ability to have an outline (#7598)
<!-- Keep the title short & concise so anyone non-technical can
understand it,
the title appears in PTB changelogs -->
#### Brief overview of PR changes/additions
Add an outline colour chooser to map label creation window in mapper.
Update createMapLabel Lua function to reflect this as well. Adds three
optional arguments to the end of createMapLabel( ..., outlineRed,
outlineGreen, outlineBlue), default to the same colour as foreground if
not specified.
Also, chosen colours weren't being saved from one dialog to the next
forcing unnecessary typing to replicate a colour scheme when creating
multiple labels, so fix this and allow chosen colours to also save
across Mudlet restarts as well.
#### Motivation for adding to Mudlet
Better user experience, more map design options, prettier maps.
#### Other info (issues closed, discussion etc)
- The outline width is only 1 pixel, but as fonts get smaller this
starts to become increasingly larger compared to the width of the small
font. Zoomed in fonts (or larger than 16 on my display) typically look
better.
- Based on this work I think it would be fairly trivial to add drop
shadows, mirroring and other text effects.

Zoomed in;

closes #2861
/claim #2861
2024-12-27 12:07:37 +04:00
|
|
|
bgColorDialog->setCurrentColor(settings.value("bgColorDialogMapLabel", bgColor).value<QColor>());
|
2022-03-10 15:24:08 +01:00
|
|
|
bgColorDialog->setAttribute(Qt::WA_DeleteOnClose);
|
2023-05-29 22:03:34 +03:00
|
|
|
//: 2D mapper create label color dialog title
|
|
|
|
|
bgColorDialog->setWindowTitle(tr("Background color"));
|
2022-03-10 15:24:08 +01:00
|
|
|
bgColorDialog->setOption(QColorDialog::ShowAlphaChannel);
|
|
|
|
|
connect(bgColorDialog, &QColorDialog::currentColorChanged, this, [&](const QColor& color) {
|
|
|
|
|
bgColor = color;
|
Add: give map label text the ability to have an outline (#7598)
<!-- Keep the title short & concise so anyone non-technical can
understand it,
the title appears in PTB changelogs -->
#### Brief overview of PR changes/additions
Add an outline colour chooser to map label creation window in mapper.
Update createMapLabel Lua function to reflect this as well. Adds three
optional arguments to the end of createMapLabel( ..., outlineRed,
outlineGreen, outlineBlue), default to the same colour as foreground if
not specified.
Also, chosen colours weren't being saved from one dialog to the next
forcing unnecessary typing to replicate a colour scheme when creating
multiple labels, so fix this and allow chosen colours to also save
across Mudlet restarts as well.
#### Motivation for adding to Mudlet
Better user experience, more map design options, prettier maps.
#### Other info (issues closed, discussion etc)
- The outline width is only 1 pixel, but as fonts get smaller this
starts to become increasingly larger compared to the width of the small
font. Zoomed in fonts (or larger than 16 on my display) typically look
better.
- Based on this work I think it would be fairly trivial to add drop
shadows, mirroring and other text effects.

Zoomed in;

closes #2861
/claim #2861
2024-12-27 12:07:37 +04:00
|
|
|
settings.setValue("bgColorDialogMapLabel", bgColor);
|
2022-03-10 15:24:08 +01:00
|
|
|
emit updated();
|
|
|
|
|
});
|
Add: give map label text the ability to have an outline (#7598)
<!-- Keep the title short & concise so anyone non-technical can
understand it,
the title appears in PTB changelogs -->
#### Brief overview of PR changes/additions
Add an outline colour chooser to map label creation window in mapper.
Update createMapLabel Lua function to reflect this as well. Adds three
optional arguments to the end of createMapLabel( ..., outlineRed,
outlineGreen, outlineBlue), default to the same colour as foreground if
not specified.
Also, chosen colours weren't being saved from one dialog to the next
forcing unnecessary typing to replicate a colour scheme when creating
multiple labels, so fix this and allow chosen colours to also save
across Mudlet restarts as well.
#### Motivation for adding to Mudlet
Better user experience, more map design options, prettier maps.
#### Other info (issues closed, discussion etc)
- The outline width is only 1 pixel, but as fonts get smaller this
starts to become increasingly larger compared to the width of the small
font. Zoomed in fonts (or larger than 16 on my display) typically look
better.
- Based on this work I think it would be fairly trivial to add drop
shadows, mirroring and other text effects.

Zoomed in;

closes #2861
/claim #2861
2024-12-27 12:07:37 +04:00
|
|
|
auto originalColor = QColor(bgColor);
|
|
|
|
|
connect(bgColorDialog, &QColorDialog::rejected, this, [this, originalColor]() {
|
2022-03-10 15:24:08 +01:00
|
|
|
bgColor = originalColor;
|
|
|
|
|
emit updated();
|
|
|
|
|
});
|
|
|
|
|
bgColorDialog->show();
|
|
|
|
|
bgColorDialog->raise();
|
|
|
|
|
}
|
|
|
|
|
|
Add: give map label text the ability to have an outline (#7598)
<!-- Keep the title short & concise so anyone non-technical can
understand it,
the title appears in PTB changelogs -->
#### Brief overview of PR changes/additions
Add an outline colour chooser to map label creation window in mapper.
Update createMapLabel Lua function to reflect this as well. Adds three
optional arguments to the end of createMapLabel( ..., outlineRed,
outlineGreen, outlineBlue), default to the same colour as foreground if
not specified.
Also, chosen colours weren't being saved from one dialog to the next
forcing unnecessary typing to replicate a colour scheme when creating
multiple labels, so fix this and allow chosen colours to also save
across Mudlet restarts as well.
#### Motivation for adding to Mudlet
Better user experience, more map design options, prettier maps.
#### Other info (issues closed, discussion etc)
- The outline width is only 1 pixel, but as fonts get smaller this
starts to become increasingly larger compared to the width of the small
font. Zoomed in fonts (or larger than 16 on my display) typically look
better.
- Based on this work I think it would be fairly trivial to add drop
shadows, mirroring and other text effects.

Zoomed in;

closes #2861
/claim #2861
2024-12-27 12:07:37 +04:00
|
|
|
void dlgMapLabel::slot_pickOutlineColor()
|
|
|
|
|
{
|
|
|
|
|
QSettings& settings = *mudlet::getQSettings();
|
|
|
|
|
outlineColorDialog = new QColorDialog(this);
|
|
|
|
|
outlineColorDialog->setCurrentColor(settings.value("outlineColorDialogMapLabel", outlineColor).value<QColor>());
|
|
|
|
|
outlineColorDialog->setAttribute(Qt::WA_DeleteOnClose);
|
|
|
|
|
//: 2D mapper create label color dialog title
|
|
|
|
|
outlineColorDialog->setWindowTitle(tr("Text outline color"));
|
|
|
|
|
outlineColorDialog->setOption(QColorDialog::ShowAlphaChannel);
|
|
|
|
|
connect(outlineColorDialog, &QColorDialog::currentColorChanged, this, [&](const QColor& color) {
|
|
|
|
|
outlineColor = color;
|
|
|
|
|
settings.setValue("outlineColorDialogMapLabel", outlineColor);
|
|
|
|
|
emit updated();
|
|
|
|
|
});
|
|
|
|
|
auto originalColor = QColor(outlineColor);
|
|
|
|
|
connect(outlineColorDialog, &QColorDialog::rejected, this, [this, originalColor]() {
|
|
|
|
|
outlineColor = originalColor;
|
|
|
|
|
emit updated();
|
|
|
|
|
});
|
|
|
|
|
outlineColorDialog->show();
|
|
|
|
|
outlineColorDialog->raise();
|
|
|
|
|
}
|
|
|
|
|
|
2022-08-27 10:47:01 +02:00
|
|
|
void dlgMapLabel::slot_pickFont()
|
2022-03-10 15:24:08 +01:00
|
|
|
{
|
|
|
|
|
auto originalFont = QFont(font);
|
|
|
|
|
fontDialog = new QFontDialog(font, this);
|
|
|
|
|
fontDialog->setAttribute(Qt::WA_DeleteOnClose);
|
2023-05-29 22:03:34 +03:00
|
|
|
//: 2D mapper create label font dialog title
|
|
|
|
|
fontDialog->setWindowTitle(tr("Label font"));
|
2022-03-10 15:24:08 +01:00
|
|
|
connect(fontDialog, &QFontDialog::currentFontChanged, this, [&](const QFont& pFont) {
|
|
|
|
|
font = pFont;
|
|
|
|
|
emit updated();
|
|
|
|
|
});
|
Add: give map label text the ability to have an outline (#7598)
<!-- Keep the title short & concise so anyone non-technical can
understand it,
the title appears in PTB changelogs -->
#### Brief overview of PR changes/additions
Add an outline colour chooser to map label creation window in mapper.
Update createMapLabel Lua function to reflect this as well. Adds three
optional arguments to the end of createMapLabel( ..., outlineRed,
outlineGreen, outlineBlue), default to the same colour as foreground if
not specified.
Also, chosen colours weren't being saved from one dialog to the next
forcing unnecessary typing to replicate a colour scheme when creating
multiple labels, so fix this and allow chosen colours to also save
across Mudlet restarts as well.
#### Motivation for adding to Mudlet
Better user experience, more map design options, prettier maps.
#### Other info (issues closed, discussion etc)
- The outline width is only 1 pixel, but as fonts get smaller this
starts to become increasingly larger compared to the width of the small
font. Zoomed in fonts (or larger than 16 on my display) typically look
better.
- Based on this work I think it would be fairly trivial to add drop
shadows, mirroring and other text effects.

Zoomed in;

closes #2861
/claim #2861
2024-12-27 12:07:37 +04:00
|
|
|
connect(fontDialog, &QFontDialog::rejected, this, [this, originalFont]() {
|
2022-03-10 15:24:08 +01:00
|
|
|
font = originalFont;
|
|
|
|
|
emit updated();
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
fontDialog->setCurrentFont(font);
|
|
|
|
|
fontDialog->show();
|
|
|
|
|
fontDialog->raise();
|
|
|
|
|
}
|
|
|
|
|
|
2022-08-27 10:47:01 +02:00
|
|
|
void dlgMapLabel::slot_pickFile()
|
2022-03-10 15:24:08 +01:00
|
|
|
{
|
2023-05-29 22:03:34 +03:00
|
|
|
//: 2D Mapper create label file dialog title
|
2024-11-04 10:54:51 +04:00
|
|
|
|
|
|
|
|
QSettings& settings = *mudlet::getQSettings();
|
|
|
|
|
QString lastDir = settings.value("lastFileDialogLocation", QDir::homePath()).toString();
|
|
|
|
|
|
|
|
|
|
imagePath = QFileDialog::getOpenFileName(nullptr, tr("Select image"), lastDir);
|
|
|
|
|
|
|
|
|
|
if (imagePath.isEmpty()) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2022-03-10 15:24:08 +01:00
|
|
|
emit updated();
|
2024-11-04 10:54:51 +04:00
|
|
|
lastDir = QFileInfo(imagePath).absolutePath();
|
|
|
|
|
settings.setValue("lastFileDialogLocation", lastDir);
|
2022-03-10 15:24:08 +01:00
|
|
|
}
|
|
|
|
|
|
2022-08-27 10:47:01 +02:00
|
|
|
void dlgMapLabel::slot_save()
|
2022-03-10 15:24:08 +01:00
|
|
|
{
|
|
|
|
|
accept();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QString dlgMapLabel::getText()
|
|
|
|
|
{
|
|
|
|
|
return text;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QColor& dlgMapLabel::getBgColor()
|
|
|
|
|
{
|
|
|
|
|
return bgColor;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QColor& dlgMapLabel::getFgColor()
|
|
|
|
|
{
|
|
|
|
|
return fgColor;
|
|
|
|
|
}
|
|
|
|
|
|
Add: give map label text the ability to have an outline (#7598)
<!-- Keep the title short & concise so anyone non-technical can
understand it,
the title appears in PTB changelogs -->
#### Brief overview of PR changes/additions
Add an outline colour chooser to map label creation window in mapper.
Update createMapLabel Lua function to reflect this as well. Adds three
optional arguments to the end of createMapLabel( ..., outlineRed,
outlineGreen, outlineBlue), default to the same colour as foreground if
not specified.
Also, chosen colours weren't being saved from one dialog to the next
forcing unnecessary typing to replicate a colour scheme when creating
multiple labels, so fix this and allow chosen colours to also save
across Mudlet restarts as well.
#### Motivation for adding to Mudlet
Better user experience, more map design options, prettier maps.
#### Other info (issues closed, discussion etc)
- The outline width is only 1 pixel, but as fonts get smaller this
starts to become increasingly larger compared to the width of the small
font. Zoomed in fonts (or larger than 16 on my display) typically look
better.
- Based on this work I think it would be fairly trivial to add drop
shadows, mirroring and other text effects.

Zoomed in;

closes #2861
/claim #2861
2024-12-27 12:07:37 +04:00
|
|
|
QColor& dlgMapLabel::getOutlineColor()
|
|
|
|
|
{
|
|
|
|
|
return outlineColor;
|
|
|
|
|
}
|
|
|
|
|
|
2022-03-10 15:24:08 +01:00
|
|
|
QFont& dlgMapLabel::getFont()
|
|
|
|
|
{
|
|
|
|
|
return font;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool dlgMapLabel::isOnTop()
|
|
|
|
|
{
|
|
|
|
|
return comboBox_position->currentIndex() == 1;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool dlgMapLabel::noScale()
|
|
|
|
|
{
|
|
|
|
|
return !checkBox_scaling->isChecked();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool dlgMapLabel::stretchImage()
|
|
|
|
|
{
|
|
|
|
|
return checkBox_stretchImage->isChecked();
|
|
|
|
|
}
|
|
|
|
|
|
2022-08-27 10:47:01 +02:00
|
|
|
void dlgMapLabel::slot_updateControls()
|
2022-03-10 15:24:08 +01:00
|
|
|
{
|
2026-01-19 07:31:50 +01:00
|
|
|
//: Font display format in map label dialog. %1 is font family name, %2 is style (e.g. "Bold", "Italic"). Size excluded since it auto-scales.
|
|
|
|
|
lineEdit_font->setText(tr("%1 %2").arg(font.family(), font.styleName()));
|
2022-03-10 15:24:08 +01:00
|
|
|
pushButton_fgColor->setStyleSheet(BUTTON_STYLESHEET.arg(QString::number(fgColor.red()), QString::number(fgColor.green()), QString::number(fgColor.blue()), QString::number(fgColor.alpha())));
|
|
|
|
|
pushButton_bgColor->setStyleSheet(BUTTON_STYLESHEET.arg(QString::number(bgColor.red()), QString::number(bgColor.green()), QString::number(bgColor.blue()), QString::number(bgColor.alpha())));
|
Add: give map label text the ability to have an outline (#7598)
<!-- Keep the title short & concise so anyone non-technical can
understand it,
the title appears in PTB changelogs -->
#### Brief overview of PR changes/additions
Add an outline colour chooser to map label creation window in mapper.
Update createMapLabel Lua function to reflect this as well. Adds three
optional arguments to the end of createMapLabel( ..., outlineRed,
outlineGreen, outlineBlue), default to the same colour as foreground if
not specified.
Also, chosen colours weren't being saved from one dialog to the next
forcing unnecessary typing to replicate a colour scheme when creating
multiple labels, so fix this and allow chosen colours to also save
across Mudlet restarts as well.
#### Motivation for adding to Mudlet
Better user experience, more map design options, prettier maps.
#### Other info (issues closed, discussion etc)
- The outline width is only 1 pixel, but as fonts get smaller this
starts to become increasingly larger compared to the width of the small
font. Zoomed in fonts (or larger than 16 on my display) typically look
better.
- Based on this work I think it would be fairly trivial to add drop
shadows, mirroring and other text effects.

Zoomed in;

closes #2861
/claim #2861
2024-12-27 12:07:37 +04:00
|
|
|
pushButton_outlineColor->setStyleSheet(
|
|
|
|
|
BUTTON_STYLESHEET.arg(QString::number(outlineColor.red()), QString::number(outlineColor.green()), QString::number(outlineColor.blue()), QString::number(outlineColor.alpha())));
|
2022-03-10 15:24:08 +01:00
|
|
|
lineEdit_image->setText(imagePath);
|
|
|
|
|
}
|
|
|
|
|
|
2022-08-27 10:47:01 +02:00
|
|
|
void dlgMapLabel::slot_updateControlsVisibility()
|
2022-03-10 15:24:08 +01:00
|
|
|
{
|
2023-05-14 15:06:15 +02:00
|
|
|
const bool isText = isTextLabel();
|
2022-03-10 15:24:08 +01:00
|
|
|
label_image->setVisible(!isText);
|
|
|
|
|
lineEdit_image->setVisible(!isText);
|
|
|
|
|
checkBox_stretchImage->setVisible(!isText);
|
|
|
|
|
toolButton_imagePick->setVisible(!isText);
|
|
|
|
|
label_text->setVisible(isText);
|
2025-01-21 21:14:02 +00:00
|
|
|
plainTextEdit_labelText->setVisible(isText);
|
2022-03-10 15:24:08 +01:00
|
|
|
label_font->setVisible(isText);
|
|
|
|
|
lineEdit_font->setVisible(isText);
|
|
|
|
|
toolButton_fontPick->setVisible(isText);
|
|
|
|
|
pushButton_fgColor->setVisible(isText);
|
|
|
|
|
label_fg->setVisible(isText);
|
Add: give map label text the ability to have an outline (#7598)
<!-- Keep the title short & concise so anyone non-technical can
understand it,
the title appears in PTB changelogs -->
#### Brief overview of PR changes/additions
Add an outline colour chooser to map label creation window in mapper.
Update createMapLabel Lua function to reflect this as well. Adds three
optional arguments to the end of createMapLabel( ..., outlineRed,
outlineGreen, outlineBlue), default to the same colour as foreground if
not specified.
Also, chosen colours weren't being saved from one dialog to the next
forcing unnecessary typing to replicate a colour scheme when creating
multiple labels, so fix this and allow chosen colours to also save
across Mudlet restarts as well.
#### Motivation for adding to Mudlet
Better user experience, more map design options, prettier maps.
#### Other info (issues closed, discussion etc)
- The outline width is only 1 pixel, but as fonts get smaller this
starts to become increasingly larger compared to the width of the small
font. Zoomed in fonts (or larger than 16 on my display) typically look
better.
- Based on this work I think it would be fairly trivial to add drop
shadows, mirroring and other text effects.

Zoomed in;

closes #2861
/claim #2861
2024-12-27 12:07:37 +04:00
|
|
|
pushButton_outlineColor->setVisible(isText);
|
|
|
|
|
label_outline->setVisible(isText);
|
2022-03-10 15:24:08 +01:00
|
|
|
}
|