File indexing completed on 2024-05-12 16:39:24

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 #ifndef WELCOMEVIEW_H
0021 #define WELCOMEVIEW_H
0022 
0023 #include "plan_export.h"
0024 #include "kptviewbase.h"
0025 #include "ui_WelcomeView.h"
0026 #include "kptmainprojectdialog.h"
0027 
0028 #include <KoFileDialog.h>
0029 
0030 class KoDocument;
0031 
0032 class QUrl;
0033 class QItemSelecteion;
0034 
0035 
0036 namespace KPlato
0037 {
0038 
0039 class RecentFilesModel;
0040 
0041 class PLAN_EXPORT WelcomeView : public ViewBase
0042 {
0043     Q_OBJECT
0044 public:
0045     WelcomeView(KoPart *part, KoDocument *doc, QWidget *parent);
0046     ~WelcomeView() override;
0047 
0048     void setRecentFiles(const QList<QAction*> &actions);
0049 
0050     void setupGui();
0051 
0052     void updateReadWrite(bool readwrite) override;
0053 
0054     KoPrintJob *createPrintJob() override;
0055 
0056     Project *project() const override;
0057 
0058 public Q_SLOTS:
0059     /// Activate/deactivate the gui
0060     void setGuiActive(bool activate) override;
0061     void setProjectTemplatesModel();
0062 
0063 Q_SIGNALS:
0064     void newProject();
0065     void openProject();
0066     void recentProject(const QUrl &file, KoPart *part);
0067     void selectDefaultView();
0068     void loadSharedResources(const QUrl &url, const QUrl &projects);
0069     void openExistingFile(const QUrl &url);
0070 
0071     void projectCreated();
0072     void finished();
0073 
0074     void openTemplate(QUrl);
0075 
0076 protected:
0077     void updateActionsEnabled(bool on = true);
0078 
0079 private Q_SLOTS:
0080     void slotContextMenuRequested(const QModelIndex &index, const QPoint& pos);
0081     void slotRecentFileSelected(const QModelIndex &idx);
0082     
0083     void slotEnableActions(bool on);
0084 
0085     void slotNewProject();
0086     void slotOpenProject();
0087     void slotLoadSharedResources(const QString &file, const QUrl &projects, bool loadProjectsAtStartup);
0088 
0089     void slotOpenProjectTemplate(const QModelIndex &idx);
0090 
0091     void slotProjectEditFinished(int result);
0092     void slotOpenFileFinished(int result);
0093 
0094     void slotCreateResourceFile();
0095 
0096 private:
0097     Ui::WelcomeView ui;
0098     RecentFilesModel *m_model;
0099     QPointer<MainProjectDialog> m_projectdialog;
0100     QPointer<KoFileDialog> m_filedialog;
0101 };
0102 
0103 }  //KPlato namespace
0104 
0105 #endif