Skip to content

Commit

Permalink
formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
zjeffer committed Feb 9, 2025
1 parent 0b96d74 commit 6697616
Show file tree
Hide file tree
Showing 48 changed files with 407 additions and 776 deletions.
61 changes: 28 additions & 33 deletions src/aboutwindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,7 @@
/**
* Initializes the window components and configures the AboutWindow
*/
AboutWindow::AboutWindow(QWidget *parent)
: QDialog(parent), m_ui(new Ui::AboutWindow), m_isProVersion(false)
AboutWindow::AboutWindow(QWidget *parent) : QDialog(parent), m_ui(new Ui::AboutWindow), m_isProVersion(false)
{
m_ui->setupUi(this);
setWindowTitle(tr("About") + " " + QCoreApplication::applicationName());
Expand All @@ -22,13 +21,10 @@ AboutWindow::AboutWindow(QWidget *parent)
m_ui->aboutText->setTextColor(QColor(26, 26, 26));

#ifdef __APPLE__
QFont fontToUse = QFont(QStringLiteral("SF Pro Text")).exactMatch()
? QStringLiteral("SF Pro Text")
: QStringLiteral("Roboto");
QFont fontToUse = QFont(QStringLiteral("SF Pro Text")).exactMatch() ? QStringLiteral("SF Pro Text") : QStringLiteral("Roboto");
m_ui->aboutText->setFont(fontToUse);
#elif _WIN32
QFont fontToUse = QFont(QStringLiteral("Segoe UI")).exactMatch() ? QStringLiteral("Segoe UI")
: QStringLiteral("Roboto");
QFont fontToUse = QFont(QStringLiteral("Segoe UI")).exactMatch() ? QStringLiteral("Segoe UI") : QStringLiteral("Roboto");
m_ui->aboutText->setFont(fontToUse);
#else
m_ui->aboutText->setFont(QFont(QStringLiteral("Roboto")));
Expand Down Expand Up @@ -57,34 +53,33 @@ void AboutWindow::setAboutText()
{
QString proVersionText = m_isProVersion ? " (Pro Version)" : "";

m_ui->aboutText->setText(
"<strong>Version:</strong> " + QCoreApplication::applicationVersion() + proVersionText
+ "<p>Notes was founded by <a href='https://rubymamistvalove.com'>Ruby "
"Mamistvalove</a>, "
"to create an elegant yet powerful cross-platform and open-source note-taking "
"app.</p><a href='https://www.notes-foss.com'>Notes Website"
"</a><br/><a href='https://github.com/nuttyartist/notes'>Source code on "
"Github</a><br/><a "
"href='https://www.notes-foss.com/notes-app-terms-privacy-policy'>Terms and Privacy "
"Policy</a><br/><br/><strong>Acknowledgments</strong><br/>This project couldn't "
"have "
"come this far without the help of these amazing "
"people:<br/><br/><strong>Programmers:</strong><br/>Alex Spataru<br/>Ali Diouri"
"<br/>David Planella<br/>Diep Ngoc<br/>Guilherme "
"Silva<br/>Thorbjørn Lindeijer<br/>Tuur Vanhoutte<br/>Waqar "
"Ahmed<br/><br/><strong>Designers:</strong><br/>Kevin Doyle<br/><br/>And to the "
"many of our beloved users who keep sending us feedback, you are an essential force "
"in "
"helping us improve, thank you!<br/><br/><strong>Notes makes use of the following "
"third-party libraries:</strong><br/><br/>QMarkdownTextEdit<br/>"
m_ui->aboutText->setText("<strong>Version:</strong> " + QCoreApplication::applicationVersion() + proVersionText
+ "<p>Notes was founded by <a href='https://rubymamistvalove.com'>Ruby "
"Mamistvalove</a>, "
"to create an elegant yet powerful cross-platform and open-source note-taking "
"app.</p><a href='https://www.notes-foss.com'>Notes Website"
"</a><br/><a href='https://github.com/nuttyartist/notes'>Source code on "
"Github</a><br/><a "
"href='https://www.notes-foss.com/notes-app-terms-privacy-policy'>Terms and Privacy "
"Policy</a><br/><br/><strong>Acknowledgments</strong><br/>This project couldn't "
"have "
"come this far without the help of these amazing "
"people:<br/><br/><strong>Programmers:</strong><br/>Alex Spataru<br/>Ali Diouri"
"<br/>David Planella<br/>Diep Ngoc<br/>Guilherme "
"Silva<br/>Thorbjørn Lindeijer<br/>Tuur Vanhoutte<br/>Waqar "
"Ahmed<br/><br/><strong>Designers:</strong><br/>Kevin Doyle<br/><br/>And to the "
"many of our beloved users who keep sending us feedback, you are an essential force "
"in "
"helping us improve, thank you!<br/><br/><strong>Notes makes use of the following "
"third-party libraries:</strong><br/><br/>QMarkdownTextEdit<br/>"
#if defined(UPDATE_CHECKER)
"QSimpleUpdater<br/>"
"QSimpleUpdater<br/>"
#endif
"QAutostart<br/>QXT<br/><br/><strong>Notes makes use of the following open source "
"fonts:</strong><br/><br/>Roboto<br/>Source Sans Pro<br/>Trykker<br/>Mate<br/>iA "
"Writer Mono<br/>iA Writer Duo<br/>iA Writer "
"Quattro<br/>Font Awesome<br/>Material Symbols<br/><br/><strong>Qt version:</strong> "
+ qVersion() + " (built with " + QT_VERSION_STR + ")");
"QAutostart<br/>QXT<br/><br/><strong>Notes makes use of the following open source "
"fonts:</strong><br/><br/>Roboto<br/>Source Sans Pro<br/>Trykker<br/>Mate<br/>iA "
"Writer Mono<br/>iA Writer Duo<br/>iA Writer "
"Quattro<br/>Font Awesome<br/>Material Symbols<br/><br/><strong>Qt version:</strong> "
+ qVersion() + " (built with " + QT_VERSION_STR + ")");
}

void AboutWindow::setTheme(Theme::Value theme)
Expand Down
3 changes: 1 addition & 2 deletions src/allnotebuttontreedelegateeditor.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,7 @@ class AllNoteButtonTreeDelegateEditor : public QWidget
{
Q_OBJECT
public:
explicit AllNoteButtonTreeDelegateEditor(QTreeView *view, const QStyleOptionViewItem &option,
const QModelIndex &index, QListView *listView,
explicit AllNoteButtonTreeDelegateEditor(QTreeView *view, const QStyleOptionViewItem &option, const QModelIndex &index, QListView *listView,
QWidget *parent = nullptr);
void setTheme(Theme::Value theme);

Expand Down
12 changes: 4 additions & 8 deletions src/customMarkdownHighlighter.cpp
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
#include "customMarkdownHighlighter.h"
#include "editorsettingsoptions.h"

CustomMarkdownHighlighter::CustomMarkdownHighlighter(QTextDocument *parent,
HighlightingOptions highlightingOptions)
CustomMarkdownHighlighter::CustomMarkdownHighlighter(QTextDocument *parent, HighlightingOptions highlightingOptions)
: MarkdownHighlighter(parent, highlightingOptions)
{
setListsColor(QColor(35, 131, 226)); // accent color
Expand Down Expand Up @@ -34,16 +33,13 @@ void CustomMarkdownHighlighter::setFontSize(qreal fontSize)
}

qreal codeBlockFontSize = fontSize - 4;
_formats[static_cast<HighlighterState>(HighlighterState::InlineCodeBlock)].setFontPointSize(
codeBlockFontSize);
_formats[static_cast<HighlighterState>(HighlighterState::InlineCodeBlock)].setFontPointSize(codeBlockFontSize);
}

void CustomMarkdownHighlighter::setListsColor(QColor color)
{
_formats[static_cast<HighlighterState>(HighlighterState::CheckBoxUnChecked)].setForeground(
color);
_formats[static_cast<HighlighterState>(HighlighterState::CheckBoxChecked)].setForeground(
QColor(90, 113, 140));
_formats[static_cast<HighlighterState>(HighlighterState::CheckBoxUnChecked)].setForeground(color);
_formats[static_cast<HighlighterState>(HighlighterState::CheckBoxChecked)].setForeground(QColor(90, 113, 140));
_formats[static_cast<HighlighterState>(HighlighterState::List)].setForeground(color);
_formats[static_cast<HighlighterState>(HighlighterState::BlockQuote)].setForeground(color);
}
Expand Down
4 changes: 1 addition & 3 deletions src/customMarkdownHighlighter.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,7 @@
class CustomMarkdownHighlighter : public MarkdownHighlighter
{
public:
explicit CustomMarkdownHighlighter(
QTextDocument *parent,
HighlightingOptions highlightingOptions = HighlightingOption::None);
explicit CustomMarkdownHighlighter(QTextDocument *parent, HighlightingOptions highlightingOptions = HighlightingOption::None);
~CustomMarkdownHighlighter() override = default;

void setFontSize(qreal fontSize);
Expand Down
3 changes: 1 addition & 2 deletions src/customapplicationstyle.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,7 @@
#include <QStyleOption>
#include "editorsettingsoptions.h"

void CustomApplicationStyle::drawPrimitive(PrimitiveElement element, const QStyleOption *option,
QPainter *painter, const QWidget *widget) const
void CustomApplicationStyle::drawPrimitive(PrimitiveElement element, const QStyleOption *option, QPainter *painter, const QWidget *widget) const
{
if (element == QStyle::PE_IndicatorItemViewItemDrop) {
painter->setRenderHint(QPainter::Antialiasing, true);
Expand Down
3 changes: 1 addition & 2 deletions src/customapplicationstyle.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,7 @@ class CustomApplicationStyle : public QProxyStyle
public:
CustomApplicationStyle();

void drawPrimitive(PrimitiveElement element, const QStyleOption *option, QPainter *painter,
const QWidget *widget) const;
void drawPrimitive(PrimitiveElement element, const QStyleOption *option, QPainter *painter, const QWidget *widget) const;
void setTheme(Theme::Value theme);

private:
Expand Down
19 changes: 6 additions & 13 deletions src/customdocument.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,7 @@ bool CustomDocument::eventFilter(QObject *obj, QEvent *event)

if (event->type() == QEvent::HoverMove) {
// if hovering and the control key is active, check whether the mouse is over a link
if (QGuiApplication::keyboardModifiers() == Qt::ExtraButton24
&& getUrlUnderMouse().isValid()) {
if (QGuiApplication::keyboardModifiers() == Qt::ExtraButton24 && getUrlUnderMouse().isValid()) {
viewport()->setCursor(Qt::PointingHandCursor);
} else {
viewport()->setCursor(Qt::IBeamCursor);
Expand All @@ -74,8 +73,7 @@ bool CustomDocument::eventFilter(QObject *obj, QEvent *event)
auto *mouseEvent = static_cast<QMouseEvent *>(event);

// track `Ctrl + Click` in the text edit
if ((obj == viewport()) && (mouseEvent->button() == Qt::LeftButton)
&& (QGuiApplication::keyboardModifiers() == Qt::ExtraButton24)) {
if ((obj == viewport()) && (mouseEvent->button() == Qt::LeftButton) && (QGuiApplication::keyboardModifiers() == Qt::ExtraButton24)) {
// open the link (if any) at the current position
// in the noteTextEdit

Expand Down Expand Up @@ -168,8 +166,7 @@ bool CustomDocument::openLinkAtCursorPosition()

const bool convertLocalFilepathsToURLs = true;

if ((url.isValid() && isValidUrl(urlString)) || isFileUrl || isLocalFilePath
|| isLegacyAttachmentUrl) {
if ((url.isValid() && isValidUrl(urlString)) || isFileUrl || isLocalFilePath || isLegacyAttachmentUrl) {

if (_ignoredClickUrlSchemata.contains(url.scheme())) {
qDebug() << __func__ << "ignored URL scheme:" << urlString;
Expand All @@ -182,18 +179,15 @@ bool CustomDocument::openLinkAtCursorPosition()
if (!QFile::exists(trimmed)) {
qDebug() << __func__ << ": File does not exist:" << urlString;
// show a message box
QMessageBox::warning(
nullptr, tr("File not found"),
tr("The file <strong>%1</strong> does not exist.").arg(trimmed));
QMessageBox::warning(nullptr, tr("File not found"), tr("The file <strong>%1</strong> does not exist.").arg(trimmed));
return false;
}
}

if (isLocalFilePath && !QFile::exists(urlString)) {
qDebug() << __func__ << ": File does not exist:" << urlString;
// show a message box
QMessageBox::warning(nullptr, tr("File not found"),
tr("The file <strong>%1</strong> does not exist.").arg(urlString));
QMessageBox::warning(nullptr, tr("File not found"), tr("The file <strong>%1</strong> does not exist.").arg(urlString));
return false;
}

Expand Down Expand Up @@ -296,8 +290,7 @@ QMap<QString, QString> CustomDocument::parseMarkdownUrlsFromText(const QString &
QString linkText = match.captured(1);
QString referenceId = match.captured(2);

QRegularExpression refRegExp(
QStringLiteral("\\[%1\\]: (.+)").arg(QRegularExpression::escape(referenceId)));
QRegularExpression refRegExp(QStringLiteral("\\[%1\\]: (.+)").arg(QRegularExpression::escape(referenceId)));
QRegularExpressionMatch urlMatch = refRegExp.match(toPlainText());

if (urlMatch.hasMatch()) {
Expand Down
20 changes: 6 additions & 14 deletions src/defaultnotefolderdelegateeditor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,21 +7,15 @@
#include "editorsettingsoptions.h"
#include "fontloader.h"

DefaultNoteFolderDelegateEditor::DefaultNoteFolderDelegateEditor(QTreeView *view,
const QStyleOptionViewItem &option,
const QModelIndex &index,
QListView *listView,
QWidget *parent)
DefaultNoteFolderDelegateEditor::DefaultNoteFolderDelegateEditor(QTreeView *view, const QStyleOptionViewItem &option, const QModelIndex &index,
QListView *listView, QWidget *parent)
: QWidget(parent),
m_option(option),
m_index(index),
#ifdef __APPLE__
m_displayFont(QFont(QStringLiteral("SF Pro Text")).exactMatch()
? QStringLiteral("SF Pro Text")
: QStringLiteral("Roboto")),
m_displayFont(QFont(QStringLiteral("SF Pro Text")).exactMatch() ? QStringLiteral("SF Pro Text") : QStringLiteral("Roboto")),
#elif _WIN32
m_displayFont(QFont(QStringLiteral("Segoe UI")).exactMatch() ? QStringLiteral("Segoe UI")
: QStringLiteral("Roboto")),
m_displayFont(QFont(QStringLiteral("Segoe UI")).exactMatch() ? QStringLiteral("Segoe UI") : QStringLiteral("Roboto")),
#else
m_displayFont(QStringLiteral("Roboto")),
#endif
Expand Down Expand Up @@ -76,8 +70,7 @@ void DefaultNoteFolderDelegateEditor::paintEvent(QPaintEvent *event)
#else
int iconPointSizeOffset = -4;
#endif
painter.setFont(
font_loader::loadFont("Material Symbols Outlined", "", 16 + iconPointSizeOffset));
painter.setFont(font_loader::loadFont("Material Symbols Outlined", "", 16 + iconPointSizeOffset));
painter.drawText(folderIconRect, u8"\ue2c7"); // folder

QRect nameRect(rect());
Expand Down Expand Up @@ -105,8 +98,7 @@ void DefaultNoteFolderDelegateEditor::paintEvent(QPaintEvent *event)
painter.setPen(m_numberOfNotesColor);
}
painter.setFont(m_numberOfNotesFont);
painter.drawText(childCountRect, Qt::AlignHCenter | Qt::AlignVCenter,
QString::number(childCount));
painter.drawText(childCountRect, Qt::AlignHCenter | Qt::AlignVCenter, QString::number(childCount));
QWidget::paintEvent(event);
}

Expand Down
3 changes: 1 addition & 2 deletions src/defaultnotefolderdelegateeditor.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,7 @@ class DefaultNoteFolderDelegateEditor : public QWidget
{
Q_OBJECT
public:
explicit DefaultNoteFolderDelegateEditor(QTreeView *view, const QStyleOptionViewItem &option,
const QModelIndex &index, QListView *listView,
explicit DefaultNoteFolderDelegateEditor(QTreeView *view, const QStyleOptionViewItem &option, const QModelIndex &index, QListView *listView,
QWidget *parent = nullptr);
void setTheme(Theme::Value theme);

Expand Down
3 changes: 1 addition & 2 deletions src/editorsettingsoptions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,7 @@ void setCSSThemeAndUpdate(QWidget *obj, Theme::Value theme)
void setCSSClassesAndUpdate(QWidget *obj, std::string const &classNames)
{
if (obj->styleSheet().isEmpty()) {
qWarning() << "setCSSClassesAndUpdate: styleSheet is empty for widget with name "
<< obj->objectName();
qWarning() << "setCSSClassesAndUpdate: styleSheet is empty for widget with name " << obj->objectName();
}
// set the class
obj->setProperty("class", classNames.c_str());
Expand Down
3 changes: 1 addition & 2 deletions src/elidedlabel.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,7 @@ class ElidedLabel : public QLabel
Q_OBJECT
public:
explicit ElidedLabel(QWidget *parent = nullptr, Qt::WindowFlags f = Qt::WindowFlags());
explicit ElidedLabel(const QString &text, QWidget *parent = nullptr,
Qt::WindowFlags f = Qt::WindowFlags());
explicit ElidedLabel(const QString &text, QWidget *parent = nullptr, Qt::WindowFlags f = Qt::WindowFlags());
void setType(const Qt::TextElideMode type);
QString const &text() const;

Expand Down
Loading

0 comments on commit 6697616

Please sign in to comment.