File indexing completed on 2025-04-27 03:58:33

0001 /* ============================================================
0002  *
0003  * This file is a part of digiKam project
0004  * https://www.digikam.org
0005  *
0006  * Date        : 2021-04-18
0007  * Description : ExifTool error view.
0008  *
0009  * SPDX-FileCopyrightText: 2021-2024 by Gilles Caulier <caulier dot gilles at gmail dot com>
0010  *
0011  * SPDX-License-Identifier: GPL-2.0-or-later
0012  *
0013  * ============================================================ */
0014 
0015 #include "exiftoolerrorview.h"
0016 
0017 // Qt includes
0018 
0019 #include <QLabel>
0020 #include <QApplication>
0021 #include <QStyle>
0022 #include <QGridLayout>
0023 #include <QPushButton>
0024 
0025 // KDE includes
0026 
0027 #include <klocalizedstring.h>
0028 
0029 namespace Digikam
0030 {
0031 
0032 class Q_DECL_HIDDEN ExifToolErrorView::Private
0033 {
0034 
0035 public:
0036 
0037     explicit Private()
0038         : errorLbl(nullptr),
0039           btn     (nullptr)
0040     {
0041     }
0042 
0043     QLabel*           errorLbl;
0044 
0045     QPushButton*      btn;
0046 };
0047 
0048 ExifToolErrorView::ExifToolErrorView(QWidget* const parent)
0049     : QWidget(parent),
0050       d      (new Private)
0051 {
0052     setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
0053     const int spacing        = qMin(QApplication::style()->pixelMetric(QStyle::PM_LayoutHorizontalSpacing),
0054                              QApplication::style()->pixelMetric(QStyle::PM_LayoutVerticalSpacing));
0055 
0056     QGridLayout* const grid  = new QGridLayout(this);
0057 
0058     d->errorLbl              = new QLabel(this);
0059     d->errorLbl->setAlignment(Qt::AlignCenter);
0060     d->errorLbl->setWordWrap(true);
0061 
0062     d->btn                   = new QPushButton(this);
0063     d->btn->setText(i18nc("@action: button", "Open Setup Dialog..."));
0064 
0065     connect(d->btn, SIGNAL(clicked()),
0066             this, SIGNAL(signalSetupExifTool()));
0067 
0068     grid->addWidget(d->errorLbl, 1, 1, 1, 1);
0069     grid->addWidget(d->btn,      2, 1, 1, 1);
0070     grid->setColumnStretch(0, 10);
0071     grid->setColumnStretch(2, 10);
0072     grid->setContentsMargins(spacing, spacing, spacing, spacing);
0073     grid->setRowStretch(0, 10);
0074     grid->setRowStretch(3, 10);
0075 }
0076 
0077 ExifToolErrorView::~ExifToolErrorView()
0078 {
0079     delete d;
0080 }
0081 
0082 void ExifToolErrorView::setErrorText(const QString& err)
0083 {
0084     d->errorLbl->setText(err);
0085 }
0086 
0087 } // namespace Digikam
0088 
0089 #include "moc_exiftoolerrorview.cpp"