FreeCAD

Форк
0
/
DlgOnlineHelpImp.cpp 
107 строк · 3.8 Кб
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
#endif
28

29
#include <App/Application.h>
30

31
#include "DlgOnlineHelpImp.h"
32
#include "ui_DlgOnlineHelp.h"
33

34

35
using 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
 */
46
DlgOnlineHelpImp::DlgOnlineHelpImp( QWidget* parent )
47
  : PreferencePage(parent)
48
  , ui(new Ui_DlgOnlineHelp)
49
{
50
    ui->setupUi(this);
51

52
    ui->prefStartPage->setFilter(QString::fromLatin1("%1 (*.html *.htm)").arg(tr("HTML files")));
53
    if (ui->prefStartPage->fileName().isEmpty()) {
54
        ui->prefStartPage->setFileName(getStartpage());
55
    }
56
}
57

58
/**
59
 *  Destroys the object and frees any allocated resources
60
 */
61
DlgOnlineHelpImp::~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
 */
69
QString DlgOnlineHelpImp::getStartpage()
70
{
71
    QDir docdir = QDir(QString::fromUtf8(App::Application::getHelpDir().c_str()));
72
    return docdir.absoluteFilePath(QString::fromUtf8("Start_Page.html"));
73
}
74

75
void DlgOnlineHelpImp::saveSettings()
76
{
77
    ui->prefStartPage->onSave();
78
}
79

80
void DlgOnlineHelpImp::loadSettings()
81
{
82
    ui->prefStartPage->onRestore();
83
}
84

85
/**
86
 * Sets the strings of the subwidgets using the current language.
87
 */
88
void DlgOnlineHelpImp::changeEvent(QEvent *e)
89
{
90
    if (e->type() == QEvent::LanguageChange) {
91
        ui->retranslateUi(this);
92
    }
93
    else {
94
        QWidget::changeEvent(e);
95
    }
96
}
97

98
void DlgOnlineHelpImp::onLineEditDownloadFileNameSelected( const QString& url )
99
{
100
    QDir dir(url);
101
    if (dir.exists() && dir.count() == 0) {
102
        QMessageBox::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

Использование cookies

Мы используем файлы cookie в соответствии с Политикой конфиденциальности и Политикой использования cookies.

Нажимая кнопку «Принимаю», Вы даете АО «СберТех» согласие на обработку Ваших персональных данных в целях совершенствования нашего веб-сайта и Сервиса GitVerse, а также повышения удобства их использования.

Запретить использование cookies Вы можете самостоятельно в настройках Вашего браузера.