noblenote-1.2.0/ 0000775 0001750 0001750 00000000000 13514615415 012510 5 ustar chris chris noblenote-1.2.0/nobleNote.pro 0000664 0001750 0001750 00000006257 13502176303 015164 0 ustar chris chris TEMPLATE = app
TARGET = bin/noblenote
DEPENDPATH = . src
INCLUDEPATH = . src
OBJECTS_DIR = build
MOC_DIR = build
UI_DIR = build
RCC_DIR = build
QT += gui widgets concurrent
win32 {
#QMAKE_LFLAGS += -static-libgcc
# use these for windows builds release builds only because debugging
#symbols wont be linked if only release is specified
#CONFIG -= debug_and_release
#CONFIG += release
RC_FILE += icon.rc
}
system(lrelease nobleNote.pro)
# BUILDTIME and BUILDDATE will be shown in the About dialog
win32 {
DEFINES += BUILDTIME=\\\"$$system('echo %time%')\\\"
DEFINES += BUILDDATE=\\\"$$system('echo %date%')\\\"
} else {
DEFINES += BUILDTIME=\\\"$$system(date '+%H:%M.%s')\\\"
DEFINES += BUILDDATE=\\\"$$system(date '+%d/%m/%y')\\\"
}
QMAKE_DISTCLEAN = src/translations/*.qm
# Input
HEADERS = src/mainwindow.h src/note.h \
src/welcome.h \
src/filesystemmodel.h \
src/preferences.h \
src/findfilesystemmodel.h \
src/findfilemodel.h \
src/lineedit.h \
src/textbrowser.h \
src/xorcipher.h \
src/textformattingtoolbar.h \
src/highlighter.h src/textsearchtoolbar.h \
src/xmlnotewriter.h \
src/xmlnotereader.h \
src/datetime.h \
src/textdocument.h \
src/notedescriptor.h \
src/abstractnotereader.h \
src/htmlnotereader.h \
src/htmlnotewriter.h \
src/fileiconprovider.h \
src/backup.h \
src/trash.h \
src/progressreceiver.h \
src/noteimporter.h
FORMS = src/ui/mainwindow.ui src/ui/welcome.ui src/ui/note.ui \
src/ui/preferences.ui src/ui/trash.ui
SOURCES = src/main.cpp src/mainwindow.cpp src/note.cpp \
src/welcome.cpp\
src/preferences.cpp \
src/findfilemodel.cpp \
src/findfilesystemmodel.cpp src/lineedit.cpp src/textbrowser.cpp \
src/xorcipher.cpp \
src/textformattingtoolbar.cpp \
src/highlighter.cpp src/textsearchtoolbar.cpp \
src/xmlnotewriter.cpp \
src/xmlnotereader.cpp \
src/textdocument.cpp \
src/notedescriptor.cpp \
src/htmlnotereader.cpp \
src/htmlnotewriter.cpp \
src/datetime.cpp \
src/fileiconprovider.cpp \
src/backup.cpp \
src/trash.cpp \
src/progressreceiver.cpp \
src/noteimporter.cpp
RESOURCES += nobleNote.qrc
TRANSLATIONS = src/translations/noblenote_ast.ts\
src/translations/noblenote_cs.ts\
src/translations/noblenote_de.ts\
src/translations/noblenote_de_DE.ts\
src/translations/noblenote_es.ts\
src/translations/noblenote_gl.ts\
src/translations/noblenote_ms.ts\
src/translations/noblenote_pl.ts\
src/translations/noblenote_ru.ts\
src/translations/noblenote_uk.ts
!win32{
# install
target.path = /usr/bin
icons.files = src/noblenote-icons/*
icons.path = /usr/share/pixmaps/noblenote-icons
translation.files = src/translations/*.qm
translation.path = /usr/share/noblenote/translations
autostart.files = autostart/noblenote.desktop
autostart.path = /usr/share/applications
INSTALLS = target icons translation autostart
deinstall.depends = uninstall FORCE
deinstall.commands = rm -R /usr/share/noblenote
QMAKE_EXTRA_TARGETS = deinstall
}
OTHER_FILES += \
icon.rc \
src/noblenote-icons/noblenote.ico
noblenote-1.2.0/nobleNote.qrc 0000664 0001750 0001750 00000003120 13502165236 015136 0 ustar chris chris version.txtsrc/noblenote-icons/noblenote_64x64.pngsrc/noblenote-icons/format-text-bold.pngsrc/noblenote-icons/format-text-italic.pngsrc/noblenote-icons/format-text-strikethrough.pngsrc/noblenote-icons/format-text-underline.pngsrc/noblenote-icons/fileclose.pngsrc/noblenote-icons/emblem-web.pngsrc/noblenote-icons/foldernew.pngsrc/noblenote-icons/filenew.pngsrc/noblenote-icons/folderremove.pngsrc/noblenote-icons/fileremove.pngsrc/noblenote-icons/folderrename.pngsrc/noblenote-icons/filerename.pngsrc/noblenote-icons/file.pngsrc/noblenote-icons/cut_file.pngsrc/noblenote-icons/folder.pngsrc/noblenote-icons/clearFormatting.pngsrc/noblenote-icons/trash.pngsrc/noblenote-icons/preferences.pngsrc/noblenote-icons/bulletpoints.png
noblenote-1.2.0/src/ 0000775 0001750 0001750 00000000000 13513631003 013265 5 ustar chris chris noblenote-1.2.0/src/textbrowser.cpp 0000664 0001750 0001750 00000004123 13502176303 016366 0 ustar chris chris /* nobleNote, a note taking application
* Copyright (C) 2019 Christian Metscher ,
Fabian Deuchler
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
* nobleNote is licensed under the MIT, see `http://copyfree.org/licenses/mit/license.txt'.
*/
#include "textbrowser.h"
#include
#include
TextBrowser::TextBrowser(QWidget *parent) : QTextBrowser(parent)
{
this->viewport()->setCursor(Qt::IBeamCursor);
setOpenLinks(false); // also disables external links
connect(this,SIGNAL(anchorClicked(QUrl)),this,SLOT(openLinkInBrowser(QUrl))); // because all links should be opened in the web browser
}
void TextBrowser::focusInEvent(QFocusEvent *event){
emit signalFocusInEvent();
QTextEdit::focusInEvent(event);
}
void TextBrowser::focusOutEvent(QFocusEvent *e)
{
emit signalFocusOutEvent();
QTextEdit::focusOutEvent(e);
}
void TextBrowser::openLinkInBrowser(const QUrl link)
{
QDesktopServices::openUrl(link);
}
void TextBrowser::slotSetReadOnly(bool ro)
{
this->setReadOnly(ro);
}
noblenote-1.2.0/src/noteimporter.h 0000664 0001750 0001750 00000004554 13502176303 016202 0 ustar chris chris /* nobleNote, a note taking application
* Copyright (C) 2019 Christian Metscher ,
Fabian Deuchler
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
* nobleNote is licensed under the MIT, see `http://copyfree.org/licenses/mit/license.txt'.
*/
#ifndef NOTEIMPORTER_H
#define NOTEIMPORTER_H
#include
#include
#include
#include "htmlnotewriter.h"
#include "progressreceiver.h"
#if QT_VERSION >= 0x050000
#include
#include
#else
#include
#include
#endif
class NoteImporter : public QObject
{
Q_OBJECT
public:
explicit NoteImporter(QObject *parent = 0);
public slots:
void importDialog();
signals:
private slots:
void importXmlNotes();
private:
struct Xml2HtmlFunctor
{
ProgressReceiver *p;
QString path;
void operator()(const QString &file)
{
HtmlNoteWriter::writeXml2Html(file,path);
p->postProgressEvent();
}
};
Xml2HtmlFunctor xml2HtmlFunctor;
QProgressDialog *dialog;
ProgressReceiver *progressReceiver;
QFutureWatcher *futureWatcher;
QStringList importFiles;
QPointer fileDialog;
QWidget * parentWidget;
};
#endif // NOTEIMPORTER_H
noblenote-1.2.0/src/progressreceiver.cpp 0000664 0001750 0001750 00000005126 13502176303 017373 0 ustar chris chris /* nobleNote, a note taking application
* Copyright (C) 2019 Christian Metscher ,
Fabian Deuchler
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
* nobleNote is licensed under the MIT, see `http://copyfree.org/licenses/mit/license.txt'.
*/
#include "progressreceiver.h"
#include
#include
#include
ProgressReceiver::ProgressReceiver(QObject *parent) :
QObject(parent)
{
interval_ = 20;
value_ = 0;
time_ = QTime::currentTime();
}
// if the event user type collides with an existing user type, the static_cast in the
// event method fails
const int userTypeOffset = 314;
void ProgressReceiver::postProgressEvent()
{
value_ = ++value_; // the number of the currently processed item
ProgressEvent * me = new ProgressEvent(static_cast(QEvent::User + userTypeOffset));
me->value = value_;
// only report periodically
if(QTime::currentTime() > time_)
{
time_ = time_.addMSecs(interval_);
// ProgressReceiver now receives a event with the current progress
QCoreApplication::postEvent(this,me);
}
}
bool ProgressReceiver::event(QEvent *e)
{
ProgressEvent * me = 0; // new nullpointer constant in c++11
// is MyEvent type?
if(e->type() == QEvent::User +userTypeOffset)
{
me = static_cast(e); // downcast
// report progress
if(me)
{
emit valueChanged(me->value);
return true;
}
}
// important!
return QObject::event(e);
}
noblenote-1.2.0/src/findfilemodel.h 0000664 0001750 0001750 00000006112 13502176303 016244 0 ustar chris chris /* nobleNote, a note taking application
* Copyright (C) 2019 Christian Metscher ,
Fabian Deuchler
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
* nobleNote is licensed under the MIT, see `http://copyfree.org/licenses/mit/license.txt'.
*/
#ifndef FINDFILEMODEL_H
#define FINDFILEMODEL_H
#include
#include
#include
#include
#include
#include
#include
/**
* @brief a model that shows a list of files
*
*/
class FindFileModel : public QStandardItemModel
{
Q_OBJECT
public:
explicit FindFileModel(QObject *parent = 0);
QString fileName(const QModelIndex & index) const;
QString filePath(const QModelIndex & index) const;
bool remove(const QModelIndex & index);
QFileInfo fileInfo(const QModelIndex & index) const;
void appendFile(QString filePath); // append file with full path
static QStringList find0(const QString &searchName, const QString &searchText,const QString& path); // searchName and searchText can be null QStrings
void findInFiles(const QString &path, const QString& fileName, const QString &content);
QStringList mimeTypes() const;
QMimeData * mimeData(const QModelIndexList &indexes) const;
bool setData(const QModelIndex &index, const QVariant &value, int role); // returns if rename succeeded, overwritten to enable QAbstractItemView::edit
qint64 size(const QModelIndex &index) const; // returns the file size in bytes
private:
struct FileContains // functor that checks if a text file (read as html) contains a given text
{
QString fileName;
QString content;
bool operator()(const QString& htmlFilePath);
private:
bool fileContentContains(const QString& htmlFilePath);
};
QFuture future;
FileContains fileContainsFunctor;
QFutureWatcher futureWatcher;
private slots:
void findInFilesFinished(); // populate model with find results
void restoreOverrideCursor();
};
#endif // FINDFILEMODEL_H
noblenote-1.2.0/src/xmlnotewriter.cpp 0000664 0001750 0001750 00000013053 13502176303 016723 0 ustar chris chris /* nobleNote, a note taking application
* Copyright (C) 2019 Christian Metscher ,
Fabian Deuchler
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
* nobleNote is licensed under the MIT, see `http://copyfree.org/licenses/mit/license.txt'.
*/
#include "xmlnotewriter.h"
#include "datetime.h"
#include
#include
#include
#include
#include
XmlNoteWriter::XmlNoteWriter() :frame_(NULL)
{
}
XmlNoteWriter::XmlNoteWriter(const QString &filePath) : file(filePath)
{
if(!file.open(QIODevice::WriteOnly))
{
//qDebug(qPrintable(QString("XmlNoteWriter::XmlNoteWriter failed : could not open filepath ") + QDir::toNativeSeparators(filePath)));
return;
}
QXmlStreamWriter::setDevice(&file);
}
// must write well formed xml 1.0 for QXmlStreamReader compatibility
void XmlNoteWriter::write()
{
if(!this->QXmlStreamWriter::device() || !frame_)
{
qDebug("XmlNoteWriter::write failed: textframe NULL or output device are NULL");
return;
}
setAutoFormatting(true);
writeStartDocument();
writeStartElement("note");
writeAttribute("version","0.3");
writeNamespace("http://example.com","link");
if(!uuid_.isNull())
{
QString uuidStr = uuid_.toString().remove(0,1); // uuid without the { } braces
uuidStr.chop(1);
writeTextElement("id","urn:uuid:" + uuidStr);
}
else
{
qDebug("XmlNoteWriter::write() : UUID is null, using generated UUID");
QString uuidStr = QUuid::createUuid().toString().remove(0,1);
uuidStr.chop(1);
writeTextElement("id","urn:uuid:" + uuidStr);
}
writeTextElement("title",frame_->document()->metaInformation(QTextDocument::DocumentTitle));
writeStartElement("text");
writeAttribute("xml:space","preserve");
writeStartElement("note-content");
// tomboy compatibility
writeAttribute("version","0.1");
for(QTextFrame::Iterator it = frame_->begin(); it != frame_->end(); ++it)
{
// QTextCursor cursor(it.currentBlock());
// cursor.movePosition(QTextCursor::PreviousBlock);
// cursor.movePosition(QTextCursor::EndOfBlock);
// cursor.movePosition(QTextCursor::NextBlock,QTextCursor::KeepAnchor);
// writeCharacters(cursor.selectedText().replace(QChar(QChar::ParagraphSeparator),QString('\n')));
// qDebug() << "selected Text:" << cursor.selectedText();
for(QTextBlock::Iterator blit = it.currentBlock().begin(); blit != it.currentBlock().end(); ++blit)
{
//qDebug("block iteration");
int elements = 0;
if(blit.fragment().charFormat().fontItalic())
writeStartElement("italic"),++elements;
if(blit.fragment().charFormat().fontStrikeOut())
writeStartElement("strikethrough"),++elements;
if(blit.fragment().charFormat().fontWeight() > QFont::Normal)
writeStartElement("bold"),++elements;
if(blit.fragment().charFormat().underlineStyle() != QTextCharFormat::NoUnderline)
writeStartElement("underline"),++elements;
writeCharacters(blit.fragment().text().replace(QChar(QChar::ParagraphSeparator),QString('\n')));
//writeCharacters(QString('\n'));
for(int i = 0; iapplicationName());
writeEndElement();
writeEndElement(); // "note"
writeEndDocument();
}
noblenote-1.2.0/src/welcome.cpp 0000664 0001750 0001750 00000011252 13502176303 015432 0 ustar chris chris /* nobleNote, a note taking application
* Copyright (C) 2019 Christian Metscher ,
Fabian Deuchler
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
* nobleNote is licensed under the MIT, see `http://copyfree.org/licenses/mit/license.txt'.
*/
#include "welcome.h"
#include "lineedit.h"
#include
#include
Welcome::Welcome(QWidget *parent): QDialog(parent)
{
setupUi(this);
isPortable = QSettings().value("isPortable",false).toBool();
path = new LineEdit(this);
if(isPortable)
defaultPath = QDir::toNativeSeparators(qApp->applicationDirPath() + "/" + qApp->applicationName());
else
defaultPath = QDir::toNativeSeparators(QDir::homePath() + "/" + qApp->applicationName());
path->setText(defaultPath);
gridLayout->addWidget(path, 3, 0, 1, 1);
connect(browse, SIGNAL(clicked(bool)), this, SLOT(openDir()));
connect(this, SIGNAL(accepted()), this, SLOT(setRootDir()));
}
void Welcome::openDir(){
QString standardPath;
if(isPortable)
standardPath = qApp->applicationDirPath();
else
standardPath = QDir::homePath();
QString str = QFileDialog::getExistingDirectory(this,
tr("Choose a directory"), standardPath,
QFileDialog::ShowDirsOnly | QFileDialog::DontResolveSymlinks);
if(str != "")
path->setText(str);
else
path->setText(defaultPath);
}
void Welcome::setRootDir(){
if(path->text() == "")
QSettings().setValue("root_path", defaultPath);
else
QSettings().setValue("root_path", path->text());
}
void Welcome::getInstance(bool rootPathIsSet, bool rootPathExists, bool rootPathIsWritable)
{
if(isPortable)
{
if(!rootPathIsSet)
welcomeText->setText(tr("Welcome to nobleNote!\nThis is the first time that nobleNote has been started.\n"
"This is the portable edition of nobleNote.\n"
"You are encouraged to use the default path, but you can also choose any other directory."
));
if(rootPathIsSet && !rootPathExists)
welcomeText->setText(tr("Welcome to nobleNote!\nThe set path for the notes does not exist.\n"
"Maybe it has been moved or renamed.\n"
"You can choose a new directory where the notes are or where they will be saved in."));
if(rootPathExists && !rootPathIsWritable)
welcomeText->setText(tr("Welcome to nobleNote!\nThe path where the notes are located is not writable.\n"
"Maybe your drive is running in read only mode."));
}
else
{
if(!rootPathIsSet)
welcomeText->setText(tr("Welcome to nobleNote!\nThis is the first time that nobleNote has been started.\n"
"You can choose a directory where the notes will be saved in."));
if(rootPathIsSet && !rootPathExists)
welcomeText->setText(tr("Welcome to nobleNote!\nThe set path for the notes does not exist.\n"
"Maybe it has been moved or renamed.\n"
"You can choose a new directory where the notes are or where they will be saved in."));
if(rootPathExists && !rootPathIsWritable)
welcomeText->setText(tr("Welcome to nobleNote!\nThe path where the notes are located is not writable.\n"
"You can choose a new directory where the notes will be saved in. "
"Otherwise changes might not be saved."));
}
}
noblenote-1.2.0/src/fileiconprovider.h 0000664 0001750 0001750 00000003376 13502176303 017017 0 ustar chris chris /* nobleNote, a note taking application
* Copyright (C) 2019 Christian Metscher ,
Fabian Deuchler
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
* nobleNote is licensed under the MIT, see `http://copyfree.org/licenses/mit/license.txt'.
*/
#ifndef FILEICONPROVIDER_H
#define FILEICONPROVIDER_H
#include
/**
* @brief The FileIconProvider class provides icons for the note and folder lists
*/
class FileIconProvider : public QFileIconProvider
{
public:
FileIconProvider();
/*override*/ QIcon icon ( const QFileInfo & info ) const;
inline void setCutFiles(QStringList files) {this->cutFiles = files;}
private:
QStringList cutFiles;
};
#endif // FILEICONPROVIDER_H
noblenote-1.2.0/src/mainwindow.h 0000664 0001750 0001750 00000013364 13502176303 015626 0 ustar chris chris /* nobleNote, a note taking application
* Copyright (C) 2019 Christian Metscher ,
Fabian Deuchler
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
* nobleNote is licensed under the MIT, see `http://copyfree.org/licenses/mit/license.txt'.
*/
#ifndef NOBLENOTE_H
#define NOBLENOTE_H
#include "ui_mainwindow.h"
#include "htmlnotewriter.h"
#include "progressreceiver.h"
#include "noteimporter.h"
#include
#include
#if QT_VERSION >= 0x050000
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#else
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#endif
#include
/**
* @brief note taking application main window
*
* nb short for notebook
* n short for note
* f short for folder
*/
//#define NO_SYSTEM_TRAY_ICON
class Welcome;
class FileIconProvider;
class Preferences;
class FindFileModel;
class FindFileSystemModel;
class FileSystemModel;
class LineEdit;
class Note;
class Highlighter;
class ProgressReceiver;
class Backup;
class FlickCharm;
class MainWindow : public QMainWindow, public Ui::MainWindow
{
Q_OBJECT // important for creating own singals and slots
public:
MainWindow();
~MainWindow();
public slots:
void showOpenNotes();
void quit();
private:
Welcome *welcome;
QFileSystemWatcher *fileWatcher;
FileIconProvider *folderIconProvider, *noteIconProvider;
QSplitter *splitter;
LineEdit *searchName, *searchText;
FindFileSystemModel *folderModel;
FileSystemModel *noteFSModel;
FindFileSystemModel *noteModel;
QListView *folderView, *noteView;
QAction *quit_action, *minimizeRestoreAction;
QPointer pref;
QHBoxLayout *hBoxLayout;
FindFileModel *findNoteModel;
QList > openNotes; // every access to openNotes must check for null pointers
QPointer backup;
QStringList shortcutNoteList;
NoteImporter * noteImporter;
#ifndef NO_SYSTEM_TRAY_ICON
QMenu *iMenu;
QSystemTrayIcon *TIcon;
#endif
Note * noteWindow(const QString & filePath); // return the open note window for the note at filePath
bool noteIsOpen(const QString &path);
QString getToBerenamedNotebook; //used for recent file list
private slots:
void writeBackupDirPath();
void changeRootIndex();
void makeStandardPaths();
void enableNoteMenu(const QItemSelection &selected, const QItemSelection &deselected);
void showPreferences();
void showBackupWindow();
void folderActivated(const QModelIndex &selected);
void folderActivated(const QItemSelection &selected, const QItemSelection &deselected); //Wrapper
void noteActivated(const QModelIndex &selected);
void noteActivated(const QItemSelection &selected, const QItemSelection &deselected); //Wrapper
#ifndef NO_SYSTEM_TRAY_ICON
void iconActivated(QSystemTrayIcon::ActivationReason reason);
void tray_actions();
#endif
void find();
void openNote(const QModelIndex &ind);
void openOneNote(QString path);
void openAllNotes();
void createAndUpdateRecent();
void openRecent();
void openNoteSource();
void showContextMenuFolder(const QPoint &pos);
void showContextMenuNote(const QPoint &pos);
void newFolder();
void newNote();
void renameFolder();
void renameNote();
void removeFolder();
void removeNote();
void setKineticScrollingEnabled(bool b);
void folderRenameFinished( QWidget * editor, QAbstractItemDelegate::EndEditHint hint = QAbstractItemDelegate::NoHint ); // reloads current folder
void noteRenameFinished(const QString &path, const QString &oldName, const QString &newName); // updates window title
void getCutFiles();
void pasteFiles();
void about();
void selectFolder();
protected:
void keyPressEvent(QKeyEvent *k);
virtual void closeEvent(QCloseEvent* window_close);
virtual void showEvent(QShowEvent* window_show);
virtual void hideEvent(QHideEvent* window_hide);
};
#endif
noblenote-1.2.0/src/findfilemodel.cpp 0000664 0001750 0001750 00000015756 13502176303 016615 0 ustar chris chris /* nobleNote, a note taking application
* Copyright (C) 2019 Christian Metscher ,
Fabian Deuchler
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
* nobleNote is licensed under the MIT, see `http://copyfree.org/licenses/mit/license.txt'.
*/
#include "findfilemodel.h"
#include
#include
#include
#include
#include
#include
#include
#include
#include
FindFileModel::FindFileModel(QObject *parent) :
QStandardItemModel(parent)
{
connect(&futureWatcher,SIGNAL(finished()),this,SLOT(findInFilesFinished()));
connect(&futureWatcher, SIGNAL(canceled()), this, SLOT(restoreOverrideCursor()));
}
QString FindFileModel::fileName(const QModelIndex &index) const
{
return QFileInfo(itemFromIndex(index)->data(Qt::UserRole + 1).toString()).fileName();
}
QString FindFileModel::filePath(const QModelIndex &index) const
{
return QFileInfo(itemFromIndex(index)->data(Qt::UserRole + 1).toString()).filePath();
}
qint64 FindFileModel::size(const QModelIndex &index) const
{
return QFileInfo(itemFromIndex(index)->data(Qt::UserRole + 1).toString()).size();
}
bool FindFileModel::remove(const QModelIndex &index)
{
QStandardItem * item = itemFromIndex(index);
if(!item)
{
qWarning("FindFileModel::remove failed: itemFromIndex returned NULL");
return false;
}
QString filePath = item->data(Qt::UserRole + 1).toString();
bool b = QFile::remove(filePath);
if(b)
this->removeRow(index.row(),index.parent());
return b;
}
QFileInfo FindFileModel::fileInfo(const QModelIndex &index) const
{
return QFileInfo(itemFromIndex(index)->data(Qt::UserRole + 1).toString());
}
void FindFileModel::appendFile(QString filePath)
{
QFileInfo info(filePath);
if(info.path().isEmpty() || info.path() == ".")
{
qWarning("FindFileModel::appendFile failed: filePath must contain the full path including the file name");
return;
}
QString filePathTrunc = info.filePath();
while(filePathTrunc.count(QDir::separator()) > 1)
filePathTrunc.remove(0,filePathTrunc.indexOf(QDir::separator())+1);
QStandardItem * fileItem = new QStandardItem(filePathTrunc);
fileItem->setIcon(QFileIconProvider().icon(info));
fileItem->setData(filePath,Qt::UserRole + 1); // store as user data
appendRow(fileItem);
}
bool FindFileModel::setData(const QModelIndex &index, const QVariant &value, int role)
{
QStandardItemModel::setData(index,value,role); //set new name for list item
//rename file before changing path of original file
//value can be folder/filename or simply filename
bool f = QFile::rename(filePath(index),fileInfo(index).path() + QDir::separator() + QFileInfo(value.toString()).fileName());
//change path data
QStandardItemModel::setData(index, fileInfo(index).path() + QDir::separator() + QFileInfo(value.toString()).fileName(), Qt::UserRole + 1);
return f;
}
QStringList FindFileModel::mimeTypes() const
{
return QStringList(QString("text/uri-list"));
}
QMimeData *FindFileModel::mimeData(const QModelIndexList &indexes) const
{
QList urls;
for(QModelIndexList::ConstIterator it = indexes.constBegin(); it != indexes.constEnd(); ++it)
{
urls+=QUrl::fromLocalFile(this->filePath(*it));
}
QMimeData * mimeData = new QMimeData();
mimeData->setUrls(urls);
return mimeData;
}
// this method may be called multiple times if the user is typing a search word
void FindFileModel::findInFiles(const QString& fileName, const QString &content,const QString &path)
{
if(path.isEmpty() || (fileName.isEmpty() && content.isEmpty()))
return;
if(future.isRunning())
future.cancel();
else
QApplication::setOverrideCursor(QCursor(Qt::WaitCursor));
QStringList files;
QDirIterator it(path, QDirIterator::Subdirectories);
while(it.hasNext())
{
QString filePath = it.next();
if(it.fileInfo().isFile())
files << filePath;
}
fileContainsFunctor.content = content;
fileContainsFunctor.fileName = fileName;
future = QtConcurrent::filtered(files,fileContainsFunctor);
futureWatcher.setFuture(future);
// sometimes, wait cursor persists, this is a workaround
QTimer::singleShot(5000,this,SLOT(restoreOverrideCursor()));
}
void FindFileModel::findInFilesFinished()
{
const auto res = future.results();
for(QString fileName : res )
this->appendFile(fileName);
QApplication::restoreOverrideCursor();
}
void FindFileModel::restoreOverrideCursor()
{
QApplication::restoreOverrideCursor();
}
bool FindFileModel::FileContains::operator ()(const QString& htmlFilePath)
{
if(!fileName.isEmpty() && !content.isEmpty())
return QFileInfo(htmlFilePath).baseName().contains(fileName, Qt::CaseInsensitive) || fileContentContains(htmlFilePath);
else if(!content.isEmpty())
return fileContentContains(htmlFilePath);
else
return QFileInfo(htmlFilePath).baseName().contains(fileName, Qt::CaseInsensitive);
}
bool FindFileModel::FileContains::fileContentContains(const QString &htmlFilePath)
{
static QRegularExpression htmlRegex("<[^>]*>");
QFile file(htmlFilePath);
if(file.open(QIODevice::ReadOnly))
{
QTextStream in(&file);
//QTextDocumentFragment doc = QTextDocumentFragment::fromHtml(in.readAll());
//QString noteText = doc.toPlainText();
//return noteText.contains(content, Qt::CaseInsensitive);
// remove this string here exactly once
const static QString whiteSpacePreWrap = "p, li { white-space: pre-wrap; }";
QString text = in.readAll();
int index;
if((index = text.indexOf(whiteSpacePreWrap)) != -1)
{
text.remove(index,whiteSpacePreWrap.size());
}
return text.remove(htmlRegex).contains(content.toHtmlEscaped(),Qt::CaseInsensitive);
}
return false;
}
noblenote-1.2.0/src/main.cpp 0000664 0001750 0001750 00000010456 13502176303 014730 0 ustar chris chris /* nobleNote, a note taking application
* Copyright (C) 2019 Christian Metscher ,
Fabian Deuchler
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
* nobleNote is licensed under the MIT, see `http://copyfree.org/licenses/mit/license.txt'.
*/
#include "mainwindow.h"
#include
#include
#include
#include
#include
#include "welcome.h"
int main (int argc, char *argv[]){
QApplication app(argc, argv);
app.setApplicationName("nobleNote");
app.setOrganizationName("nobleNote");
//Qt translations
QTranslator qtTranslator;
qtTranslator.load("qt_" + QLocale::system().name(),
QLibraryInfo::location(QLibraryInfo::TranslationsPath));
app.installTranslator(&qtTranslator);
//NobleNote translations
QTranslator translator;
#ifdef Q_OS_WIN32
translator.load(":" + QLocale::system().name());
#else
QString tmp = "/usr/share/noblenote/translations/noblenote_";
translator.load(tmp + QLocale::system().name());
#endif
app.installTranslator(&translator);
app.setQuitOnLastWindowClosed(false);
QSettings::setDefaultFormat(QSettings::IniFormat);
QFileInfo settingsFile = QFile(QDir::toNativeSeparators(app.applicationDirPath() + "/" +
app.applicationName() + "/" + QFileInfo(QSettings().fileName()).fileName()));
if(settingsFile.exists()) //check if there is a conf/ini file in a folder called nobleNote next to the executable (for portable version)
{
QDir settingsParentDir = settingsFile.dir();
settingsParentDir.cdUp(); //cdUp because the current folder will be created by QSettings here after.
QSettings::setPath(QSettings::IniFormat,QSettings::UserScope,settingsParentDir.absolutePath()); //use this file instead of system standard if this is the case
QSettings().setValue("isPortable",true);
}
else
QSettings().setValue("isPortable",false);
if(!QSettings().isWritable()) // TODO QObject::tr does not work here because there is no Q_OBJECT macro in main
QMessageBox::critical(0,"Settings not writable", QString("%1 settings not writable!").arg(app.applicationName()));
if(!QFile(QSettings().value("import_path").toString()).exists())
QSettings().setValue("import_path", QDir::homePath());
bool rootPathIsSet = QSettings().value("root_path").isValid();
bool rootPathExists = QFileInfo(QSettings().value("root_path").toString()).exists();
bool rootPathIsWritable = QFileInfo(QSettings().value("root_path").toString()).isWritable();
if(!rootPathExists || !rootPathIsWritable)
{
QScopedPointer welcome(new Welcome);
welcome->getInstance(rootPathIsSet, rootPathExists, rootPathIsWritable);
if(welcome->exec() == QDialog::Rejected) // welcome writes the root path
return 0; // leave main if the user rejects the welcome dialog, else go on
}
else if(!rootPathIsSet)
QSettings().setValue("root_path", app.applicationDirPath() + "/" + app.applicationName());
MainWindow window;
if(QSettings().value("Hide_main_at_startup",false).toBool())
window.showOpenNotes();
else
window.show();
return app.exec();
}
noblenote-1.2.0/src/ui/ 0000775 0001750 0001750 00000000000 13513631003 013702 5 ustar chris chris noblenote-1.2.0/src/ui/preferences.ui 0000664 0001750 0001750 00000022563 13502165236 016562 0 ustar chris chris
Preferences0043943700Preferences:/nobleNote:/nobleNote10true00&Browse ...QDialogButtonBox::Cancel|QDialogButtonBox::Ok75trueNote editor default font:DejaVu Sans1075trueNote editor default size:&Close to trayQLayout::SetDefaultConstraintWidth:Height:655365335655365250Automatically convert non-HTML notes to the HTML format. If disabled, non-HTML notes are opened read only.Convert notes to the &HTML formatNumber of recently opened notes00155Enables drag to scroll&Touch screen scrollingDo not show the main interface and notes on startup.
(Minimized to tray icon)&Hide main window at startup&Show "Show Source" menu entry00QFrame::StyledPanelroot foldertrueQt::LinksAccessibleByMouse|Qt::TextSelectableByMouse0075trueRoot directory:0075trueBackup directroy:00backup foldertrueQt::LinksAccessibleByMouse|Qt::TextSelectableByMousebrowseButtondontQuitconvertNoteskineticScrollingsizeSpinWidthsizeSpinHeightfontComboBoxfontSizeComboBoxbuttonBoxbuttonBoxrejected()Preferencesreject()1748317459
noblenote-1.2.0/src/ui/note.ui 0000664 0001750 0001750 00000001275 13502165236 015223 0 ustar chris chris
Note00500355Note-Editor:/nobleNote:/nobleNote
noblenote-1.2.0/src/ui/mainwindow.ui 0000664 0001750 0001750 00000017060 13502165236 016431 0 ustar chris chris
MainWindow00280331nobleNote:/nobleNote:/nobleNoteQt::ToolButtonTextUnderIcon0028023&FileOpen recent&Settings&Help&View&EditTopToolBarAreafalse&QuitCtrl+Q&Import:/preferences:/preferences&Configure...Ctrl+P&Abouttruetrue&Show toolbarCtrl+Shift+T:/trash:/trash&TrashCtrl+Tfalse:/history:/history&HistoryCtrl+Shift+Hfalse:/newFolder:/newFolder&New notebookCtrl+N:/renameFolder:/renameFolder&Rename notebookCtrl+R:/deleteFolder:/deleteFolder&Delete notebookCtrl+D:/newNote:/newNote&New noteCtrl+Shift+Nfalse:/renameNote:/renameNote&Rename noteCtrl+Shift+Rfalsefalse:/deleteNote:/deleteNote&Delete noteCtrl+Shift+D&CutCtrl+Xfalse&PasteCtrl+Va
noblenote-1.2.0/src/ui/welcome.ui 0000664 0001750 0001750 00000005641 13502165236 015712 0 ustar chris chris
Welcome00421220Welcome to nobleNoteQt::Horizontal4020Welcome to nobleNote!
This is the first time that nobleNote has been started.
You can choose a directory where the notes will be saved in.true&BrowseQt::HorizontalQDialogButtonBox::Cancel|QDialogButtonBox::OkQt::Vertical2040Qt::Vertical2040buttonBoxaccepted()Welcomeaccept()248254157274buttonBoxrejected()Welcomereject()316260286274
noblenote-1.2.0/src/ui/trash.ui 0000664 0001750 0001750 00000007040 13502165236 015373 0 ustar chris chris
Trash00468355TrashQt::HorizontalQDialogButtonBox::Close&Restore&Deletetrue00Select the notes you want to delete or restoretrue00PreviewtrueQAbstractItemView::ExtendedSelectionQAbstractItemView::ScrollPerPixeltrueDeleted notestreeWidgetrestoreButtondeleteButtonbuttonBoxtextEditbuttonBoxrejected()Trashreject()316260286274
noblenote-1.2.0/src/trash.cpp 0000664 0001750 0001750 00000011343 13502176303 015121 0 ustar chris chris /* nobleNote, a note taking application
* Copyright (C) 2019 Christian Metscher ,
Fabian Deuchler
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
* nobleNote is licensed under the MIT, see `http://copyfree.org/licenses/mit/license.txt'.
*/
#include "trash.h"
#include
#include
Trash::Trash(QHash *backupDataHash, QWidget *parent): QDialog(parent){
setupUi(this);
setAttribute(Qt::WA_DeleteOnClose);
const auto keys = backupDataHash->keys();
for(QString key : keys)
{
QTreeWidgetItem *item = new QTreeWidgetItem(treeWidget);
item->setText(0,backupDataHash->value(key).first()); //title
item->setData(0,Qt::UserRole,backupDataHash->value(key)); //title, path and content
}
treeWidget->sortByColumn(0,Qt::AscendingOrder);
// TODO flickcharm here
connect(treeWidget, SIGNAL(itemSelectionChanged()), this, SLOT(showPreview()));
connect(deleteButton, SIGNAL(clicked(bool)), this, SLOT(deleteBackup()));
connect(restoreButton, SIGNAL(clicked(bool)), this, SLOT(restoreBackup()));
}
void Trash::restoreBackup()
{
if(treeWidget->selectedItems().isEmpty())
return;
QString dir = QSettings().value("root_path").toString()+"/restored notes";
if(!QDir(dir).exists())
QDir().mkpath(dir);
for(QTreeWidgetItem *item : treeWidget->selectedItems())
{
QStringList dataList = item->data(0,Qt::UserRole).toStringList();
QString title = dataList.takeFirst();
if(!QFile(dataList.first()).exists())
return;
else
{
QString filePath = dir+QDir::separator()+title;
int i = 0;
while(QFile::exists(filePath))
{
i++;
filePath = dir+QDir::separator()+title+" ("+QString::number(i)+")";
}
QFile(dataList.first()).copy(filePath);
}
delete item;
}
}
void Trash::deleteBackup()
{
if(treeWidget->selectedItems().isEmpty())
return;
QStringList files;
const QList itemList = treeWidget->selectedItems();
for(QTreeWidgetItem *item : itemList)
{
QStringList dataList = item->data(0,Qt::UserRole).toStringList();
dataList.takeFirst(); //removing title from the list
files << dataList.first();
}
if(QMessageBox::warning(this,tr("Deleting notes"),
tr("Are you sure you want to permanently delete the selected notes?")
,QMessageBox::Yes | QMessageBox::Abort) != QMessageBox::Yes)
return;
for(QString file : files)
{
if(QFile(file).exists())
QFile(file).remove();
QString uuid = file;
uuid.remove(QSettings().value("backup_dir_path").toString() + QDir::separator());
QSettings().remove("Notes/" + QUuid(uuid).toString() + "_size");
QSettings().remove("Notes/" + QUuid(uuid).toString() + "_cursor_position");
QSettings().remove("Notes/" + QUuid(uuid).toString() + "_window_position");
}
for(QTreeWidgetItem *item : itemList)
delete item;
}
void Trash::showPreview()
{
if(treeWidget->currentItem() == NULL) //Prevents program crush
{
textEdit->clear();
return;
}
if(!treeWidget->currentItem()->isSelected())
{
if(treeWidget->selectedItems().count() != 1)
textEdit->clear();
else
textEdit->setText(treeWidget->selectedItems().first()->data(0,Qt::UserRole).toStringList().last());
}
else
textEdit->setText(treeWidget->currentItem()->data(0,Qt::UserRole).toStringList().last());
}
noblenote-1.2.0/src/xmlnotewriter.h 0000664 0001750 0001750 00000007570 13502176303 016377 0 ustar chris chris /* nobleNote, a note taking application
* Copyright (C) 2019 Christian Metscher ,
Fabian Deuchler
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
* nobleNote is licensed under the MIT, see `http://copyfree.org/licenses/mit/license.txt'.
*/
#ifndef XMLNOTEWRITER_H
#define XMLNOTEWRITER_H
#include
#include
#include
#include
#include
#include
/**
* a class writing formatted text in xml files
* the format is similar to the xml format used by tomboy/gnote
* writing requires a QTextFrame
*
* Warning: when using a QIODevice for each of the methods XmlNoteReader::read, XmlNoteWriter::write
* and the static XmlNoteReader::uuid(QIODevice* devce)
* the device must be closed and opened separately
* The same QString* in QXmlStreamWriter cannot be reused in QXmlStreamReader.
*
*
* this class should not be used at the moment because the xml output is missing new line special chars
* this is due to implementation problems of the detection of QChar::ParagraphSeparator between the QTextFragments and
* QTextBlocks while iterating over a QTextFragment. See write() for details
*
*/
class XmlNoteWriter : protected QXmlStreamWriter
{
public:
XmlNoteWriter();
XmlNoteWriter(const QString &filePath);
// Warning: The application will crash if device* points to a local stack object
// that gets destroyed before write() is called
void setDevice(QIODevice * device) { QXmlStreamWriter::setDevice(device);}
QIODevice * device() const { return QXmlStreamWriter::device();}
// obtain this via QTextFrame* frame = textEdit->document()->rootFrame();
void setFrame(QTextFrame * frame) { frame_ = frame;}
QTextFrame * frame() const { return frame_;}
// set last change date, if not set, the current date is used
void setLastChange(const QDateTime& dt) { lastChange_ = dt;}
const QDateTime& lastChange() const { return lastChange_;}
// set last metadata change date, if not set, the current date is used
void setLastMetadataChange(const QDateTime& dt) { lastMetadataChange_ = dt;}
const QDateTime& lastMetadataChange() const { return lastMetadataChange_;}
// set create date, if not set, the current date is used
void setCreateDate(const QDateTime& dt) { createDate_ = dt;}
const QDateTime& createDate() const { return createDate_;}
void write(); // write the content's of frame to the specified device/outputString
void setUuid(QUuid uuid) { uuid_ = uuid;}
QUuid uuid() const {return uuid_;}
// TODO clear statement?
private:
QTextFrame * frame_;
QUuid uuid_;
QDateTime lastChange_;
QDateTime lastMetadataChange_;
QDateTime createDate_;
QFile file;
};
#endif // XMLNOTEWRITER_H
noblenote-1.2.0/src/note.h 0000664 0001750 0001750 00000010354 13502176303 014413 0 ustar chris chris /* nobleNote, a note taking application
* Copyright (C) 2019 Christian Metscher ,
Fabian Deuchler
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
* nobleNote is licensed under the MIT, see `http://copyfree.org/licenses/mit/license.txt'.
*/
#ifndef NOTE_H
#define NOTE_H
#include "ui_note.h"
#include "textdocument.h"
#include
#include
#include
#include
#include
#include
#include
#include "textbrowser.h"
class TextFormattingToolbar;
class TextSearchToolbar;
class Highlighter;
class NoteDescriptor;
/**
* @brief The Note class is the widget that displays note content
*
* most lifecycle handling and loading/saving of html and xml type notes is handled
* in NoteDescriptor.
*
* note loading workflow:
* //TODO workflow should be refactored to load the file before creating the note window
*
* this clas creates a NoteDescriptor
* the NoteDescriptor loads the html file asynchronously and reads the uuid
* a signal onLoadFinished() is sent, this is used in this class to call loadSizeAndShow
* loadSizeAndShow reads the UUId from NoteDescriptor, that is now initialized
* (before, it is 0000-...) and loads the Note Window size from the QSettings
* loadSizeAndSHow resizes the Note window and calls show()
*
* you should not directly call show() but instead call showAfterLoaded()
* to set the flag to show the Note window after all initialization has been finished
*/
class Note : public QMainWindow, public Ui::Note {
Q_OBJECT // important for creating own singals and slots
public:
Note(QString filePath, QWidget *parent = 0);
NoteDescriptor* noteDescriptor() const { return noteDescriptor_; }
void highlightText(const QString & str);
QTextEdit * textEdit() const { return textBrowser;}
// the future of the worker thread that handles saving settings
QFuture future() const { return future_;}
// adds this file Path to the list of open notes that is stored in the settings
static void addToOpenNoteList(QString path);
private:
TextBrowser *textBrowser;
TextDocument *textDocument;
QMenu *menu;
QAction *showHideToolbars;
TextFormattingToolbar *toolbar;
TextSearchToolbar *searchBar;
QFuture future_; // a future that holds the worker thread that is invoked when window states are changed
NoteDescriptor *noteDescriptor_;
bool showAfterLoading_; // state variable, call show() after loadSizeAndShow()
// this is called asynchronously when the window is closed and saves geometry etc.
void saveWindowState(QVariantList variantList);
public slots:
void setSearchBarText(QString str);
void showAfterLoaded(); // calls show() after loading data and size settings
private slots:
void showContextMenu(const QPoint &pt);
void showOrHideToolbars();
protected:
void keyPressEvent(QKeyEvent *k);
void keyReleaseEvent(QKeyEvent *k);
virtual void closeEvent(QCloseEvent *close_Note);
// focus events must be overridden in the TextBrowser class
private slots:
void loadSizeAndShow(); // load size from settings and resize
};
#endif
noblenote-1.2.0/src/lineedit.cpp 0000664 0001750 0001750 00000005375 13502176303 015605 0 ustar chris chris /* nobleNote, a note taking application
* Copyright (C) 2019 Christian Metscher ,
Fabian Deuchler
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
* nobleNote is licensed under the MIT, see `http://copyfree.org/licenses/mit/license.txt'.
*/
#include "lineedit.h"
#include
#include
LineEdit::LineEdit(QWidget *parent)
: QLineEdit(parent)
{
clearButton = new QToolButton(this);
QPixmap pixmap(":closeB");
clearButton->setIcon(QIcon(pixmap));
clearButton->setIconSize(pixmap.size());
clearButton->setCursor(Qt::ArrowCursor);
clearButton->setStyleSheet("QToolButton { border: none; padding: 0px; }");
clearButton->hide();
connect(clearButton, SIGNAL(clicked()), this, SLOT(clear()));
connect(clearButton, SIGNAL(clicked()), this, SIGNAL(sendCleared()));
connect(this, SIGNAL(textChanged(const QString&)), this, SLOT(updateCloseButton(const QString&)));
int frameWidth = style()->pixelMetric(QStyle::PM_DefaultFrameWidth);
setStyleSheet(QString("QLineEdit { padding-right: %1px; } ").arg(clearButton->sizeHint().width() + frameWidth + 1));
QSize msz = minimumSizeHint();
setMinimumSize(qMax(msz.width(), clearButton->sizeHint().height() + frameWidth * 2 + 2),
qMax(msz.height(), clearButton->sizeHint().height() + frameWidth * 2 + 2));
}
void LineEdit::resizeEvent(QResizeEvent *)
{
QSize sz = clearButton->sizeHint();
int frameWidth = style()->pixelMetric(QStyle::PM_DefaultFrameWidth);
clearButton->move(rect().right() - frameWidth - sz.width(),
(rect().bottom() + 1 - sz.height())/2);
}
void LineEdit::updateCloseButton(const QString& text)
{
clearButton->setVisible(!text.isEmpty());
}
noblenote-1.2.0/src/xorcipher.h 0000664 0001750 0001750 00000003257 13502176303 015455 0 ustar chris chris /* nobleNote, a note taking application
* Copyright (C) 2019 Christian Metscher ,
Fabian Deuchler
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
* nobleNote is licensed under the MIT, see `http://copyfree.org/licenses/mit/license.txt'.
*/
#ifndef XORCIPHER_H
#define XORCIPHER_H
#include
/**
* simple Xor encryption/decryption class
*
*
*/
class XorCipher
{
private:
XorCipher();
public:
// todo also encrypt the key if it is kept in memory
static QString encrypt(QString sourceString, ushort key);
static QString decrypt(QString encryptedString, ushort key);
};
#endif // XORCIPHER_H
noblenote-1.2.0/src/noblenote-icons/ 0000775 0001750 0001750 00000000000 13513631003 016363 5 ustar chris chris noblenote-1.2.0/src/noblenote-icons/clear_formatting_smooth_eraser.svg 0000664 0001750 0001750 00000042414 13502165236 025373 0 ustar chris chris
noblenote-1.2.0/src/noblenote-icons/filerename.png 0000664 0001750 0001750 00000003007 13502165236 021210 0 ustar chris chris PNG
IHDR 0 0 W sRGB bKGD pHYs
B(x tIMEJW IDAThYOhU?3ǰ4Cj
%i!&x