Skip to content

Commit

Permalink
Merge pull request #1141 from deXol/develop
Browse files Browse the repository at this point in the history
[BLE] Notes improvements
  • Loading branch information
limpkin authored Feb 5, 2023
2 parents 77100ea + cb97676 commit 9c03c94
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/BleDev.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ void BleDev::on_btnFileBrowser_clicked()
s.value("last_used_path/bundle_dir", QDir::homePath()).toString(),
"*.img");

// Due to file selection dialog opened, release events are not catched
// Due to file selection dialog opened, release events are not caught
DeviceDetector::instance().shiftReleased();
DeviceDetector::instance().ctrlReleased();

Expand Down
13 changes: 12 additions & 1 deletion src/NotesManagement.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ void NotesManagement::setWsClient(WSClient *c)
connect(wsClient, &WSClient::notesFetched, this, &NotesManagement::loadNotes);
connect(wsClient, &WSClient::noteSaved, this, &NotesManagement::onNoteSaved);
connect(wsClient, &WSClient::noteDeleted, this, &NotesManagement::onNoteDeleted);
connect(wsClient, &WSClient::deviceDisconnected, this, &NotesManagement::onDeviceDisconnected);
}

void NotesManagement::loadNotes(const QJsonArray &notes)
Expand Down Expand Up @@ -223,8 +224,9 @@ void NotesManagement::onNoteSaved(const QString &note, bool success)
{
if (m_isNewFile)
{
addNewIcon(note);
m_noteList.append(note);
std::sort(std::begin(m_noteList), std::end(m_noteList));
refreshNotes();
}
}
else
Expand Down Expand Up @@ -300,3 +302,12 @@ void NotesManagement::onNoteDeleted(bool success, const QString &note)
QMessageBox::warning(this, tr("Failure"), tr("'%1' note delete failed!").arg(note));
}
}

void NotesManagement::onDeviceDisconnected()
{
if (m_isNoteEditing)
{
// Exit editing mode when device disconnected
on_pushButtonDiscard_clicked();
}
}
2 changes: 2 additions & 0 deletions src/NotesManagement.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@ private slots:

void onNoteDeleted(bool success, const QString& note);

void onDeviceDisconnected();

private:
void loadNotes(const QJsonArray& notes);
void refreshNotes();
Expand Down

0 comments on commit 9c03c94

Please sign in to comment.