diff --git a/src/libs/ui/CMakeLists.txt b/src/libs/ui/CMakeLists.txt index 3eb018b0..3ff830e0 100644 --- a/src/libs/ui/CMakeLists.txt +++ b/src/libs/ui/CMakeLists.txt @@ -1,213 +1,214 @@ include_directories( ${PLANKERNEL_INCLUDES} ${PLANMODELS_INCLUDES} ${PLANMAIN_INCLUDES} ${PLANWIDGETS_INCLUDES} ${KDEPIMLIBS_INCLUDE_DIR} ) #add_subdirectory( tests ) ########### KPlato private library ############### if (PLAN_USE_KREPORT) message(STATUS "-- Building plan with reports capability") add_subdirectory(reports/items) set(planreports_LIB_SRC reports/reportview.cpp reports/reportdata.cpp reports/reportsourceeditor.cpp reports/reportscripts.cpp ) set(planreports_ui_LIB_SRCS reports/reportsourceeditor.ui reports/reportnavigator.ui reports/reportsectionswidget.ui reports/reportgroupsectionswidget.ui reports/reporttoolswidget.ui ) endif() set(planui_LIB_SRCS ${planreports_LIB_SRC} TasksEditController.cpp TasksEditDialog.cpp + RichTextWidget.cpp welcome/WelcomeView.cpp reportsgenerator/ReportsGeneratorView.cpp kptganttitemdelegate.cpp kptworkpackagesendpanel.cpp kptworkpackagesenddialog.cpp kptdocumentseditor.cpp kptdocumentspanel.cpp kptdocumentsdialog.cpp kptitemviewsettup.cpp kptsplitterview.cpp kptrelationeditor.cpp kptdependencyeditor.cpp kptusedefforteditor.cpp kpttaskstatusview.cpp kptcalendareditor.cpp kptviewbase.cpp kptaccountseditor.cpp kptperteditor.cpp kptpertresult.cpp kpttaskeditor.cpp kptresourceeditor.cpp kptscheduleeditor.cpp kptsummarytaskdialog.cpp kptsummarytaskgeneralpanel.cpp kptresourceappointmentsview.cpp kptaccountsviewconfigdialog.cpp kptaccountsview.cpp kpttaskcostpanel.cpp kptmilestoneprogresspanel.cpp kptmilestoneprogressdialog.cpp kpttaskdialog.cpp kptmainprojectdialog.cpp kptmainprojectpanel.cpp kptganttview.cpp gantt/DateTimeTimeLine.cpp gantt/DateTimeGrid.cpp kptrelationdialog.cpp kptrequestresourcespanel.cpp kptresourcedialog.cpp kptstandardworktimedialog.cpp kptintervaledit.cpp kpttaskgeneralpanel.cpp kpttaskprogresspanel.cpp kpttaskprogressdialog.cpp kpttaskdescriptiondialog.cpp kptwbsdefinitiondialog.cpp kptwbsdefinitionpanel.cpp kptresourceassignmentview.cpp kptresourceallocationeditor.cpp kptworkpackagemergedialog.cpp kptrecalculatedialog.cpp kpthtmlview.cpp locale/localemon.cpp kptlocaleconfigmoneydialog.cpp ResourceAllocationView.cpp performance/KPlatoChart.cpp performance/PerformanceStatusBase.cpp performance/ProjectStatusView.cpp performance/PerformanceStatusView.cpp performance/PerformanceTableView.cpp ) ki18n_wrap_ui(planui_LIB_SRCS ${planreports_ui_LIB_SRCS} welcome/WelcomeView.ui kptresourceappointmentsdisplayoptions.ui kptganttchartdisplayoptions.ui kptprintingheaderfooter.ui kptganttprintingoptions.ui kptworkpackagesendpanel.ui kptdocumentspanel.ui performance/PerformanceStatus.ui performance/PerformanceStatusViewSettingsPanel.ui kptcpmwidget.ui kptitemviewsettings.ui kptpertresult.ui standardworktimedialogbase.ui kptwbsdefinitionpanelbase.ui kptaccountsviewconfigurepanelbase.ui kptintervaleditbase.ui kpttaskcostpanelbase.ui kpttaskdescriptionpanelbase.ui kptsummarytaskgeneralpanelbase.ui kptmilestoneprogresspanelbase.ui resourcedialogbase.ui kptmainprojectpanelbase.ui relationpanel.ui kpttaskgeneralpanelbase.ui kpttaskprogresspanelbase.ui kptperteditor.ui kptresourceassignmentview.ui kpttaskstatusviewsettingspanel.ui kptworkpackagemergepanel.ui kptrecalculatedialog.ui kptscheduleeditor.ui locale/localemon.ui ) add_library(planui SHARED ${planui_LIB_SRCS}) generate_export_header(planui) target_link_libraries(planui PUBLIC planmain planmodels KF5::KHtml PRIVATE KChart KF5::ItemViews KF5::IconThemes KF5::Archive KF5::TextWidgets KF5::KIOCore KF5::KIOFileWidgets KF5::KIOWidgets KF5::KIONTLM ) if (PLAN_USE_KREPORT) target_link_libraries(planui PUBLIC KReport PRIVATE KPropertyWidgets) endif() if(KF5AkonadiContact_FOUND) target_link_libraries(planui PRIVATE KF5::AkonadiContact) endif() set_target_properties(planui PROPERTIES VERSION ${GENERIC_PLAN_LIB_VERSION} SOVERSION ${GENERIC_PLAN_LIB_SOVERSION} ) install(TARGETS planui ${INSTALL_TARGETS_DEFAULT_ARGS}) install( FILES AccountsEditorUi.rc AccountsViewUi.rc CalendarEditorUi.rc TaskEditorUi.rc DependencyEditorUi.rc ResourceEditorUi.rc ResourceAppointmentsViewUi.rc ScheduleEditorUi.rc GanttViewUi.rc WorkPackageViewUi.rc reportsgenerator/ReportsGeneratorViewUi.rc performance/PerformanceStatusViewUi.rc performance/ProjectStatusViewUi.rc PertResultUi.rc TaskViewUi.rc TaskStatusViewUi.rc DESTINATION ${KXMLGUI_INSTALL_DIR}/calligraplan ) # reports files install(FILES reportsgenerator/templates/EmptyTemplate.odt reportsgenerator/templates/ProjectPerformanceCost.odt reportsgenerator/templates/ProjectPerformanceEffort.odt reportsgenerator/templates/TaskStatus.odt DESTINATION ${DATA_INSTALL_DIR}/calligraplan/reports ) diff --git a/src/libs/ui/RichTextWidget.cpp b/src/libs/ui/RichTextWidget.cpp new file mode 100644 index 00000000..21114914 --- /dev/null +++ b/src/libs/ui/RichTextWidget.cpp @@ -0,0 +1,68 @@ +/*This file is part of the KDE project + * Copyright (C) 2019 Dag Andersen + +#include + +#include +#include + +using namespace KPlato; + +RichTextWidget::RichTextWidget(QWidget *parent) + : KRichTextWidget(parent) +{ +} + +QList RichTextWidget::createActions() +{ + QList lst = KRichTextWidget::createActions(); + if (richTextSupport() & RichTextWidget::SupportHyperlinks) { + openLink = new QAction(QIcon::fromTheme("link"), xi18nc("@action:intoolbar", "Open Link")); + openLink->setShortcut(Qt::CTRL + Qt::Key_O); + openLink->setObjectName("open_link"); + connect(openLink, &QAction::triggered, this, &RichTextWidget::slotOpenLink); + lst.append(openLink); + } + return lst; +} + +QMenu *RichTextWidget::mousePopupMenu() { + QMenu *menu = KRichTextWidget::mousePopupMenu(); + if (!currentLinkUrl().isEmpty()) { + menu->insertSeparator(menu->actions().first()); + QAction *a = new QAction(QIcon::fromTheme("link"), xi18nc("@action:intoolbar", "Open Link")); + if (openLink) { + a->setShortcut(openLink->shortcut()); + } + menu->insertAction(menu->actions().first(), a); + connect(a, &QAction::triggered, this, &RichTextWidget::slotOpenLink); + } + return menu; +} + +void RichTextWidget::slotOpenLink() +{ + QUrl url = QUrl::fromUserInput(currentLinkUrl()); + if (url.isValid()) { + QDesktopServices::openUrl(url); + } +} diff --git a/src/libs/ui/RichTextWidget.h b/src/libs/ui/RichTextWidget.h new file mode 100644 index 00000000..1475d28c --- /dev/null +++ b/src/libs/ui/RichTextWidget.h @@ -0,0 +1,56 @@ +/*This file is part of the KDE project + * Copyright (C) 2019 Dag Andersen + +class QMenu; + +namespace KPlato +{ + +/** + * Extends KRichTextWidget with capability to open links. + * + * If SupportHyperlinks is enabled, an action with object name 'open_link' + * is ceated that can be used in a tool bar, and an action is also + * added to the context menu when the caret is on a link. + */ +class RichTextWidget : public KRichTextWidget +{ + Q_OBJECT +public: + RichTextWidget(QWidget *parent); + + QList createActions() override; + QMenu *mousePopupMenu() override; + +private Q_SLOTS: + void slotOpenLink(); + +private: + QAction *openLink; +}; + +} //KPlato namespace + +#endif diff --git a/src/libs/ui/kpttaskdescriptiondialog.cpp b/src/libs/ui/kpttaskdescriptiondialog.cpp index 2ba05b06..6163a349 100644 --- a/src/libs/ui/kpttaskdescriptiondialog.cpp +++ b/src/libs/ui/kpttaskdescriptiondialog.cpp @@ -1,186 +1,170 @@ /* This file is part of the KDE project Copyright (C) 2009 Dag Andersen #include #include -#include - namespace KPlato { TaskDescriptionPanel::TaskDescriptionPanel(Node &node, QWidget *p, bool readOnly ) : TaskDescriptionPanelImpl( node, p ) { initDescription( readOnly ); setStartValues( node ); descriptionfield->setFocus(); } void TaskDescriptionPanel::setStartValues( Node &node ) { namefield->setText(node.name()); descriptionfield->setTextOrHtml( node.description() ); } MacroCommand *TaskDescriptionPanel::buildCommand() { KUndo2MagicString s = kundo2_i18n("Modify task description"); if ( m_node.type() == Node::Type_Milestone ) { s = kundo2_i18n("Modify milestone description"); } else if ( m_node.type() == Node::Type_Summarytask ) { s = kundo2_i18n("Modify summary task description"); } else if ( m_node.type() == Node::Type_Project ) { s = kundo2_i18n("Modify project description"); } MacroCommand *cmd = new MacroCommand(s); bool modified = false; if ( m_node.description() != descriptionfield->textOrHtml() ) { cmd->addCommand(new NodeModifyDescriptionCmd(m_node, descriptionfield->textOrHtml())); modified = true; } if (!modified) { delete cmd; return 0; } return cmd; } bool TaskDescriptionPanel::ok() { return true; } void TaskDescriptionPanel::initDescription( bool readOnly ) { toolbar->setVisible( ! readOnly ); toolbar->setToolButtonStyle( Qt::ToolButtonIconOnly ); KActionCollection *collection = new KActionCollection( this ); //krazy:exclude=tipsandthis collection->addActions(descriptionfield->createActions()); toolbar->addAction( collection->action( "format_text_bold" ) ); toolbar->addAction( collection->action( "format_text_italic" ) ); toolbar->addAction( collection->action( "format_text_underline" ) ); toolbar->addAction( collection->action( "format_text_strikeout" ) ); toolbar->addSeparator(); toolbar->addAction( collection->action( "format_list_style" ) ); toolbar->addSeparator(); toolbar->addAction( collection->action( "format_align_left" ) ); toolbar->addAction( collection->action( "format_align_center" ) ); toolbar->addAction( collection->action( "format_align_right" ) ); toolbar->addAction( collection->action( "format_align_justify" ) ); toolbar->addSeparator(); toolbar->addAction( collection->action( "manage_link" ) ); - - if (descriptionfield->richTextSupport() & KRichTextWidget::SupportHyperlinks) { - QAction *openLink = new QAction(QIcon::fromTheme("link"), i18nc("@action:intoolbar", "Open Link"), toolbar); - openLink->setObjectName("open_link"); - toolbar->addAction(openLink); - connect(openLink, &QAction::triggered, this, &TaskDescriptionPanel::slotOpenLink); - } + toolbar->addAction(collection->action("open_link")); descriptionfield->append( "" ); descriptionfield->setReadOnly( readOnly ); descriptionfield->setOverwriteMode( false ); descriptionfield->setLineWrapMode( KTextEdit::WidgetWidth ); descriptionfield->setTabChangesFocus( true ); - -} - -void TaskDescriptionPanel::slotOpenLink() -{ - QUrl url = QUrl::fromUserInput(descriptionfield->currentLinkUrl()); - if (url.isValid()) { - QDesktopServices::openUrl(url); - } } //----------------------------- TaskDescriptionPanelImpl::TaskDescriptionPanelImpl( Node &node, QWidget *p ) : QWidget(p), m_node(node) { setupUi(this); CONNECT(descriptionfield, &QTextEdit::textChanged, this, &TaskDescriptionPanelImpl::slotChanged); } TaskDescriptionPanelImpl::~TaskDescriptionPanelImpl() { DISCONNECT; } void TaskDescriptionPanelImpl::slotChanged() { emit textChanged( descriptionfield->textOrHtml() != m_node.description() ); } //----------------------------- TaskDescriptionDialog::TaskDescriptionDialog( Node &node, QWidget *p, bool readOnly ) : KoDialog(p) { setCaption(node.type() == Node::Type_Project ? i18n( "Project Description" ) : i18n( "Task Description" ) ); if ( readOnly ) { setButtons( Close ); } else { setButtons( Ok|Cancel ); setDefaultButton( Ok ); } showButtonSeparator( true ); m_descriptionTab = new TaskDescriptionPanel( node, this, readOnly ); setMainWidget(m_descriptionTab); enableButtonOk(false); connect( m_descriptionTab, &TaskDescriptionPanelImpl::textChanged, this, &KoDialog::enableButtonOk ); } MacroCommand *TaskDescriptionDialog::buildCommand() { return m_descriptionTab->buildCommand(); } void TaskDescriptionDialog::slotButtonClicked( int button ) { if (button == KoDialog::Ok) { if ( ! m_descriptionTab->ok() ) { return; } accept(); } else { KoDialog::slotButtonClicked( button ); } } } //KPlato namespace diff --git a/src/libs/ui/kpttaskdescriptiondialog.h b/src/libs/ui/kpttaskdescriptiondialog.h index 9b548475..b0835302 100644 --- a/src/libs/ui/kpttaskdescriptiondialog.h +++ b/src/libs/ui/kpttaskdescriptiondialog.h @@ -1,100 +1,97 @@ /* This file is part of the KDE project Copyright (C) 2009 Dag Andersen This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public License for more details. You should have received a copy of the GNU Library General Public License along with this library; see the file COPYING.LIB. If not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #ifndef KPTTASKDESCRIPTIONDIALOG_H #define KPTTASKDESCRIPTIONDIALOG_H #include "planui_export.h" #include "PlanMacros.h" #include "ui_kpttaskdescriptionpanelbase.h" #include namespace KPlato { class TaskDescriptionPanel; class Task; class Node; class MacroCommand; class TaskDescriptionPanelImpl : public QWidget, public Ui_TaskDescriptionPanelBase { Q_OBJECT public: TaskDescriptionPanelImpl( Node &node, QWidget *parent ); ~TaskDescriptionPanelImpl(); public Q_SLOTS: virtual void slotChanged(); Q_SIGNALS: void textChanged( bool ); protected: Node &m_node; private: OBJECTCONNECTIONS; }; class TaskDescriptionPanel : public TaskDescriptionPanelImpl { Q_OBJECT public: explicit TaskDescriptionPanel( Node &node, QWidget *parent = 0, bool readOnly = false ); MacroCommand *buildCommand(); bool ok(); void setStartValues( Node &node ); protected: void initDescription( bool readOnly ); - -protected Q_SLOTS: - void slotOpenLink(); }; class PLANUI_EXPORT TaskDescriptionDialog : public KoDialog { Q_OBJECT public: /** * The constructor for the task description dialog. * @param task the node to show * @param parent parent widget * @param readOnly determines whether the data are read-only */ explicit TaskDescriptionDialog( Node &node, QWidget *parent = 0, bool readOnly = false ); MacroCommand *buildCommand(); protected Q_SLOTS: void slotButtonClicked( int button ); protected: TaskDescriptionPanel *m_descriptionTab; }; } //KPlato namespace #endif // KPTTASKDESCRIPTIONDIALOG_H diff --git a/src/libs/ui/kpttaskdescriptionpanelbase.ui b/src/libs/ui/kpttaskdescriptionpanelbase.ui index ea5e3aa0..282a8fce 100644 --- a/src/libs/ui/kpttaskdescriptionpanelbase.ui +++ b/src/libs/ui/kpttaskdescriptionpanelbase.ui @@ -1,87 +1,96 @@ KPlato::TaskDescriptionPanelBase 0 0 - 450 - 300 + 600 + 400 - + + 0 + + + 0 + + + 0 + + 0 The name of the Task. Name: false namefield The name of the Task. true 0 11 - + KLineEdit QLineEdit
klineedit.h
1
KToolBar QWidget
KToolBar
1
- KRichTextWidget + KPlato::RichTextWidget QTextEdit -
KRichTextWidget
+
RichTextWidget.h