diff --git a/rm_cache.sh b/rm_cache.sh index 4fca4941..97bd58fb 100755 --- a/rm_cache.sh +++ b/rm_cache.sh @@ -1,5 +1,6 @@ #!/bin/bash +rm -rf src/CodeKeeper/build rm src/CodeKeeper/CodeKeeper.pro.user rm src/CodeKeeper/CodeKeeper.pro.user.1f90c22 rm src/CodeKeeper/main.o @@ -35,4 +36,4 @@ rm src/CodeKeeper/settingswindow.o rm src/CodeKeeper/syncwindow.o rm src/CodeKeeper/ui_qplaintexteditsearchwidget.h -echo "Done!" \ No newline at end of file +echo "Done!" diff --git a/src/CodeKeeper/keeperFunc/functional.cpp b/src/CodeKeeper/keeperFunc/functional.cpp index f8ffa7bb..4bc2e71c 100644 --- a/src/CodeKeeper/keeperFunc/functional.cpp +++ b/src/CodeKeeper/keeperFunc/functional.cpp @@ -48,6 +48,14 @@ void MainWindow::getSettingsData() isVisibleFolders = globalSettings->value("isVisibleFolders", true).toBool(); isVisiblePreview = globalSettings->value("isVisiblePreview", false).toBool(); isViewMode = globalSettings->value("isViewMode", false).toBool(); + git_repo = globalSettings->value("git_repo").value(); + git_user = globalSettings->value("git_user").value(); + git_token = globalSettings->value("git_token").value(); + isAutoSyncB = globalSettings->value("isAutoSync").value(); + + qDebug() << dir << selectedFont << font_size << theme << isCustomTitlebar << sortNotesRole + << isAutoSyncing << isVisibleNotesList << isVisibleFolders << isVisiblePreview + << isViewMode << git_repo << git_user << git_token << isAutoSyncB; } void MainWindow::setConnectionStatus() diff --git a/src/CodeKeeper/keeperFunc/notesFunc.cpp b/src/CodeKeeper/keeperFunc/notesFunc.cpp index 4a398ec1..1621ee90 100644 --- a/src/CodeKeeper/keeperFunc/notesFunc.cpp +++ b/src/CodeKeeper/keeperFunc/notesFunc.cpp @@ -1,7 +1,9 @@ #include #include #include +#include #include +#include QModelIndex indexFromItem(QTreeWidgetItem *item, int column) { } @@ -20,6 +22,49 @@ bool createFile(const QString &path) } } +void MainWindow::exportNoteToPdf() +{ + QModelIndex selectedIndex = notesList->currentIndex(); + QFileSystemModel *fileSystemModel = static_cast(notesList->model()); + QString filePath = fileSystemModel->filePath(selectedIndex); + qDebug() << "File Path: " << filePath; + + QFile markdownFile(filePath); +} + +void MainWindow::exportNoteToHtml() +{ + QModelIndex selectedIndex = notesList->currentIndex(); + QFileSystemModel *fileSystemModel = static_cast(notesList->model()); + QString filePath = fileSystemModel->filePath(selectedIndex); + qDebug() << "File Path: " << filePath; + + QString str = QFileDialog::getSaveFileName(0, "Enter filename"); + QString html_file = str + ".html"; + + QString md = noteEdit->toPlainText(); + + QString html; + md_html( + md.toUtf8().constData(), md.length(), + [](const MD_CHAR *html, MD_SIZE html_size, void *userdata) { + QString *htmlPtr = static_cast(userdata); + QString htmlStr(QString::fromUtf8(reinterpret_cast(html), html_size)); + *htmlPtr += htmlStr; + }, + &html, 0, 0); + + QFile file(html_file); + if (file.open(QIODevice::WriteOnly)) { + QTextStream stream(&file); + stream << html; + file.close(); + qDebug() << "File saved successfully at" << filePath; + } else { + qDebug() << "Error, Failed to open file for writing."; + } +} + void MainWindow::loadNotes() { dir = globalSettings->value("path").value(); @@ -54,236 +99,6 @@ void MainWindow::setSortByName() notesList->sortByColumn(0, Qt::SortOrder()); } -void MainWindow::updateMDPreview() -{ - QString md = noteEdit->toPlainText(); - - QString html; - md_html( - md.toUtf8().constData(), md.length(), - [](const MD_CHAR *html, MD_SIZE html_size, void *userdata) { - QString *htmlPtr = static_cast(userdata); - QString htmlStr(QString::fromUtf8(reinterpret_cast(html), html_size)); - *htmlPtr += htmlStr; - }, - &html, 0, 0); - html += ""; - - QString html_result = - "" - "" - "" - "" - + html; - - mdPreview->setHtml(html_result); -} - void MainWindow::saveNote() { QModelIndex index = notesList->currentIndex(); @@ -618,3 +433,233 @@ void MainWindow::setTable() noteEdit->setTextCursor(cursor); } + +void MainWindow::updateMDPreview() +{ + QString md = noteEdit->toPlainText(); + + QString html; + md_html( + md.toUtf8().constData(), md.length(), + [](const MD_CHAR *html, MD_SIZE html_size, void *userdata) { + QString *htmlPtr = static_cast(userdata); + QString htmlStr(QString::fromUtf8(reinterpret_cast(html), html_size)); + *htmlPtr += htmlStr; + }, + &html, 0, 0); + html += ""; + + QString html_result = + "" + "" + "" + "" + + html; + + mdPreview->setHtml(html_result); +} diff --git a/src/CodeKeeper/mainwindow.cpp b/src/CodeKeeper/mainwindow.cpp index 59e7d591..f5033f23 100644 --- a/src/CodeKeeper/mainwindow.cpp +++ b/src/CodeKeeper/mainwindow.cpp @@ -108,7 +108,10 @@ MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent) menuLayout->setAlignment(Qt::AlignHCenter); QStringList filters; - filters << "" << "*.md" << "*.html" << "*.txt"; + filters << "" + << "*.md" + << "*.html" + << "*.txt"; iconProvider = new CustomIconProvider(); @@ -225,8 +228,8 @@ MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent) QMenu *exportMenu = new QMenu("Export as", menu); exportMenu->setIcon(QIcon(":/export.png")); - exportToHtml = exportMenu->addAction("HTML"); - exportToPdf = exportMenu->addAction("Pdf"); + exportToHtml = exportMenu->addAction("HTML", this, SLOT(exportNoteToHtml())); + exportToPdf = exportMenu->addAction("Pdf", this, SLOT(exportNoteToPdf())); menu->addMenu(editMenu); menu->addMenu(viewMenu); diff --git a/src/CodeKeeper/mainwindow.h b/src/CodeKeeper/mainwindow.h index 9fa31684..b39c743b 100644 --- a/src/CodeKeeper/mainwindow.h +++ b/src/CodeKeeper/mainwindow.h @@ -100,6 +100,11 @@ class MainWindow : public QMainWindow int sortNotesRole; bool isAutoSyncing; + QString git_repo; + QString git_user; + QString git_token; + bool isAutoSyncB; + QFileSystemModel *notesDirModel; QFileSystemModel *noteFileModel; @@ -183,6 +188,9 @@ private slots: void create_tasks_connection(); void create_projects_connection(); + void exportNoteToPdf(); + void exportNoteToHtml(); + void updateTaskStatus(QString *task, QString *status, QString *cT); void updateTaskData(QString *task, QString *status, QString *cT); void onMovingTaskFrom(QListWidgetItem *item, QListWidget *list); diff --git a/src/CodeKeeper/settingsFunc/functional.cpp b/src/CodeKeeper/settingsFunc/functional.cpp index f649391f..d6f192fd 100644 --- a/src/CodeKeeper/settingsFunc/functional.cpp +++ b/src/CodeKeeper/settingsFunc/functional.cpp @@ -76,7 +76,7 @@ void SettingsWindow::saveData() void SettingsWindow::fopenFolder() { - QString str = QFileDialog::getExistingDirectory(0, "Select a directory"); + QString str = QFileDialog::getExistingDirectory(this, "Select Folder"); if (!str.isEmpty()) { qDebug() << str; globalSettings->setValue("path", str);