File indexing completed on 2024-05-12 16:37:19

0001 /* This file is part of the KDE project
0002    Copyright (C) 2017 Dag Andersen <danders@get2net.dk>
0003 
0004    This library is free software; you can redistribute it and/or
0005    modify it under the terms of the GNU Library General Public
0006    License as published by the Free Software Foundation; either
0007    version 2 of the License, or (at your option) any later version.
0008 
0009    This library is distributed in the hope that it will be useful,
0010    but WITHOUT ANY WARRANTY; without even the implied warranty of
0011    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
0012    Library General Public License for more details.
0013 
0014    You should have received a copy of the GNU Library General Public License
0015    along with this library; see the file COPYING.LIB.  If not, write to
0016    the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
0017    Boston, MA 02110-1301, USA.
0018 */
0019 
0020 // clazy:excludeall=qstring-arg
0021 #include "ConfigProjectPanel.h"
0022 
0023 #include "calligraplansettings.h"
0024 
0025 
0026 #include <kactioncollection.h>
0027 
0028 #include <QFileDialog>
0029 
0030 namespace KPlato
0031 {
0032 
0033 ConfigProjectPanel::ConfigProjectPanel(QWidget *parent)
0034     : ConfigProjectPanelImpl(parent)
0035 {
0036 }
0037 
0038 //-----------------------------
0039 ConfigProjectPanelImpl::ConfigProjectPanelImpl(QWidget *p)
0040     : QWidget(p)
0041 {
0042 
0043     setupUi(this);
0044 
0045     initDescription();
0046 
0047     connect(resourceFileBrowseBtn, &QAbstractButton::clicked, this, &ConfigProjectPanelImpl::resourceFileBrowseBtnClicked);
0048     connect(projectsPlaceBrowseBtn, &QAbstractButton::clicked, this, &ConfigProjectPanelImpl::projectsPlaceBrowseBtnClicked);
0049 
0050     QString tooltip = xi18nc("@info:tooltip", "The project manager of this project.");
0051     kcfg_Manager->setToolTip(tooltip);
0052     leaderlabel->setToolTip(tooltip);
0053     tooltip = xi18nc("@info:tooltip", "Check to enable shared resources");
0054     kcfg_UseSharedResources->setToolTip(tooltip);
0055     usrlabel->setToolTip(tooltip);
0056     tooltip = xi18nc("@info:tooltip", "The file where shared resources are defined");
0057     kcfg_SharedResourcesFile->setToolTip(tooltip);
0058     srflabel->setToolTip(tooltip);
0059     tooltip = xi18nc("@info:tooltip", "The directory where projects sharing the resources are placed");
0060     kcfg_SharedProjectsPlace->setToolTip(tooltip);
0061     spplabel->setToolTip(tooltip);
0062 }
0063 
0064 void ConfigProjectPanelImpl::resourceFileBrowseBtnClicked()
0065 {
0066     QFileDialog dialog(this, tr("Shared resources file"));
0067     dialog.setFileMode(QFileDialog::AnyFile);
0068     dialog.setNameFilters(QStringList()<<tr("Plan file (*.plan)"));
0069     if (dialog.exec()) {
0070         kcfg_SharedResourcesFile->setText(dialog.selectedFiles().value(0));
0071     }
0072 }
0073 
0074 void ConfigProjectPanelImpl::projectsPlaceBrowseBtnClicked()
0075 {
0076     QFileDialog dialog(this, tr("Shared projects place"));
0077     dialog.setFileMode(QFileDialog::Directory);
0078     if (dialog.exec()) {
0079         kcfg_SharedProjectsPlace->setText(dialog.directory().absolutePath());
0080     }
0081 }
0082 
0083 void ConfigProjectPanelImpl::initDescription()
0084 {
0085     toolbar->setToolButtonStyle(Qt::ToolButtonIconOnly);
0086 
0087     KActionCollection *collection = new KActionCollection(this); //krazy:exclude=tipsandthis
0088     kcfg_ProjectDescription->setRichTextSupport(KRichTextWidget::SupportBold |
0089                                             KRichTextWidget::SupportItalic |
0090                                             KRichTextWidget::SupportUnderline |
0091                                             KRichTextWidget::SupportStrikeOut |
0092                                             KRichTextWidget::SupportChangeListStyle |
0093                                             KRichTextWidget::SupportAlignment |
0094                                             KRichTextWidget::SupportFormatPainting);
0095 
0096     collection->addActions(kcfg_ProjectDescription->createActions());
0097 
0098     toolbar->addAction(collection->action("format_text_bold"));
0099     toolbar->addAction(collection->action("format_text_italic"));
0100     toolbar->addAction(collection->action("format_text_underline"));
0101     toolbar->addAction(collection->action("format_text_strikeout"));
0102     toolbar->addSeparator();
0103 
0104     toolbar->addAction(collection->action("format_list_style"));
0105     toolbar->addSeparator();
0106 
0107     toolbar->addAction(collection->action("format_align_left"));
0108     toolbar->addAction(collection->action("format_align_center"));
0109     toolbar->addAction(collection->action("format_align_right"));
0110     toolbar->addAction(collection->action("format_align_justify"));
0111     toolbar->addSeparator();
0112 
0113 //    toolbar->addAction(collection->action("format_painter"));
0114 
0115     kcfg_ProjectDescription->append("");
0116     kcfg_ProjectDescription->setReadOnly(false);
0117     kcfg_ProjectDescription->setOverwriteMode(false);
0118     kcfg_ProjectDescription->setLineWrapMode(KTextEdit::WidgetWidth);
0119     kcfg_ProjectDescription->setTabChangesFocus(true);
0120 
0121 }
0122 
0123 
0124 }  //KPlato namespace