FreeCAD
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 "PreCompiled.h"24#ifndef _PreComp_25# include <QDir>26# include <QMessageBox>27#endif28
29#include <App/Application.h>30
31#include "DlgOnlineHelpImp.h"32#include "ui_DlgOnlineHelp.h"33
34
35using namespace Gui::Dialog;36
37/* TRANSLATOR Gui::Dialog::DlgOnlineHelpImp */
38
39/**
40* Constructs a DlgOnlineHelpImp which is a child of 'parent', with the
41* name 'name' and widget flags set to 'f'
42*
43* The dialog will by default be modeless, unless you set 'modal' to
44* true to construct a modal dialog.
45*/
46DlgOnlineHelpImp::DlgOnlineHelpImp( QWidget* parent )47: PreferencePage(parent)48, ui(new Ui_DlgOnlineHelp)49{
50ui->setupUi(this);51
52ui->prefStartPage->setFilter(QString::fromLatin1("%1 (*.html *.htm)").arg(tr("HTML files")));53if (ui->prefStartPage->fileName().isEmpty()) {54ui->prefStartPage->setFileName(getStartpage());55}56}
57
58/**
59* Destroys the object and frees any allocated resources
60*/
61DlgOnlineHelpImp::~DlgOnlineHelpImp() = default;62
63/**
64* Returns the start page for the HelpView. If none is defined the default
65* start page "<FreeCADHome>/doc/free-cad.sourceforge.net/wiki/index.php.html"
66* is returned.
67* \remark It is not checked if the returned page really exists.
68*/
69QString DlgOnlineHelpImp::getStartpage()70{
71QDir docdir = QDir(QString::fromUtf8(App::Application::getHelpDir().c_str()));72return docdir.absoluteFilePath(QString::fromUtf8("Start_Page.html"));73}
74
75void DlgOnlineHelpImp::saveSettings()76{
77ui->prefStartPage->onSave();78}
79
80void DlgOnlineHelpImp::loadSettings()81{
82ui->prefStartPage->onRestore();83}
84
85/**
86* Sets the strings of the subwidgets using the current language.
87*/
88void DlgOnlineHelpImp::changeEvent(QEvent *e)89{
90if (e->type() == QEvent::LanguageChange) {91ui->retranslateUi(this);92}93else {94QWidget::changeEvent(e);95}96}
97
98void DlgOnlineHelpImp::onLineEditDownloadFileNameSelected( const QString& url )99{
100QDir dir(url);101if (dir.exists() && dir.count() == 0) {102QMessageBox::critical(this, tr("Access denied"), tr("Access denied to '%1'\n\n"103"Specify another directory, please.").arg(url));104}105}
106
107#include "moc_DlgOnlineHelpImp.cpp"108