File indexing completed on 2025-03-09 03:57:05

0001 /* ============================================================
0002  *
0003  * This file is a part of digiKam project
0004  * https://www.digikam.org
0005  *
0006  * Date        : 2010-05-28
0007  * Description : a dialog for showing the advancedrename tooltip
0008  *
0009  * SPDX-FileCopyrightText: 2010-2012 by Andi Clemens <andi dot clemens at gmail dot com>
0010  *
0011  * SPDX-License-Identifier: GPL-2.0-or-later
0012  *
0013  * ============================================================ */
0014 
0015 #include "tooltipdialog.h"
0016 
0017 // Qt includes
0018 
0019 #include <QTextBrowser>
0020 #include <QDialogButtonBox>
0021 #include <QVBoxLayout>
0022 #include <QPushButton>
0023 
0024 // KDE includes
0025 
0026 #include <klocalizedstring.h>
0027 
0028 // Local includes
0029 
0030 #include "digikam_globals.h"
0031 #include "tooltipcreator.h"
0032 
0033 namespace Digikam
0034 {
0035 
0036 class Q_DECL_HIDDEN TooltipDialog::Private
0037 {
0038 public:
0039 
0040     explicit Private()
0041       : buttons(nullptr),
0042         textBrowser(nullptr)
0043     {
0044     }
0045 
0046     QDialogButtonBox* buttons;
0047     QTextBrowser*     textBrowser;
0048 };
0049 
0050 TooltipDialog::TooltipDialog(QWidget* const parent)
0051     : QDialog(parent),
0052       d(new Private)
0053 {
0054     setWindowTitle(i18nc("@title:window", "Information"));
0055 
0056     d->buttons     = new QDialogButtonBox(QDialogButtonBox::Close | QDialogButtonBox::Help, this);
0057     d->buttons->button(QDialogButtonBox::Close)->setDefault(true);
0058 
0059     d->textBrowser = new QTextBrowser(this);
0060     d->textBrowser->setFrameStyle(QFrame::NoFrame);
0061     d->textBrowser->setOpenLinks(true);
0062     d->textBrowser->setOpenExternalLinks(true);
0063 
0064     QVBoxLayout* const vbx = new QVBoxLayout(this);
0065     vbx->addWidget(d->textBrowser);
0066     vbx->addWidget(d->buttons);
0067     setLayout(vbx);
0068 
0069     connect(d->buttons->button(QDialogButtonBox::Close), SIGNAL(clicked()),
0070             this, SLOT(accept()));
0071 
0072     connect(d->buttons->button(QDialogButtonBox::Help), SIGNAL(clicked()),
0073             this, SLOT(slotHelp()));
0074 }
0075 
0076 TooltipDialog::~TooltipDialog()
0077 {
0078     delete d;
0079 }
0080 
0081 void TooltipDialog::setTooltip(const QString& tooltip)
0082 {
0083     clearTooltip();
0084 
0085     d->textBrowser->setHtml(tooltip);
0086 }
0087 
0088 void TooltipDialog::clearTooltip()
0089 {
0090     d->textBrowser->clear();
0091 }
0092 
0093 void TooltipDialog::slotHelp()
0094 {
0095     openOnlineDocumentation(QLatin1String("main_window"), QLatin1String("image_view"), QLatin1String("renaming-photograph"));
0096 }
0097 
0098 } // namespace Digikam
0099 
0100 #include "moc_tooltipdialog.cpp"