| 1 |
/*************************************************************************** |
| 2 |
* Copyright (c) 2004 Werner Mayer <wmayer[at]users.sourceforge.net> * |
| 3 |
* * |
| 4 |
* This file is part of the FreeCAD CAx development system. * |
| 5 |
* * |
| 6 |
* This library is free software; you can redistribute it and/or * |
| 7 |
* modify it under the terms of the GNU Library General Public * |
| 8 |
* License as published by the Free Software Foundation; either * |
| 9 |
* version 2 of the License, or (at your option) any later version. * |
| 10 |
* * |
| 11 |
* This library is distributed in the hope that it will be useful, * |
| 12 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of * |
| 13 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * |
| 14 |
* GNU Library General Public License for more details. * |
| 15 |
* * |
| 16 |
* You should have received a copy of the GNU Library General Public * |
| 17 |
* License along with this library; see the file COPYING.LIB. If not, * |
| 18 |
* write to the Free Software Foundation, Inc., 59 Temple Place, * |
| 19 |
* Suite 330, Boston, MA 02111-1307, USA * |
| 20 |
* * |
| 21 |
***************************************************************************/ |
| 22 |
|
| 23 |
#include <QDir> |
| 24 |
#include <QMessageBox> |
| 25 |
|
| 26 |
#include <App/Application.h> |
| 27 |
|
| 28 |
#include "Dialogs/DlgOnlineHelpImp.h" |
| 29 |
#include "ui_DlgOnlineHelp.h" |
| 30 |
|
| 31 |
|
| 32 |
using namespace Gui::Dialog; |
| 33 |
|
| 34 |
/* TRANSLATOR Gui::Dialog::DlgOnlineHelpImp */ |
| 35 |
|
| 36 |
/** |
| 37 |
* Constructs a DlgOnlineHelpImp which is a child of 'parent', with the |
| 38 |
* name 'name' and widget flags set to 'f' |
| 39 |
* |
| 40 |
* The dialog will by default be modeless, unless you set 'modal' to |
| 41 |
* true to construct a modal dialog. |
| 42 |
*/ |
| 43 |
DlgOnlineHelpImp::DlgOnlineHelpImp(QWidget* parent) |
| 44 |
: PreferencePage(parent) |
| 45 |
, ui(new Ui_DlgOnlineHelp) |
| 46 |
{ |
| 47 |
ui->setupUi(this); |
| 48 |
|
| 49 |
ui->prefStartPage->setFilter(QStringLiteral("%1 (*.html *.htm)").arg(tr("HTML files"))); |
| 50 |
if (ui->prefStartPage->fileName().isEmpty()) { |
| 51 |
ui->prefStartPage->setFileName(getStartpage()); |
| 52 |
} |
| 53 |
} |
| 54 |
|
| 55 |
/** |
| 56 |
* Destroys the object and frees any allocated resources |
| 57 |
*/ |
| 58 |
DlgOnlineHelpImp::~DlgOnlineHelpImp() = default; |
| 59 |
|
| 60 |
/** |
| 61 |
* Returns the start page for the HelpView. If none is defined the default |
| 62 |
* start page "<FreeCADHome>/doc/free-cad.sourceforge.net/wiki/index.php.html" |
| 63 |
* is returned. |
| 64 |
* \remark It is not checked if the returned page really exists. |
| 65 |
*/ |
| 66 |
QString DlgOnlineHelpImp::getStartpage() |
| 67 |
{ |
| 68 |
QDir docdir = QDir(QString::fromUtf8(App::Application::getHelpDir().c_str())); |
| 69 |
return docdir.absoluteFilePath(QStringLiteral("Start_Page.html")); |
| 70 |
} |
| 71 |
|
| 72 |
void DlgOnlineHelpImp::saveSettings() |
| 73 |
{ |
| 74 |
ui->prefStartPage->onSave(); |
| 75 |
} |
| 76 |
|
| 77 |
void DlgOnlineHelpImp::loadSettings() |
| 78 |
{ |
| 79 |
ui->prefStartPage->onRestore(); |
| 80 |
} |
| 81 |
|
| 82 |
/** |
| 83 |
* Sets the strings of the subwidgets using the current language. |
| 84 |
*/ |
| 85 |
void DlgOnlineHelpImp::changeEvent(QEvent* e) |
| 86 |
{ |
| 87 |
if (e->type() == QEvent::LanguageChange) { |
| 88 |
ui->retranslateUi(this); |
| 89 |
} |
| 90 |
else { |
| 91 |
QWidget::changeEvent(e); |
| 92 |
} |
| 93 |
} |
| 94 |
|
| 95 |
void DlgOnlineHelpImp::onLineEditDownloadFileNameSelected(const QString& url) |
| 96 |
{ |
| 97 |
QDir dir(url); |
| 98 |
if (dir.exists() && dir.isEmpty()) { |
| 99 |
QMessageBox::critical( |
| 100 |
this, |
| 101 |
tr("Access denied"), |
| 102 |
tr("Access denied to '%1'\n\n" |
| 103 |
"Specify another directory.") |
| 104 |
.arg(url) |
| 105 |
); |
| 106 |
} |
| 107 |
} |
| 108 |
|
| 109 |
#include "moc_DlgOnlineHelpImp.cpp" |