DrewTechs
3 years ago
5 changed files with 859 additions and 0 deletions
@ -0,0 +1,241 @@ |
|||||
|
/* DrewTechs
|
||||
|
* Note Binder |
||||
|
* @Version 1.0 |
||||
|
*/ |
||||
|
|
||||
|
#include "newSectionDialog.h" |
||||
|
#include "ui_newSectionDialog.h" |
||||
|
|
||||
|
/* Constructors */ |
||||
|
newSectionDialog::newSectionDialog(QStringList notebookColorList, QStringList notebookDirList, QStringList list, QList<ApplicationLaunchers*> applicationLaunchers, QWidget *parent) |
||||
|
: QDialog(parent) |
||||
|
, ui(new Ui::newSectionDialog) |
||||
|
{ |
||||
|
setNotebookColorList(notebookColorList); |
||||
|
setNotebookDirList(notebookDirList); |
||||
|
setDirectories(list); |
||||
|
setApplicationLauncher(applicationLaunchers); |
||||
|
ui->setupUi(this); |
||||
|
init(); |
||||
|
} |
||||
|
|
||||
|
/* Destructor */ |
||||
|
newSectionDialog::~newSectionDialog() |
||||
|
{ |
||||
|
delete ui; |
||||
|
} |
||||
|
|
||||
|
|
||||
|
void newSectionDialog::on_buttonBox_accepted() |
||||
|
{ |
||||
|
if(ui->fileNameBox->text() != "" && ui->directorySelection->currentText() != "") // Cannot have Empty Filename
|
||||
|
{ |
||||
|
applicationLauncher(); |
||||
|
accept(); |
||||
|
} else { |
||||
|
reject(); |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
void newSectionDialog::on_buttonBox_rejected() |
||||
|
{ |
||||
|
reject(); |
||||
|
} |
||||
|
|
||||
|
void newSectionDialog::addItemsToDirectory() |
||||
|
{ |
||||
|
int idx = 0; |
||||
|
for(idx = 0; idx < getDirectories().size(); idx++) |
||||
|
{ |
||||
|
if(!getDirectories().at(idx).startsWith(" ")) |
||||
|
{ |
||||
|
ui->directorySelection->addItem(SetNotebookIcon(notebookcolorlist.at(idx)), getDirectories().at(idx)); |
||||
|
} else { |
||||
|
ui->directorySelection->addItem(SetSectionGroupIcon(notebookcolorlist.at(idx)), getDirectories().at(idx)); |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
void newSectionDialog::init() |
||||
|
{ |
||||
|
QStringList extensionItems; |
||||
|
QStringList extensions; |
||||
|
int appLauncher_idx = 0; |
||||
|
for(appLauncher_idx = 0; appLauncher_idx < applicationLaunchers.size(); appLauncher_idx++) |
||||
|
{ |
||||
|
int extensions_idx = 0; |
||||
|
for(extensions_idx = 0; extensions_idx < applicationLaunchers.at(appLauncher_idx)->getApplicationExtensions().size(); extensions_idx++) |
||||
|
{ |
||||
|
extensions.append(applicationLaunchers.at(appLauncher_idx)->getSingleApplicationExtension(extensions_idx)); |
||||
|
extensionItems.append(applicationLaunchers.at(appLauncher_idx)->getApplicationName() |
||||
|
+ " (" + applicationLaunchers.at(appLauncher_idx)->getSingleApplicationExtension(extensions_idx) + ")"); |
||||
|
} |
||||
|
} |
||||
|
setExtensionList(extensions); |
||||
|
ui->fileExtensionBox->addItems(extensionItems); |
||||
|
addItemsToDirectory(); |
||||
|
} |
||||
|
|
||||
|
void newSectionDialog::applicationLauncher() |
||||
|
{ |
||||
|
QString fileName, fileExtension; |
||||
|
fileName = ui->fileNameBox->text(); // File Name without the Extension
|
||||
|
QStringList extensionItems = getExtensionList(); |
||||
|
int idx = 0; |
||||
|
for(idx = 0; idx < extensionItems.size(); idx++) |
||||
|
{ |
||||
|
if(idx == ui->fileExtensionBox->currentIndex()) |
||||
|
{ |
||||
|
int itemLocation; |
||||
|
fileName += extensionItems.at(idx); |
||||
|
itemLocation = ui->directorySelection->currentIndex(); |
||||
|
fullFileName = notebookdirList.at(itemLocation); |
||||
|
fullFileName += QDir::separator() + fileName; |
||||
|
setFullFileName(fullFileName); |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
QIcon newSectionDialog::SetNotebookIcon(QString notebookColor) |
||||
|
{ |
||||
|
QIcon icon; |
||||
|
QString iconPath = "../NoteBinder/Icons"; |
||||
|
if(!QDir(iconPath).exists()) |
||||
|
{ |
||||
|
return icon; |
||||
|
} |
||||
|
if(notebookColor == "Red") { |
||||
|
icon = QIcon(iconPath + "/NotebookIcon_Red.png"); |
||||
|
} else if(notebookColor == "Blue") { |
||||
|
icon = QIcon(iconPath + "/NotebookIcon_Blue.png"); |
||||
|
} else if(notebookColor == "Purple") { |
||||
|
icon = QIcon(iconPath + "/NotebookIcon_Purple.png"); |
||||
|
} else if(notebookColor == "Orange") { |
||||
|
icon = QIcon(iconPath + "/NotebookIcon_Orange.png"); |
||||
|
} else if(notebookColor == "Yellow") { |
||||
|
icon = QIcon(iconPath + "/NotebookIcon_Yellow.png"); |
||||
|
} else if(notebookColor == "Green") { |
||||
|
icon = QIcon(iconPath + "/NotebookIcon_Green.png"); |
||||
|
} else if(notebookColor == "Cyan") { |
||||
|
icon = QIcon(iconPath + "/NotebookIcon_Cyan.png"); |
||||
|
} else if(notebookColor == "Tan") { |
||||
|
icon = QIcon(iconPath + "/NotebookIcon_Tan.png"); |
||||
|
} else if(notebookColor == "Teal") { |
||||
|
icon = QIcon(iconPath + "/NotebookIcon_Teal.png"); |
||||
|
} else if(notebookColor == "Red Chalk") { |
||||
|
icon = QIcon(iconPath + "/NotebookIcon_RedChalk.png"); |
||||
|
} else if(notebookColor == "Blue Mist") { |
||||
|
icon = QIcon(iconPath + "/NotebookIcon_BlueMist.png"); |
||||
|
} else if(notebookColor == "Purple Mist") { |
||||
|
icon = QIcon(iconPath + "/NotebookIcon_PurpleMist.png"); |
||||
|
} else if(notebookColor == "Magenta") { |
||||
|
icon = QIcon(iconPath + "/NotebookIcon_Magenta.png"); |
||||
|
} else if(notebookColor == "Lemon Lime") { |
||||
|
icon = QIcon(iconPath + "/NotebookIcon_LemonLime.png"); |
||||
|
} else if(notebookColor == "Apple") { |
||||
|
icon = QIcon(iconPath + "/NotebookIcon_Apple.png"); |
||||
|
} else if(notebookColor == "Silver") { |
||||
|
icon = QIcon(iconPath + "/NotebookIcon_Silver.png"); |
||||
|
} else if(notebookColor == "Black") { |
||||
|
icon = QIcon(iconPath + "/NotebookIcon_Black.png"); |
||||
|
} else { |
||||
|
// If it's either White/None or an invalid value, set to the white icon
|
||||
|
icon = QIcon(iconPath + "/NotebookIcon_White.png"); |
||||
|
} |
||||
|
return icon; |
||||
|
} |
||||
|
QIcon newSectionDialog::SetSectionGroupIcon(QString sectionGroupColor) |
||||
|
{ |
||||
|
QIcon icon; |
||||
|
QString iconPath = "../NoteBinder/Icons"; |
||||
|
if(!QDir(iconPath).exists()) |
||||
|
{ |
||||
|
return icon; |
||||
|
} |
||||
|
if(sectionGroupColor == "Red") { |
||||
|
icon = QIcon(iconPath + "/SectionGroupIcon_Red.png"); |
||||
|
} else if(sectionGroupColor == "Blue") { |
||||
|
icon = QIcon(iconPath + "/SectionGroupIcon_Blue.png"); |
||||
|
} else if(sectionGroupColor == "Purple") { |
||||
|
icon = QIcon(iconPath + "/SectionGroupIcon_Purple.png"); |
||||
|
} else if(sectionGroupColor == "Orange") { |
||||
|
icon = QIcon(iconPath + "/SectionGroupIcon_Orange.png"); |
||||
|
} else if(sectionGroupColor == "Yellow") { |
||||
|
icon = QIcon(iconPath + "/SectionGroupIcon_Yellow.png"); |
||||
|
} else if(sectionGroupColor == "Green") { |
||||
|
icon = QIcon(iconPath + "/SectionGroupIcon_Green.png"); |
||||
|
} else if(sectionGroupColor == "Cyan") { |
||||
|
icon = QIcon(iconPath + "/SectionGroupIcon_Cyan.png"); |
||||
|
} else if(sectionGroupColor == "Tan") { |
||||
|
icon = QIcon(iconPath + "/SectionGroupIcon_Tan.png"); |
||||
|
} else if(sectionGroupColor == "Teal") { |
||||
|
icon = QIcon(iconPath + "/SectionGroupIcon_Teal.png"); |
||||
|
} else if(sectionGroupColor == "Red Chalk") { |
||||
|
icon = QIcon(iconPath + "/SectionGroupIcon_RedChalk.png"); |
||||
|
} else if(sectionGroupColor == "Blue Mist") { |
||||
|
icon = QIcon(iconPath + "/SectionGroupIcon_BlueMist.png"); |
||||
|
} else if(sectionGroupColor == "Purple Mist") { |
||||
|
icon = QIcon(iconPath + "/SectionGroupIcon_PurpleMist.png"); |
||||
|
} else if(sectionGroupColor == "Magenta") { |
||||
|
icon = QIcon(iconPath + "/SectionGroupIcon_Magenta.png"); |
||||
|
} else if(sectionGroupColor == "Lemon Lime") { |
||||
|
icon = QIcon(iconPath + "/SectionGroupIcon_LemonLime.png"); |
||||
|
} else if(sectionGroupColor == "Apple") { |
||||
|
icon = QIcon(iconPath + "/SectionGroupIcon_Apple.png"); |
||||
|
} else if(sectionGroupColor == "Silver") { |
||||
|
icon = QIcon(iconPath + "/SectionGroupIcon_Silver.png"); |
||||
|
} else if(sectionGroupColor == "Black") { |
||||
|
icon = QIcon(iconPath + "/SectionGroupIcon_Black.png"); |
||||
|
} else { |
||||
|
// If it's either White/None or an invalid value, set to the white icon
|
||||
|
icon = QIcon(iconPath + "/SectionGroupIcon_White.png"); |
||||
|
} |
||||
|
return icon; |
||||
|
} |
||||
|
|
||||
|
/* Getter Functions */ |
||||
|
QStringList newSectionDialog::getDirectories() const |
||||
|
{ |
||||
|
return var_directoryList; |
||||
|
} |
||||
|
QStringList newSectionDialog::getNotebookDirList() const |
||||
|
{ |
||||
|
return notebookdirList; |
||||
|
} |
||||
|
QStringList newSectionDialog::getNotebookColorList() const |
||||
|
{ |
||||
|
return notebookcolorlist; |
||||
|
} |
||||
|
QStringList newSectionDialog::getExtensionList() const |
||||
|
{ |
||||
|
return extensionList; |
||||
|
} |
||||
|
QString newSectionDialog::getFullFileName() const |
||||
|
{ |
||||
|
return fullFileName; |
||||
|
} |
||||
|
|
||||
|
/* Setter Functions */ |
||||
|
void newSectionDialog::setApplicationLauncher(QList<ApplicationLaunchers*> newApplicationLaunchers) |
||||
|
{ |
||||
|
applicationLaunchers = newApplicationLaunchers; |
||||
|
} |
||||
|
void newSectionDialog::setDirectories(QStringList dirList) |
||||
|
{ |
||||
|
var_directoryList = dirList; |
||||
|
} |
||||
|
void newSectionDialog::setNotebookDirList(QStringList nbDirList) |
||||
|
{ |
||||
|
notebookdirList = nbDirList; |
||||
|
} |
||||
|
void newSectionDialog::setNotebookColorList(QStringList nbColorList) |
||||
|
{ |
||||
|
notebookcolorlist = nbColorList; |
||||
|
} |
||||
|
void newSectionDialog::setExtensionList(QStringList newExtensionList) |
||||
|
{ |
||||
|
extensionList = newExtensionList; |
||||
|
} |
||||
|
void newSectionDialog::setFullFileName(QString newFullFileName) |
||||
|
{ |
||||
|
fullFileName = newFullFileName; |
||||
|
} |
@ -0,0 +1,69 @@ |
|||||
|
/* DrewTechs
|
||||
|
* Note Binder |
||||
|
* @Version 1.0 |
||||
|
*/ |
||||
|
|
||||
|
#ifndef NEWSECTIONDIALOG_H |
||||
|
#define NEWSECTIONDIALOG_H |
||||
|
|
||||
|
#include <QDialog> |
||||
|
#include <QObject> |
||||
|
#include <QFileInfo> |
||||
|
#include <QDir> |
||||
|
#include <QTreeWidgetItem> |
||||
|
#include <QPushButton> |
||||
|
#include "mainwindow.h" |
||||
|
#include "notebook.h" |
||||
|
#include "sectiongroup.h" |
||||
|
#include "notebooklist.h" |
||||
|
#include "notebookmanager.h" |
||||
|
#include "settings.h" |
||||
|
|
||||
|
namespace Ui { class newSectionDialog; } |
||||
|
|
||||
|
class newSectionDialog : public QDialog |
||||
|
{ |
||||
|
Q_OBJECT |
||||
|
|
||||
|
public: |
||||
|
//newSectionDialog(QWidget *parent = nullptr);
|
||||
|
newSectionDialog(QStringList notebookColorList, QStringList notebookDirList, QStringList list, QList<ApplicationLaunchers*> applicationLaunchers, QWidget *parent = nullptr); |
||||
|
~newSectionDialog(); |
||||
|
|
||||
|
QStringList getDirectories() const; |
||||
|
QStringList getNotebookDirList() const; |
||||
|
QStringList getNotebookColorList() const; |
||||
|
QStringList getExtensionList() const; |
||||
|
QString getFullFileName() const; |
||||
|
|
||||
|
void setDirectories(QStringList dirList); |
||||
|
void setNotebookDirList(QStringList nbDirList); |
||||
|
void setNotebookColorList(QStringList nbColorList); |
||||
|
void setExtensionList(QStringList newExtensionList); |
||||
|
void setFullFileName(QString newFullFileName); |
||||
|
void setApplicationLauncher(QList<ApplicationLaunchers*> newApplicationLaunchers); |
||||
|
|
||||
|
QIcon SetNotebookIcon(QString notebookColor); |
||||
|
QIcon SetSectionGroupIcon(QString sectionGroupColor); |
||||
|
|
||||
|
private slots: |
||||
|
void on_buttonBox_accepted(); |
||||
|
void on_buttonBox_rejected(); |
||||
|
void addItemsToDirectory(); |
||||
|
void applicationLauncher(); |
||||
|
|
||||
|
private: |
||||
|
Ui::newSectionDialog *ui; |
||||
|
|
||||
|
QStringList var_directoryList; // Directories displayed on the ComboBox of Directory List
|
||||
|
QStringList notebookdirList; // Actual Filepaths of each Notebook or Section Group.
|
||||
|
QStringList notebookcolorlist; // Icon Colors of Notebook or Section Group
|
||||
|
QStringList extensionList; // List of File Extensions
|
||||
|
QString fullFileName; // Full Filename including the extension.
|
||||
|
QList<ApplicationLaunchers*> applicationLaunchers; // Application Launchers
|
||||
|
|
||||
|
|
||||
|
void init(); |
||||
|
}; |
||||
|
|
||||
|
#endif // NEWSECTIONDIALOG_H
|
@ -0,0 +1,133 @@ |
|||||
|
<?xml version="1.0" encoding="UTF-8"?> |
||||
|
<ui version="4.0"> |
||||
|
<class>newSectionDialog</class> |
||||
|
<widget class="QDialog" name="newSectionDialog"> |
||||
|
<property name="geometry"> |
||||
|
<rect> |
||||
|
<x>0</x> |
||||
|
<y>0</y> |
||||
|
<width>551</width> |
||||
|
<height>232</height> |
||||
|
</rect> |
||||
|
</property> |
||||
|
<property name="windowTitle"> |
||||
|
<string>Create New Section</string> |
||||
|
</property> |
||||
|
<layout class="QVBoxLayout" name="verticalLayout"> |
||||
|
<item> |
||||
|
<widget class="QLabel" name="notebookLabel"> |
||||
|
<property name="font"> |
||||
|
<font> |
||||
|
<pointsize>12</pointsize> |
||||
|
</font> |
||||
|
</property> |
||||
|
<property name="text"> |
||||
|
<string>Select Notebook or Section Group:</string> |
||||
|
</property> |
||||
|
</widget> |
||||
|
</item> |
||||
|
<item> |
||||
|
<widget class="QComboBox" name="directorySelection"> |
||||
|
<property name="font"> |
||||
|
<font> |
||||
|
<pointsize>12</pointsize> |
||||
|
</font> |
||||
|
</property> |
||||
|
<property name="iconSize"> |
||||
|
<size> |
||||
|
<width>24</width> |
||||
|
<height>24</height> |
||||
|
</size> |
||||
|
</property> |
||||
|
</widget> |
||||
|
</item> |
||||
|
<item> |
||||
|
<widget class="QLabel" name="fileNameLabel"> |
||||
|
<property name="font"> |
||||
|
<font> |
||||
|
<pointsize>12</pointsize> |
||||
|
</font> |
||||
|
</property> |
||||
|
<property name="text"> |
||||
|
<string>Filename and File Type:</string> |
||||
|
</property> |
||||
|
</widget> |
||||
|
</item> |
||||
|
<item> |
||||
|
<layout class="QHBoxLayout" name="horizontalLayout"> |
||||
|
<item> |
||||
|
<widget class="QLineEdit" name="fileNameBox"> |
||||
|
<property name="font"> |
||||
|
<font> |
||||
|
<pointsize>12</pointsize> |
||||
|
</font> |
||||
|
</property> |
||||
|
<property name="text"> |
||||
|
<string/> |
||||
|
</property> |
||||
|
</widget> |
||||
|
</item> |
||||
|
<item> |
||||
|
<widget class="QComboBox" name="fileExtensionBox"> |
||||
|
<property name="font"> |
||||
|
<font> |
||||
|
<pointsize>12</pointsize> |
||||
|
</font> |
||||
|
</property> |
||||
|
</widget> |
||||
|
</item> |
||||
|
</layout> |
||||
|
</item> |
||||
|
<item> |
||||
|
<widget class="QDialogButtonBox" name="buttonBox"> |
||||
|
<property name="font"> |
||||
|
<font> |
||||
|
<pointsize>12</pointsize> |
||||
|
</font> |
||||
|
</property> |
||||
|
<property name="orientation"> |
||||
|
<enum>Qt::Horizontal</enum> |
||||
|
</property> |
||||
|
<property name="standardButtons"> |
||||
|
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set> |
||||
|
</property> |
||||
|
</widget> |
||||
|
</item> |
||||
|
</layout> |
||||
|
</widget> |
||||
|
<resources/> |
||||
|
<connections> |
||||
|
<connection> |
||||
|
<sender>buttonBox</sender> |
||||
|
<signal>accepted()</signal> |
||||
|
<receiver>newSectionDialog</receiver> |
||||
|
<slot>accept()</slot> |
||||
|
<hints> |
||||
|
<hint type="sourcelabel"> |
||||
|
<x>17</x> |
||||
|
<y>222</y> |
||||
|
</hint> |
||||
|
<hint type="destinationlabel"> |
||||
|
<x>157</x> |
||||
|
<y>192</y> |
||||
|
</hint> |
||||
|
</hints> |
||||
|
</connection> |
||||
|
<connection> |
||||
|
<sender>buttonBox</sender> |
||||
|
<signal>rejected()</signal> |
||||
|
<receiver>newSectionDialog</receiver> |
||||
|
<slot>reject()</slot> |
||||
|
<hints> |
||||
|
<hint type="sourcelabel"> |
||||
|
<x>85</x> |
||||
|
<y>222</y> |
||||
|
</hint> |
||||
|
<hint type="destinationlabel"> |
||||
|
<x>286</x> |
||||
|
<y>192</y> |
||||
|
</hint> |
||||
|
</hints> |
||||
|
</connection> |
||||
|
</connections> |
||||
|
</ui> |
@ -0,0 +1,172 @@ |
|||||
|
<?xml version="1.0" encoding="UTF-8"?> |
||||
|
<ui version="4.0"> |
||||
|
<class>newSectionDialog</class> |
||||
|
<widget class="QDialog" name="newSectionDialog"> |
||||
|
<property name="geometry"> |
||||
|
<rect> |
||||
|
<x>0</x> |
||||
|
<y>0</y> |
||||
|
<width>610</width> |
||||
|
<height>259</height> |
||||
|
</rect> |
||||
|
</property> |
||||
|
<property name="windowTitle"> |
||||
|
<string>Dialog</string> |
||||
|
</property> |
||||
|
<widget class="QDialogButtonBox" name="buttonBox"> |
||||
|
<property name="geometry"> |
||||
|
<rect> |
||||
|
<x>240</x> |
||||
|
<y>210</y> |
||||
|
<width>351</width> |
||||
|
<height>31</height> |
||||
|
</rect> |
||||
|
</property> |
||||
|
<property name="font"> |
||||
|
<font> |
||||
|
<pointsize>12</pointsize> |
||||
|
</font> |
||||
|
</property> |
||||
|
<property name="orientation"> |
||||
|
<enum>Qt::Horizontal</enum> |
||||
|
</property> |
||||
|
<property name="standardButtons"> |
||||
|
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set> |
||||
|
</property> |
||||
|
</widget> |
||||
|
<widget class="QComboBox" name="directorySelection"> |
||||
|
<property name="geometry"> |
||||
|
<rect> |
||||
|
<x>10</x> |
||||
|
<y>50</y> |
||||
|
<width>591</width> |
||||
|
<height>41</height> |
||||
|
</rect> |
||||
|
</property> |
||||
|
<property name="font"> |
||||
|
<font> |
||||
|
<pointsize>12</pointsize> |
||||
|
</font> |
||||
|
</property> |
||||
|
<item> |
||||
|
<property name="text"> |
||||
|
<string>(select Notebook/Section Group)</string> |
||||
|
</property> |
||||
|
</item> |
||||
|
</widget> |
||||
|
<widget class="QLabel" name="notebookLabel"> |
||||
|
<property name="geometry"> |
||||
|
<rect> |
||||
|
<x>50</x> |
||||
|
<y>10</y> |
||||
|
<width>341</width> |
||||
|
<height>41</height> |
||||
|
</rect> |
||||
|
</property> |
||||
|
<property name="font"> |
||||
|
<font> |
||||
|
<pointsize>12</pointsize> |
||||
|
</font> |
||||
|
</property> |
||||
|
<property name="text"> |
||||
|
<string>Select Notebook or Section Group:</string> |
||||
|
</property> |
||||
|
</widget> |
||||
|
<widget class="QLineEdit" name="fileNameBox"> |
||||
|
<property name="geometry"> |
||||
|
<rect> |
||||
|
<x>10</x> |
||||
|
<y>150</y> |
||||
|
<width>391</width> |
||||
|
<height>41</height> |
||||
|
</rect> |
||||
|
</property> |
||||
|
<property name="font"> |
||||
|
<font> |
||||
|
<pointsize>12</pointsize> |
||||
|
</font> |
||||
|
</property> |
||||
|
<property name="text"> |
||||
|
<string/> |
||||
|
</property> |
||||
|
</widget> |
||||
|
<widget class="QComboBox" name="fileExtensionBox"> |
||||
|
<property name="geometry"> |
||||
|
<rect> |
||||
|
<x>410</x> |
||||
|
<y>150</y> |
||||
|
<width>191</width> |
||||
|
<height>41</height> |
||||
|
</rect> |
||||
|
</property> |
||||
|
<property name="font"> |
||||
|
<font> |
||||
|
<pointsize>12</pointsize> |
||||
|
</font> |
||||
|
</property> |
||||
|
<item> |
||||
|
<property name="text"> |
||||
|
<string>(select extension)</string> |
||||
|
</property> |
||||
|
</item> |
||||
|
<item> |
||||
|
<property name="text"> |
||||
|
<string>Xournal++ (.xopp)</string> |
||||
|
</property> |
||||
|
</item> |
||||
|
</widget> |
||||
|
<widget class="QLabel" name="fileNameLabel"> |
||||
|
<property name="geometry"> |
||||
|
<rect> |
||||
|
<x>50</x> |
||||
|
<y>100</y> |
||||
|
<width>291</width> |
||||
|
<height>41</height> |
||||
|
</rect> |
||||
|
</property> |
||||
|
<property name="font"> |
||||
|
<font> |
||||
|
<pointsize>12</pointsize> |
||||
|
</font> |
||||
|
</property> |
||||
|
<property name="text"> |
||||
|
<string>Filename and File Type:</string> |
||||
|
</property> |
||||
|
</widget> |
||||
|
</widget> |
||||
|
<resources/> |
||||
|
<connections> |
||||
|
<connection> |
||||
|
<sender>buttonBox</sender> |
||||
|
<signal>accepted()</signal> |
||||
|
<receiver>newSectionDialog</receiver> |
||||
|
<slot>accept()</slot> |
||||
|
<hints> |
||||
|
<hint type="sourcelabel"> |
||||
|
<x>248</x> |
||||
|
<y>254</y> |
||||
|
</hint> |
||||
|
<hint type="destinationlabel"> |
||||
|
<x>157</x> |
||||
|
<y>274</y> |
||||
|
</hint> |
||||
|
</hints> |
||||
|
</connection> |
||||
|
<connection> |
||||
|
<sender>buttonBox</sender> |
||||
|
<signal>rejected()</signal> |
||||
|
<receiver>newSectionDialog</receiver> |
||||
|
<slot>reject()</slot> |
||||
|
<hints> |
||||
|
<hint type="sourcelabel"> |
||||
|
<x>316</x> |
||||
|
<y>260</y> |
||||
|
</hint> |
||||
|
<hint type="destinationlabel"> |
||||
|
<x>286</x> |
||||
|
<y>274</y> |
||||
|
</hint> |
||||
|
</hints> |
||||
|
</connection> |
||||
|
</connections> |
||||
|
</ui> |
@ -0,0 +1,244 @@ |
|||||
|
/* DrewTechs
|
||||
|
* Note Binder |
||||
|
* @Version 1.0 |
||||
|
*/ |
||||
|
|
||||
|
#include "newSectionGroupDialog.h" |
||||
|
#include "ui_newSectionGroupDialog.h" |
||||
|
|
||||
|
newSectionGroupDialog::newSectionGroupDialog(QStringList notebookColorList, QStringList notebookDirList, QStringList list, QWidget *parent) |
||||
|
: QDialog(parent) |
||||
|
, ui(new Ui::newSectionGroupDialog) |
||||
|
{ |
||||
|
setNotebookColorList(notebookColorList); |
||||
|
setNotebookDirList(notebookDirList); |
||||
|
setDirectories(list); |
||||
|
ui->setupUi(this); |
||||
|
init(); |
||||
|
} |
||||
|
|
||||
|
/* Destructor */ |
||||
|
newSectionGroupDialog::~newSectionGroupDialog() |
||||
|
{ |
||||
|
delete ui; |
||||
|
} |
||||
|
|
||||
|
|
||||
|
void newSectionGroupDialog::on_buttonBox_accepted() |
||||
|
{ |
||||
|
if(ui->fileNameBox->text() != "" && ui->directorySelection->currentText() != "") // Cannot have Empty Filename
|
||||
|
{ |
||||
|
QDir dir(getNotebookDirList().at(ui->directorySelection->currentIndex()) + QDir::separator() + ui->fileNameBox->text()); |
||||
|
if(!dir.exists()) |
||||
|
{ |
||||
|
directoryCreator(); |
||||
|
accept(); |
||||
|
} else { |
||||
|
QMessageBox messageBox; |
||||
|
messageBox.setWindowTitle("Error"); |
||||
|
messageBox.setText("This Section Group already exists!"); |
||||
|
messageBox.exec(); |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
void newSectionGroupDialog::on_buttonBox_rejected() |
||||
|
{ |
||||
|
reject(); |
||||
|
} |
||||
|
|
||||
|
void newSectionGroupDialog::addItemsToDirectory() |
||||
|
{ |
||||
|
int idx = 0; |
||||
|
for(idx = 0; idx < getDirectories().size(); idx++) |
||||
|
{ |
||||
|
if(!getDirectories().at(idx).startsWith(" ")) |
||||
|
{ |
||||
|
ui->directorySelection->addItem(SetNotebookIcon(notebookcolorlist.at(idx)), getDirectories().at(idx)); |
||||
|
} else { |
||||
|
ui->directorySelection->addItem(SetSectionGroupIcon(notebookcolorlist.at(idx)), getDirectories().at(idx)); |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
void newSectionGroupDialog::init() |
||||
|
{ |
||||
|
addItemsToDirectory(); |
||||
|
} |
||||
|
|
||||
|
void newSectionGroupDialog::directoryCreator() |
||||
|
{ |
||||
|
QString fileName, fullFilePath, fullDirPath, color; |
||||
|
setSgName(ui->fileNameBox->text()); // File Name without the Extension
|
||||
|
int itemLocation; |
||||
|
itemLocation = ui->directorySelection->currentIndex(); |
||||
|
fullDirPath = notebookdirList.at(itemLocation); |
||||
|
fullDirPath += QDir::separator() + sgName; |
||||
|
setSgDirectory(fullDirPath); |
||||
|
if(!QDir(sgDirectory).exists()) |
||||
|
{ |
||||
|
QDir().mkdir(fullDirPath); |
||||
|
} |
||||
|
setSgColor(ui->sectionGroupColorBox->currentText()); |
||||
|
fileName = "sectiongroup.sectgr"; |
||||
|
fullFilePath = fullDirPath + QDir::separator() + fileName; |
||||
|
setSgFileName(fullFilePath); |
||||
|
} |
||||
|
|
||||
|
QIcon newSectionGroupDialog::SetNotebookIcon(QString notebookColor) |
||||
|
{ |
||||
|
QIcon icon; |
||||
|
QString iconPath = "../NoteBinder/Icons"; |
||||
|
if(!QDir(iconPath).exists()) |
||||
|
{ |
||||
|
return icon; |
||||
|
} |
||||
|
if(notebookColor == "Red") { |
||||
|
icon = QIcon(iconPath + "/NotebookIcon_Red.png"); |
||||
|
} else if(notebookColor == "Blue") { |
||||
|
icon = QIcon(iconPath + "/NotebookIcon_Blue.png"); |
||||
|
} else if(notebookColor == "Purple") { |
||||
|
icon = QIcon(iconPath + "/NotebookIcon_Purple.png"); |
||||
|
} else if(notebookColor == "Orange") { |
||||
|
icon = QIcon(iconPath + "/NotebookIcon_Orange.png"); |
||||
|
} else if(notebookColor == "Yellow") { |
||||
|
icon = QIcon(iconPath + "/NotebookIcon_Yellow.png"); |
||||
|
} else if(notebookColor == "Green") { |
||||
|
icon = QIcon(iconPath + "/NotebookIcon_Green.png"); |
||||
|
} else if(notebookColor == "Cyan") { |
||||
|
icon = QIcon(iconPath + "/NotebookIcon_Cyan.png"); |
||||
|
} else if(notebookColor == "Tan") { |
||||
|
icon = QIcon(iconPath + "/NotebookIcon_Tan.png"); |
||||
|
} else if(notebookColor == "Teal") { |
||||
|
icon = QIcon(iconPath + "/NotebookIcon_Teal.png"); |
||||
|
} else if(notebookColor == "Red Chalk") { |
||||
|
icon = QIcon(iconPath + "/NotebookIcon_RedChalk.png"); |
||||
|
} else if(notebookColor == "Blue Mist") { |
||||
|
icon = QIcon(iconPath + "/NotebookIcon_BlueMist.png"); |
||||
|
} else if(notebookColor == "Purple Mist") { |
||||
|
icon = QIcon(iconPath + "/NotebookIcon_PurpleMist.png"); |
||||
|
} else if(notebookColor == "Magenta") { |
||||
|
icon = QIcon(iconPath + "/NotebookIcon_Magenta.png"); |
||||
|
} else if(notebookColor == "Lemon Lime") { |
||||
|
icon = QIcon(iconPath + "/NotebookIcon_LemonLime.png"); |
||||
|
} else if(notebookColor == "Apple") { |
||||
|
icon = QIcon(iconPath + "/NotebookIcon_Apple.png"); |
||||
|
} else if(notebookColor == "Silver") { |
||||
|
icon = QIcon(iconPath + "/NotebookIcon_Silver.png"); |
||||
|
} else if(notebookColor == "Black") { |
||||
|
icon = QIcon(iconPath + "/NotebookIcon_Black.png"); |
||||
|
} else { |
||||
|
// If it's either White/None or an invalid value, set to the white icon
|
||||
|
icon = QIcon(iconPath + "/NotebookIcon_White.png"); |
||||
|
} |
||||
|
return icon; |
||||
|
} |
||||
|
QIcon newSectionGroupDialog::SetSectionGroupIcon(QString sectionGroupColor) |
||||
|
{ |
||||
|
QIcon icon; |
||||
|
QString iconPath = "../NoteBinder/Icons"; |
||||
|
if(!QDir(iconPath).exists()) |
||||
|
{ |
||||
|
return icon; |
||||
|
} |
||||
|
if(sectionGroupColor == "Red") { |
||||
|
icon = QIcon(iconPath + "/SectionGroupIcon_Red.png"); |
||||
|
} else if(sectionGroupColor == "Blue") { |
||||
|
icon = QIcon(iconPath + "/SectionGroupIcon_Blue.png"); |
||||
|
} else if(sectionGroupColor == "Purple") { |
||||
|
icon = QIcon(iconPath + "/SectionGroupIcon_Purple.png"); |
||||
|
} else if(sectionGroupColor == "Orange") { |
||||
|
icon = QIcon(iconPath + "/SectionGroupIcon_Orange.png"); |
||||
|
} else if(sectionGroupColor == "Yellow") { |
||||
|
icon = QIcon(iconPath + "/SectionGroupIcon_Yellow.png"); |
||||
|
} else if(sectionGroupColor == "Green") { |
||||
|
icon = QIcon(iconPath + "/SectionGroupIcon_Green.png"); |
||||
|
} else if(sectionGroupColor == "Cyan") { |
||||
|
icon = QIcon(iconPath + "/SectionGroupIcon_Cyan.png"); |
||||
|
} else if(sectionGroupColor == "Tan") { |
||||
|
icon = QIcon(iconPath + "/SectionGroupIcon_Tan.png"); |
||||
|
} else if(sectionGroupColor == "Teal") { |
||||
|
icon = QIcon(iconPath + "/SectionGroupIcon_Teal.png"); |
||||
|
} else if(sectionGroupColor == "Red Chalk") { |
||||
|
icon = QIcon(iconPath + "/SectionGroupIcon_RedChalk.png"); |
||||
|
} else if(sectionGroupColor == "Blue Mist") { |
||||
|
icon = QIcon(iconPath + "/SectionGroupIcon_BlueMist.png"); |
||||
|
} else if(sectionGroupColor == "Purple Mist") { |
||||
|
icon = QIcon(iconPath + "/SectionGroupIcon_PurpleMist.png"); |
||||
|
} else if(sectionGroupColor == "Magenta") { |
||||
|
icon = QIcon(iconPath + "/SectionGroupIcon_Magenta.png"); |
||||
|
} else if(sectionGroupColor == "Lemon Lime") { |
||||
|
icon = QIcon(iconPath + "/SectionGroupIcon_LemonLime.png"); |
||||
|
} else if(sectionGroupColor == "Apple") { |
||||
|
icon = QIcon(iconPath + "/SectionGroupIcon_Apple.png"); |
||||
|
} else if(sectionGroupColor == "Silver") { |
||||
|
icon = QIcon(iconPath + "/SectionGroupIcon_Silver.png"); |
||||
|
} else if(sectionGroupColor == "Black") { |
||||
|
icon = QIcon(iconPath + "/SectionGroupIcon_Black.png"); |
||||
|
} else { |
||||
|
// If it's either White/None or an invalid value, set to the white icon
|
||||
|
icon = QIcon(iconPath + "/SectionGroupIcon_White.png"); |
||||
|
} |
||||
|
return icon; |
||||
|
} |
||||
|
|
||||
|
/* Getter Functions */ |
||||
|
QStringList newSectionGroupDialog::getDirectories() const |
||||
|
{ |
||||
|
return var_directoryList; |
||||
|
} |
||||
|
QStringList newSectionGroupDialog::getNotebookDirList() const |
||||
|
{ |
||||
|
return notebookdirList; |
||||
|
} |
||||
|
QStringList newSectionGroupDialog::getNotebookColorList() const |
||||
|
{ |
||||
|
return notebookcolorlist; |
||||
|
} |
||||
|
QString newSectionGroupDialog::getSgName() const |
||||
|
{ |
||||
|
return sgName; |
||||
|
} |
||||
|
QString newSectionGroupDialog::getSgDirectory() const |
||||
|
{ |
||||
|
return sgDirectory; |
||||
|
} |
||||
|
QString newSectionGroupDialog::getSgFileName() const |
||||
|
{ |
||||
|
return sgFileName; |
||||
|
} |
||||
|
QString newSectionGroupDialog::getSgColor() const |
||||
|
{ |
||||
|
return sgColor; |
||||
|
} |
||||
|
|
||||
|
|
||||
|
/* Setter Functions */ |
||||
|
void newSectionGroupDialog::setDirectories(QStringList dirList) |
||||
|
{ |
||||
|
var_directoryList = dirList; |
||||
|
} |
||||
|
void newSectionGroupDialog::setNotebookDirList(QStringList nbDirList) |
||||
|
{ |
||||
|
notebookdirList = nbDirList; |
||||
|
} |
||||
|
void newSectionGroupDialog::setNotebookColorList(QStringList nbColorList) |
||||
|
{ |
||||
|
notebookcolorlist = nbColorList; |
||||
|
} |
||||
|
void newSectionGroupDialog::setSgName(QString newSgName) |
||||
|
{ |
||||
|
sgName = newSgName; |
||||
|
} |
||||
|
void newSectionGroupDialog::setSgDirectory(QString newSgDirectory) |
||||
|
{ |
||||
|
sgDirectory = newSgDirectory; |
||||
|
} |
||||
|
void newSectionGroupDialog::setSgFileName(QString newSgFileName) |
||||
|
{ |
||||
|
sgFileName = newSgFileName; |
||||
|
} |
||||
|
void newSectionGroupDialog::setSgColor(QString newSgColor) |
||||
|
{ |
||||
|
sgColor = newSgColor; |
||||
|
} |
Loading…
Reference in new issue