Skip to content

Commit

Permalink
#3194 add: emoji for all status messages
Browse files Browse the repository at this point in the history
Signed-off-by: Patrizio Bekerle <[email protected]>
  • Loading branch information
pbek committed Dec 30, 2024
1 parent 3f4e4f1 commit 1d37b30
Show file tree
Hide file tree
Showing 6 changed files with 91 additions and 53 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# QOwnNotes Changelog

## 25.1.0
- All status messages got an emoji to make them more recognizable
(for [#3194](https://github.com/pbek/QOwnNotes/issues/3194))

## 24.12.7
- The [Web Companion browser extension](https://github.com/qownnotes/web-companion)
can now tell QOwnNotes to not send bookmarks and links from the current note
Expand Down
115 changes: 71 additions & 44 deletions src/mainwindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1122,7 +1122,8 @@ void MainWindow::reloadTodoLists() {
ownCloud->todoGetTodoList(calendar, nullptr);
}

showStatusBarMessage(tr("Your tasks are being loaded from your server"), 4000);
showStatusBarMessage(tr("Your tasks are being loaded from your server"),
QStringLiteral("☑️"), 4000);

// generate the system tray context menu to show modified tasks
// in 15 sec (because we don't know when all new tasks will be loaded)
Expand Down Expand Up @@ -1813,13 +1814,25 @@ void MainWindow::changeDistractionFreeMode(const bool enabled) {
/**
* Shows a status bar message if not in distraction free mode
*/
void MainWindow::showStatusBarMessage(const QString &message, const int timeout) {
void MainWindow::showStatusBarMessage(const QString &message, const QString &symbol, int timeout) {
// Add a symbol to the message
const QString text = symbol.isEmpty() ? message : QStringLiteral("%1 %2").arg(symbol, message);

// If timeout is smaller than 100, it is in seconds
if (timeout < 100) {
timeout = timeout * 1000;
}

if (!isInDistractionFreeMode()) {
ui->statusBar->showMessage(message, timeout);
ui->statusBar->showMessage(text, timeout);
}

// write to the log widget
emit log(LogWidget::StatusLogType, message);
// Write to the log widget
emit log(LogWidget::StatusLogType, text);
}

void MainWindow::showStatusBarMessage(const QString &message, int timeout) {
showStatusBarMessage(message, QString(), timeout);
}

/**
Expand Down Expand Up @@ -2836,7 +2849,8 @@ void MainWindow::notesWereModified(const QString &str) {
return;
}

showStatusBarMessage(tr("Current note was modified externally"), 5000);
showStatusBarMessage(tr("Current note was modified externally"), QStringLiteral("🔄"),
5000);

// if we don't want to get notifications at all
// external modifications check if we really need one
Expand All @@ -2858,7 +2872,7 @@ void MainWindow::notesWereModified(const QString &str) {

showStatusBarMessage(
tr("Overwriting external changes of: %1").arg(currentNote.getFileName()),
3000);
QStringLiteral("💾"), 3000);

// the note text has to be stored newly because the
// external change is already in the note table entry
Expand All @@ -2870,7 +2884,7 @@ void MainWindow::notesWereModified(const QString &str) {
case NoteDiffDialog::Reload:
showStatusBarMessage(
tr("Loading external changes from: %1").arg(currentNote.getFileName()),
3000);
QStringLiteral("🔄"), 3000);
updateNoteTextFromDisk(note);
break;

Expand Down Expand Up @@ -2902,6 +2916,7 @@ void MainWindow::notesWereModified(const QString &str) {
const bool noteWasStored = note.storeNoteTextFileToDisk();
showStatusBarMessage(noteWasStored ? tr("Stored current note to disk")
: tr("Current note could not be stored to disk"),
noteWasStored ? QStringLiteral("💾") : QStringLiteral("❌"),
3000);

// rebuild and reload the notes directory list
Expand All @@ -2923,7 +2938,8 @@ void MainWindow::notesWereModified(const QString &str) {
} else {
qDebug() << "other note was changed: " << str;

showStatusBarMessage(tr("Note was modified externally: %1").arg(str), 5000);
showStatusBarMessage(tr("Note was modified externally: %1").arg(str), QStringLiteral("🔄"),
5000);

// rebuild and reload the notes directory list
buildNotesIndexAndLoadNoteDirectoryList();
Expand All @@ -2943,7 +2959,7 @@ void MainWindow::notesDirectoryWasModified(const QString &str) {
}

qDebug() << "notesDirectoryWasModified: " << str;
showStatusBarMessage(tr("Notes directory was modified externally"), 5000);
showStatusBarMessage(tr("Notes directory was modified externally"), QStringLiteral("🔄"), 5000);

// rebuild and reload the notes directory list
buildNotesIndexAndLoadNoteDirectoryList();
Expand Down Expand Up @@ -3016,7 +3032,8 @@ void MainWindow::storeUpdatedNotesToDisk() {

qDebug() << __func__ << " - 'count': " << count;

showStatusBarMessage(tr("Stored %n note(s) to disk", "", count), 3000);
showStatusBarMessage(tr("Stored %n note(s) to disk", "", count), QStringLiteral("💾"),
3000);

if (currentNoteChanged) {
// strip trailing spaces of the current note (if enabled)
Expand Down Expand Up @@ -3466,13 +3483,13 @@ void MainWindow::removeConflictedNotesDatabaseCopies() {
QFile::remove(file)
? tr("Removed duplicate conflicted database: %1").arg(file)
: tr("Could not remove duplicate conflicted database: %1").arg(file),
4000);
QStringLiteral("🗄️"), 4000);
} else if (DatabaseService::mergeNoteFolderDatabase(file)) {
showStatusBarMessage(
QFile::remove(file)
? tr("Removed merged conflicted database: %1").arg(file)
: tr("Could not remove merged conflicted database: %1").arg(file),
4000);
QStringLiteral("🗄️"), 4000);
} else {
files << file;
}
Expand Down Expand Up @@ -3505,7 +3522,8 @@ void MainWindow::removeConflictedNotesDatabaseCopies() {
}
}

showStatusBarMessage(tr("Removed %n conflicted database copies", "", count));
showStatusBarMessage(tr("Removed %n conflicted database copies", "", count),
QStringLiteral("🗄️"));
}

/**
Expand Down Expand Up @@ -4918,7 +4936,8 @@ void MainWindow::tagSelectedNotes(const Tag &tag) {
reloadTagTree();

showStatusBarMessage(
tr("%n note(s) were tagged with \"%2\"", "", tagCount).arg(tag.getName()), 5000);
tr("%n note(s) were tagged with \"%2\"", "", tagCount).arg(tag.getName()),
QStringLiteral("🏷️"), 5000);

// turn off the workaround again
directoryWatcherWorkaround(false, true);
Expand Down Expand Up @@ -5958,7 +5977,7 @@ void MainWindow::jumpToNoteOrCreateNew(bool disableLoadNoteDirectoryList) {
const bool noteWasStored = note.storeNoteTextFileToDisk();
showStatusBarMessage(noteWasStored ? tr("Stored current note to disk")
: tr("Current note could not be stored to disk"),
3000);
noteWasStored ? QStringLiteral("💾") : QStringLiteral("❌"), 3000);

{
const QSignalBlocker blocker2(ui->noteTreeWidget);
Expand Down Expand Up @@ -6319,7 +6338,7 @@ void MainWindow::on_actionShow_versions_triggered() {
showStatusBarMessage(
Utils::Misc::replaceOwnCloudText(tr("Note versions are currently loaded from your ownCloud "
"server")),
20000);
QStringLiteral("🛜"), 20000);

OwnCloudService *ownCloud = OwnCloudService::instance();
ownCloud->loadVersions(this->currentNote.relativeNoteFilePath(QStringLiteral("/")));
Expand All @@ -6332,7 +6351,7 @@ void MainWindow::on_actionShow_trash_triggered() {
showStatusBarMessage(
Utils::Misc::replaceOwnCloudText(tr("Trashed notes are currently loaded from your ownCloud"
" server")),
20000);
QStringLiteral("🗑"), 20000);

OwnCloudService *ownCloud = OwnCloudService::instance();
ownCloud->loadTrash();
Expand Down Expand Up @@ -6552,7 +6571,7 @@ bool MainWindow::insertTextAsAttachment(const QString &text, const QString &titl
QStringLiteral("text-XXXXXX.txt"));

if (!tempFile->open()) {
showStatusBarMessage(tr("Temporary file can't be opened"), 3000);
showStatusBarMessage(tr("Temporary file can't be opened"), QStringLiteral("❌"), 3000);

return false;
}
Expand All @@ -6568,7 +6587,8 @@ bool MainWindow::insertTextAsAttachment(const QString &text, const QString &titl
bool result = insertAttachment(file, title);

if (result) {
showStatusBarMessage(tr("Inserted text as text attachment file"), 3000);
showStatusBarMessage(tr("Inserted text as text attachment file"), QStringLiteral("📄"),
3000);
}

// for some reason the temp file on disk will not be removed automatically
Expand Down Expand Up @@ -6868,7 +6888,7 @@ void MainWindow::storeNoteBookmark(int slot) {
QVariant::fromValue(item));

showStatusBarMessage(tr("Bookmarked note position at slot %1").arg(QString::number(slot)),
3000);
QStringLiteral("🔖"), 3000);
}

void MainWindow::loadNoteBookmarks() {
Expand All @@ -6895,7 +6915,8 @@ void MainWindow::gotoNoteBookmark(int slot) {
setCurrentNoteFromHistoryItem(item);

showStatusBarMessage(
tr("Jumped to bookmark position at slot %1").arg(QString::number(slot)), 3000);
tr("Jumped to bookmark position at slot %1").arg(QString::number(slot)),
QStringLiteral("🔖"), 3000);
}
}

Expand Down Expand Up @@ -7068,19 +7089,20 @@ void MainWindow::handleInsertingFromMimeData(const QMimeData *mimeData) {
}
// only allow image files to be inserted as image
} else if (isValidMediaFile(file)) {
showStatusBarMessage(tr("Inserting image"), 0);
showStatusBarMessage(tr("Inserting image"), QStringLiteral("🖼️"), 0);

// insert the image
insertMedia(file);

showStatusBarMessage(tr("Done inserting image"), 3000);
showStatusBarMessage(tr("Done inserting image"), QStringLiteral("🖼️"), 3000);
} else {
showStatusBarMessage(tr("Inserting attachment"), 0);
showStatusBarMessage(tr("Inserting attachment"), QStringLiteral("🖼️"), 0);

// inserting the attachment
insertAttachment(file);

showStatusBarMessage(tr("Done inserting attachment"), 3000);
showStatusBarMessage(tr("Done inserting attachment"), QStringLiteral("📥️"),
3000);
}

delete file;
Expand Down Expand Up @@ -7116,14 +7138,14 @@ void MainWindow::handleInsertingFromMimeData(const QMimeData *mimeData) {
}

if (!message.isEmpty()) {
showStatusBarMessage(message, 5000);
showStatusBarMessage(message, QStringLiteral("⤵️️"), 5000);
}
} else if (mimeData->hasImage()) {
// get the image from mime data
QImage image = mimeData->imageData().value<QImage>();

if (!image.isNull()) {
showStatusBarMessage(tr("Saving temporary image"), 0);
showStatusBarMessage(tr("Saving temporary image"), QStringLiteral("🖼️"), 0);

QTemporaryFile tempFile(QDir::tempPath() + QDir::separator() +
QStringLiteral("qownnotes-media-XXXXXX.png"));
Expand All @@ -7135,13 +7157,14 @@ void MainWindow::handleInsertingFromMimeData(const QMimeData *mimeData) {
// insert media into note
auto *file = new QFile(tempFile.fileName());

showStatusBarMessage(tr("Inserting image"), 0);
showStatusBarMessage(tr("Inserting image"), QStringLiteral("🖼️"), 0);
insertMedia(file);
delete file;

showStatusBarMessage(tr("Done inserting image"), 3000);
showStatusBarMessage(tr("Done inserting image"), QStringLiteral("🖼️"), 3000);
} else {
showStatusBarMessage(tr("Temporary file can't be opened"), 3000);
showStatusBarMessage(tr("Temporary file can't be opened"), QStringLiteral("❌️"),
3000);
}
}
} else if (mimeData->hasText() || mimeData->hasHtml()) {
Expand Down Expand Up @@ -7200,7 +7223,8 @@ void MainWindow::insertHtmlAsMarkdownIntoCurrentNote(QString html) {
continue;
}

showStatusBarMessage(tr("Downloading %1").arg(imageUrl.toString()), 0);
showStatusBarMessage(tr("Downloading %1").arg(imageUrl.toString()), QStringLiteral("⬇️️"),
0);

// download the image and get the media Markdown code for it
markdownCode = currentNote.downloadUrlToMedia(imageUrl);
Expand All @@ -7212,7 +7236,7 @@ void MainWindow::insertHtmlAsMarkdownIntoCurrentNote(QString html) {
}
}

showStatusBarMessage(tr("Downloading images finished"), 3000);
showStatusBarMessage(tr("Downloading images finished"), QStringLiteral("🖼️"), 3000);

// remove all html tags
static const QRegularExpression tagRE(QStringLiteral("<.+?>"));
Expand Down Expand Up @@ -7368,7 +7392,7 @@ void MainWindow::on_action_Reset_note_text_size_triggered() {
"Will be shown after "
"the font size is reset by 'Reset note text size'")
.arg(fontSize),
3000);
QStringLiteral("🔤️"), 3000);

// Allow to update the preview if the zoom level of the note text edits change
forceRegenerateNotePreview();
Expand Down Expand Up @@ -8436,7 +8460,8 @@ void MainWindow::on_tagTreeWidget_customContextMenuRequested(const QPoint pos) {
if (tag.isFetched()) {
reloadTagTree();
} else {
showStatusBarMessage(tr("Tag could not be created!"), 3000);
showStatusBarMessage(tr("Tag could not be created!"), QStringLiteral("🏷️"),
3000);
}
}
}
Expand Down Expand Up @@ -8671,7 +8696,7 @@ void MainWindow::moveSelectedTagsToTagId(int tagId) {
if (tag.isFetched()) {
if (tag.hasChild(tagId) || (id == tagId)) {
showStatusBarMessage(tr("Cannot move tag '%1' to this tag").arg(tag.getName()),
3000);
QStringLiteral("🏷️"), 3000);
} else {
tagList << tag;
}
Expand Down Expand Up @@ -8713,7 +8738,8 @@ void MainWindow::moveSelectedTagsToTagId(int tagId) {
}
}

showStatusBarMessage(tr("Moved tag '%1' to new tag").arg(tag.getName()), 3000);
showStatusBarMessage(tr("Moved tag '%1' to new tag").arg(tag.getName()),
QStringLiteral("🏷️"), 3000);
}

reloadCurrentNoteTags();
Expand Down Expand Up @@ -8966,7 +8992,7 @@ void MainWindow::moveSelectedNotesToNoteSubFolder(const NoteSubFolder &noteSubFo
showStatusBarMessage(
tr("%n note(s) were moved to note subfolder \"%2\"", "", noteSubFolderCount)
.arg(noteSubFolder.getName()),
5000);
QStringLiteral("📁"), 5000);

// wait some time to enable the check again to prevent troubles on macOS
QTimer::singleShot(4000, this, SLOT(enableNoteExternallyRemovedCheck()));
Expand Down Expand Up @@ -9057,7 +9083,7 @@ void MainWindow::copySelectedNotesToNoteSubFolder(const NoteSubFolder &noteSubFo
showStatusBarMessage(
tr("%n note(s) were copied to note subfolder \"%2\"", "", noteSubFolderCount)
.arg(noteSubFolder.getName()),
5000);
QStringLiteral("📁"), 5000);
}
}

Expand Down Expand Up @@ -9155,7 +9181,7 @@ void MainWindow::on_actionSelect_note_folder_triggered() {
*/
void MainWindow::on_actionReload_scripting_engine_triggered() {
ScriptingService::instance()->reloadEngine();
showStatusBarMessage(tr("The scripting engine was reloaded"), 3000);
showStatusBarMessage(tr("The scripting engine was reloaded"), QStringLiteral("🔧"), 3000);
forceRegenerateNotePreview();
}

Expand Down Expand Up @@ -11207,7 +11233,7 @@ void MainWindow::automaticScriptUpdateCheck() {
// Show a message once if no script update were found
// We need to do that in a slot, because you can't use a timer in a separate thread
QObject::connect(dialog, &ScriptRepositoryDialog::noUpdateFound, this, [this, dialog]() {
showStatusBarMessage(tr("No script updates were found"), 3000);
showStatusBarMessage(tr("No script updates were found"), QStringLiteral("🔧"), 3000);
delete (dialog);
});

Expand All @@ -11219,7 +11245,7 @@ void MainWindow::automaticScriptUpdateCheck() {
}

_scriptUpdateFound = true;
showStatusBarMessage(tr("A script update was found!"), 4000);
showStatusBarMessage(tr("A script update was found!"), QStringLiteral("🔧"), 4000);
delete (dialog);

if (Utils::Gui::question(this, tr("Script updates"),
Expand Down Expand Up @@ -11486,7 +11512,7 @@ void MainWindow::on_actionCopy_headline_triggered() {
QClipboard *clipboard = QApplication::clipboard();
clipboard->setText(headline);
showStatusBarMessage(tr("Note headline '%1' was copied to the clipboard").arg(headline),
3000);
QStringLiteral("📋"), 3000);
}
}

Expand Down Expand Up @@ -12017,7 +12043,8 @@ void MainWindow::on_actionCopy_path_to_note_to_clipboard_triggered() {

QClipboard *clipboard = QApplication::clipboard();
clipboard->setText(path);
showStatusBarMessage(tr("Note path '%1' was copied to the clipboard").arg(path), 3000);
showStatusBarMessage(tr("Note path '%1' was copied to the clipboard").arg(path),
QStringLiteral("📋"), 3000);
}

void MainWindow::on_actionMove_up_in_subfolder_list_triggered() {
Expand Down
Loading

0 comments on commit 1d37b30

Please sign in to comment.