Commit 52a9df26 authored by Ralf Habacker's avatar Ralf Habacker
Browse files

Add welcome page as dock widget.

The welcome page is based on the file welcome.docbook
which is converted into a html file on building.

The implementation has support for loading a translated
welcome file installed in the directory where other umbrello
related docbook files lives.

BUG:372252


FIXED-IN:2.20.80 (KDE Applications 16.11.80)

Signed-off-by: Ralf Habacker's avatarRalf Habacker <ralf.habacker@freenet.de>
parent dc6ff10c
......@@ -28,7 +28,7 @@ if(NOT BUILD_KF5)
set(CMAKE_AUTOMOC ON)
set(CMAKE_INCLUDE_CURRENT_DIR ON)
find_package(Qt4 4.4.3 REQUIRED QtCore QtGui QtXml QtTest)
find_package(Qt4 4.4.3 REQUIRED QtCore QtGui QtXml QtTest QtWebKit)
set(KDE4_BUILD_TESTS ON) # for unit tests
......@@ -148,6 +148,7 @@ else()
Test
Widgets
Xml
WebKitWidgets
)
# search packages used by KDE
......
if (NOT BUILD_KF5)
set(KDOCTOOLS_CUSTOMIZATION_DIR "${KDE4_DATA_INSTALL_DIR}/ksgmltools2/customization")
set(KDOCTOOLS_MEINPROC_EXECUTABLE meinproc4)
else()
set(KDOCTOOLS_CUSTOMIZATION_DIR "${KDOCTOOLS_DATA_INSTALL_DIR}/kdoctools/customization")
endif()
function(_kdoctools_create_target_name out in)
string(REGEX REPLACE "^${CMAKE_BINARY_DIR}/?" "" in "${in}")
string(REGEX REPLACE "[^0-9a-zA-Z]+" "-" tmp "${in}")
set(${out} ${tmp} PARENT_SCOPE)
endfunction()
function (kdoctools_create_article docbook)
# Parse arguments
set(options)
set(oneValueArgs INSTALL_DESTINATION SUBDIR)
set(multiValueArgs)
cmake_parse_arguments(ARGS "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN})
if(NOT DEFINED ARGS_SUBDIR)
message(FATAL_ERROR "SUBDIR needs to be defined when calling kdoctools_create_article")
endif()
# Init vars
get_filename_component(docbook ${docbook} ABSOLUTE)
file(RELATIVE_PATH src_doc ${CMAKE_CURRENT_SOURCE_DIR} ${docbook})
get_filename_component(src_dir ${src_doc} DIRECTORY)
get_filename_component(_name ${docbook} NAME_WE)
set(build_dir ${CMAKE_CURRENT_BINARY_DIR}/${src_dir})
set(build_html ${build_dir}/${_name}.html)
# current directory is the docbook directory, but if this is empty, the
# globs which finds the docbooks and the images will be empty too as
# they will expand into "/*.docbook" and "/*.png"
if (src_dir STREQUAL "")
set(src_dir ".")
endif ()
# Create some place to store our files
file(MAKE_DIRECTORY ${build_dir})
#Bootstrap
if (_kdoctoolsBootStrapping)
set(_bootstrapOption "--srcdir=${KDocTools_BINARY_DIR}/src")
elseif (CMAKE_CROSSCOMPILING AND CMAKE_SYSTEM_NAME STREQUAL "Windows")
set(_bootstrapOption "--srcdir=${KDOCTOOLS_DATA_INSTALL_DIR}/kdoctools")
else ()
set(_bootstrapOption)
endif ()
set(_ssheet "${KDOCTOOLS_CUSTOMIZATION_DIR}/kde-chunk.xsl")
add_custom_command(OUTPUT ${build_html}
COMMAND ${KDOCTOOLS_MEINPROC_EXECUTABLE} --check ${_bootstrapOption} -o ${build_html} ${src_doc}
DEPENDS ${src_doc} ${_ssheet}
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
)
_kdoctools_create_target_name(_targ_html ${build_html})
add_custom_target(${_targ_html} ALL DEPENDS ${build_html})
set(installDest "${ARGS_INSTALL_DESTINATION}")
if(installDest)
set(subdir "${ARGS_SUBDIR}")
# file(GLOB images ${src_dir}/*.png)
# install(FILES ${build_doc} ${src_docs} ${images} DESTINATION ${installDest}/${subdir})
install(FILES ${build_html} DESTINATION ${installDest}/${subdir})
endif()
endfunction()
########### install files ###############
if(BUILD_KF5)
file(READ "index.docbook" index_file)
......@@ -5,6 +75,15 @@ if(BUILD_KF5)
string(REPLACE "kdex.dtd" "kdedbx45.dtd" index_file "${index_file}")
file(WRITE "index-kf5.docbook" "${index_file}")
kdoctools_create_handbook(index-kf5.docbook INSTALL_DESTINATION ${HTML_INSTALL_DIR}/en SUBDIR umbrello)
file(READ "welcome.docbook" index_file)
string(REPLACE "4.2" "4.5" index_file "${index_file}")
string(REPLACE "kdex.dtd" "kdedbx45.dtd" index_file "${index_file}")
file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/welcome.docbook "${index_file}")
kdoctools_create_article(${CMAKE_CURRENT_BINARY_DIR}/welcome.docbook INSTALL_DESTINATION ${HTML_INSTALL_DIR}/en SUBDIR umbrello)
else()
kde4_create_handbook(index.docbook INSTALL_DESTINATION ${HTML_INSTALL_DIR}/en SUBDIR umbrello)
kdoctools_create_article(welcome.docbook INSTALL_DESTINATION ${HTML_INSTALL_DIR}/en SUBDIR umbrello)
endif()
<?xml version="1.0" ?>
<!DOCTYPE article PUBLIC "-//KDE//DTD DocBook XML V4.2-Based Variant V1.1//EN"
"dtd/kdex.dtd" [
<!ENTITY umbrello "<application>Umbrello &UML; Modeller</application>">
<!ENTITY kappname "&umbrello;">
<!ENTITY UML "<acronym>UML</acronym>">
<!ENTITY % addindex "IGNORE">
<!ENTITY % English "INCLUDE"><!-- change language only here -->
<!-- Do not define any other entities; instead, use the entities
from kde-genent.entities and $LANG/user.entities. -->
]>
<article id="Welcome" lang="&language;">
<articleinfo>
<title>Welcome</title>
</articleinfo>
<para>
Welcome to &umbrello; an &UML; diagram tool that can support you
in the software development process.
Especially during the analysis and design phases of this process, &umbrello; will help you to
get a high quality product. &UML; can also be used to document your software designs to help you and your
fellow developers.
</para>
<para>
To start working with UML you may create a new diagram from one of the following diagram types:
</para>
<itemizedlist>
<listitem><para><emphasis><ulink url="use-case-diagram">Use Case
Diagram</ulink></emphasis> - show actors (people or other users of the
system), use cases (the scenarios when they use the system), and their
relationships</para> </listitem>
<listitem><para><emphasis><ulink url="class-diagram">Class
Diagram</ulink></emphasis> - show classes and the relationships between
them</para> </listitem>
<listitem><para><emphasis><ulink url="sequence-diagram">Sequence
Diagram</ulink></emphasis> - show objects and a sequence of method calls
they make to other objects.</para> </listitem>
<listitem><para><emphasis><ulink
url="collaboration-diagram">Collaboration
Diagram</ulink></emphasis> - show objects and their relationship,
putting emphasis on the objects that participate in the message exchange</para>
</listitem>
<listitem><para><emphasis><ulink url="state-diagram">State
Diagram</ulink></emphasis> - show states, state changes and events in an
object or a part of the system</para> </listitem>
<listitem><para><emphasis><ulink url="activity-diagram">Activity
Diagram</ulink></emphasis> - show activities and the changes from one
activity to another with the events occurring in some part of the
system</para></listitem>
<listitem><para><emphasis><ulink url="component-diagram">Component
Diagram</ulink></emphasis> - show the high level programming components
(such as KParts or Java Beans).</para></listitem>
<listitem><para><emphasis><ulink
url="deployment-diagram">Deployment Diagram</ulink></emphasis> - show
the instances of the components and their
relationships.</para></listitem>
<listitem><para><emphasis><ulink
url="entity-relationship-diagram">Entity Relationship Diagram</ulink></emphasis> - show
data and the relationships and constraints between the data.</para></listitem>
</itemizedlist>
</article>
......@@ -15,6 +15,8 @@ if(UNIX)
add_definitions(-D_GLIBCXX_PERMIT_BACKWARD_HASH)
endif()
add_definitions(-DCMAKE_BINARY_DIR="${CMAKE_BINARY_DIR}")
include_directories(
${LIBXML2_INCLUDE_DIR}
${LIBXSLT_INCLUDE_DIR}
......@@ -516,6 +518,7 @@ if(NOT BUILD_KF5)
Qt4::QtCore
Qt4::QtGui
Qt4::QtXml
Qt4::QtWebKit
${LIBXML2_LIBRARIES}
${LIBXSLT_LIBRARIES}
${KDE4_KTEXTEDITOR_LIBS}
......@@ -537,6 +540,7 @@ else()
Qt5::Xml
Qt5::PrintSupport
Qt5::Svg
Qt5::WebKitWidgets
KF5::Archive
KF5::Completion
KF5::CoreAddons
......
......@@ -11,9 +11,6 @@
#ifndef CMDS_H
#define CMDS_H
#if QT_VERSION < 0x050000
#include <kundostack.h>
#endif
#include <QUndoCommand>
#include <QUndoStack>
......@@ -49,4 +46,8 @@
#include "cmds/widget/cmdsetname.h"
#include "cmds/widget/cmdsettxt.h"
#if QT_VERSION < 0x050000
#include <kundostack.h>
#endif
#endif
......@@ -936,6 +936,7 @@ void UMLApp::initView()
m_d->createObjectsWindow();
#endif
m_d->createStereotypesWindow();
m_d->createWelcomeWindow();
// create the tree viewer
m_listDock = new QDockWidget(i18n("&Tree View"), this);
......
......@@ -10,4 +10,105 @@
#include "umlappprivate.h"
// Empty file is required for signal/slot support provided by automoc4.
#include "debug_utils.h"
/**
* Find welcome.html file for displaying in the welcome window.
*
* @return path to welcome file or empty if not found
*/
QString UMLAppPrivate::findWelcomeFile()
{
QStringList dirList;
// from build dir
dirList.append(QCoreApplication::applicationDirPath() + QLatin1String("/../doc"));
// determine path from installation
#if QT_VERSION > 0x050000
QString name = QLocale().name();
QStringList lang = name.split(QLatin1Char('_'));
QStringList langList;
langList.append(lang[0]);
if (lang.size() > 1)
langList.append(name);
// from custom install
foreach(const QString &lang, langList) {
dirList.append(QCoreApplication::applicationDirPath() + QString(QLatin1String("/../share/doc/HTML/%1/umbrello")).arg(lang));
}
dirList.append(QCoreApplication::applicationDirPath() + QLatin1String("/../share/doc/HTML/en/umbrello"));
QStringList locations = QStandardPaths::standardLocations(QStandardPaths::GenericDataLocation);
// from real installation
foreach(const QString &location, locations) {
foreach(const QString &lang, langList) {
dirList.append(QString(QLatin1String("%1/doc/HTML/%2/umbrello")).arg(location).arg(lang));
}
dirList.append(QString(QLatin1String("%1/doc/HTML/en/umbrello")).arg(location));
}
#else
KLocale *local = KGlobal::locale();
QString lang = local->language();
// from custom install
dirList.append(QCoreApplication::applicationDirPath() + QString(QLatin1String("/../share/doc/HTML/%1/umbrello")).arg(lang));
dirList.append(QCoreApplication::applicationDirPath() + QLatin1String("/../share/doc/HTML/en/umbrello"));
// /usr/share/doc/kde
dirList.append(KStandardDirs::installPath("html") + lang + QLatin1String("/umbrello"));
#endif
foreach(const QString &dir, dirList) {
QString filePath = dir + QLatin1String("/welcome.html");
QFileInfo fi(filePath);
if (fi.exists()) {
uDebug() << "searching for" << filePath << "found";
return filePath;
} else
uDebug() << "searching for" << filePath;
}
return QString();
}
/**
* Read welcome file for displaying in the welcome window.
*
* This method also patches out some unrelated stuff from
* the html file intended or being displayed with khelpcenter.
*
* @return html content of welcome file
*/
QString UMLAppPrivate::readWelcomeFile(const QString &file)
{
QFile f(file);
if (!f.open(QIODevice::ReadOnly))
return QString();
QTextStream in(&f);
QString html = in.readAll();
html.replace(QLatin1String("<FILENAME filename=\"index.html\">"),QLatin1String(""));
html.replace(QLatin1String("</FILENAME>"),QLatin1String(""));
//#define WITH_HEADER
#ifndef WITH_HEADER
html.replace(QLatin1String("<div id=\"header\""),QLatin1String("<div id=\"header\" hidden"));
html.replace(QLatin1String("<div class=\"navCenter\""),QLatin1String("<div id=\"navCenter\" hidden"));
#else
// replace help:/ urls in html file to be able to find css files and images from kde help system
#if QT_VERSION >= 0x050000
QString path;
QStringList locations = QStandardPaths::standardLocations(QStandardPaths::GenericDataLocation);
foreach(const QString &l, locations) {
QString a = QString(QLatin1String("%1/doc/HTML/en/")).arg(l);
QFileInfo fi(a);
if (fi.exists()) {
path = a;
break;
}
}
#else
QString path = KStandardDirs::installPath("html") + QLatin1String("en/");
#endif
QUrl url(QUrl::fromLocalFile(path));
QByteArray a = url.toEncoded();
html.replace(QLatin1String("help:/"), QString::fromLocal8Bit(a));
#endif
return html;
}
......@@ -12,15 +12,20 @@
#define UMLAPPPRIVATE_H
// app includes
#include "cmds.h"
#include "finddialog.h"
#include "findresults.h"
#include "uml.h"
#include "umldoc.h"
#include "diagramswindow.h"
#include "objectswindow.h"
#include "stereotypeswindow.h"
// kde includes
#include <KActionCollection>
#if QT_VERSION < 0x050000
#include <KStandardDirs>
#endif
#include <KToggleAction>
#include <ktexteditor/configinterface.h>
#include <ktexteditor/document.h>
......@@ -31,13 +36,16 @@
#include <ktexteditor/view.h>
// qt includes
#include <QDesktopServices>
#include <QFile>
#include <QFileInfo>
#include <QListWidget>
#include <QObject>
#include <QWebView>
class QWidget;
/**
* Class UMLAppPrivate holds private class members/methods
* to reduce the size of the public class and to speed up
......@@ -55,9 +63,11 @@ public:
KToggleAction *viewDiagramsWindow;
KToggleAction *viewObjectsWindow;
KToggleAction *viewStereotypesWindow;
KToggleAction *viewWelcomeWindow;
DiagramsWindow *diagramsWindow;
ObjectsWindow *objectsWindow;
StereotypesWindow *stereotypesWindow;
QDockWidget *welcomeWindow;
KTextEditor::Editor *editor;
KTextEditor::View *view;
......@@ -69,9 +79,11 @@ public:
viewDiagramsWindow(0),
viewObjectsWindow(0),
viewStereotypesWindow(0),
viewWelcomeWindow(0),
diagramsWindow(0),
objectsWindow(0),
stereotypesWindow(0),
welcomeWindow(0),
view(0),
document(0)
{
......@@ -149,6 +161,54 @@ public slots:
connect(viewStereotypesWindow, SIGNAL(triggered(bool)), stereotypesWindow, SLOT(setVisible(bool)));
}
void createWelcomeWindow()
{
QString file = findWelcomeFile();
if (file.isEmpty())
return;
QString html = readWelcomeFile(file);
// qDebug() << html;
welcomeWindow = new QDockWidget(i18n("Welcome"), parent);
welcomeWindow->setObjectName(QLatin1String("WelcomeDock"));
QWebView *view = new QWebView;
view->page()->setLinkDelegationPolicy(QWebPage::DelegateAllLinks);
view->setContextMenuPolicy(Qt::NoContextMenu);
connect(view, SIGNAL(linkClicked(const QUrl)), this, SLOT(slotWelcomeWindowLinkClicked(const QUrl)));
view->setHtml(html);
view->show();
welcomeWindow->setWidget(view);
parent->addDockWidget(Qt::LeftDockWidgetArea, welcomeWindow);
viewWelcomeWindow = parent->actionCollection()->add<KToggleAction>(QLatin1String("view_welcome_window"));
connect(viewWelcomeWindow, SIGNAL(triggered(bool)), welcomeWindow, SLOT(setVisible(bool)));
}
void slotWelcomeWindowLinkClicked(const QUrl &url)
{
//qDebug() << url;
if (url.scheme() == QLatin1String("mailto") || url.scheme().startsWith(QLatin1String("http"))) {
QDesktopServices::openUrl(url);
return;
}
QStringList list = url.toString().split(QLatin1Char('-'));
list.removeLast();
QString key;
foreach(const QString s, list) {
QString a = s;
a[0] = a[0].toUpper();
key.append(a);
}
Uml::DiagramType::Enum type = Uml::DiagramType::fromString(key);
if (type == Uml::DiagramType::Undefined)
return;
QString diagramName = UMLApp::app()->document()->createDiagramName(type);
if (!diagramName.isEmpty())
UMLApp::app()->executeCommand(new Uml::CmdCreateDiagram(UMLApp::app()->document(), type, diagramName));
}
private:
QString findWelcomeFile();
QString readWelcomeFile(const QString &file);
};
#endif
......@@ -48,6 +48,7 @@ if(NOT BUILD_KF5)
Qt4::QtGui
Qt4::QtXml
Qt4::QtTest
Qt4::QtWebKit
${KDE4_KFILE_LIBS}
${LIBXML2_LIBRARIES}
${LIBXSLT_LIBRARIES}
......@@ -58,6 +59,7 @@ else()
Qt5::Xml
Qt5::Test
Qt5::Widgets
Qt5::WebKitWidgets
KF5::I18n
${LIBXML2_LIBRARIES}
${LIBXSLT_LIBRARIES}
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment