Take default name of a background image from a file path.

This commit is contained in:
Roman Telezhynskyi 2022-02-03 17:11:21 +02:00
parent 62ff405cc0
commit 111b7f356c
3 changed files with 5 additions and 3 deletions

View file

@ -26,14 +26,16 @@
**
*************************************************************************/
#include "dialogaddbackgroundimage.h"
#include "qfileinfo.h"
#include "ui_dialogaddbackgroundimage.h"
//---------------------------------------------------------------------------------------------------------------------
DialogAddBackgroundImage::DialogAddBackgroundImage(QWidget *parent) :
DialogAddBackgroundImage::DialogAddBackgroundImage(const QString &fileName, QWidget *parent) :
QDialog(parent),
ui(new Ui::DialogAddBackgroundImage)
{
ui->setupUi(this);
ui->lineEditName->setText(QFileInfo(fileName).baseName());
}
//---------------------------------------------------------------------------------------------------------------------

View file

@ -44,7 +44,7 @@ class DialogAddBackgroundImage : public QDialog
Q_OBJECT
public:
explicit DialogAddBackgroundImage(QWidget *parent = nullptr);
explicit DialogAddBackgroundImage(const QString &fileName, QWidget *parent = nullptr);
~DialogAddBackgroundImage() override;
auto Name() const -> QString;

View file

@ -1382,7 +1382,7 @@ void MainWindow::ZoomFitBestCurrent()
//---------------------------------------------------------------------------------------------------------------------
void MainWindow::PlaceBackgroundImage(const QPointF &pos, const QString &fileName)
{
DialogAddBackgroundImage dialog(this);
DialogAddBackgroundImage dialog(fileName, this);
if (dialog.exec() == QDialog::Rejected)
{
qCritical() << tr("Unable to add background image");