From f2632488e06bf62e2b76cddd2644c2fd0cf1b162 Mon Sep 17 00:00:00 2001 From: DrewTechs Date: Sat, 12 Mar 2022 03:40:10 -0500 Subject: [PATCH] Upload files to '' --- sectiongroup.h | 30 +++ settings.cpp | 402 ++++++++++++++++++++++++++++++ settings.h | 80 ++++++ settings.ui | 628 +++++++++++++++++++++++++++++++++++++++++++++++ unfilednotes.cpp | 6 + 5 files changed, 1146 insertions(+) create mode 100644 sectiongroup.h create mode 100644 settings.cpp create mode 100644 settings.h create mode 100644 settings.ui create mode 100644 unfilednotes.cpp diff --git a/sectiongroup.h b/sectiongroup.h new file mode 100644 index 0000000..603cc2e --- /dev/null +++ b/sectiongroup.h @@ -0,0 +1,30 @@ +/* DrewTechs + * Note Binder + * @Version 1.0 + */ + +#ifndef SECTIONGROUP_H +#define SECTIONGROUP_H + +#include +#include +#include +#include +#include +#include +#include +#include + +class SectionGroup +{ +public: + SectionGroup(); + QString name; + QString color; + QString location; + QString parentDir; + QStringList files; + QVector sectionGroupArray; +}; + +#endif // SECTIONGROUP_H diff --git a/settings.cpp b/settings.cpp new file mode 100644 index 0000000..d92e179 --- /dev/null +++ b/settings.cpp @@ -0,0 +1,402 @@ +#include "settings.h" +#include "ui_settings.h" + +Settings::Settings(QString newDefaultNotebookPath, QString newOpenedNotebookList, + QString newGeneralSettingsConfigFile, QString newApplicationLauncherConfigFile, + QList newApplicationLaunchers, int tabPage, QWidget *parent) : + QDialog(parent), + ui(new Ui::Settings) +{ + setDefaultNotebookPath(newDefaultNotebookPath); + setOpenNotebookList(newOpenedNotebookList); + setGeneralSettingsConfigFile(newGeneralSettingsConfigFile); + setApplicationLauncherConfigFile(newApplicationLauncherConfigFile); + int launcher_idx = 0; + for(launcher_idx = 0; launcher_idx < newApplicationLaunchers.size(); launcher_idx++) + { + appendApplicationLauncher(newApplicationLaunchers.at(launcher_idx)); + } + + ui->setupUi(this); + init(); +} + +Settings::~Settings() +{ + delete ui; +} + +void Settings::init() +{ + // About Page + ui->versionLabel->setText("Version: " + getProgramVersion()); + ui->authorLabel->setText("Author: " +getProgramAuthor()); + QPixmap pixmap("../NoteBinder/NoteBinderLogo.png"); + pixmap.scaled(300,225,Qt::KeepAspectRatio,Qt::FastTransformation); + ui->ApplicationLogoLabel->setPixmap(pixmap); + ui->ApplicationLogoLabel->adjustSize(); + // General Settings + ui->settingsTabs->setCurrentIndex(settingsTabPage); + ui->defaultNotebookPath_Field->setText(defaultNotebookPath); + ui->generalSettingsConfig_Field->setText(generalSettingsConfigFile); + ui->applicationLauncherConfig_Field->setText(applicationLauncherConfigFile); + ui->notebookListConfig_Field->setText(openedNotebookList); + helpList_DisplayItem(1); // Display First Page by default. + int launcher_idx = 0; + for(launcher_idx = 0; launcher_idx < applicationLaunchers.size(); launcher_idx++) + { + QTreeWidgetItem* launcherItem = new QTreeWidgetItem; + launcherItem->setText(0, applicationLaunchers.at(launcher_idx)->getApplicationName()); + int str_idx = 0; + QString Extensions; + QStringList ExtensionList = applicationLaunchers.at(launcher_idx)->getApplicationExtensions(); + for(str_idx = 0; str_idx < ExtensionList.size(); str_idx++) + { + if(str_idx == ExtensionList.size() - 1) + { + Extensions += ExtensionList.at(str_idx); + } else { + Extensions += ExtensionList.at(str_idx) + ","; + } + + } + launcherItem->setText(1, Extensions); + launcherItem->setText(2, applicationLaunchers.at(launcher_idx)->getApplicationLocation()); + + ui->applicationLauncherList->addTopLevelItem(launcherItem); + } + ui->helpItems->expandAll(); +} + +void Settings::on_addApplication_Button_clicked() +{ + // Create New Application Launcher + AddApplicationLauncher* addAppLauncher = new AddApplicationLauncher(); + if(!addAppLauncher->exec()) return; + ApplicationLaunchers* newAppLauncher = addAppLauncher->getApplicationLauncher(); + applicationLaunchers.append(newAppLauncher); + QTreeWidgetItem* item = new QTreeWidgetItem(); + item->setText(0, newAppLauncher->getApplicationName()); + int str_idx = 0; + QString Extensions = ""; + QStringList ExtensionList = newAppLauncher->getApplicationExtensions(); + for(str_idx = 0; str_idx < ExtensionList.size(); str_idx++) + { + if(str_idx == ExtensionList.size() - 1) + { + Extensions += ExtensionList.at(str_idx); + } else { + Extensions += ExtensionList.at(str_idx) + ","; + } + } + item->setText(1, Extensions); + item->setText(2, newAppLauncher->getApplicationLocation()); + ui->applicationLauncherList->insertTopLevelItem(ui->applicationLauncherList->topLevelItemCount(), item); + +} +void Settings::on_editApplication_Button_clicked() +{ + // Edit Application Launcher on the List + QModelIndex index = ui->applicationLauncherList->currentIndex(); + int idx = index.row(); + if(idx >= 0) + { + AddApplicationLauncher* addAppLauncher = new AddApplicationLauncher(applicationLaunchers.at(idx)); + if(!addAppLauncher->exec()) return; + applicationLaunchers.removeAt(idx); + ApplicationLaunchers* newAppLauncher = addAppLauncher->getApplicationLauncher(); + applicationLaunchers.insert(idx, newAppLauncher); + QTreeWidgetItem* item = ui->applicationLauncherList->currentItem(); + item->setText(0, newAppLauncher->getApplicationName()); + int str_idx = 0; + QString Extensions = ""; + QStringList ExtensionList = newAppLauncher->getApplicationExtensions(); + for(str_idx = 0; str_idx < ExtensionList.size(); str_idx++) + { + if(str_idx == ExtensionList.size() - 1) + { + Extensions += ExtensionList.at(str_idx); + } else { + Extensions += ExtensionList.at(str_idx) + ","; + } + } + item->setText(1, Extensions); + item->setText(2, newAppLauncher->getApplicationLocation()); + } + // idx will be at -1 if nothing is selected indicating out of bounds, to solve that the item has to be selected to open the launcher. +} +void Settings::on_removeApplication_Button_clicked() +{ + // Remove Application Launcher from the List. + QModelIndex index = ui->applicationLauncherList->currentIndex(); + int idx = index.row(); + if(idx >= 0) + { + QMessageBox messageBox; + QFont fontSize; + fontSize.setPointSize(12); + QString s_txt = ui->applicationLauncherList->currentItem()->text(0); + messageBox.setWindowTitle("Delete Application Launcher"); + messageBox.setFont(fontSize); + messageBox.setText("Are you sure you want to remove " + s_txt + " from the list?"); + messageBox.setStandardButtons(QMessageBox::Yes); + messageBox.addButton(QMessageBox::No); + messageBox.setDefaultButton(QMessageBox::No); + if(messageBox.exec() == QMessageBox::Yes) + { + delete ui->applicationLauncherList->currentItem(); + applicationLaunchers.removeAt(idx); + } + } +} + +void Settings::on_selectDir_defaultNbPath_Button_clicked() +{ + QFileDialog dialog(this); + dialog.setFileMode(QFileDialog::DirectoryOnly); + dialog.setNameFilter(tr("Directory")); + QString fileName = dialog.getExistingDirectory(this, tr("Open File"), QDir().homePath() + "/Documents", QFileDialog::ShowDirsOnly | QFileDialog::DontResolveSymlinks); // Open Dialog + if(fileName != "") + { + ui->defaultNotebookPath_Field->setText(fileName); + setDefaultNotebookPath(fileName); + } +} +void Settings::on_selectDir_generalSettingConf_Button_clicked() +{ + QFileDialog dialog(this); + dialog.setFileMode(QFileDialog::AnyFile); + dialog.setNameFilter(tr("Config File")); + QString fileName = dialog.getSaveFileName(this, tr("Save File"), QDir().homePath() + "/.config/notebinder/", tr("Config File (*.conf)")); // Open Dialog + if(fileName != "") + { + ui->generalSettingsConfig_Field->setText(fileName); + setGeneralSettingsConfigFile(fileName); + } +} +void Settings::on_selectDir_appLauncher_Button_clicked() +{ + QFileDialog dialog(this); + dialog.setFileMode(QFileDialog::AnyFile); + dialog.setNameFilter(tr("Config File")); + QString fileName = dialog.getSaveFileName(this, tr("Save File"), QDir().homePath() + "/.config/notebinder/", tr("Config File (*.conf)")); // Open Dialog + if(fileName != "") + { + ui->applicationLauncherConfig_Field->setText(fileName); + setApplicationLauncherConfigFile(fileName); + } +} +void Settings::on_selectDir_nbListConfig_Button_clicked() +{ + QFileDialog dialog(this); + dialog.setFileMode(QFileDialog::AnyFile); + dialog.setNameFilter(tr("Config File")); + QString fileName = dialog.getSaveFileName(this, tr("Save File"), QDir().homePath() + "/.config/notebinder/", tr("Config File (*.conf)")); // Open Dialog + if(fileName != "") + { + ui->notebookListConfig_Field->setText(fileName); + setOpenNotebookList(fileName); + } +} + +void Settings::on_helpItems_itemSelectionChanged() +{ + QString itemSelected = ui->helpItems->currentItem()->text(0); + ui->helpInformation->clear(); + if(itemSelected == "1) Introduction") + helpList_DisplayItem(1); + else if(itemSelected == "1.1) What does Note Binder Application Do?") + helpList_DisplayItem(2); + else if(itemSelected == "1.2) Why use this Application?") + helpList_DisplayItem(3); + else if(itemSelected == "2) Notebook Management") + helpList_DisplayItem(4); + else if(itemSelected == "2.1) Notebook") + helpList_DisplayItem(5); + else if(itemSelected == "2.1.1) Create/Open Notebook") + helpList_DisplayItem(6); + else if(itemSelected == "2.1.2) Close/Remove Notebook") + helpList_DisplayItem(7); + else if(itemSelected == "2.2) Section") + helpList_DisplayItem(8); + else if(itemSelected == "2.2.1) Create/Open Sections") + helpList_DisplayItem(9); + else if(itemSelected == "2.2.2) Importing a Section to Notebook") + helpList_DisplayItem(10); + else if(itemSelected == "2.2.3) Export Section") + helpList_DisplayItem(11); + else if(itemSelected == "2.3) Section Group") + helpList_DisplayItem(12); + else if(itemSelected == "2.4) Unfiled Notes") + helpList_DisplayItem(13); + else if(itemSelected == "3) Application Settings") + helpList_DisplayItem(14); + else if(itemSelected == "3.1) Configuration Files") + helpList_DisplayItem(15); + else if(itemSelected == "3.2) Application Launchers") + helpList_DisplayItem(16); + else + helpList_DisplayItem(1); +} + +void Settings::helpList_DisplayItem(int pageSelected) +{ + QString helpPagesDir = "../NoteBinder/HelpText"; + QString helpPageFile; + switch(pageSelected) + { + case 1: + helpPageFile = helpPagesDir + QDir::separator() + "Page01"; + break; + case 2: + helpPageFile = helpPagesDir + QDir::separator() + "Page02"; + break; + case 3: + helpPageFile = helpPagesDir + QDir::separator() + "Page03"; + break; + case 4: + helpPageFile = helpPagesDir + QDir::separator() + "Page04"; + break; + case 5: + helpPageFile = helpPagesDir + QDir::separator() + "Page05"; + break; + case 6: + helpPageFile = helpPagesDir + QDir::separator() + "Page06"; + break; + case 7: + helpPageFile = helpPagesDir + QDir::separator() + "Page07"; + break; + case 8: + helpPageFile = helpPagesDir + QDir::separator() + "Page08"; + break; + case 9: + helpPageFile = helpPagesDir + QDir::separator() + "Page09"; + break; + case 10: + helpPageFile = helpPagesDir + QDir::separator() + "Page10"; + break; + case 11: + helpPageFile = helpPagesDir + QDir::separator() + "Page11"; + break; + case 12: + helpPageFile = helpPagesDir + QDir::separator() + "Page12"; + break; + case 13: + helpPageFile = helpPagesDir + QDir::separator() + "Page13"; + break; + case 14: + helpPageFile = helpPagesDir + QDir::separator() + "Page14"; + break; + case 15: + helpPageFile = helpPagesDir + QDir::separator() + "Page15"; + break; + case 16: + helpPageFile = helpPagesDir + QDir::separator() + "Page16"; + break; + default: + helpPageFile = helpPagesDir + QDir::separator() + "Page01"; + break; + } + QFile file(helpPageFile); + if(file.exists()) + { + QString readData; + if(file.open(QIODevice::ReadOnly)|QIODevice::Text) + { + QTextStream in(&file); + while(!in.atEnd()) + { + readData = in.readAll(); + } + } + ui->helpInformation->setPlainText(readData); + } else { + ui->helpInformation->setPlainText("Error: Help Page Information not available!"); + } +} + +void Settings::appendApplicationLauncher(ApplicationLaunchers* launcher) +{ + applicationLaunchers.append(launcher); +} +void Settings::removeApplicationLauncherAt(int idx) +{ + applicationLaunchers.removeAt(idx); +} + +/* Setter Functions */ +void Settings::setDefaultNotebookPath(QString newDefaultNotebookPath) +{ + defaultNotebookPath = newDefaultNotebookPath; +} +void Settings::setOpenNotebookList(QString newOpenedNotebookList) +{ + openedNotebookList = newOpenedNotebookList; +} +void Settings::setGeneralSettingsConfigFile(QString newGeneralSettingsConfigFile) +{ + generalSettingsConfigFile = newGeneralSettingsConfigFile; +} +void Settings::setApplicationLauncherConfigFile(QString newApplicationLauncherConfigFile) +{ + applicationLauncherConfigFile = newApplicationLauncherConfigFile; +} +void Settings::setSettingsTabPage(int newSettingsTab) +{ + settingsTabPage = newSettingsTab; + ui->settingsTabs->setCurrentIndex(settingsTabPage); +} +void Settings::setProgramVersion(QString progVersion) +{ + programAuthor = progVersion; +} +void Settings::setProgramAuthor(QString progAuthor) +{ + programAuthor = progAuthor; +} + +/* Getter Functions */ +QString Settings::getDefaultNotebookPath() +{ + return defaultNotebookPath; +} +QString Settings::getOpenedNotebookList() +{ + return openedNotebookList; +} +QString Settings::getGeneralSettingsConfigFile() +{ + return generalSettingsConfigFile; +} +QString Settings::getApplicationLauncherConfigFile() +{ + return applicationLauncherConfigFile; +} + +ApplicationLaunchers* Settings::getApplicationLauncherAt(int idx) +{ + return applicationLaunchers.at(idx); +} +int Settings::getSettingsTabPage() +{ + return settingsTabPage; +} +QString Settings::getProgramVersion() +{ + return programVersion; +} +QString Settings::getProgramAuthor() +{ + return programAuthor; +} + +void Settings::on_dialogButtonBox_accepted() +{ + accept(); +} + +void Settings::on_dialogButtonBox_rejected() +{ + reject(); +} + diff --git a/settings.h b/settings.h new file mode 100644 index 0000000..eb84f2a --- /dev/null +++ b/settings.h @@ -0,0 +1,80 @@ +#ifndef SETTINGS_H +#define SETTINGS_H + +#include +#include +#include +#include "applicationlaunchers.h" +#include "addApplicationLauncher.h" +#define APPLICATION_VERSION "1.0" +#define APPLICATION_AUTHOR "DrewTechs" + +namespace Ui { +class Settings; +} + +class Settings : public QDialog +{ + Q_OBJECT + +public: + //explicit Settings(QWidget *parent = nullptr); + Settings(QString newDefaultNotebookPath, QString newOpenedNotebookList, + QString newGeneralSettingsConfigFile, QString newApplicationLauncherConfigFile, + QList newApplicationLaunchers, int tabPage, QWidget *parent = nullptr); + ~Settings(); + + void init(); + + + /* Application Launcher Settings */ + QList applicationLaunchers; + + void appendApplicationLauncher(ApplicationLaunchers* launcher); + void removeApplicationLauncherAt(int idx); + + /* Setter Functions */ + void setDefaultNotebookPath(QString newDefaultNotebookPath); + void setOpenNotebookList(QString newOpenedNotebookList); + void setGeneralSettingsConfigFile(QString newGeneralSettingsConfigFile); + void setApplicationLauncherConfigFile(QString newApplicationLauncherConfigFile); + void setSettingsTabPage(int newSettingsTab); + void setProgramVersion(QString progVersion); + void setProgramAuthor(QString progAuthor); + + /* Getter Functions */ + QString getDefaultNotebookPath(); + QString getOpenedNotebookList(); + QString getGeneralSettingsConfigFile(); + QString getApplicationLauncherConfigFile(); + ApplicationLaunchers* getApplicationLauncherAt(int idx); + int getSettingsTabPage(); + QString getProgramVersion(); + QString getProgramAuthor(); + +private slots: + void on_addApplication_Button_clicked(); + void on_editApplication_Button_clicked(); + void on_removeApplication_Button_clicked(); + void on_selectDir_defaultNbPath_Button_clicked(); + void on_selectDir_generalSettingConf_Button_clicked(); + void on_selectDir_appLauncher_Button_clicked(); + void on_selectDir_nbListConfig_Button_clicked(); + void on_helpItems_itemSelectionChanged(); + void helpList_DisplayItem(int pageSelected); + void on_dialogButtonBox_accepted(); + void on_dialogButtonBox_rejected(); + +private: + Ui::Settings *ui; + /* General Settings */ + QString defaultNotebookPath = ""; // Default directory to save Notebooks in + QString openedNotebookList = ""; // List of Previously Opened Notebooks via the last instance. + QString generalSettingsConfigFile = ""; // General Settings Configuration File. + QString applicationLauncherConfigFile = ""; // Application Launcher Configuration. + int settingsTabPage = 0; + QString programVersion = APPLICATION_VERSION; + QString programAuthor = APPLICATION_AUTHOR; +}; + +#endif // SETTINGS_H diff --git a/settings.ui b/settings.ui new file mode 100644 index 0000000..45cdc87 --- /dev/null +++ b/settings.ui @@ -0,0 +1,628 @@ + + + Settings + + + + 0 + 0 + 777 + 425 + + + + Note Binder Settings + + + + + + + 12 + + + + 0 + + + + General Settings + + + + + + + + + 10 + + + + Default Notebook Path: + + + + + + + + 10 + + + + + + + + + + + + 10 + + + + Select Directory + + + + + + + + + + + + 10 + + + + General Settings Config: + + + + + + + + 10 + + + + + + + + + 10 + + + + Select Directory + + + + + + + + + + + + 10 + + + + Application Launcher Config: + + + + + + + + 10 + + + + + + + + + 10 + + + + Select Directory + + + + + + + + + + + + 10 + + + + Notebook List Config: + + + + + + + + 10 + + + + + + + + + + + + 10 + + + + Select Directory + + + + + + + + + + Application Launcher Settings + + + + + + + 10 + + + + Qt::LeftToRight + + + false + + + false + + + true + + + true + + + false + + + 200 + + + true + + + + Application Name + + + + + Extensions + + + + + Locations + + + + + + + + + + Qt::Horizontal + + + + 278 + 20 + + + + + + + + Add Application + + + + + + + Edit Application + + + + + + + Remove Application + + + + + + + + + + Help + + + + + + + 120 + 0 + + + + Qt::Horizontal + + + 1 + + + + + 120 + 0 + + + + + 120 + 0 + + + + + 10 + + + + + Help + + + + + 1) Introduction + + + + 1.1) What does Note Binder Application Do? + + + + + 1.2) Why use this Application? + + + + + + 2) Notebook Management + + + + 2.1) Notebook + + + + 2.1.1) Create/Open Notebook + + + + + 2.1.2) Close/Remove Notebook + + + + + + 2.2) Section + + + + 2.2.1) Create/Open Sections + + + + + 2.2.2) Importing a Section to Notebook + + + + + 2.2.3) Export Section + + + + + + 2.3) Section Group + + + + + 2.4) Unfiled Notes + + + + + + 3) Application Settings + + + + 3.1) Configuration Files + + + + + 3.2) Application Launchers + + + + + + + + 120 + 0 + + + + + 0 + 0 + + + + + 10 + + + + true + + + + + + + + + About + + + + + + QLayout::SetMinimumSize + + + + + Qt::Horizontal + + + QSizePolicy::Maximum + + + + 40 + 20 + + + + + + + + true + + + + 0 + 0 + + + + QFrame::Panel + + + + + + NoteBinderLogo.png + + + true + + + false + + + + + + + Qt::Vertical + + + QSizePolicy::Preferred + + + + 20 + 40 + + + + + + + + Qt::Vertical + + + QSizePolicy::Preferred + + + + 20 + 40 + + + + + + + + Qt::Horizontal + + + QSizePolicy::Maximum + + + + 40 + 20 + + + + + + + + + + + + Qt::Vertical + + + + 20 + 40 + + + + + + + + + 20 + + + + Note Binder + + + Qt::AlignCenter + + + + + + + + 12 + + + + Version: + + + Qt::AlignCenter + + + + + + + Author: DrewTechs + + + Qt::AlignCenter + + + + + + + Qt::Vertical + + + + 20 + 40 + + + + + + + + + + + + + + + + + 12 + + + + QDialogButtonBox::Cancel|QDialogButtonBox::Ok + + + + + + + + + + diff --git a/unfilednotes.cpp b/unfilednotes.cpp new file mode 100644 index 0000000..00f3b09 --- /dev/null +++ b/unfilednotes.cpp @@ -0,0 +1,6 @@ +#include "unfilednotes.h" + +UnfiledNotes::UnfiledNotes() +{ + +}