1 /* ============================================================
2  *
3  * This file is a part of digiKam project
4  * https://www.digikam.org
5  *
6  * Date        : 2003-01-28
7  * Description : a dialog to display camera information.
8  *
9  * Copyright (C) 2003-2005 by Renchi Raju <renchi dot raju at gmail dot com>
10  * Copyright (C) 2006-2021 by Gilles Caulier <caulier dot gilles at gmail dot com>
11  *
12  * This program is free software; you can redistribute it
13  * and/or modify it under the terms of the GNU General
14  * Public License as published by the Free Software Foundation;
15  * either version 2, or (at your option)
16  * any later version.
17  *
18  * This program is distributed in the hope that it will be useful,
19  * but WITHOUT ANY WARRANTY; without even the implied warranty of
20  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
21  * GNU General Public License for more details.
22  *
23  * ============================================================ */
24 
25 #include "camerainfodialog.h"
26 
27 // Qt includes
28 
29 #include <QIcon>
30 #include <QPushButton>
31 #include <QVBoxLayout>
32 #include <QTabWidget>
33 #include <QTextEdit>
34 #include <QDialogButtonBox>
35 
36 // KDE includes
37 
38 #include <klocalizedstring.h>
39 
40 // Local includes
41 
42 #include "dxmlguiwindow.h"
43 
44 namespace Digikam
45 {
46 
CameraInfoDialog(QWidget * const parent,const QString & summary,const QString & manual,const QString & about)47 CameraInfoDialog::CameraInfoDialog(QWidget* const parent,
48                                    const QString& summary,
49                                    const QString& manual,
50                                    const QString& about)
51     : QDialog(parent)
52 {
53     setModal(true);
54     setWindowTitle(i18nc("@title:window", "Device Information"));
55     QDialogButtonBox* const buttons = new QDialogButtonBox(QDialogButtonBox::Help | QDialogButtonBox::Ok, this);
56     buttons->button(QDialogButtonBox::Ok)->setDefault(true);
57     resize(500, 400);
58 
59     QTabWidget* const tab           = new QTabWidget(this);
60 
61     // ----------------------------------------------------------
62 
63     QTextEdit* const summaryView = new QTextEdit(this);
64     summaryView->setWordWrapMode(QTextOption::WordWrap);
65     summaryView->setPlainText(summary);
66     summaryView->setReadOnly(true);
67     tab->insertTab(0, summaryView, QIcon::fromTheme(QLatin1String("dialog-information")), i18nc("@title", "Device Summary"));
68 
69     // ----------------------------------------------------------
70 
71     QTextEdit* const manualView  = new QTextEdit(this);
72     manualView->setWordWrapMode(QTextOption::WordWrap);
73     manualView->setPlainText(manual);
74     manualView->setReadOnly(true);
75     tab->insertTab(1, manualView, QIcon::fromTheme(QLatin1String("help-contents")), i18nc("@title", "Device Manual"));
76 
77     // ----------------------------------------------------------
78 
79     QTextEdit* const aboutView   = new QTextEdit(this);
80     aboutView->setWordWrapMode(QTextOption::WordWrap);
81     aboutView->setPlainText(about);
82     aboutView->setReadOnly(true);
83     tab->insertTab(2, aboutView, QIcon::fromTheme(QLatin1String("camera-photo")), i18nc("@title", "About Driver"));
84 
85     // ----------------------------------------------------------
86 
87     QVBoxLayout* const vbx       = new QVBoxLayout(this);
88     vbx->addWidget(tab);
89     vbx->addWidget(buttons);
90     setLayout(vbx);
91 
92     connect(buttons->button(QDialogButtonBox::Ok), SIGNAL(clicked()),
93             this, SLOT(accept()));
94 
95     connect(buttons->button(QDialogButtonBox::Help), SIGNAL(clicked()),
96             this, SLOT(slotHelp()));
97 }
98 
~CameraInfoDialog()99 CameraInfoDialog::~CameraInfoDialog()
100 {
101 }
102 
slotHelp()103 void CameraInfoDialog::slotHelp()
104 {
105     DXmlGuiWindow::openHandbook();
106 }
107 
108 } // namespace Digikam
109