aboutsummaryrefslogtreecommitdiffstats
path: root/include/ui/widgets
diff options
context:
space:
mode:
Diffstat (limited to 'include/ui/widgets')
-rw-r--r--include/ui/widgets/Attachments.h59
-rw-r--r--include/ui/widgets/EditorPage.h106
-rw-r--r--include/ui/widgets/FilePage.h56
-rw-r--r--include/ui/widgets/HelpPage.h46
-rw-r--r--include/ui/widgets/InfoBoardWidget.h2
-rw-r--r--include/ui/widgets/KeyList.h11
-rw-r--r--include/ui/widgets/TextEdit.h266
7 files changed, 539 insertions, 7 deletions
diff --git a/include/ui/widgets/Attachments.h b/include/ui/widgets/Attachments.h
new file mode 100644
index 00000000..00433028
--- /dev/null
+++ b/include/ui/widgets/Attachments.h
@@ -0,0 +1,59 @@
+/**
+ * This file is part of GPGFrontend.
+ *
+ * GPGFrontend is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * Foobar 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 General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with Foobar. If not, see <https://www.gnu.org/licenses/>.
+ *
+ * The initial version of the source code is inherited from gpg4usb-team.
+ * Their source code version also complies with GNU General Public License.
+ *
+ * The source code version of this software was modified and released
+ * by Saturneric<[email protected]> starting on May 12, 2021.
+ *
+ */
+
+#ifndef __ATTACHMENTS_H__
+#define __ATTACHMENTS_H__
+
+#include "ui/AttachmentTableModel.h"
+
+class Attachments : public QWidget {
+Q_OBJECT
+
+public slots:
+
+ void slotSaveFile();
+
+ void slotOpenFile();
+
+public:
+ explicit Attachments(QWidget *parent = nullptr);
+
+ void addMimePart(MimePart *mp);
+
+private:
+ void createActions();
+
+ void saveByteArrayToFile(QByteArray outBuffer, QString filename);
+
+ QAction *saveFileAct{};
+ QAction *openFileAct{};
+ AttachmentTableModel *table;
+ QTableView *tableView;
+ QSettings settings;
+
+protected:
+ void contextMenuEvent(QContextMenuEvent *event) override;
+};
+
+#endif // __ATTACHMENTS_H__
diff --git a/include/ui/widgets/EditorPage.h b/include/ui/widgets/EditorPage.h
new file mode 100644
index 00000000..a06d6cd6
--- /dev/null
+++ b/include/ui/widgets/EditorPage.h
@@ -0,0 +1,106 @@
+/**
+ * This file is part of GPGFrontend.
+ *
+ * GPGFrontend is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * Foobar 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 General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with Foobar. If not, see <https://www.gnu.org/licenses/>.
+ *
+ * The initial version of the source code is inherited from gpg4usb-team.
+ * Their source code version also complies with GNU General Public License.
+ *
+ * The source code version of this software was modified and released
+ * by Saturneric<[email protected]> starting on May 12, 2021.
+ *
+ */
+
+#ifndef __EDITORPAGE_H__
+#define __EDITORPAGE_H__
+
+#include <GpgFrontend.h>
+
+#include "gpg/GpgConstants.h"
+
+
+QT_BEGIN_NAMESPACE
+class QVBoxLayout;
+
+class QHBoxLayout;
+
+class QString;
+
+class QLabel;
+
+QT_END_NAMESPACE
+
+/**
+ * @brief Class for handling a single tab of the tabwidget
+ *
+ */
+class EditorPage : public QWidget {
+Q_OBJECT
+
+public:
+ /**
+ * @details Add layout and add plaintextedit
+ *
+ * @param filePath Path of the file handled in this tab
+ * @param parent Pointer to the parent widget
+ */
+ explicit EditorPage(QString filePath = "", QWidget *parent = nullptr);
+
+ /**
+ * @details Get the filepath of the currently activated tab.
+ */
+ const QString &getFilePath() const;
+
+ /**
+ * @details Set filepath of currently activated tab.
+ *
+ * @param filePath The path to be set
+ */
+ void setFilePath(const QString &filePath);
+
+ /**
+ * @details Return pointer tp the textedit of the currently activated tab.
+ */
+ QTextEdit *getTextPage();
+
+ /**
+ * @details Show additional widget at buttom of currently active tab
+ *
+ * @param widget The widget to be added
+ * @param className The name to handle the added widget
+ */
+ void showNotificationWidget(QWidget *widget, const char *className);
+
+ /**
+ * @details Hide all widgets with the given className
+ *
+ * @param className The classname of the widgets to hide
+ */
+ void closeNoteByClass(const char *className);
+
+private:
+ QTextEdit *textPage; /** The textedit of the tab */
+ QVBoxLayout *mainLayout; /** The layout for the tab */
+ QString fullFilePath; /** The path to the file handled in the tab */
+ bool signMarked{}; /** true, if the signed header is marked, false if not */
+
+private slots:
+
+ /**
+ * @details Format the gpg header in another font-style
+ */
+ void slotFormatGpgHeader();
+};
+
+#endif // __EDITORPAGE_H__
diff --git a/include/ui/widgets/FilePage.h b/include/ui/widgets/FilePage.h
new file mode 100644
index 00000000..6585bed9
--- /dev/null
+++ b/include/ui/widgets/FilePage.h
@@ -0,0 +1,56 @@
+/**
+ * This file is part of GPGFrontend.
+ *
+ * GPGFrontend is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * Foobar 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 General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with Foobar. If not, see <https://www.gnu.org/licenses/>.
+ *
+ * The initial version of the source code is inherited from gpg4usb-team.
+ * Their source code version also complies with GNU General Public License.
+ *
+ * The source code version of this software was modified and released
+ * by Saturneric<[email protected]> starting on May 12, 2021.
+ *
+ */
+
+#ifndef GPGFRONTEND_FILEPAGE_H
+#define GPGFRONTEND_FILEPAGE_H
+
+#include <GpgFrontend.h>
+
+class FilePage : public QWidget {
+Q_OBJECT
+public:
+
+ explicit FilePage(QWidget* parent = nullptr);
+
+ void getSelected(QString &path);
+
+
+private slots:
+
+ void fileTreeViewItemClicked(const QModelIndex &index);
+ void fileTreeViewItemDoubleClicked(const QModelIndex &index);
+
+ void slotUpLevel();
+
+private:
+ QFileSystemModel *dirModel;
+ QTreeView *dirTreeView;
+ QString mPath;
+
+ QPushButton *upLevelButton;
+
+};
+
+
+#endif //GPGFRONTEND_FILEPAGE_H
diff --git a/include/ui/widgets/HelpPage.h b/include/ui/widgets/HelpPage.h
new file mode 100644
index 00000000..0b5e4ca3
--- /dev/null
+++ b/include/ui/widgets/HelpPage.h
@@ -0,0 +1,46 @@
+/*
+ * helppage.h
+ *
+ * Copyright 2008 gpg4usb-team <[email protected]>
+ *
+ * This file is part of gpg4usb.
+ *
+ * Gpg4usb is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * Gpg4usb 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 General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with gpg4usb. If not, see <http://www.gnu.org/licenses/>
+ */
+
+#ifndef HELPPAGE_H
+#define HELPPAGE_H
+
+#include <GpgFrontend.h>
+
+class HelpPage : public QWidget {
+Q_OBJECT
+public:
+ explicit HelpPage(const QString& path, QWidget *parent = nullptr);
+
+ QTextBrowser *getBrowser();
+
+signals:
+
+public slots:
+
+ void slotOpenUrl(const QUrl& url);
+
+private:
+ QTextBrowser *browser; /** The textbrowser of the tab */
+ QUrl localizedHelp(const QUrl& path);
+
+};
+
+#endif // HELPPAGE_H
diff --git a/include/ui/widgets/InfoBoardWidget.h b/include/ui/widgets/InfoBoardWidget.h
index 88c7cb04..9d3dbd16 100644
--- a/include/ui/widgets/InfoBoardWidget.h
+++ b/include/ui/widgets/InfoBoardWidget.h
@@ -25,7 +25,7 @@
#ifndef __VERIFYNOTIFICATION_H__
#define __VERIFYNOTIFICATION_H__
-#include "ui/EditorPage.h"
+#include "EditorPage.h"
#include "ui/VerifyDetailsDialog.h"
#include "gpg/result_analyse/VerifyResultAnalyse.h"
diff --git a/include/ui/widgets/KeyList.h b/include/ui/widgets/KeyList.h
index 295ba224..413d0969 100644
--- a/include/ui/widgets/KeyList.h
+++ b/include/ui/widgets/KeyList.h
@@ -85,9 +85,10 @@ public:
void setChecked(QStringList *keyIds);
- //QStringList *getPrivateChecked();
QStringList *getSelected();
+ GpgKey getSelectedKey();
+
[[maybe_unused]] static void markKeys(QStringList *keyIds);
[[maybe_unused]] bool containsPrivateKeys();
@@ -96,12 +97,13 @@ public slots:
void slotRefresh();
- void uploadKeyToServer(QByteArray *keys);
-
private:
void importKeys(QByteArray inBuffer);
+ QString appPath;
+ QSettings settings;
+
GpgME::GpgContext *mCtx;
QTableWidget *mKeyList;
QMenu *popupMenu;
@@ -117,11 +119,8 @@ private:
private slots:
- void uploadFinished();
-
void slotDoubleClicked(const QModelIndex &index);
-
protected:
void contextMenuEvent(QContextMenuEvent *event) override;
diff --git a/include/ui/widgets/TextEdit.h b/include/ui/widgets/TextEdit.h
new file mode 100644
index 00000000..f98da145
--- /dev/null
+++ b/include/ui/widgets/TextEdit.h
@@ -0,0 +1,266 @@
+/**
+ * This file is part of GPGFrontend.
+ *
+ * GPGFrontend is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * Foobar 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 General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with Foobar. If not, see <https://www.gnu.org/licenses/>.
+ *
+ * The initial version of the source code is inherited from gpg4usb-team.
+ * Their source code version also complies with GNU General Public License.
+ *
+ * The source code version of this software was modified and released
+ * by Saturneric<[email protected]> starting on May 12, 2021.
+ *
+ */
+
+#ifndef __TEXTEDIT_H__
+#define __TEXTEDIT_H__
+
+#include "ui/widgets/EditorPage.h"
+#include "ui/widgets/HelpPage.h"
+#include "ui/widgets/FilePage.h"
+#include "ui/QuitDialog.h"
+
+
+/**
+ * @brief TextEdit class
+ */
+class TextEdit : public QWidget {
+Q_OBJECT
+public:
+ /**
+ * @brief
+ */
+ TextEdit();
+
+ /**
+ * @details Load the content of file into the current textpage
+ *
+ * @param fileName QString containing the filename to load
+ * @return nothing
+ */
+ void loadFile(const QString &fileName);
+
+
+ /**
+ * @details Checks if there are unsaved documents in any tab,
+ * which may need to be saved. Call this function before
+ * closing the programme or all tabs.
+ * @return \li false, if the close event should be aborted.
+ * \li true, otherwise
+ */
+ bool maybeSaveAnyTab();
+
+ [[nodiscard]] int tabCount() const;
+
+ /**
+ * @details textpage of the currently activated tab
+ * @return \li reference to QTextEdit if tab has one
+ * \li 0 otherwise (e.g. if helppage)
+ */
+ [[nodiscard]] QTextEdit *curTextPage() const;
+
+ [[nodiscard]] QTextBrowser *curHelpPage() const;
+
+ /**
+ * @details List of currently unsaved tabs.
+ * @returns QHash<int, QString> Hash of tabindexes and title of unsaved tabs.
+ */
+ [[nodiscard]] QHash<int, QString> unsavedDocuments() const;
+
+ QTabWidget *tabWidget; /** Widget containing the tabs of the editor */
+
+public slots:
+
+ /**
+ * @details Return pointer to the currently activated tabpage.
+ *
+ */
+ [[nodiscard]] EditorPage *slotCurPage() const;
+
+ /**
+ * @details Insert a ">" at the begining of every line of current textedit.
+ */
+ void slotQuote() const;
+
+ /**
+ * @details replace the text of currently active textedit with given text.
+ * @param text to fill on.
+ */
+ void slotFillTextEditWithText(const QString& text) const;
+
+ /**
+ * @details Saves the content of the current tab, if it has a filepath
+ * otherwise it calls saveAs for the current tab
+ */
+ void slotSave();
+
+ /**
+ * @details Opens a savefiledialog and calls saveFile with the choosen filename.
+ *
+ * @return Return the return value of the savefile method
+ */
+ bool slotSaveAs();
+
+ /**
+ * @details Show an OpenFileDoalog and open the file in a new tab.
+ * Shows an error dialog, if the open fails.
+ * Set the focus to the tab of the opened file.
+ */
+ void slotOpen();
+
+ /**
+ * @details Open a print-dialog for the current tab
+ */
+ void slotPrint();
+
+ /**
+ * @details Adds a new tab with the title "untitled"+countpage+".txt"
+ * Sets the focus to the new tab. Increase Tab-Count by one
+ */
+ void slotNewTab();
+
+ /**
+ * @details Adds a new tab with the given title and opens given html file.
+ * Increase Tab-Count by one
+ * @param title title for the tab
+ * @param path path for html file to show
+ */
+ void slotNewHelpTab(const QString& title, const QString& path) const;
+
+ /**
+ * New File Tab to do file operation
+ */
+ void slotNewFileTab() const;
+
+ /**
+ * @details put a * in front of current tabs title, if current textedit is modified
+ */
+ void slotShowModified() const;
+
+ /**
+ * @details close the current tab and decrease TabWidget->count by \a 1
+ *
+ */
+ void slotCloseTab();
+
+ /**
+ * @details Switch to the next tab.
+ *
+ */
+ void slotSwitchTabUp() const;
+
+ /**
+ * @details Switch to the previous tab.
+ *
+ */
+ void slotSwitchTabDown() const;
+
+private:
+ /**
+ * @details return just a filename stripped of a whole path
+ *
+ * @param a filename path
+ * @return QString containing the filename
+ */
+ static QString strippedName(const QString &fullFileName);
+
+ /**
+ * @brief
+ *
+ * @param askToSave
+ */
+ bool maybeSaveCurrentTab(bool askToSave);
+
+ /****************************************************************************************
+ * Name: countPage
+ * Description: int cotaining the number of added tabs
+ */
+ int countPage; /* TODO */
+
+private slots:
+
+ /**
+ * @details Remove the tab with given index
+ *
+ * @param index Tab-number to remove
+ */
+ void removeTab(int index);
+
+ /**
+ * @details Cut selected text in current textpage.
+ */
+ void slotCut() const;
+
+ /**
+ * @details Copy selected text of current textpage to clipboard.
+ */
+ void slotCopy() const;
+
+ /**
+ * @details Paste text from clipboard to current textpage.
+ */
+ void slotPaste() const;
+
+ /**
+ * @details Undo last change in current textpage.
+ *
+ */
+ void slotUndo() const;
+ /****************************************************************************************
+ * Name: redo
+ * Description: redo last change in current textpage
+ * Parameters: none
+ * Return Values: none
+ * Change on members: none
+ */
+ /**
+ * @brief
+ *
+ */
+ void slotRedo() const;
+
+ void slotZoomIn() const;
+
+ void slotZoomOut() const;
+ /****************************************************************************************
+ * Name: selectAll
+ * Description: select all in current textpage
+ * Parameters: none
+ * Return Values: none
+ * Change on members: none
+ */
+ /**
+ * @brief
+ *
+ */
+ void slotSelectAll() const;
+
+protected:
+
+ /****************************************************************************************
+ * Name: saveFile
+ * Description: Saves the content of currentTab to the file filename
+ * Parameters: QString filename contains the full path of the file to save
+ * Return Values: true, if the file was saved succesfully
+ * false, if parameter filename is empty or the saving failed
+ * Change on members: sets isModified of the current tab to false
+ */
+ /**
+ * @brief
+ *
+ * @param fileName
+ */
+ bool saveFile(const QString &fileName);
+};
+
+#endif // __TEXTEDIT_H__