From b824ab5ddbc7f9b48eec7661e2978ffa94507e40 Mon Sep 17 00:00:00 2001 From: zjeffer <4633209+zjeffer@users.noreply.github.com> Date: Sun, 20 Oct 2024 11:48:16 +0200 Subject: [PATCH 1/2] Fix build deprecation warnings --- src/dbmanager.cpp | 28 ++++++++--------- src/foldertreedelegateeditor.cpp | 2 +- src/listviewlogic.cpp | 24 +++++++------- src/mainwindow.cpp | 54 ++++++++++++++++---------------- src/nodetreemodel.cpp | 6 ++-- src/nodetreeview.cpp | 40 +++++++++++------------ src/notelistdelegate.cpp | 12 +++---- src/notelistmodel.cpp | 14 ++++----- src/notelistview.cpp | 40 +++++++++++------------ src/taglistmodel.cpp | 2 +- src/tagtreedelegateeditor.cpp | 4 +-- src/treeviewlogic.cpp | 2 +- src/updaterwindow.cpp | 13 ++++---- 13 files changed, 121 insertions(+), 120 deletions(-) diff --git a/src/dbmanager.cpp b/src/dbmanager.cpp index 8b32bc06c..6249ee8b8 100644 --- a/src/dbmanager.cpp +++ b/src/dbmanager.cpp @@ -408,7 +408,7 @@ void DBManager::recalculateChildNotesCount() qDebug() << __FUNCTION__ << __LINE__ << query.lastError(); } query.clear(); - for (const auto &id : qAsConst(tagIds)) { + for (const auto &id : std::as_const(tagIds)) { query.prepare("SELECT count(*) FROM tag_relationship WHERE tag_id=:id"); query.bindValue(QStringLiteral(":id"), id); status = query.exec(); @@ -925,7 +925,7 @@ QList DBManager::readOldNBK(const QString &fileName) // notified } if (!nl.isEmpty()) { - for (const auto &n : qAsConst(nl)) { + for (const auto &n : std::as_const(nl)) { noteList.append(*n); } } @@ -1175,14 +1175,14 @@ void DBManager::moveNode(int nodeId, const NodeData &target) && target.id() == SpecialNodeID::TrashFolder) { decreaseChildNotesCountFolder(SpecialNodeID::RootFolder); auto allTagInNote = getAllTagForNote(node.id()); - for (const auto &tagId : qAsConst(allTagInNote)) { + for (const auto &tagId : std::as_const(allTagInNote)) { decreaseChildNotesCountTag(tagId); } } else if (node.parentId() == SpecialNodeID::TrashFolder && target.id() != SpecialNodeID::TrashFolder) { increaseChildNotesCountFolder(SpecialNodeID::RootFolder); auto allTagInNote = getAllTagForNote(node.id()); - for (const auto &tagId : qAsConst(allTagInNote)) { + for (const auto &tagId : std::as_const(allTagInNote)) { increaseChildNotesCountTag(tagId); } } @@ -1325,7 +1325,7 @@ void DBManager::searchForNotes(const QString &keyword, const ListViewInfo &inf) nds_id = i; } } - for (const int id : qAsConst(nds[nds_id])) { + for (const int id : std::as_const(nds[nds_id])) { bool ok = true; for (int i = 0; i < nds.size(); ++i) { if (i == nds_id) { @@ -1680,7 +1680,7 @@ void DBManager::onNotesListInTagsRequested(const QSet &tagIds, bool newNote nds_id = i; } } - for (const int id : qAsConst(nds[nds_id])) { + for (const int id : std::as_const(nds[nds_id])) { bool ok = true; for (int i = 0; i < nds.size(); ++i) { if (i == nds_id) { @@ -1784,7 +1784,7 @@ void DBManager::onImportNotesRequested(const QString &fileName) out_qr.finish(); std::sort(tagList.begin(), tagList.end(), [](auto a, auto b) { return a.relativePosition() < b.relativePosition(); }); - for (const auto &tag : qAsConst(tagList)) { + for (const auto &tag : std::as_const(tagList)) { QSqlQuery qr(m_db); qr.prepare(R"(SELECT "id" FROM tag_table WHERE name = :name AND color = :color;)"); qr.bindValue(QStringLiteral(":name"), tag.name()); @@ -1877,7 +1877,7 @@ void DBManager::onImportNotesRequested(const QString &fileName) } } else { auto prL = NodePath(node.absolutePath()).separate(); - for (const auto &pr : qAsConst(prL)) { + for (const auto &pr : std::as_const(prL)) { matchFolderFunctor(pr.toInt(), matchFolderFunctor); } } @@ -1891,7 +1891,7 @@ void DBManager::onImportNotesRequested(const QString &fileName) }; Folder *rootFolder = nullptr; QHash needImportFolderMap; - for (const auto &node : qAsConst(nodeList)) { + for (const auto &node : std::as_const(nodeList)) { Folder f; f.id = node.id(); f.parentId = node.parentId(); @@ -1901,7 +1901,7 @@ void DBManager::onImportNotesRequested(const QString &fileName) } } if (rootFolder) { - for (const auto &folder : qAsConst(needImportFolderMap)) { + for (const auto &folder : std::as_const(needImportFolderMap)) { if (folder.id != SpecialNodeID::RootFolder) { needImportFolderMap[folder.parentId].children.push_back( &needImportFolderMap[folder.id]); @@ -1930,7 +1930,7 @@ void DBManager::onImportNotesRequested(const QString &fileName) matchFunc(rootFolder, matchFunc); } else { qDebug() << __FUNCTION__ << "Error while keeping folder position"; - for (const auto &node : qAsConst(nodeList)) { + for (const auto &node : std::as_const(nodeList)) { matchFolderFunc(node.id(), matchFolderFunc); } } @@ -1960,7 +1960,7 @@ void DBManager::onImportNotesRequested(const QString &fileName) bool status = out_qr.exec(); QVector nodeList; QMap> parents; - for (const auto &id : qAsConst(folderIdMap)) { + for (const auto &id : std::as_const(folderIdMap)) { if (parents.contains(id)) { continue; } @@ -1993,7 +1993,7 @@ void DBManager::onImportNotesRequested(const QString &fileName) } m_db.transaction(); auto nodeId = nextAvailableNodeId(); - for (auto node : qAsConst(nodeList)) { + for (auto node : std::as_const(nodeList)) { if (folderIdMap.contains(node.parentId()) && parents.contains(folderIdMap[node.parentId()])) { auto parentId = folderIdMap[node.parentId()]; @@ -2035,7 +2035,7 @@ void DBManager::onImportNotesRequested(const QString &fileName) std::make_pair(out_qr.value(0).toInt(), out_qr.value(1).toInt())); } m_db.transaction(); - for (const auto &rel : qAsConst(tagRela)) { + for (const auto &rel : std::as_const(tagRela)) { if (tagIdMap.contains(rel.first) && noteIdMap.contains(rel.second)) { addNoteToTag(noteIdMap[rel.second], tagIdMap[rel.first]); } else { diff --git a/src/foldertreedelegateeditor.cpp b/src/foldertreedelegateeditor.cpp index 6e5aab28f..cff1d36c4 100644 --- a/src/foldertreedelegateeditor.cpp +++ b/src/foldertreedelegateeditor.cpp @@ -221,7 +221,7 @@ void FolderTreeDelegateEditor::paintEvent(QPaintEvent *event) void FolderTreeDelegateEditor::mouseDoubleClickEvent(QMouseEvent *event) { - if (m_label->geometry().contains(event->pos())) { + if (m_label->geometry().contains(event->position().toPoint())) { m_label->openEditor(); } else { QWidget::mouseDoubleClickEvent(event); diff --git a/src/listviewlogic.cpp b/src/listviewlogic.cpp index 3b248c474..9fa437f78 100644 --- a/src/listviewlogic.cpp +++ b/src/listviewlogic.cpp @@ -16,7 +16,7 @@ static bool isInvalidCurrentNotesId(const QSet ¤tNotesId) return true; } bool isInvalid = true; - for (const auto &id : qAsConst(currentNotesId)) { + for (const auto &id : std::as_const(currentNotesId)) { if (id != SpecialNodeID::InvalidNodeId) { isInvalid = false; } @@ -179,7 +179,7 @@ void ListViewLogic::setNoteData(const NodeData ¬e) m_listModel->setItemData(noteIndex, dataValue); if (wasTemp) { auto tagIds = noteIndex.data(NoteListModel::NoteTagsList).value>(); - for (const auto tagId : qAsConst(tagIds)) { + for (const auto tagId : std::as_const(tagIds)) { emit requestAddTagDb(note.id(), tagId); } } @@ -276,7 +276,7 @@ void ListViewLogic::onSearchEditTextChanged(const QString &keyword) if (!m_listViewInfo.isInSearch) { auto indexes = m_listView->selectedIndex(); m_listViewInfo.currentNotesId.clear(); - for (const auto &index : qAsConst(indexes)) { + for (const auto &index : std::as_const(indexes)) { if (index.isValid()) { m_listViewInfo.currentNotesId.insert(index.data(NoteListModel::NoteID).toInt()); } @@ -334,7 +334,7 @@ void ListViewLogic::loadNoteListModel(const QVector ¬eList, const L } if (!currentNotesId.isEmpty()) { QModelIndexList indexes; - for (const auto &id : qAsConst(currentNotesId)) { + for (const auto &id : std::as_const(currentNotesId)) { if (id != SpecialNodeID::InvalidNodeId) { indexes.append(m_listModel->getNoteIndex(id)); } @@ -349,7 +349,7 @@ void ListViewLogic::loadNoteListModel(const QVector ¬eList, const L m_needLoadSavedState -= 1; if (!m_lastSelectedNotes.isEmpty()) { QModelIndexList indexes; - for (const auto &id : qAsConst(m_lastSelectedNotes)) { + for (const auto &id : std::as_const(m_lastSelectedNotes)) { if (id != SpecialNodeID::InvalidNodeId) { indexes.append(m_listModel->getNoteIndex(id)); } @@ -419,7 +419,7 @@ void ListViewLogic::setLastSelectedNote() { auto indexes = m_listView->selectedIndex(); QSet ids; - for (const auto &index : qAsConst(indexes)) { + for (const auto &index : std::as_const(indexes)) { if (index.isValid()) { ids.insert(index.data(NoteListModel::NoteID).toInt()); } @@ -470,7 +470,7 @@ void ListViewLogic::selectNotes(const QModelIndexList &indexes) m_listView->clearSelection(); m_listView->setSelectionMode(QAbstractItemView::MultiSelection); QModelIndex lastIdx; - for (const auto index : qAsConst(indexes)) { + for (const auto index : std::as_const(indexes)) { if (index.isValid()) { lastIdx = index; m_listView->selectionModel()->select(index, QItemSelectionModel::Select); @@ -533,7 +533,7 @@ void ListViewLogic::deleteNoteRequestedI(const QModelIndexList &indexes) bool isInTrash = false; QVector needDelete; QModelIndexList needDeleteI; - for (const auto &index : qAsConst(indexes)) { + for (const auto &index : std::as_const(indexes)) { if (index.isValid()) { auto id = index.data(NoteListModel::NoteID).toInt(); NodeData note; @@ -561,7 +561,7 @@ void ListViewLogic::deleteNoteRequestedI(const QModelIndexList &indexes) if (needClose) { emit closeNoteEditor(); } - for (const auto ¬e : qAsConst(needDelete)) { + for (const auto ¬e : std::as_const(needDelete)) { emit requestRemoveNoteDb(note); } } @@ -575,7 +575,7 @@ void ListViewLogic::deleteNoteRequestedI(const QModelIndexList &indexes) if (needClose) { emit closeNoteEditor(); } - for (const auto ¬e : qAsConst(needDelete)) { + for (const auto ¬e : std::as_const(needDelete)) { emit requestRemoveNoteDb(note); } } @@ -586,7 +586,7 @@ void ListViewLogic::restoreNotesRequestedI(const QModelIndexList &indexes) { QModelIndexList needRestoredI; QSet needRestored; - for (const auto &index : qAsConst(indexes)) { + for (const auto &index : std::as_const(indexes)) { if (index.isValid()) { auto id = index.data(NoteListModel::NoteID).toInt(); NodeData note; @@ -612,7 +612,7 @@ void ListViewLogic::restoreNotesRequestedI(const QModelIndexList &indexes) QMetaObject::invokeMethod(m_dbManager, "getNode", Qt::BlockingQueuedConnection, Q_RETURN_ARG(NodeData, defaultNotesFolder), Q_ARG(int, SpecialNodeID::DefaultNotesFolder)); - for (const auto &id : qAsConst(needRestored)) { + for (const auto &id : std::as_const(needRestored)) { emit requestMoveNoteDb(id, defaultNotesFolder); } } diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index ca7e8a6d2..7c84be029 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -1941,7 +1941,7 @@ void MainWindow::restoreStates() m_settingsDatabase->value(QStringLiteral("currentSelectTagsId"), QStringList{}) .toStringList(); QSet tags; - for (const auto &tagId : qAsConst(currentSelectTagsId)) { + for (const auto &tagId : std::as_const(currentSelectTagsId)) { tags.insert(tagId.toInt()); } m_treeViewLogic->setLastSavedState(isSelectingFolder, currentSelectFolder, tags, @@ -1950,7 +1950,7 @@ void MainWindow::restoreStates() m_settingsDatabase->value(QStringLiteral("currentSelectNotesId"), QStringList{}) .toStringList(); QSet notesId; - for (const auto &id : qAsConst(currentSelectNotes)) { + for (const auto &id : std::as_const(currentSelectNotes)) { notesId.insert(id.toInt()); } m_listViewLogic->setLastSavedState(notesId); @@ -3180,8 +3180,8 @@ void MainWindow::mousePressEvent(QMouseEvent *event) return; } - m_mousePressX = event->pos().x(); - m_mousePressY = event->pos().y(); + m_mousePressX = event->position().toPoint().x(); + m_mousePressY = event->position().toPoint().y(); if (event->buttons() == Qt::LeftButton) { if (isTitleBar(m_mousePressX, m_mousePressY)) { @@ -3243,8 +3243,8 @@ void MainWindow::mouseMoveEvent(QMouseEvent *event) # ifndef __APPLE__ if (!m_canStretchWindow && !m_canMoveWindow) { - m_mousePressX = event->pos().x(); - m_mousePressY = event->pos().y(); + m_mousePressX = event->position().toPoint().x(); + m_mousePressY = event->position().toPoint().y(); if ((m_mousePressX < width() && m_mousePressX > width() - m_layoutMargin) && (m_mousePressY < m_layoutMargin && m_mousePressY > 0)) { @@ -3298,8 +3298,8 @@ void MainWindow::mouseMoveEvent(QMouseEvent *event) # endif if (m_canMoveWindow) { - int dx = event->globalX() - m_mousePressX; - int dy = event->globalY() - m_mousePressY; + int dx = event->globalPosition().x() - m_mousePressX; + int dy = event->globalPosition().y() - m_mousePressY; move(dx, dy); } @@ -3314,11 +3314,11 @@ void MainWindow::mouseMoveEvent(QMouseEvent *event) switch (m_stretchSide) { case StretchSide::Right: - newWidth = abs(event->globalPos().x() - x() + 1); + newWidth = abs(event->globalPosition().x() - x() + 1); newWidth = newWidth < minimumWidth() ? minimumWidth() : newWidth; break; case StretchSide::Left: - newX = event->globalPos().x() - m_mousePressX; + newX = event->globalPosition().x() - m_mousePressX; newX = newX > 0 ? newX : 0; newX = newX > geometry().bottomRight().x() - minimumWidth() ? geometry().bottomRight().x() - minimumWidth() @@ -3327,7 +3327,7 @@ void MainWindow::mouseMoveEvent(QMouseEvent *event) newWidth = newWidth < minimumWidth() ? minimumWidth() : newWidth; break; case StretchSide::Top: - newY = event->globalY() - m_mousePressY; + newY = event->globalPosition().y() - m_mousePressY; newY = newY < minY ? minY : newY; newY = newY > geometry().bottomRight().y() - minimumHeight() ? geometry().bottomRight().y() - minimumHeight() @@ -3337,18 +3337,18 @@ void MainWindow::mouseMoveEvent(QMouseEvent *event) break; case StretchSide::Bottom: - newHeight = abs(event->globalY() - y() + 1); + newHeight = abs(event->globalPosition().y() - y() + 1); newHeight = newHeight < minimumHeight() ? minimumHeight() : newHeight; break; case StretchSide::TopLeft: - newX = event->globalPos().x() - m_mousePressX; + newX = event->globalPosition().x() - m_mousePressX; newX = newX < 0 ? 0 : newX; newX = newX > geometry().bottomRight().x() - minimumWidth() ? geometry().bottomRight().x() - minimumWidth() : newX; - newY = event->globalY() - m_mousePressY; + newY = event->globalPosition().y() - m_mousePressY; newY = newY < minY ? minY : newY; newY = newY > geometry().bottomRight().y() - minimumHeight() ? geometry().bottomRight().y() - minimumHeight() @@ -3362,7 +3362,7 @@ void MainWindow::mouseMoveEvent(QMouseEvent *event) break; case StretchSide::BottomLeft: - newX = event->globalPos().x() - m_mousePressX; + newX = event->globalPosition().x() - m_mousePressX; newX = newX < 0 ? 0 : newX; newX = newX > geometry().bottomRight().x() - minimumWidth() ? geometry().bottomRight().x() - minimumWidth() @@ -3371,18 +3371,18 @@ void MainWindow::mouseMoveEvent(QMouseEvent *event) newWidth = geometry().bottomRight().x() - newX + 1; newWidth = newWidth < minimumWidth() ? minimumWidth() : newWidth; - newHeight = event->globalY() - y() + 1; + newHeight = event->globalPosition().y() - y() + 1; newHeight = newHeight < minimumHeight() ? minimumHeight() : newHeight; break; case StretchSide::TopRight: - newY = event->globalY() - m_mousePressY; + newY = event->globalPosition().y() - m_mousePressY; newY = newY > geometry().bottomRight().y() - minimumHeight() ? geometry().bottomRight().y() - minimumHeight() : newY; newY = newY < minY ? minY : newY; - newWidth = event->globalPos().x() - x() + 1; + newWidth = event->globalPosition().x() - x() + 1; newWidth = newWidth < minimumWidth() ? minimumWidth() : newWidth; newHeight = geometry().bottomRight().y() - newY + 1; @@ -3390,10 +3390,10 @@ void MainWindow::mouseMoveEvent(QMouseEvent *event) break; case StretchSide::BottomRight: - newWidth = event->globalPos().x() - x() + 1; + newWidth = event->globalPosition().x() - x() + 1; newWidth = newWidth < minimumWidth() ? minimumWidth() : newWidth; - newHeight = event->globalY() - y() + 1; + newHeight = event->globalPosition().y() - y() + 1; newHeight = newHeight < minimumHeight() ? minimumHeight() : newHeight; break; @@ -3438,15 +3438,15 @@ void MainWindow::mousePressEvent(QMouseEvent *event) } if (event->button() == Qt::LeftButton) { - if (isTitleBar(event->pos().x(), event->pos().y())) { + if (isTitleBar(event->position().toPoint().x(), event->position().toPoint().y())) { # if QT_VERSION >= QT_VERSION_CHECK(5, 15, 0) m_canMoveWindow = !window()->windowHandle()->startSystemMove(); # else m_canMoveWindow = true; # endif - m_mousePressX = event->pos().x(); - m_mousePressY = event->pos().y(); + m_mousePressX = event->position().toPoint().x(); + m_mousePressY = event->position().toPoint().y(); } } @@ -3467,8 +3467,8 @@ void MainWindow::mouseMoveEvent(QMouseEvent *event) if (m_canMoveWindow) { // setCursor(Qt::ClosedHandCursor); - int dx = event->globalPos().x() - m_mousePressX; - int dy = event->globalY() - m_mousePressY; + int dx = event->globalPosition().x() - m_mousePressX; + int dy = event->globalPosition().y() - m_mousePressY; move(dx, dy); } } @@ -3766,7 +3766,7 @@ double MainWindow::gaussianDist(double x, const double center, double sigma) con void MainWindow::mouseDoubleClickEvent(QMouseEvent *event) { if (m_useNativeWindowFrame || event->buttons() != Qt::LeftButton - || !isTitleBar(event->pos().x(), event->pos().y())) { + || !isTitleBar(event->position().toPoint().x(), event->position().toPoint().y())) { MainWindowBase::mouseDoubleClickEvent(event); return; } @@ -3782,7 +3782,7 @@ void MainWindow::mouseDoubleClickEvent(QMouseEvent *event) /*! * \brief MainWindow::leaveEvent */ -void MainWindow::leaveEvent(QEvent *) +void MainWindow::leaveEvent(QEvent * /*event*/) { unsetCursor(); } diff --git a/src/nodetreemodel.cpp b/src/nodetreemodel.cpp index 84cce7b09..6c47540f3 100644 --- a/src/nodetreemodel.cpp +++ b/src/nodetreemodel.cpp @@ -121,7 +121,7 @@ void NodeTreeItem::recursiveSort() } else if (type == NodeItem::Type::RootItem) { QVector allNoteButton, trashFolder, folderSep, folderItems, tagSep, tagItems; - for (const auto child : qAsConst(m_childItems)) { + for (const auto child : std::as_const(m_childItems)) { auto childType = static_cast(child->data(NodeItem::Roles::ItemType).toInt()); if (childType == NodeItem::Type::AllNoteButton) { @@ -333,7 +333,7 @@ QModelIndex NodeTreeModel::folderIndexFromIdPath(const NodePath &idPath) } auto ps = idPath.separate(); auto item = rootItem; - for (const auto &ite : qAsConst(ps)) { + for (const auto &ite : std::as_const(ps)) { bool ok = false; auto id = ite.toInt(&ok); if (!ok) { @@ -769,7 +769,7 @@ bool NodeTreeModel::dropMimeData(const QMimeData *mime, Qt::DropAction action, i auto idl = QString::fromUtf8(mime->data(TAG_MIME)).split(QStringLiteral(PATH_SEPARATOR)); beginResetModel(); QSet movedIds; - for (const auto &id_s : qAsConst(idl)) { + for (const auto &id_s : std::as_const(idl)) { auto id = id_s.toInt(); for (int i = 0; i < rootItem->childCount(); ++i) { auto child = rootItem->child(i); diff --git a/src/nodetreeview.cpp b/src/nodetreeview.cpp index a155816ac..46fa14b5e 100644 --- a/src/nodetreeview.cpp +++ b/src/nodetreeview.cpp @@ -138,7 +138,7 @@ void NodeTreeView::onTagsDropSuccessful(const QSet &ids) setCurrentIndex(QModelIndex()); clearSelection(); setSelectionMode(QAbstractItemView::MultiSelection); - for (const auto &id : qAsConst(ids)) { + for (const auto &id : std::as_const(ids)) { auto index = m_model->tagIndexFromId(id); if (index.isValid()) { setCurrentIndex(index); @@ -239,7 +239,7 @@ void NodeTreeView::selectionChanged(const QItemSelection &selected, } auto indexes = selectedIndexes(); QSet tagIds; - for (const auto index : qAsConst(indexes)) { + for (const auto index : std::as_const(indexes)) { auto itemType = static_cast(index.data(NodeItem::Roles::ItemType).toInt()); switch (itemType) { case NodeItem::Type::RootItem: @@ -314,32 +314,32 @@ void NodeTreeView::dragEnterEvent(QDragEnterEvent *event) void NodeTreeView::dragMoveEvent(QDragMoveEvent *event) { if (event->mimeData()->hasFormat(NOTE_MIME)) { - auto index = indexAt(event->pos()); + auto index = indexAt(event->position().toPoint()); auto itemType = static_cast(index.data(NodeItem::Roles::ItemType).toInt()); if (itemType != NodeItem::Type::AllNoteButton) { - updateEditingIndex(event->pos()); + updateEditingIndex(event->position().toPoint()); event->acceptProposedAction(); } } else { if (event->mimeData()->hasFormat(TAG_MIME)) { - if (event->pos().y() < visualRect(m_treeSeparator[1]).y() + 25) { + if (event->position().toPoint().y() < visualRect(m_treeSeparator[1]).y() + 25) { event->ignore(); return; } } else if (event->mimeData()->hasFormat(FOLDER_MIME)) { auto trashRect = visualRect(dynamic_cast(model())->getTrashButtonIndex()); - if (event->pos().y() > (trashRect.y() + 5) - && event->pos().y() < (trashRect.bottom() - 5)) { + if (event->position().toPoint().y() > (trashRect.y() + 5) + && event->position().toPoint().y() < (trashRect.bottom() - 5)) { setDropIndicatorShown(true); QTreeView::dragMoveEvent(event); return; } - if (event->pos().y() > visualRect(m_treeSeparator[1]).y()) { + if (event->position().toPoint().y() > visualRect(m_treeSeparator[1]).y()) { event->ignore(); return; } - if (event->pos().y() < visualRect(m_defaultNotesIndex).y() + 25) { + if (event->position().toPoint().y() < visualRect(m_defaultNotesIndex).y() + 25) { event->ignore(); return; } @@ -358,14 +358,14 @@ void NodeTreeView::reset() void NodeTreeView::dropEvent(QDropEvent *event) { if (event->mimeData()->hasFormat(NOTE_MIME)) { - auto dropIndex = indexAt(event->pos()); + auto dropIndex = indexAt(event->position().toPoint()); if (dropIndex.isValid()) { auto itemType = static_cast(dropIndex.data(NodeItem::Roles::ItemType).toInt()); bool ok = false; auto idl = QString::fromUtf8(event->mimeData()->data(NOTE_MIME)) .split(QStringLiteral(PATH_SEPARATOR)); - for (const auto &s : qAsConst(idl)) { + for (const auto &s : std::as_const(idl)) { auto nodeId = s.toInt(&ok); if (ok) { if (itemType == NodeItem::Type::FolderItem) { @@ -474,11 +474,11 @@ void NodeTreeView::onCustomContextMenu(QPoint point) void NodeTreeView::setTreeSeparator(const QVector &newTreeSeparator, const QModelIndex &defaultNotesIndex) { - for (const auto &sep : qAsConst(m_treeSeparator)) { + for (const auto &sep : std::as_const(m_treeSeparator)) { closePersistentEditor(sep); } m_treeSeparator = newTreeSeparator; - for (const auto &sep : qAsConst(m_treeSeparator)) { + for (const auto &sep : std::as_const(m_treeSeparator)) { openPersistentEditor(sep); } m_defaultNotesIndex = defaultNotesIndex; @@ -488,12 +488,12 @@ void NodeTreeView::mouseMoveEvent(QMouseEvent *event) { Q_D(NodeTreeView); QPoint topLeft; - QPoint bottomRight = event->pos(); + QPoint bottomRight = event->position().toPoint(); if (state() == ExpandingState || state() == CollapsingState) { return; } - updateEditingIndex(event->pos()); + updateEditingIndex(event->position().toPoint()); if (state() == DraggingState) { topLeft = d->pressedPosition - d->offset(); if ((topLeft - bottomRight).manhattanLength() > QApplication::startDragDistance()) { @@ -516,7 +516,7 @@ void NodeTreeView::mousePressEvent(QMouseEvent *event) Q_D(NodeTreeView); d->delayedAutoScroll.stop(); { - auto index = indexAt(event->pos()); + auto index = indexAt(event->position().toPoint()); if (index.isValid()) { auto itemType = static_cast(index.data(NodeItem::Roles::ItemType).toInt()); @@ -524,7 +524,7 @@ void NodeTreeView::mousePressEvent(QMouseEvent *event) case NodeItem::Type::FolderItem: { auto rect = visualRect(index); auto iconRect = QRect(rect.x() + 5, rect.y() + (rect.height() - 20) / 2, 20, 20); - if (iconRect.contains(event->pos())) { + if (iconRect.contains(event->position().toPoint())) { if (isExpanded(index)) { collapse(index); } else { @@ -537,7 +537,7 @@ void NodeTreeView::mousePressEvent(QMouseEvent *event) } case NodeItem::Type::TagItem: { auto oldIndexes = selectionModel()->selectedIndexes(); - for (const auto &ix : qAsConst(oldIndexes)) { + for (const auto &ix : std::as_const(oldIndexes)) { auto selectedItemType = static_cast(ix.data(NodeItem::Roles::ItemType).toInt()); if (selectedItemType != NodeItem::Type::TagItem) { @@ -567,14 +567,14 @@ void NodeTreeView::mousePressEvent(QMouseEvent *event) } } } - QPoint pos = event->pos(); + QPoint pos = event->position().toPoint(); QPersistentModelIndex index = indexAt(pos); d->pressedAlreadySelected = d->selectionModel->isSelected(index); d->pressedIndex = index; d->pressedModifiers = event->modifiers(); QPoint offset = d->offset(); d->pressedPosition = pos + offset; - updateEditingIndex(event->pos()); + updateEditingIndex(event->position().toPoint()); } void NodeTreeView::leaveEvent(QEvent *event) diff --git a/src/notelistdelegate.cpp b/src/notelistdelegate.cpp index 4030c4d8b..aaa1a5506 100644 --- a/src/notelistdelegate.cpp +++ b/src/notelistdelegate.cpp @@ -61,21 +61,21 @@ NoteListDelegate::NoteListDelegate(NoteListView *view, TagPool *tagPool, QObject m_timeLine->setEasingCurve(QEasingCurve::InCurve); m_folderIcon = QImage(":/images/folder.png"); connect(m_timeLine, &QTimeLine::frameChanged, this, [this]() { - for (const auto &index : qAsConst(m_animatedIndexes)) { + for (const auto &index : std::as_const(m_animatedIndexes)) { emit sizeHintChanged(index); } }); connect(m_timeLine, &QTimeLine::finished, this, [this]() { emit animationFinished(m_state); - for (const auto &index : qAsConst(m_animatedIndexes)) { + for (const auto &index : std::as_const(m_animatedIndexes)) { m_view->openPersistentEditorC(index); } if (!animationQueue.empty()) { auto a = animationQueue.front(); animationQueue.pop_front(); QModelIndexList indexes; - for (const auto &id : qAsConst(a.first)) { + for (const auto &id : std::as_const(a.first)) { auto model = dynamic_cast(m_view->model()); if (model) { auto index = model->getNoteIndex(id); @@ -96,7 +96,7 @@ void NoteListDelegate::setState(NoteListState NewState, QModelIndexList indexes) { if (animationState() != QTimeLine::NotRunning) { QSet ids; - for (const auto &index : qAsConst(indexes)) { + for (const auto &index : std::as_const(indexes)) { auto noteId = index.data(NoteListModel::NoteID).toInt(); if (noteId != SpecialNodeID::InvalidNodeId) { ids.insert(noteId); @@ -813,7 +813,7 @@ void NoteListDelegate::paintTagList(int top, QPainter *painter, const QStyleOpti auto tagIds = index.data(NoteListModel::NoteTagsList).value>(); int left = option.rect.x() + 10; - for (const auto &id : qAsConst(tagIds)) { + for (const auto &id : std::as_const(tagIds)) { if (left >= option.rect.width()) { break; } @@ -911,7 +911,7 @@ void NoteListDelegate::setStateI(NoteListState NewState, const QModelIndexList & m_animatedIndexes = indexes; auto startAnimation = [this](QTimeLine::Direction diretion, int duration) { - for (const auto &index : qAsConst(m_animatedIndexes)) { + for (const auto &index : std::as_const(m_animatedIndexes)) { m_view->closePersistentEditorC(index); } m_timeLine->setDirection(diretion); diff --git a/src/notelistmodel.cpp b/src/notelistmodel.cpp index 7c814f715..d9f3bcec1 100644 --- a/src/notelistmodel.cpp +++ b/src/notelistmodel.cpp @@ -93,7 +93,7 @@ void NoteListModel::setListNote(const QVector ¬es, const ListViewIn m_listViewInfo = inf; if ((!m_listViewInfo.isInTag) && (m_listViewInfo.parentFolderId != SpecialNodeID::TrashFolder)) { - for (const auto ¬e : qAsConst(notes)) { + for (const auto ¬e : std::as_const(notes)) { if (note.isPinnedNote()) { m_pinnedList.append(note); } else { @@ -404,14 +404,14 @@ bool NoteListModel::dropMimeData(const QMimeData *mime, Qt::DropAction action, i auto idl = QString::fromUtf8(mime->data(NOTE_MIME)).split(QStringLiteral(PATH_SEPARATOR)); QSet movedIds; QModelIndexList idxe; - for (const auto &id_s : qAsConst(idl)) { + for (const auto &id_s : std::as_const(idl)) { auto nodeId = id_s.toInt(); idxe.append(getNoteIndex(nodeId)); } emit rowsAboutToBeMovedC(idxe); beginResetModel(); if (toPinned) { - for (const auto &index : qAsConst(idxe)) { + for (const auto &index : std::as_const(idxe)) { auto ¬e = getRef(index.row()); if (!note.isPinnedNote()) { note.setIsPinnedNote(true); @@ -419,7 +419,7 @@ bool NoteListModel::dropMimeData(const QMimeData *mime, Qt::DropAction action, i m_pinnedList.prepend(m_noteList.takeAt(index.row() - m_pinnedList.size())); } } - for (const auto &id_s : qAsConst(idl)) { + for (const auto &id_s : std::as_const(idl)) { auto nodeId = id_s.toInt(); for (int i = 0; i < m_pinnedList.size(); ++i) { if (m_pinnedList[i].id() == nodeId) { @@ -430,7 +430,7 @@ bool NoteListModel::dropMimeData(const QMimeData *mime, Qt::DropAction action, i movedIds.insert(nodeId); } } else { - for (const auto &index : qAsConst(idxe)) { + for (const auto &index : std::as_const(idxe)) { auto ¬e = getRef(index.row()); movedIds.insert(note.id()); if (!note.isPinnedNote()) { @@ -514,7 +514,7 @@ void NoteListModel::setNotesIsPinned(const QModelIndexList &indexes, bool isPinn if (isPinned) { emit rowsAboutToBeMovedC(needMovingIndexes); beginResetModel(); - for (const auto &id : qAsConst(needMovingIds)) { + for (const auto &id : std::as_const(needMovingIds)) { auto index = getNoteIndex(id); if (!index.isValid()) { continue; @@ -541,7 +541,7 @@ void NoteListModel::setNotesIsPinned(const QModelIndexList &indexes, bool isPinn } else { emit rowsAboutToBeMovedC(needMovingIndexes); beginResetModel(); - for (const auto &id : qAsConst(needMovingIds)) { + for (const auto &id : std::as_const(needMovingIds)) { auto index = getNoteIndex(id); if (!index.isValid()) { continue; diff --git a/src/notelistview.cpp b/src/notelistview.cpp index d4a7553d0..71e12d007 100644 --- a/src/notelistview.cpp +++ b/src/notelistview.cpp @@ -132,7 +132,7 @@ QModelIndexList NoteListView::selectedIndex() const void NoteListView::onRemoveRowRequested(const QModelIndexList &indexes) { if (!indexes.isEmpty()) { - for (const auto index : qAsConst(indexes)) { + for (const auto index : std::as_const(indexes)) { m_needRemovedNotes.push_back(index.data(NoteListModel::NoteID).toInt()); } NoteListDelegate *delegate = dynamic_cast(itemDelegate()); @@ -272,7 +272,7 @@ void NoteListView::mouseMoveEvent(QMouseEvent *event) return; } if (event->buttons() & Qt::LeftButton) { - if ((event->pos() - m_dragStartPosition).manhattanLength() + if ((event->position().toPoint() - m_dragStartPosition).manhattanLength() >= QApplication::startDragDistance()) { startDrag(Qt::MoveAction); } @@ -284,7 +284,7 @@ void NoteListView::mousePressEvent(QMouseEvent *e) { Q_D(NoteListView); m_isMousePressed = true; - auto index = indexAt(e->pos()); + auto index = indexAt(e->position().toPoint()); if (!index.isValid()) { emit noteListViewClicked(); return; @@ -293,7 +293,7 @@ void NoteListView::mousePressEvent(QMouseEvent *e) if (model && model->isFirstPinnedNote(index)) { auto rect = visualRect(index); auto iconRect = QRect(rect.right() - 25, rect.y() + 2, 20, 20); - if (iconRect.contains(e->pos())) { + if (iconRect.contains(e->position().toPoint())) { setIsPinnedNotesCollapsed(!isPinnedNotesCollapsed()); m_mousePressHandled = true; return; @@ -301,7 +301,7 @@ void NoteListView::mousePressEvent(QMouseEvent *e) } if (e->button() == Qt::LeftButton) { - m_dragStartPosition = e->pos(); + m_dragStartPosition = e->position().toPoint(); auto oldIndexes = selectionModel()->selectedIndexes(); if (!oldIndexes.contains(index)) { if (e->modifiers() == Qt::ControlModifier) { @@ -324,13 +324,13 @@ void NoteListView::mousePressEvent(QMouseEvent *e) } } QPoint offset = d->offset(); - d->pressedPosition = e->pos() + offset; + d->pressedPosition = e->position().toPoint() + offset; } void NoteListView::mouseReleaseEvent(QMouseEvent *e) { m_isMousePressed = false; - auto index = indexAt(e->pos()); + auto index = indexAt(e->position().toPoint()); if (!index.isValid()) { return; } @@ -392,7 +392,7 @@ void NoteListView::dragEnterEvent(QDragEnterEvent *event) void NoteListView::dragMoveEvent(QDragMoveEvent *event) { if (event->mimeData()->hasFormat(NOTE_MIME)) { - auto index = indexAt(event->pos()); + auto index = indexAt(event->position().toPoint()); auto isPinned = index.data(NoteListModel::NoteIsPinned).toBool(); if (!index.isValid()) { event->ignore(); @@ -512,7 +512,7 @@ void NoteListView::startDrag(Qt::DropActions supportedActions) rect = px.rect(); } m_isDraggingPinnedNotes = false; - for (const auto &index : qAsConst(indexes)) { + for (const auto &index : std::as_const(indexes)) { if (index.data(NoteListModel::NoteIsPinned).toBool()) { m_isDraggingPinnedNotes = true; break; @@ -542,7 +542,7 @@ void NoteListView::startDrag(Qt::DropActions supportedActions) d->dropIndicatorRect = QRect(); d->dropIndicatorPosition = OnItem; closeAllEditor(); - for (const auto &id : qAsConst(openedEditors)) { + for (const auto &id : std::as_const(openedEditors)) { auto index = dynamic_cast(model())->getNoteIndex(id); openPersistentEditorC(index); } @@ -646,7 +646,7 @@ void NoteListView::setupStyleSheet() void NoteListView::addNotesToTag(QSet notesId, int tagId) { - for (const auto &id : qAsConst(notesId)) { + for (const auto &id : std::as_const(notesId)) { auto model = dynamic_cast(this->model()); if (model) { auto index = model->getNoteIndex(id); @@ -659,7 +659,7 @@ void NoteListView::addNotesToTag(QSet notesId, int tagId) void NoteListView::removeNotesFromTag(QSet notesId, int tagId) { - for (const auto &id : qAsConst(notesId)) { + for (const auto &id : std::as_const(notesId)) { auto model = dynamic_cast(this->model()); if (model) { auto index = model->getNoteIndex(id); @@ -699,13 +699,13 @@ void NoteListView::onCustomContextMenu(QPoint point) indexList = selectionModel()->selectedIndexes(); } QSet notes; - for (const auto &idx : qAsConst(indexList)) { + for (const auto &idx : std::as_const(indexList)) { notes.insert(idx.data(NoteListModel::NoteID).toInt()); } contextMenu->clear(); if (m_tagPool) { m_tagsMenu = contextMenu->addMenu("Tags ..."); - for (auto action : qAsConst(m_noteTagActions)) { + for (auto action : std::as_const(m_noteTagActions)) { delete action; } m_noteTagActions.clear(); @@ -730,7 +730,7 @@ void NoteListView::onCustomContextMenu(QPoint point) const auto tagIds = m_tagPool->tagIds(); for (const auto &id : tagIds) { bool all = true; - for (const auto &selectedIndex : qAsConst(indexList)) { + for (const auto &selectedIndex : std::as_const(indexList)) { auto tags = selectedIndex.data(NoteListModel::NoteTagsList).value>(); if (!tags.contains(id)) { all = false; @@ -741,7 +741,7 @@ void NoteListView::onCustomContextMenu(QPoint point) tagInNote.insert(id); } } - for (auto id : qAsConst(tagInNote)) { + for (auto id : std::as_const(tagInNote)) { auto tag = m_tagPool->getTag(id); auto tagAction = new QAction(QString("✓ Remove tag ") + tag.name(), this); connect(tagAction, &QAction::triggered, this, @@ -786,7 +786,7 @@ void NoteListView::onCustomContextMenu(QPoint point) unpinNoteAction->setText(tr("Unpin Notes")); enum class ShowAction { NotInit, ShowPin, ShowBoth, ShowUnpin }; ShowAction a = ShowAction::NotInit; - for (const auto &idx : qAsConst(indexList)) { + for (const auto &idx : std::as_const(indexList)) { if (idx.data(NoteListModel::NoteIsPinned).toBool()) { if (a == ShowAction::ShowPin) { a = ShowAction::ShowBoth; @@ -827,7 +827,7 @@ void NoteListView::onCustomContextMenu(QPoint point) } contextMenu->addSeparator(); if (m_dbManager) { - for (auto action : qAsConst(m_folderActions)) { + for (auto action : std::as_const(m_folderActions)) { delete action; } m_folderActions.clear(); @@ -842,7 +842,7 @@ void NoteListView::onCustomContextMenu(QPoint point) auto action = new QAction(folders[id], this); connect(action, &QAction::triggered, this, [this, id] { auto indexes = selectedIndexes(); - for (const auto &selectedIndex : qAsConst(indexes)) { + for (const auto &selectedIndex : std::as_const(indexes)) { if (selectedIndex.isValid()) { emit moveNoteRequested( selectedIndex.data(NoteListModel::NoteID).toInt(), id); @@ -866,7 +866,7 @@ void NoteListView::onAnimationFinished(NoteListState state) if (state == NoteListState::Remove) { auto model = dynamic_cast(this->model()); if (model) { - for (const auto id : qAsConst(m_needRemovedNotes)) { + for (const auto id : std::as_const(m_needRemovedNotes)) { auto index = model->getNoteIndex(id); model->removeRow(index.row()); } diff --git a/src/taglistmodel.cpp b/src/taglistmodel.cpp index caf9779d2..3938e5f34 100644 --- a/src/taglistmodel.cpp +++ b/src/taglistmodel.cpp @@ -69,7 +69,7 @@ QVariant TagListModel::data(const QModelIndex &index, int role) const void TagListModel::updateTagData() { m_data.clear(); - for (const auto &id : qAsConst(m_ids)) { + for (const auto &id : std::as_const(m_ids)) { if (m_tagPool->contains(id)) { m_data.append(m_tagPool->getTag(id)); } else { diff --git a/src/tagtreedelegateeditor.cpp b/src/tagtreedelegateeditor.cpp index a6e6d2bc2..799675ee0 100644 --- a/src/tagtreedelegateeditor.cpp +++ b/src/tagtreedelegateeditor.cpp @@ -174,9 +174,9 @@ void TagTreeDelegateEditor::paintEvent(QPaintEvent *event) void TagTreeDelegateEditor::mouseDoubleClickEvent(QMouseEvent *event) { auto iconRect = QRect(rect().x() + 10, rect().y() + (rect().height() - 14) / 2, 14, 14); - if (iconRect.contains(event->pos())) { + if (iconRect.contains(event->position().toPoint())) { dynamic_cast(m_view)->onChangeTagColorAction(); - } else if (m_label->geometry().contains(event->pos())) { + } else if (m_label->geometry().contains(event->position().toPoint())) { m_label->openEditor(); } else { QWidget::mouseDoubleClickEvent(event); diff --git a/src/treeviewlogic.cpp b/src/treeviewlogic.cpp index 67bce015a..b1cb155b4 100644 --- a/src/treeviewlogic.cpp +++ b/src/treeviewlogic.cpp @@ -129,7 +129,7 @@ void TreeViewLogic::loadTreeModel(const NodeTagTreeData &treeData) m_treeView->setCurrentIndexC(m_treeModel->getAllNotesButtonIndex()); } } else { - for (const auto &id : qAsConst(m_lastSelectTags)) { + for (const auto &id : std::as_const(m_lastSelectTags)) { m_treeView->setCurrentIndexNC(m_treeModel->tagIndexFromId(id)); } } diff --git a/src/updaterwindow.cpp b/src/updaterwindow.cpp index 22f06150d..1af4ba45d 100644 --- a/src/updaterwindow.cpp +++ b/src/updaterwindow.cpp @@ -554,15 +554,16 @@ void UpdaterWindow::onDownloadFinished() void UpdaterWindow::mousePressEvent(QMouseEvent *event) { if (event->button() == Qt::LeftButton) { - if (event->x() < width() - 5 && event->x() > 5 && event->pos().y() < height() - 5 - && event->pos().y() > 5) { + if (event->position().x() < width() - 5 && event->position().x() > 5 + && event->position().toPoint().y() < height() - 5 + && event->position().toPoint().y() > 5) { #if QT_VERSION >= QT_VERSION_CHECK(5, 15, 0) m_canMoveWindow = !window()->windowHandle()->startSystemMove(); #else m_canMoveWindow = true; #endif - m_mousePressX = event->pos().x(); - m_mousePressY = event->pos().y(); + m_mousePressX = event->position().toPoint().x(); + m_mousePressY = event->position().toPoint().y(); } } event->accept(); @@ -576,8 +577,8 @@ void UpdaterWindow::mousePressEvent(QMouseEvent *event) void UpdaterWindow::mouseMoveEvent(QMouseEvent *event) { if (m_canMoveWindow) { - int dx = event->globalX() - m_mousePressX; - int dy = event->globalY() - m_mousePressY; + int dx = event->globalPosition().x() - m_mousePressX; + int dy = event->globalPosition().y() - m_mousePressY; move(dx, dy); } } From bfb0827416bea16875995f15be681dbc8e0a2fd0 Mon Sep 17 00:00:00 2001 From: zjeffer <4633209+zjeffer@users.noreply.github.com> Date: Wed, 23 Oct 2024 18:22:42 +0200 Subject: [PATCH 2/2] Remove Qt 5 support As time goes by, it becomes more and more laborious to maintain two major Qt versions in parallel. We had many workarounds and missing features for the Qt 5 version, which had its last public release almost 4 years ago. Additionally, the system requirements for Qt 6 are not unreasonable, so the majority of people should be able to run it. So, for those reasons, we decided to remove Qt 5 support completely. Users that can't run the Qt 6 version for whatever reason, are free to either disable updates and stay on Notes 2.3.x, or manually build Notes off of the "qt5" branch. Co-authored-by: guihkx <626206+guihkx@users.noreply.github.com> --- .github/workflows/linux.yml | 27 +- .github/workflows/macos.yml | 56 +- .github/workflows/windows.yml | 101 +- CMakeLists.txt | 78 +- Dockerfiles/appimage-qt5 | 83 -- Dockerfiles/ubuntu-20_04 | 23 - docs/build_on_linux.md | 2 - docs/build_on_windows.md | 10 +- docs/build_options.md | 7 - .../windows/Notes_Inno_Script_Github.iss | 40 - snap/snapcraft.yaml | 1 - src/aboutwindow.cpp | 3 - src/dbmanager.cpp | 8 - src/fontloader.cpp | 8 - src/fontloader.h | 6 - src/framelesswindow.cpp | 12 +- src/framelesswindow.h | 4 - src/main.cpp | 4 - src/mainwindow.cpp | 25 +- src/nodepath.cpp | 4 - src/noteeditorlogic.cpp | 8 - src/notelistdelegate.cpp | 8 - src/notelistdelegateeditor.cpp | 4 - src/notelistdelegateeditor.h | 4 - src/notelistview.cpp | 21 - src/qml.qrc | 1 - src/qml/EditorSettingsQt512.qml | 945 ------------------ src/updaterwindow.cpp | 7 - 28 files changed, 68 insertions(+), 1432 deletions(-) delete mode 100644 Dockerfiles/appimage-qt5 delete mode 100644 Dockerfiles/ubuntu-20_04 delete mode 100644 src/qml/EditorSettingsQt512.qml diff --git a/.github/workflows/linux.yml b/.github/workflows/linux.yml index 1cfa3179b..1305966b7 100644 --- a/.github/workflows/linux.yml +++ b/.github/workflows/linux.yml @@ -9,7 +9,7 @@ env: jobs: deb: - name: deb (${{ matrix.build-type }}, Qt ${{ matrix.qt-version-major }}, ${{ matrix.image }}) + name: deb (${{ matrix.build-type }}, Qt 6, ${{ matrix.image }}) runs-on: ubuntu-latest permissions: contents: read @@ -18,20 +18,12 @@ jobs: fail-fast: false matrix: include: - # Ubuntu's release cycle: https://wiki.ubuntu.com/Releases - - image: ubuntu-20_04 - build-script: ubuntu_deb_entrypoint.sh - qt-version-major: 5 - build-type: release - - image: ubuntu-22_04 build-script: ubuntu_deb_entrypoint.sh - qt-version-major: 6 build-type: release - image: ubuntu-23_10 build-script: ubuntu_deb_entrypoint.sh - qt-version-major: 6 build-type: release steps: - name: Checkout code @@ -75,7 +67,7 @@ jobs: uses: actions/upload-artifact@v4 with: if-no-files-found: error - name: ${{ steps.build.outputs.deb_name }}-qt${{ matrix.qt-version-major }}-${{ steps.build.outputs.distro_name }}-${{ matrix.build-type }} + name: ${{ steps.build.outputs.deb_name }}-qt6-${{ steps.build.outputs.distro_name }}-${{ matrix.build-type }} path: ${{ steps.build.outputs.deb_path }} - name: Login to GitHub Container Registry @@ -104,7 +96,7 @@ jobs: tags: ${{ env.REGISTRY }}/nuttyartist/notes:${{ matrix.image }} rpm: - name: rpm (${{ matrix.build-type }}, Qt ${{ matrix.qt-version-major }}, ${{ matrix.image }}) + name: rpm (${{ matrix.build-type }}, Qt 6, ${{ matrix.image }}) runs-on: ubuntu-latest strategy: fail-fast: false @@ -113,13 +105,11 @@ jobs: # Fedora's release cycle: https://endoflife.date/fedora - image: fedora-38 build-script: rpm_entrypoint.sh - qt-version-major: 6 build-type: release # openSUSE's release cycle: https://endoflife.date/opensuse - image: opensuse-15_5 build-script: rpm_entrypoint.sh - qt-version-major: 6 build-type: release steps: - name: Checkout code @@ -163,7 +153,7 @@ jobs: uses: actions/upload-artifact@v4 with: if-no-files-found: error - name: ${{ steps.build.outputs.rpm_name }}-qt${{ matrix.qt-version-major }}-${{ steps.build.outputs.distro_name }}-${{ matrix.build-type }} + name: ${{ steps.build.outputs.rpm_name }}-qt6-${{ steps.build.outputs.distro_name }}-${{ matrix.build-type }} path: ${{ steps.build.outputs.rpm_path }} - name: Login to GitHub Container Registry @@ -192,20 +182,14 @@ jobs: tags: ${{ env.REGISTRY }}/nuttyartist/notes:${{ matrix.image }} appimage: - name: AppImage (${{ matrix.build-type }}, Qt ${{ matrix.qt-version-major }}, ${{ matrix.image }}) + name: AppImage (${{ matrix.build-type }}, Qt 6, ${{ matrix.image }}) runs-on: ubuntu-latest strategy: fail-fast: false matrix: include: - - image: appimage-qt5 - build-script: appimage_entrypoint.sh - qt-version-major: 5 - build-type: release - - image: appimage-qt6 build-script: appimage_entrypoint.sh - qt-version-major: 6 build-type: release steps: - name: Checkout code @@ -246,7 +230,6 @@ jobs: run: docker run --rm -v "${GITHUB_OUTPUT}:/GITHUB_OUTPUT" -v "$(pwd):/src" -t '${{ env.REGISTRY }}/nuttyartist/notes:${{ matrix.image }}' -t ${{ matrix.build-type }} ${{ github.ref_type == 'tag' && '-n' || ' ' }} - name: (FIXME) Run qmllint - if: endsWith(matrix.image, 'qt6') run: docker run --rm -v "$(pwd):/src" --entrypoint '' -t '${{ env.REGISTRY }}/nuttyartist/notes:${{ matrix.image }}' cmake --build build --target all_qmllint || true - name: Upload AppImage artifact diff --git a/.github/workflows/macos.yml b/.github/workflows/macos.yml index fd777f443..0c7eaf941 100644 --- a/.github/workflows/macos.yml +++ b/.github/workflows/macos.yml @@ -9,18 +9,13 @@ jobs: # So it doesn't make much sense to have different build types other than 'debug' here. # The release dmg is built using aqtinstall instead (the job below this one). build-homebrew: - name: Build (${{ matrix.build-type }}, homebrew (qt${{ matrix.qt-version-major }}), ${{ matrix.os }}) + name: Build (${{ matrix.build-type }}, homebrew (qt6), ${{ matrix.os }}) runs-on: ${{ matrix.os }} strategy: fail-fast: false matrix: include: - os: macos-13 - qt-version-major: 5 - build-type: debug - - - os: macos-13 - qt-version-major: 6 build-type: debug steps: - name: Checkout code @@ -28,19 +23,9 @@ jobs: with: submodules: recursive - - name: Install Qt ${{ matrix.qt-version-major }} (homebrew) - run: | - brew install ninja qt@${{ matrix.qt-version-major }} - - - name: Configure Qt ${{ matrix.qt-version-major }} (homebrew) - if: matrix.qt-version-major == 5 + - name: Install Qt 6 (homebrew) run: | - brew link qt@${{ matrix.qt-version-major }} - cat << EOF - LDFLAGS="-L/usr/local/opt/qt@${{ matrix.qt-version-major }}/lib" - export CPPFLAGS="-I/usr/local/opt/qt@${{ matrix.qt-version-major }}/include" - export PATH="/usr/local/opt/qt@${{ matrix.qt-version-major }}/bin:$PATH" - EOF >> ~/.bashrc + brew install ninja qt@6 - name: Setup CLang problem matcher # Technically, this action only supports GCC, but it seems to work well for Clang too. @@ -55,13 +40,10 @@ jobs: cmake . --warn-uninitialized --warn-unused-vars \ -G Ninja -B build \ -DCMAKE_BUILD_TYPE=${{ matrix.build-type }} \ - -DCMAKE_PREFIX_PATH="$(brew --prefix qt@${{ matrix.qt-version-major }})" \ + -DCMAKE_PREFIX_PATH="$(brew --prefix qt@6)" \ -DPRO_VERSION=OFF cmake --build build - # Build the dmg disk image using the official Qt 5 release downloaded by aqtinstall. - # This is also done for Linux and Windows, just to make sure we use the exact same Qt version across all three OSes. - # # NOTE: This job uses a fixed Qt version (set in the 'qt-version' key below)! # So, remember to keep it updated whenever a new Qt version is available on aqtinstall. dmg-aqtinstall: @@ -71,10 +53,6 @@ jobs: fail-fast: false matrix: include: - - os: macos-13 - qt-version: 5.15.2 - build-type: release - - os: macos-13 qt-version: 6.5.2 build-type: release @@ -98,11 +76,7 @@ jobs: then version="${version}+g${GITHUB_SHA::7}" fi - arches='x86_64' - if [[ '${{ matrix.qt-version }}' == 6.* ]] - then - arches+='-arm64' - fi + arches='x86_64-arm64' artifact_name="Notes_${version}-Qt${{ matrix.qt-version }}-${arches}" if [ '${{ matrix.build-type }}' == 'debug' ] then @@ -126,23 +100,20 @@ jobs: - name: Build (${{ matrix.build-type }}) env: - # Only commercial Qt 5 supports targeting Apple Silicon at the moment: - # https://www.qt.io/blog/qt-on-apple-silicon - TARGET_ARCH: ${{ startsWith(matrix.qt-version, '6.') && 'x86_64;arm64' || 'x86_64' }} + TARGET_ARCH: x86_64;arm64 VERBOSE: 1 run: | export CMAKE_BUILD_PARALLEL_LEVEL=$(sysctl -n hw.logicalcpu) cmake . --warn-uninitialized --warn-unused-vars \ -B build -G Ninja \ - -DCMAKE_OSX_DEPLOYMENT_TARGET=${{ startsWith(matrix.qt-version, '6.') && '11.0' || '10.15' }} \ + -DCMAKE_OSX_DEPLOYMENT_TARGET=11.0 \ -DCMAKE_BUILD_TYPE=${{ matrix.build-type }} \ -DGIT_REVISION=${{ github.ref_type != 'tag' && 'ON' || 'OFF' }} \ - -DCMAKE_OSX_ARCHITECTURES="${{ env.TARGET_ARCH }}" \ + -DCMAKE_OSX_ARCHITECTURES='x86_64;arm64' \ -DPRO_VERSION=OFF cmake --build build - name: (FIXME) Run qmllint - if: startsWith(matrix.qt-version, '6.') run: | cmake --build build --target all_qmllint || true @@ -158,17 +129,6 @@ jobs: mv Notes.app 'Notes Better.app' macdeployqt 'Notes Better.app' -qmldir=../src/qml -appstore-compliant - - name: Remove unnecessary Qt plugins and libraries - run: | - set -x - set -e - cd 'build/Notes Better.app' - if [[ '${{ matrix.qt-version }}' == 5.* ]] - then - # The bearer plugin has caused problems for us in the past. Plus, it was removed altogether in Qt 6. - rm -rv Contents/PlugIns/bearer - fi - - name: Import signing certificate if: github.repository == 'nuttyartist/notes' && github.event_name != 'pull_request' run: | diff --git a/.github/workflows/windows.yml b/.github/workflows/windows.yml index c1446d04e..bfdc55345 100644 --- a/.github/workflows/windows.yml +++ b/.github/workflows/windows.yml @@ -8,24 +8,13 @@ jobs: # NOTE: This job uses a fixed Qt version (set in the 'qt-version' key below)! # So, remember to keep it updated whenever a new Qt version is available on aqtinstall. build-aqtinstall: - name: Build (${{ matrix.arch }}, ${{ matrix.build-type }}, Qt ${{ matrix.qt-version }}, ${{ matrix.os }}) + name: Build (${{ matrix.build-type }}, Qt ${{ matrix.qt-version }}, ${{ matrix.os }}) runs-on: ${{ matrix.os }} strategy: fail-fast: false matrix: include: - os: windows-2019 - arch: x64 - qt-version: 5.15.2 - build-type: release - - - os: windows-2019 - arch: x86 - qt-version: 5.15.2 - build-type: release - - - os: windows-2019 - arch: x64 qt-version: 6.4.3 build-type: release outputs: @@ -46,26 +35,26 @@ jobs: if ('${{ github.ref_type }}' -ne 'tag') { $version += "+g$($env:GITHUB_SHA.Substring(0,7))" } - $artifact_name = "Notes_$version-Qt${{ matrix.qt-version }}-${{ matrix.arch }}" + $artifact_name = "Notes_$version-Qt${{ matrix.qt-version }}-x64" Write-Output "version=$version" >> $env:GITHUB_OUTPUT Write-Output "artifact_name=$artifact_name" >> $env:GITHUB_OUTPUT - - name: Setup MSVC (${{ matrix.arch }}) + - name: Setup MSVC uses: ilammy/msvc-dev-cmd@v1 with: - arch: ${{ matrix.arch }} + arch: x64 - - name: Install Qt ${{ matrix.qt-version }} (aqtinstall, ${{ matrix.arch }}) + - name: Install Qt ${{ matrix.qt-version }} (aqtinstall) uses: jurplel/install-qt-action@v4 with: version: ${{ matrix.qt-version }} cache: true - arch: ${{ matrix.arch == 'x86' && 'win32_msvc2019' || 'win64_msvc2019_64' }} + arch: win64_msvc2019_64 # Details about this OpenSSL build: https://kb.firedaemon.com/support/solutions/articles/4000121705 # TODO: Remove/tweak this step if/when we get rid of the x86 build or upgrade to Qt 6.5+. - name: Download OpenSSL 1.x binaries from FireDaemon - if: ${{ startsWith(matrix.qt-version, '5.') || startsWith(matrix.qt-version, '6.4.') }} + if: startsWith(matrix.qt-version, '6.4.') run: | $out_file = "openssl-1.1.1w.zip" Invoke-WebRequest -Uri https://download.firedaemon.com/FireDaemon-OpenSSL/openssl-1.1.1w.zip -OutFile $env:Temp\$out_file @@ -75,7 +64,7 @@ jobs: - name: Setup MSVC problem matcher uses: ammaraskar/msvc-problem-matcher@0.3.0 - - name: Build (${{ matrix.build-type }}, ${{ matrix.arch }}) + - name: Build (${{ matrix.build-type }}) env: VERBOSE: 1 run: | @@ -88,49 +77,38 @@ jobs: cmake --build build - name: (FIXME) Run qmllint - if: startsWith(matrix.qt-version, '6.') run: | cmake --build build --target all_qmllint || $(exit 0) - - name: Install (${{ matrix.build-type }}, ${{ matrix.arch }}) + - name: Install (${{ matrix.build-type }}) run: | cmake --install build --prefix build - - name: Deploy (${{ matrix.build-type }}, ${{ matrix.arch }}) + - name: Deploy (${{ matrix.build-type }}) run: | - windeployqt ${{ startsWith(matrix.qt-version, '5.') && '--no-qmltooling' || ' ' }} --qmldir src\qml build\bin + windeployqt --qmldir src\qml build\bin - name: Remove unnecessary Qt plugins and libraries run: | Set-Location build\bin # We ship all required runtime DLLs individually. Remove-Item -Verbose vc_redist.*.exe - if ('${{ matrix.qt-version }}'.StartsWith('5.')) { - # The bearer plugin has caused problems for us in the past. Plus, it was removed altogether in Qt 6. - Remove-Item -Verbose -Recurse bearer - } # We only use the SQLite Qt driver, so it's fine to delete others. Remove-Item -Verbose sqldrivers\qsqlodbc.dll Remove-Item -Verbose sqldrivers\qsqlpsql.dll - - name: Include required runtime libraries (${{ matrix.build-type }}, ${{ matrix.arch }}) + - name: Include required runtime libraries (${{ matrix.build-type }}) run: | Set-Location build\bin - if ('${{ matrix.arch }}' -ieq 'x64') { - $openssl_lib_suffix = '-x64' - } else { - $openssl_lib_suffix = '' - } - # Include OpenSSL libraries. - Copy-Item $env:Temp\OpenSSL\${{ matrix.arch }}\bin\libcrypto-1_1$openssl_lib_suffix.dll - Copy-Item $env:Temp\OpenSSL\${{ matrix.arch }}\bin\libssl-1_1$openssl_lib_suffix.dll + Copy-Item $env:Temp\OpenSSL\x64\bin\libcrypto-1_1-x64.dll + Copy-Item $env:Temp\OpenSSL\x64\bin\libssl-1_1-x64.dll # Also include OpenSSL debug symbols (when building Notes in debug mode). if ('${{ matrix.build-type }}' -ieq 'debug') { - Copy-Item $env:Temp\OpenSSL\${{ matrix.arch }}\bin\libcrypto-1_1$openssl_lib_suffix.pdb - Copy-Item $env:Temp\OpenSSL\${{ matrix.arch }}\bin\libssl-1_1$openssl_lib_suffix.pdb + Copy-Item $env:Temp\OpenSSL\x64\bin\libcrypto-1_1-x64.pdb + Copy-Item $env:Temp\OpenSSL\x64\bin\libssl-1_1-x64.pdb } # Include MSVC 2019 runtime libraries. @@ -139,33 +117,25 @@ jobs: # XXX: Hack to work around this issue: https://github.com/actions/runner-images/issues/10819 $env:VCToolsRedistDir = -join ($env:VCINSTALLDIR, "Redist\MSVC\", $env:VCToolsVersion, "\") } - Copy-Item $env:VCToolsRedistDir\${{ matrix.arch }}\Microsoft.VC142.CRT\msvcp140.dll - Copy-Item $env:VCToolsRedistDir\${{ matrix.arch }}\Microsoft.VC142.CRT\msvcp140_1.dll - - # Only Qt 6 builds also need msvcp140_2.dll - if ('${{ matrix.qt-version }}'.StartsWith('6')) { - Copy-Item $env:VCToolsRedistDir\${{ matrix.arch }}\Microsoft.VC142.CRT\msvcp140_2.dll - } - - Copy-Item $env:VCToolsRedistDir\${{ matrix.arch }}\Microsoft.VC142.CRT\vcruntime140.dll - if ('${{ matrix.arch }}' -ieq 'x64') { - # Only 64-bit builds also need 'vcruntime140_1.dll' (tested on Windows 7) - Copy-Item $env:VCToolsRedistDir\${{ matrix.arch }}\Microsoft.VC142.CRT\vcruntime140_1.dll - } + Copy-Item $env:VCToolsRedistDir\x64\Microsoft.VC142.CRT\msvcp140.dll + Copy-Item $env:VCToolsRedistDir\x64\Microsoft.VC142.CRT\msvcp140_1.dll + Copy-Item $env:VCToolsRedistDir\x64\Microsoft.VC142.CRT\msvcp140_2.dll + Copy-Item $env:VCToolsRedistDir\x64\Microsoft.VC142.CRT\vcruntime140.dll + Copy-Item $env:VCToolsRedistDir\x64\Microsoft.VC142.CRT\vcruntime140_1.dll } else { # On debug builds, the libraries above are included automatically, so we only need 'urtcbased.dll'. - Copy-Item $env:WindowsSdkBinPath\${{ matrix.arch }}\ucrt\ucrtbased.dll + Copy-Item $env:WindowsSdkBinPath\x64\ucrt\ucrtbased.dll } - - name: Upload artifacts (${{ matrix.build-type }}, ${{ matrix.arch }}) + - name: Upload artifacts (${{ matrix.build-type }}) uses: actions/upload-artifact@v4 with: if-no-files-found: error name: ${{ steps.vars.outputs.artifact_name }}-${{ runner.os }}-${{ matrix.build-type }} path: build\bin - unified-installer: - name: Unified x64-x86 Installer + installer: + name: Installer needs: build-aqtinstall runs-on: windows-2019 steps: @@ -178,29 +148,18 @@ jobs: path: artifacts pattern: '*Windows*' - - name: Ensure a 64-bit Qt 6 build is present + - name: Ensure a x64 Qt 6 build is present run: | Set-Location artifacts $x64_build = Get-ChildItem -Filter '*Qt6*-x64-Windows-release' -Attributes Directory | Sort-Object -Property @{Expression = "Name"; Descending = $true} | Select-Object -First 1 if (!$x64_build) { - Throw 'Could not find a 64-bit Qt 6 build.' + Throw 'Could not find a x64 Qt 6 build.' } Move-Item $x64_build Notes64 - - name: Ensure a 32-bit Qt 5 build is present - run: | - Set-Location artifacts - $x86_build = Get-ChildItem -Filter '*Qt5*-x86-Windows-release' -Attributes Directory | - Sort-Object -Property @{Expression = "Name"; Descending = $true} | - Select-Object -First 1 - if (!$x86_build) { - Throw 'Could not find a 32-bit Qt 5 build.' - } - Move-Item $x86_build Notes32 - - - name: Create unified installer + - name: Create installer run: | Set-Location artifacts Copy-Item ..\packaging\windows\Notes_Inno_Script_Github.iss @@ -214,7 +173,7 @@ jobs: run: | Set-Location artifacts $inno_setup_manifest = ".\installer\Setup-Manifest.txt" - $windeployqt_paths = @(".\Notes32", ".\Notes64") + $windeployqt_paths = @(".\Notes64") $inno_setup_files = @() Get-Content -LiteralPath $inno_setup_manifest -ErrorAction Stop | Select-Object -Skip 1 | Foreach-Object { @@ -244,7 +203,7 @@ jobs: } Write-Host "SUCCESS: List of files in the installer matches the ones copied by windeployqt." - - name: Upload unified installer artifact + - name: Upload installer artifact uses: actions/upload-artifact@v4 with: if-no-files-found: error diff --git a/CMakeLists.txt b/CMakeLists.txt index 4380d39ef..e2c7ad190 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -12,9 +12,6 @@ string(TIMESTAMP CURRENT_YEAR "%Y") set(CMAKE_OSX_DEPLOYMENT_TARGET "10.15" CACHE STRING "Minimum macOS version to target for deployment") -set(USE_QT_VERSION - "" - CACHE STRING "Use a specific version of Qt to build the app") option(GIT_REVISION "Append the current git revision to the app's version string" OFF) option(UPDATE_CHECKER @@ -56,44 +53,15 @@ set(QT_COMPONENTS Widgets Quick) -# No Qt version was specified, try to use either Qt 6 (preferred) or Qt 5. -if(USE_QT_VERSION STREQUAL "") - # This can probably be simplified once the following bug gets resolved: - # https://gitlab.kitware.com/cmake/cmake/-/issues/23575 - message(STATUS "Trying to find Qt 6...") +message(STATUS "Trying to find Qt 6...") +find_package(QT NAMES Qt6 QUIET) - find_package(QT NAMES Qt6 QUIET) - - if(NOT DEFINED QT_VERSION_MAJOR) - message(STATUS "Could not find Qt 6, will try Qt 5 next...") - - find_package(QT NAMES Qt5 QUIET) - - if(NOT DEFINED QT_VERSION_MAJOR) - message(FATAL_ERROR "Could not find Qt 5, aborting compilation.") - endif() - endif() - - find_package(Qt${QT_VERSION_MAJOR} REQUIRED COMPONENTS ${QT_COMPONENTS}) -else() - if(NOT USE_QT_VERSION STREQUAL "5" AND NOT USE_QT_VERSION STREQUAL "6") - message( - FATAL_ERROR - "An unsupported version of Qt was specified: '${USE_QT_VERSION}'. Valid values are: 5 or 6." - ) - endif() - message(STATUS "Trying to find Qt ${USE_QT_VERSION} (manually specified)...") - - find_package(QT NAMES Qt${USE_QT_VERSION} QUIET) - - if(NOT DEFINED QT_VERSION_MAJOR) - message( - FATAL_ERROR "Could not find Qt ${USE_QT_VERSION}, aborting compilation.") - endif() - - find_package(Qt${USE_QT_VERSION} REQUIRED COMPONENTS ${QT_COMPONENTS}) +if(NOT DEFINED QT_VERSION_MAJOR OR QT_VERSION_MAJOR LESS 6) + message(STATUS "Could not find Qt 6, aborting compilation.") endif() +find_package(Qt${QT_VERSION_MAJOR} REQUIRED COMPONENTS ${QT_COMPONENTS}) + message(STATUS "Success! Configuration details:") message(STATUS "App name: ${PROJECT_NAME}") message(STATUS "App version: ${PROJECT_VERSION}") @@ -211,10 +179,6 @@ set(SOURCES ${PROJECT_SOURCE_DIR}/src/images.qrc ${PROJECT_SOURCE_DIR}/src/styles.qrc) -if(QT_VERSION VERSION_LESS 6.0) - list(APPEND SOURCES ${PROJECT_SOURCE_DIR}/src/qml.qrc) -endif() - # Third-party source files. set(SOURCES_3RD_PARTY ${PROJECT_SOURCE_DIR}/3rdParty/qautostart/src/qautostart.cpp @@ -490,16 +454,10 @@ elseif(UNIX) # deb-specific set(CPACK_DEBIAN_FILE_NAME DEB-DEFAULT) - if(QT_VERSION_MAJOR VERSION_GREATER_EQUAL 6) - set(CPACK_DEBIAN_PACKAGE_DEPENDS "qt6-qpa-plugins") - if(QT_VERSION_MINOR VERSION_GREATER_EQUAL 2) - set(CPACK_DEBIAN_PACKAGE_DEPENDS - "${CPACK_DEBIAN_PACKAGE_DEPENDS}, qml6-module-qtqml-workerscript, qml6-module-qtquick-controls, qml6-module-qtquick-layouts, qml6-module-qtquick-particles, qml6-module-qtquick-templates, qml6-module-qtquick-window" - ) - endif() - elseif(QT_VERSION_MAJOR VERSION_EQUAL 5) + set(CPACK_DEBIAN_PACKAGE_DEPENDS "qt6-qpa-plugins") + if(QT_VERSION_MINOR VERSION_GREATER_EQUAL 2) set(CPACK_DEBIAN_PACKAGE_DEPENDS - "qml-module-qtquick2, qml-module-qtquick-controls2, qml-module-qtquick-window2" + "${CPACK_DEBIAN_PACKAGE_DEPENDS}, qml6-module-qtqml-workerscript, qml6-module-qtquick-controls, qml6-module-qtquick-layouts, qml6-module-qtquick-particles, qml6-module-qtquick-templates, qml6-module-qtquick-window" ) endif() set(CPACK_DEBIAN_PACKAGE_SHLIBDEPS ON) @@ -508,16 +466,14 @@ elseif(UNIX) # rpm-specific set(CPACK_RPM_FILE_NAME RPM-DEFAULT) - if(QT_VERSION_MAJOR VERSION_GREATER_EQUAL 6) - if(UNIX - AND NOT APPLE - AND EXISTS /etc/os-release) - file(READ /etc/os-release DISTRO_INFO) - if(DISTRO_INFO MATCHES "SUSE") - # Note: Different from Fedora 36, the SQLite library we need is not a dependency - # of the base Qt 6 package on openSUSE Leap 15.4, so we have to manually include it here. - set(CPACK_RPM_PACKAGE_REQUIRES "qt6-sql-sqlite") - endif() + if(UNIX + AND NOT APPLE + AND EXISTS /etc/os-release) + file(READ /etc/os-release DISTRO_INFO) + if(DISTRO_INFO MATCHES "SUSE") + # Note: Different from Fedora 36, the SQLite library we need is not a dependency + # of the base Qt 6 package on openSUSE Leap 15.4, so we have to manually include it here. + set(CPACK_RPM_PACKAGE_REQUIRES "qt6-sql-sqlite") endif() endif() set(CPACK_RPM_PACKAGE_LICENSE MPL-2.0) diff --git a/Dockerfiles/appimage-qt5 b/Dockerfiles/appimage-qt5 deleted file mode 100644 index 155191f60..000000000 --- a/Dockerfiles/appimage-qt5 +++ /dev/null @@ -1,83 +0,0 @@ -# vim: set syntax=dockerfile: -FROM ubuntu:20.04 - -LABEL org.opencontainers.image.description="Base image used to build Notes with Qt 5 and AppImage-package it" - -ENV QT_VERSION=5.15.2 -ENV QT_ARCHITECTURE=gcc_64 - -# Prevent tzdata from asking for input. -ARG DEBIAN_FRONTEND=noninteractive - -# Install all required dependencies: -# -# - appstream: Used to validate the AppStream metadata file. -# - cmake: Used to help build the application. -# - desktop-file-utils: Used to validate the desktop file. -# - file: Required by linuxdeploy. -# - git: Used to clone this repository. -# - g++: Used to compile the application. -# - libdbus-1-3: libQt5DBus links against this library. -# - libegl1: Used as dependency of the resulting AppImage. -# - libfontconfig1: Used as dependency of the resulting AppImage. -# - libglib2.0-0: The iuc binary included with Qt 5 links against this library. -# - libgl-dev: OpenGL headers needed at build time by Qt 6. -# - libxcb-icccm4: Used as dependency of the resulting AppImage. -# - libxcb-image0: Used as dependency of the resulting AppImage. -# - libxcb-keysyms1: Used as dependency of the resulting AppImage. -# - libxcb-randr0: Used as dependency of the resulting AppImage. -# - libxcb-render-util0: Used as dependency of the resulting AppImage. -# - libxcb-shape0: Used as dependency of the resulting AppImage. -# - libxcb-xinerama0: Used as dependency of the resulting AppImage. -# - libxcb-xkb1: Used as dependency of the resulting AppImage. -# - libxkbcommon-x11-0: Used as dependency of the resulting AppImage. -# - make: Used to help build the application. -# - python3/python3-dev/python3-pip: Used to install and run aqtinstall. -RUN apt-get update && \ - apt-get install -y --no-install-recommends appstream cmake desktop-file-utils file git g++ libdbus-1-3 \ - libegl1 libfontconfig1 libglib2.0-0 libgl-dev libxcb-icccm4 libxcb-image0 libxcb-keysyms1 libxcb-randr0 \ - libxcb-render-util0 libxcb-shape0 libxcb-xinerama0 libxcb-xkb1 libxkbcommon-x11-0 make python3 python3-dev python3-pip && \ - apt-get clean && \ - rm -rf /var/lib/apt/lists - -# Install Qt using aqtinstall. -RUN python3 -m pip install aqtinstall && \ - rm -rf ~/.cache - -# Download the specified Qt version using aqtinstall. -RUN python3 -m aqt install-qt --outputdir /Qt linux desktop "$QT_VERSION" "$QT_ARCHITECTURE" && \ - rm -f aqtinstall.log - -# Qt 5 ships with a variety of SQL drivers, but we only need the SQLite one, so here we symlink all -# the other drivers to it, in order to avoid having to install their dependencies for no reason. -# This is a workaround for: https://github.com/linuxdeploy/linuxdeploy-plugin-qt/issues/153 -RUN for driver in libqsqlodbc libqsqlpsql; do \ - ln -fsv libqsqlite.so "/Qt/$QT_VERSION/$QT_ARCHITECTURE/plugins/sqldrivers/$driver.so"; \ - done - -# Download linuxdeploy and its Qt plugin: -ADD --chmod=755 https://github.com/linuxdeploy/linuxdeploy/releases/download/continuous/linuxdeploy-x86_64.AppImage /usr/bin/linuxdeploy -ADD --chmod=755 https://github.com/linuxdeploy/linuxdeploy-plugin-qt/releases/download/continuous/linuxdeploy-plugin-qt-x86_64.AppImage /usr/bin/linuxdeploy-plugin-qt - -# Note's app ID on Linux. -ENV APP_ID="io.github.nuttyartist.notes" -# Other environment variables expected by CMake and linuxdeploy. -ENV APPIMAGE_EXTRACT_AND_RUN=1 -ENV DISABLE_COPYRIGHT_FILES_DEPLOYMENT=1 -ENV LD_LIBRARY_PATH="/Qt/$QT_VERSION/$QT_ARCHITECTURE/lib" -ENV PATH="/Qt/$QT_VERSION/$QT_ARCHITECTURE/bin:$PATH" -ENV PKG_CONFIG_PATH="/Qt/$QT_VERSION/$QT_ARCHITECTURE/lib/pkgconfig" -ENV QML2_IMPORT_PATH="/Qt/$QT_VERSION/$QT_ARCHITECTURE/qml" -ENV QML_SOURCES_PATHS="/src/src/qml" -ENV Qt5_DIR="/Qt/$QT_VERSION/$QT_ARCHITECTURE" -ENV QT_PLUGIN_PATH="/Qt/$QT_VERSION/$QT_ARCHITECTURE/plugins" - -# Prevent a fatal error from git: "detected dubious ownership in repository at '/src'". -RUN git config --global --add safe.directory /src - -# Don't forget to mount the current git tree to /src, i.e.: -# docker run -v $(pwd):/src -it --rm ... -WORKDIR /src - -ADD --chmod=755 ./Dockerfiles/appimage_entrypoint.sh /usr/bin/entrypoint.sh -ENTRYPOINT ["entrypoint.sh"] diff --git a/Dockerfiles/ubuntu-20_04 b/Dockerfiles/ubuntu-20_04 deleted file mode 100644 index b37662dba..000000000 --- a/Dockerfiles/ubuntu-20_04 +++ /dev/null @@ -1,23 +0,0 @@ -# vim: set syntax=dockerfile: -FROM ubuntu:20.04 - -LABEL org.opencontainers.image.description="Base image used to build and DEB-package Notes on Ubuntu 20.04" - -# Prevent tzdata from asking for input. -ENV DEBIAN_FRONTEND=noninteractive - -# Install dependencies. -RUN apt-get update && \ - apt-get install -y --no-install-recommends cmake git g++ lintian make qtbase5-private-dev qtdeclarative5-dev && \ - apt-get clean && \ - rm -rf /var/lib/apt/lists - -# Prevent a fatal error from git: "detected dubious ownership in repository at '/src'". -RUN git config --global --add safe.directory /src - -# Don't forget to mount the current git tree to /src, i.e.: -# docker run -v $(pwd):/src -it --rm ... -WORKDIR /src - -ADD --chmod=755 ./Dockerfiles/ubuntu_deb_entrypoint.sh /usr/bin/entrypoint.sh -ENTRYPOINT ["entrypoint.sh"] diff --git a/docs/build_on_linux.md b/docs/build_on_linux.md index f24cab0d1..a78ca7b4d 100644 --- a/docs/build_on_linux.md +++ b/docs/build_on_linux.md @@ -9,14 +9,12 @@ It's impossible to create a guide that will work for all Linux distros out there | Arch Linux[^3] | `cmake` `gcc` `git` `qt6-base` `qt6-declarative` | `hicolor-icon-theme` `qt6-base` `qt6-declarative` | | Fedora 37 - 39 | `cmake` `gcc` `git` `libxkbcommon-devel` `qt6-qtbase-private-devel` `qt6-qtdeclarative-devel` | `qt6-qtbase-gui` `qt6-qtdeclarative` | | openSUSE Leap 15[^4] | `cmake` `gcc` `git` `qt6-base-private-devel` `qt6-declarative-devel` | `libQt6Concurrent6` `libQt6Gui6` `qt6-sql-sqlite` | -| Ubuntu 20.04[^5] | `cmake` `g++` `git` `qtbase5-private-dev` `qt5qtdeclarative5-dev` | `libqt5network5` `libqt5sql5` `libqt5widgets5` `qml-module-qtquick2` `qml-module-qtquick-controls2` `qml-module-qtquick-window2` | | Ubuntu 22.04 - 23.04 | `cmake` `g++` `git` `qt6-base-private-dev` `qt6-declarative-dev` `libgl-dev` | `libqt6network6` `libqt6sql6` `libqt6widgets6` `qml6-module-qtqml-workerscript` `qml6-module-qtquick-controls` `qml6-module-qtquick-layouts` `qml6-module-qtquick-particles` `qml6-module-qtquick-templates` `qml6-module-qtquick-window` `qt6-qpa-plugins` | [^1]: These packages are only required to build Notes, meaning you can remove all of them (or some of them) afterward. [^2]: These packages are required to actually run Notes. [^3]: We recommend building and installing through the [official AUR package](https://aur.archlinux.org/packages/notes). [^4]: You may need to tell `cmake` to use use GCC 8 (or newer), e.g. run `export CXX=g++-10` before you invoke `cmake`. -[^5]: This distro can only build Notes with Qt 5. ### Build options diff --git a/docs/build_on_windows.md b/docs/build_on_windows.md index 42e67eadd..63e270237 100644 --- a/docs/build_on_windows.md +++ b/docs/build_on_windows.md @@ -2,13 +2,13 @@ These are common steps to build Notes from source on Windows. ### Requirements -Windows 7 (or newer) is required to build Notes. +Windows 10 21H2 (1809 or later) is required to build Notes. Additionally, you need to install the following tools/components: - [Git](https://gitforwindows.org/) - [Microsoft Visual C++](https://visualstudio.microsoft.com/downloads) `>= 2017` *(only the build tools are required)* -- [Qt](https://www.qt.io/download-qt-installer) `>= 5.12` *(using the latest version is recommended)* +- [Qt](https://www.qt.io/download-qt-installer) `>= 6.0` *(using the latest version is recommended)* - [CMake](https://cmake.org/download/) *(can be installed via the Qt installer)* - [Ninja](https://ninja-build.org/) *(can be installed via the Qt installer)* @@ -29,7 +29,7 @@ git clone https://github.com/nuttyartist/notes.git --recurse-submodules cd notes ``` -Now, let's configure our build environment. In this example, we will be using Microsoft Visual C++ 2017 and Qt 5.15.2 (the MSVC 2019 build), targeting a 64-bit system. +Now, let's configure our build environment. In this example, we will be using Microsoft Visual C++ 2017 and Qt 6.4.3 (the MSVC 2019 build), targeting a 64-bit system. Depending on what versions of these applications you have installed, you may need to make some path adjustments in the following steps. @@ -44,8 +44,8 @@ Now, we need to add CMake, Ninja, Qt sources and tools to our `Path` environment ```shell set Path=C:\Qt\Tools\CMake_64\bin;%Path% set Path=C:\Qt\Tools\Ninja;%Path% -set Path=C:\Qt\5.15.2\msvc2019_64;%Path% -set Path=C:\Qt\5.15.2\msvc2019_64\bin;%Path% +set Path=C:\Qt\6.4.3\msvc2019_64;%Path% +set Path=C:\Qt\6.4.3\msvc2019_64\bin;%Path% ``` Optionally, if you want to dedicate all cores of your CPU to build Notes much faster, set this environment variable: diff --git a/docs/build_options.md b/docs/build_options.md index fa7097ec2..bc8cfda7f 100644 --- a/docs/build_options.md +++ b/docs/build_options.md @@ -7,7 +7,6 @@ You should set those while invoking CMake to build the project. See the [example | Name | Default value | Supported values | Description | | ------------------------------------------ | ------------- | ------------------- | ----------------------------------------------------------- | | `CMAKE_OSX_DEPLOYMENT_TARGET` (macOS-only) | `10.15` | (any macOS version) | Minimum macOS version to target for deployment | -| `USE_QT_VERSION` | (unset) | `5` / `6` | Use a specific version of Qt to build the app | | `GIT_REVISION` | `OFF` | `ON` / `OFF` | Append the current git revision to the app's version string | | `UPDATE_CHECKER` | `ON` | `ON` / `OFF` | Enable or disable both the update checker and auto-updater | | `PRO_VERSION` | `ON` | `ON` / `OFF` | Enable or disable Notes Pro features | @@ -20,12 +19,6 @@ To build Notes without any update-checking feature: cmake -B build -DUPDATE_CHECKER=OFF ``` -To force CMake to use Qt 5 (useful when you also have Qt 6 installed, which will be chosen by default, if present): - -``` -cmake -B build -USE_QT_VERSION=5 -``` - To build Notes in `Release` mode (for other modes, check the [CMake documentation](https://cmake.org/cmake/help/latest/variable/CMAKE_BUILD_TYPE.html)): ``` diff --git a/packaging/windows/Notes_Inno_Script_Github.iss b/packaging/windows/Notes_Inno_Script_Github.iss index bb7eae59c..e5b903ed7 100644 --- a/packaging/windows/Notes_Inno_Script_Github.iss +++ b/packaging/windows/Notes_Inno_Script_Github.iss @@ -188,46 +188,6 @@ Source: "{#SourcePath}\Notes64\Qt6Widgets.dll"; DestDir: "{app}"; Flags: ignorev Source: "{#SourcePath}\Notes64\vcruntime140.dll"; DestDir: "{app}"; Flags: ignoreversion; Check: IsWin64; MinVersion: 10.0.17763 Source: "{#SourcePath}\Notes64\vcruntime140_1.dll"; DestDir: "{app}"; Flags: ignoreversion; Check: IsWin64; MinVersion: 10.0.17763 -; Qt 5 build (32-bit) -; Minimum supported OS: -; - Windows 7 (x86 and x86_64) -; Source: https://doc.qt.io/qt-5/supported-platforms.html#windows -Source: "{#SourcePath}\Notes32\iconengines\*"; DestDir: "{app}\iconengines"; Flags: ignoreversion recursesubdirs createallsubdirs; MinVersion: 6.1; OnlyBelowVersion: 10.0.17763 -Source: "{#SourcePath}\Notes32\imageformats\*"; DestDir: "{app}\imageformats"; Flags: ignoreversion recursesubdirs createallsubdirs; MinVersion: 6.1; OnlyBelowVersion: 10.0.17763 -Source: "{#SourcePath}\Notes32\platforms\*"; DestDir: "{app}\platforms"; Flags: ignoreversion recursesubdirs createallsubdirs; MinVersion: 6.1; OnlyBelowVersion: 10.0.17763 -Source: "{#SourcePath}\Notes32\QtGraphicalEffects\*"; DestDir: "{app}\QtGraphicalEffects"; Flags: ignoreversion recursesubdirs createallsubdirs; MinVersion: 6.1; OnlyBelowVersion: 10.0.17763 -Source: "{#SourcePath}\Notes32\QtQml\*"; DestDir: "{app}\QtQml"; Flags: ignoreversion recursesubdirs createallsubdirs; MinVersion: 6.1; OnlyBelowVersion: 10.0.17763 -Source: "{#SourcePath}\Notes32\QtQuick\*"; DestDir: "{app}\QtQuick"; Flags: ignoreversion recursesubdirs createallsubdirs; MinVersion: 6.1; OnlyBelowVersion: 10.0.17763 -Source: "{#SourcePath}\Notes32\QtQuick.2\*"; DestDir: "{app}\QtQuick.2"; Flags: ignoreversion recursesubdirs createallsubdirs; MinVersion: 6.1; OnlyBelowVersion: 10.0.17763 -Source: "{#SourcePath}\Notes32\scenegraph\*"; DestDir: "{app}\scenegraph"; Flags: ignoreversion recursesubdirs createallsubdirs; MinVersion: 6.1; OnlyBelowVersion: 10.0.17763 -Source: "{#SourcePath}\Notes32\sqldrivers\*"; DestDir: "{app}\sqldrivers"; Flags: ignoreversion recursesubdirs createallsubdirs; MinVersion: 6.1; OnlyBelowVersion: 10.0.17763 -Source: "{#SourcePath}\Notes32\styles\*"; DestDir: "{app}\styles"; Flags: ignoreversion recursesubdirs createallsubdirs; MinVersion: 6.1; OnlyBelowVersion: 10.0.17763 -Source: "{#SourcePath}\Notes32\translations\*"; DestDir: "{app}\translations"; Flags: ignoreversion recursesubdirs createallsubdirs; MinVersion: 6.1; OnlyBelowVersion: 10.0.17763 -Source: "{#SourcePath}\Notes32\d3dcompiler_47.dll"; DestDir: "{app}"; Flags: ignoreversion; MinVersion: 6.1; OnlyBelowVersion: 10.0.17763 -Source: "{#SourcePath}\Notes32\libcrypto-1_1.dll"; DestDir: "{app}"; Flags: ignoreversion; MinVersion: 6.1; OnlyBelowVersion: 10.0.17763 -Source: "{#SourcePath}\Notes32\libEGL.dll"; DestDir: "{app}"; Flags: ignoreversion; MinVersion: 6.1; OnlyBelowVersion: 10.0.17763 -Source: "{#SourcePath}\Notes32\libGLESv2.dll"; DestDir: "{app}"; Flags: ignoreversion; MinVersion: 6.1; OnlyBelowVersion: 10.0.17763 -Source: "{#SourcePath}\Notes32\libssl-1_1.dll"; DestDir: "{app}"; Flags: ignoreversion; MinVersion: 6.1; OnlyBelowVersion: 10.0.17763 -Source: "{#SourcePath}\Notes32\msvcp140.dll"; DestDir: "{app}"; Flags: ignoreversion; MinVersion: 6.1; OnlyBelowVersion: 10.0.17763 -Source: "{#SourcePath}\Notes32\msvcp140_1.dll"; DestDir: "{app}"; Flags: ignoreversion; MinVersion: 6.1; OnlyBelowVersion: 10.0.17763 -Source: "{#SourcePath}\Notes32\Notes.exe"; DestDir: "{app}"; Flags: ignoreversion; MinVersion: 6.1; OnlyBelowVersion: 10.0.17763 -Source: "{#SourcePath}\Notes32\opengl32sw.dll"; DestDir: "{app}"; Flags: ignoreversion; MinVersion: 6.1; OnlyBelowVersion: 10.0.17763 -Source: "{#SourcePath}\Notes32\Qt5Core.dll"; DestDir: "{app}"; Flags: ignoreversion; MinVersion: 6.1; OnlyBelowVersion: 10.0.17763 -Source: "{#SourcePath}\Notes32\Qt5Gui.dll"; DestDir: "{app}"; Flags: ignoreversion; MinVersion: 6.1; OnlyBelowVersion: 10.0.17763 -Source: "{#SourcePath}\Notes32\Qt5Network.dll"; DestDir: "{app}"; Flags: ignoreversion; MinVersion: 6.1; OnlyBelowVersion: 10.0.17763 -Source: "{#SourcePath}\Notes32\Qt5Qml.dll"; DestDir: "{app}"; Flags: ignoreversion; MinVersion: 6.1; OnlyBelowVersion: 10.0.17763 -Source: "{#SourcePath}\Notes32\Qt5QmlModels.dll"; DestDir: "{app}"; Flags: ignoreversion; MinVersion: 6.1; OnlyBelowVersion: 10.0.17763 -Source: "{#SourcePath}\Notes32\Qt5QmlWorkerScript.dll"; DestDir: "{app}"; Flags: ignoreversion; MinVersion: 6.1; OnlyBelowVersion: 10.0.17763 -Source: "{#SourcePath}\Notes32\Qt5Quick.dll"; DestDir: "{app}"; Flags: ignoreversion; MinVersion: 6.1; OnlyBelowVersion: 10.0.17763 -Source: "{#SourcePath}\Notes32\Qt5QuickControls2.dll"; DestDir: "{app}"; Flags: ignoreversion; MinVersion: 6.1; OnlyBelowVersion: 10.0.17763 -Source: "{#SourcePath}\Notes32\Qt5QuickParticles.dll"; DestDir: "{app}"; Flags: ignoreversion; MinVersion: 6.1; OnlyBelowVersion: 10.0.17763 -Source: "{#SourcePath}\Notes32\Qt5QuickTemplates2.dll"; DestDir: "{app}"; Flags: ignoreversion; MinVersion: 6.1; OnlyBelowVersion: 10.0.17763 -Source: "{#SourcePath}\Notes32\Qt5RemoteObjects.dll"; DestDir: "{app}"; Flags: ignoreversion; MinVersion: 6.1; OnlyBelowVersion: 10.0.17763 -Source: "{#SourcePath}\Notes32\Qt5Sql.dll"; DestDir: "{app}"; Flags: ignoreversion; MinVersion: 6.1; OnlyBelowVersion: 10.0.17763 -Source: "{#SourcePath}\Notes32\Qt5Svg.dll"; DestDir: "{app}"; Flags: ignoreversion; MinVersion: 6.1; OnlyBelowVersion: 10.0.17763 -Source: "{#SourcePath}\Notes32\Qt5Widgets.dll"; DestDir: "{app}"; Flags: ignoreversion; MinVersion: 6.1; OnlyBelowVersion: 10.0.17763 -Source: "{#SourcePath}\Notes32\vcruntime140.dll"; DestDir: "{app}"; Flags: ignoreversion; MinVersion: 6.1; OnlyBelowVersion: 10.0.17763 - [Icons] Name: "{group}\Notes"; Filename: "{app}\Notes.exe" Name: "{group}\{cm:UninstallProgram,Notes}"; Filename: "{uninstallexe}" diff --git a/snap/snapcraft.yaml b/snap/snapcraft.yaml index 4bd175347..8654eead4 100644 --- a/snap/snapcraft.yaml +++ b/snap/snapcraft.yaml @@ -113,7 +113,6 @@ parts: - -DGIT_REVISION=ON - -DPRO_VERSION=OFF # Note: You may want to remove this option if you're building the snap yourself. - -DUPDATE_CHECKER=OFF - - -DUSE_QT_VERSION=6 parse-info: - usr/share/metainfo/io.github.nuttyartist.notes.metainfo.xml build-packages: diff --git a/src/aboutwindow.cpp b/src/aboutwindow.cpp index 7bfbcf4b6..c77694522 100644 --- a/src/aboutwindow.cpp +++ b/src/aboutwindow.cpp @@ -15,9 +15,6 @@ AboutWindow::AboutWindow(QWidget *parent) : QDialog(parent), m_ui(new Ui::AboutWindow), m_isProVersion(false) { m_ui->setupUi(this); -#if QT_VERSION < QT_VERSION_CHECK(5, 10, 0) - setWindowFlag(Qt::WindowContextHelpButtonHint, false); -#endif setWindowTitle(tr("About") + " " + QCoreApplication::applicationName()); setAboutText(); diff --git a/src/dbmanager.cpp b/src/dbmanager.cpp index 6249ee8b8..bb92ea16e 100644 --- a/src/dbmanager.cpp +++ b/src/dbmanager.cpp @@ -2436,11 +2436,7 @@ void DBManager::exportNotes(const QString &baseExportPath, const QString &extens if (folder.id() != SpecialNodeID::RootFolder) { // Skip root folder QStringList folderNames; QString currentPath = folder.absolutePath(); -#if QT_VERSION >= QT_VERSION_CHECK(5, 14, 0) QStringList pathParts = currentPath.split(QDir::separator(), Qt::SkipEmptyParts); -#else - QStringList pathParts = currentPath.split(QDir::separator(), QString::SkipEmptyParts); -#endif for (const auto &part : pathParts) { int id = part.toInt(); if (id == SpecialNodeID::RootFolder) @@ -2475,9 +2471,7 @@ void DBManager::exportNotes(const QString &baseExportPath, const QString &extens } // Export each note as a .txt file in its corresponding directory -#if QT_VERSION >= QT_VERSION_CHECK(5, 14, 0) QTextDocument doc; -#endif while (query.next()) { // int noteId = query.value(0).toInt(); QString title = query.value(1).toString(); @@ -2489,11 +2483,9 @@ void DBManager::exportNotes(const QString &baseExportPath, const QString &extens if (safeTitle.contains("
")) safeTitle = safeTitle.section("
", 0, 0, QString::SectionSkipEmpty); safeTitle = safeTitle.simplified(); -#if QT_VERSION >= QT_VERSION_CHECK(5, 14, 0) // Convert Markdown to plain text, only available in Qt 5.14+ doc.setMarkdown(safeTitle); safeTitle = doc.toPlainText(); -#endif safeTitle.replace(QRegularExpression(R"([\/\\:*?"<>|])"), "_"); // Make the title filesystem-safe QString filePath = notePath + QDir::separator() + safeTitle + extension; diff --git a/src/fontloader.cpp b/src/fontloader.cpp index cd16a2732..ba22f4411 100644 --- a/src/fontloader.cpp +++ b/src/fontloader.cpp @@ -1,14 +1,6 @@ #include "fontloader.h" -#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) -FontLoader::FontLoader() : m_fontDatabase() { } -#endif - QFont FontLoader::loadFont(const QString &family, const QString &style, int pointSize) { -#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) - return m_fontDatabase.font(family, style, pointSize); -#else return QFontDatabase::font(family, style, pointSize); -#endif } diff --git a/src/fontloader.h b/src/fontloader.h index 577a07824..b73b4a330 100644 --- a/src/fontloader.h +++ b/src/fontloader.h @@ -7,13 +7,7 @@ class FontLoader { public: -#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) - QFontDatabase m_fontDatabase; - FontLoader(); -#else FontLoader() = default; -#endif - ~FontLoader() = default; static FontLoader &getInstance() diff --git a/src/framelesswindow.cpp b/src/framelesswindow.cpp index e4a998a5e..fbc863288 100644 --- a/src/framelesswindow.cpp +++ b/src/framelesswindow.cpp @@ -97,19 +97,11 @@ void CFramelessWindow::addIgnoreWidget(QWidget *widget) m_whiteList.append(widget); } -# if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0) bool CFramelessWindow::nativeEvent(const QByteArray &eventType, void *message, qintptr *result) -# else -bool CFramelessWindow::nativeEvent(const QByteArray &eventType, void *message, long *result) -# endif { -// Workaround for known bug -> check Qt forum : -// https://forum.qt.io/topic/93141/qtablewidget-itemselectionchanged/13 -# if (QT_VERSION == QT_VERSION_CHECK(5, 11, 1)) - MSG *msg = *reinterpret_cast(message); -# else + // Workaround for known bug -> check Qt forum : + // https://forum.qt.io/topic/93141/qtablewidget-itemselectionchanged/13 MSG *msg = reinterpret_cast(message); -# endif switch (msg->message) { case WM_NCCALCSIZE: { diff --git a/src/framelesswindow.h b/src/framelesswindow.h index 60a8c3761..ff2d0fade 100644 --- a/src/framelesswindow.h +++ b/src/framelesswindow.h @@ -44,11 +44,7 @@ class CFramelessWindow : public QMainWindow // this by add "label1" to a ignorelist, just call addIgnoreWidget(label1) void addIgnoreWidget(QWidget *widget); -# if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0) bool nativeEvent(const QByteArray &eventType, void *message, qintptr *result); -# else - bool nativeEvent(const QByteArray &eventType, void *message, long *result); -# endif private slots: void onTitleBarDestroyed(); diff --git a/src/main.cpp b/src/main.cpp index bfcf36b64..d4cd081e9 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -20,10 +20,6 @@ int main(int argc, char *argv[]) app.setDesktopFileName(APP_ID); #endif -#if QT_VERSION >= QT_VERSION_CHECK(5, 10, 0) && QT_VERSION < QT_VERSION_CHECK(6, 0, 0) - app.setAttribute(Qt::AA_DisableWindowContextHelpButton); -#endif - if (QFontDatabase::addApplicationFont(":/fonts/fontawesome/fa-solid-900.ttf") < 0) qWarning() << "FontAwesome Solid cannot be loaded !"; diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index 7c84be029..87373d9f1 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -204,11 +204,7 @@ void MainWindow::InitData() setButtonsAndFieldsEnabled(true); }); -#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0) QFuture migration = QtConcurrent::run(&MainWindow::migrateFromV0_9_0, this); -#else - QFuture migration = QtConcurrent::run(this, &MainWindow::migrateFromV0_9_0); -#endif watcher->setFuture(migration); } /// Check if it is running with an argument (ex. hide) @@ -1040,10 +1036,8 @@ void MainWindow::setupEditorSettings() #if QT_VERSION >= QT_VERSION_CHECK(6, 2, 0) QUrl source("qrc:/qt/qml/EditorSettings.qml"); -#elif QT_VERSION > QT_VERSION_CHECK(5, 12, 8) - QUrl source("qrc:/qml/EditorSettings.qml"); #else - QUrl source("qrc:/qml/EditorSettingsQt512.qml"); + QUrl source("qrc:/qml/EditorSettings.qml"); #endif m_editorSettingsQuickView.rootContext()->setContextProperty("mainWindow", this); @@ -1138,11 +1132,7 @@ void MainWindow::setCurrentFontBasedOnTypeface(FontTypeface::Value selectedFontT // Set tab width QFontMetrics currentFontMetrics(m_currentSelectedFont); -#if QT_VERSION < QT_VERSION_CHECK(5, 11, 0) - m_textEdit->setTabStopWidth(4 * currentFontMetrics.width(' ')); -#else m_textEdit->setTabStopDistance(4 * currentFontMetrics.horizontalAdvance(QLatin1Char(' '))); -#endif alignTextEditText(); @@ -1212,11 +1202,7 @@ void MainWindow::alignTextEditText() QString("The quick brown fox jumps over the lazy dog the quick brown fox jumps over " "the lazy dog the quick brown fox jumps over the lazy dog"); limitingStringSample.truncate(m_textEdit->lineWrapColumnOrWidth()); -#if QT_VERSION < QT_VERSION_CHECK(5, 11, 0) - qreal textSamplePixelsWidth = fm.width(limitingStringSample); -#else qreal textSamplePixelsWidth = fm.horizontalAdvance(limitingStringSample); -#endif m_noteEditorLogic->setCurrentAdaptableEditorPadding( (m_textEdit->width() - textSamplePixelsWidth) / 2 - 10); @@ -3186,11 +3172,7 @@ void MainWindow::mousePressEvent(QMouseEvent *event) if (event->buttons() == Qt::LeftButton) { if (isTitleBar(m_mousePressX, m_mousePressY)) { -# if QT_VERSION >= QT_VERSION_CHECK(5, 15, 0) m_canMoveWindow = !window()->windowHandle()->startSystemMove(); -# else - m_canMoveWindow = true; -# endif # ifndef __APPLE__ } else if (!isMaximized() && !isFullScreen()) { @@ -3439,12 +3421,7 @@ void MainWindow::mousePressEvent(QMouseEvent *event) if (event->button() == Qt::LeftButton) { if (isTitleBar(event->position().toPoint().x(), event->position().toPoint().y())) { - -# if QT_VERSION >= QT_VERSION_CHECK(5, 15, 0) m_canMoveWindow = !window()->windowHandle()->startSystemMove(); -# else - m_canMoveWindow = true; -# endif m_mousePressX = event->position().toPoint().x(); m_mousePressY = event->position().toPoint().y(); } diff --git a/src/nodepath.cpp b/src/nodepath.cpp index 91e0a884f..f96115456 100644 --- a/src/nodepath.cpp +++ b/src/nodepath.cpp @@ -5,11 +5,7 @@ NodePath::NodePath(const QString &path) : m_path(path) { } QStringList NodePath::separate() const { -#if QT_VERSION < QT_VERSION_CHECK(5, 14, 0) - return m_path.split(PATH_SEPARATOR, QString::SkipEmptyParts); -#else return m_path.split(PATH_SEPARATOR, Qt::SkipEmptyParts); -#endif } QString NodePath::path() const diff --git a/src/noteeditorlogic.cpp b/src/noteeditorlogic.cpp index efc396874..af2c903e3 100644 --- a/src/noteeditorlogic.cpp +++ b/src/noteeditorlogic.cpp @@ -786,7 +786,6 @@ QString NoteEditorLogic::getNthLine(const QString &str, int targetLineNumber) QString line = str.mid(previousLineBreakIndex + 1, i - previousLineBreakIndex - 1); line = line.trimmed(); if (!line.isEmpty() && !line.startsWith("---") && !line.startsWith("```")) { -#if QT_VERSION >= QT_VERSION_CHECK(5, 14, 0) QTextDocument doc; doc.setMarkdown(line); QString text = doc.toPlainText(); @@ -798,13 +797,6 @@ QString NoteEditorLogic::getNthLine(const QString &str, int targetLineNumber) } QTextStream ts(&text); return ts.readLine(FIRST_LINE_MAX); -#else - if (line.isEmpty()) { - return tr("No additional text"); - } - QTextStream ts(&line); - return ts.readLine(FIRST_LINE_MAX); -#endif } } previousLineBreakIndex = i; diff --git a/src/notelistdelegate.cpp b/src/notelistdelegate.cpp index aaa1a5506..84c050ce5 100644 --- a/src/notelistdelegate.cpp +++ b/src/notelistdelegate.cpp @@ -167,12 +167,8 @@ QSize NoteListDelegate::sizeHint(const QStyleOptionViewItem &option, const QMode const auto ¬e = model->getNote(index); auto id = note.id(); bool isHaveTags = note.tagIds().size() > 0; -#if QT_VERSION < QT_VERSION_CHECK(5, 10, 0) - if ((!m_animatedIndexes.contains(index)) && isHaveTags) { -#else if (m_view->isPersistentEditorOpen(index) && (!m_animatedIndexes.contains(index)) && isHaveTags) { -#endif if (szMap.contains(id)) { result.setHeight(szMap[id].height()); return result; @@ -249,12 +245,8 @@ QSize NoteListDelegate::bufferSizeHint(const QStyleOptionViewItem &option, result.setWidth(option.rect.width()); auto id = index.data(NoteListModel::NoteID).toInt(); bool isHaveTags = index.data(NoteListModel::NoteTagsList).value>().size() > 0; -#if QT_VERSION < QT_VERSION_CHECK(5, 10, 0) - if (!m_animatedIndexes.contains(index) && isHaveTags) { -#else if (m_view->isPersistentEditorOpen(index) && (!m_animatedIndexes.contains(index)) && isHaveTags) { -#endif if (szMap.contains(id)) { result.setHeight(szMap[id].height()); return result; diff --git a/src/notelistdelegateeditor.cpp b/src/notelistdelegateeditor.cpp index bcdc6f9ee..0b0a767c8 100644 --- a/src/notelistdelegateeditor.cpp +++ b/src/notelistdelegateeditor.cpp @@ -518,11 +518,7 @@ void NoteListDelegateEditor::dragLeaveEvent(QDragLeaveEvent *event) Q_UNUSED(event); } -#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0) void NoteListDelegateEditor::enterEvent(QEnterEvent *event) -#else -void NoteListDelegateEditor::enterEvent(QEvent *event) -#endif { m_containsMouse = true; QWidget::enterEvent(event); diff --git a/src/notelistdelegateeditor.h b/src/notelistdelegateeditor.h index 3871aa6d6..d87229160 100644 --- a/src/notelistdelegateeditor.h +++ b/src/notelistdelegateeditor.h @@ -98,11 +98,7 @@ public slots: virtual void resizeEvent(QResizeEvent *event) override; virtual void dragEnterEvent(QDragEnterEvent *event) override; virtual void dragLeaveEvent(QDragLeaveEvent *event) override; -#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0) virtual void enterEvent(QEnterEvent *event) override; -#else - virtual void enterEvent(QEvent *event) override; -#endif virtual void leaveEvent(QEvent *event) override; virtual void dropEvent(QDropEvent *event) override; diff --git a/src/notelistview.cpp b/src/notelistview.cpp index 71e12d007..db8df9d66 100644 --- a/src/notelistview.cpp +++ b/src/notelistview.cpp @@ -534,9 +534,7 @@ void NoteListView::startDrag(Qt::DropActions supportedActions) drag->deleteLater(); mimeData->deleteLater(); } -#if QT_VERSION > QT_VERSION_CHECK(5, 15, 0) d->dropEventMoved = false; -#endif m_isDragging = false; // Reset the drop indicator d->dropIndicatorRect = QRect(); @@ -881,19 +879,8 @@ QPixmap NoteListViewPrivate::renderToPixmap(const QModelIndexList &indexes, QRec QItemViewPaintPairs paintPairs = draggablePaintPairs(indexes, r); if (paintPairs.isEmpty()) return QPixmap(); -#if QT_VERSION < QT_VERSION_CHECK(5, 14, 0) - qreal scale = 1.0f; - Q_Q(const QAbstractItemView); - QWidget *window = q->window(); - if (window) { - QWindow *windowHandle = window->windowHandle(); - if (windowHandle) - scale = windowHandle->devicePixelRatio(); - } -#else QWindow *window = windowHandle(WindowHandleMode::Closest); const qreal scale = window ? window->devicePixelRatio() : qreal(1); -#endif QPixmap pixmap(r->size() * scale); pixmap.setDevicePixelRatio(scale); @@ -905,13 +892,9 @@ QPixmap NoteListViewPrivate::renderToPixmap(const QModelIndexList &indexes, QRec for (int j = 0; j < paintPairs.count(); ++j) { option.rect = paintPairs.at(j).rect.translated(-r->topLeft()); const QModelIndex ¤t = paintPairs.at(j).index; -#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0) Q_Q(const QAbstractItemView); adjustViewOptionsForIndex(&option, current); q->itemDelegateForIndex(current)->paint(&painter, option, current); -#else - delegateForIndex(current)->paint(&painter, option, current); -#endif } return pixmap; } @@ -919,11 +902,7 @@ QPixmap NoteListViewPrivate::renderToPixmap(const QModelIndexList &indexes, QRec QStyleOptionViewItem NoteListViewPrivate::viewOptionsV1() const { Q_Q(const NoteListView); -#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0) QStyleOptionViewItem option; q->initViewItemOption(&option); return option; -#else - return q->viewOptions(); -#endif } diff --git a/src/qml.qrc b/src/qml.qrc index e33605e2d..5a120acd3 100644 --- a/src/qml.qrc +++ b/src/qml.qrc @@ -17,7 +17,6 @@ qml/TodoColumnDelegate.qml qml/TodoTaskDelegate.qml qml/ViewChooserButton.qml - qml/EditorSettingsQt512.qml qml/SubscriptionWindow.qml qml/CustomTextField.qml qml/Utilities.js diff --git a/src/qml/EditorSettingsQt512.qml b/src/qml/EditorSettingsQt512.qml deleted file mode 100644 index 742afa859..000000000 --- a/src/qml/EditorSettingsQt512.qml +++ /dev/null @@ -1,945 +0,0 @@ -import QtQuick 2.12 -import QtQuick.Controls 2.12 -import QtQuick.Controls.Material 2.12 -import nuttyartist.notes 1.0 -//import notes - -Item { - id: settingsContainer - property int extraWidthForQWidgets: platform === "Apple" ? 60 : 0 - property int extraHeightForQWidgets: platform === "Apple" ? 40 : 0 - width: settingsPane.width + extraWidthForQWidgets - height: settingsPane.height + extraHeightForQWidgets - property var themeData: {{theme: "Light"}} - property string displayFontFamily: "Roboto" - property string platform: "" - property string categoriesFontColor: settingsContainer.themeData.theme === "Dark" ? "#868686" : "#7d7c78" - property string mainFontColor: settingsContainer.themeData.theme === "Dark" ? "#d6d6d6" : "#37352e" - property string highlightBackgroundColor: settingsContainer.themeData.theme === "Dark" ? "#313131" : "#efefef" - property string pressedBackgroundColor: settingsContainer.themeData.theme === "Dark" ? "#2c2c2c" : "#dfdfde" - property string separatorLineColors: settingsContainer.themeData.theme === "Dark" ? "#3a3a3a" : "#ededec" - property string mainBackgroundColor: settingsContainer.themeData.theme === "Dark" ? "#252525" : "white" - signal themeChanged - property int paddingRightLeft: 12 - property var listOfSansSerifFonts: [] - property var listOfSerifFonts: [] - property var listOfMonoFonts: [] - property int chosenSansSerifFontIndex: 0 - property int chosenSerifFontIndex: 0 - property int chosenMonoFontIndex: 0 - property string currentFontTypeface - property real latestScrollBarPosition: 0.0 - property int pointSizeOffset: -4 - property int qtVersion: 6 - property string currentlySelectedView: "TextView" // "KanbanView" - -// signal changeFontType(fontType : EditorSettingsOptions) // TODO: It's better to use signal & slots for calling C++ functions -// to change the editor settings rather than calling public slots directly. But I couldn't make it work between QML and C++ -// (QObject::connect: Error: No such signal EditorSettings_QMLTYPE_45::changeFontType(int)) -// So, currently following this: -// https://scythe-studio.com/en/blog/how-to-integrate-c-and-qml-registering-enums - - Connections { - target: mainWindow - - onEditorSettingsShowed: (data) => { - var settingsPaneHeightByParentWindow = 0.80 * data.parentWindowHeight; // 80 percent of the parent window's height - settingsPane.height = scrollViewControl.contentHeight > settingsPaneHeightByParentWindow ? settingsPaneHeightByParentWindow : scrollViewControl.contentHeight; - revealSettingsAnimation.start(); - settingsContainer.upadteScrollBarPosition(); - } - - onMainWindowResized: (data) => { - var settingsPaneHeightByParentWindow = 0.80 * data.parentWindowHeight; // 80 percent of the parent window's height - settingsPane.height = scrollViewControl.contentHeight > settingsPaneHeightByParentWindow ? settingsPaneHeightByParentWindow : scrollViewControl.contentHeight; - } - - onDisplayFontSet: (data) => { - settingsContainer.displayFontFamily = data.displayFont; - } - - onPlatformSet: (data) => { - settingsContainer.platform = data; - } - - onQtVersionSet: (data) => { - settingsContainer.qtVersion = data; - } - - onThemeChanged: (data) => { - settingsContainer.themeData = data; - themeChanged(); - } - - onEditorSettingsScrollBarPositionChanged: (data) => { - settingsContainer.latestScrollBarPosition = data; - } - - onSettingsChanged: (data) => { - if (data.currentFontTypeface === "SansSerif") { - fontChooserSans.checked = true; - fontChooserSerif.checked = false; - fontChooserMono.checked = false; - } else if (data.currentFontTypeface === "Serif") { - fontChooserSerif.checked = true; - fontChooserSans.checked = false; - fontChooserMono.checked = false; - } else if (data.currentFontTypeface === "Mono") { - fontChooserMono.checked = true; - fontChooserSans.checked = false; - fontChooserSerif.checked = false; - } - - if (data.currentTheme === "Light") { - lightThemeChooserButton.themeSelected(true); - darkThemeChooserButton.themeSelected(false); - sepiaThemeChooserButton.themeSelected(false); - } else if (data.currentTheme === "Dark") { - darkThemeChooserButton.themeSelected(true); - sepiaThemeChooserButton.themeSelected(false); - lightThemeChooserButton.themeSelected(false); - } else if (data.currentTheme === "Sepia") { - sepiaThemeChooserButton.themeSelected(true); - darkThemeChooserButton.themeSelected(false); - lightThemeChooserButton.themeSelected(false); - } - - focusModeOption.setOptionSelected(!data.isTextFullWidth); - - if (data.currentView === "TextView") { - settingsContainer.currentlySelectedView = "TextView"; - textView.viewSelected(); - } else if (data.currentView === "KanbanView") { - settingsContainer.currentlySelectedView = "KanbanView"; - kanbanView.viewSelected(); - } - - notesListCollapsedOption.setOptionSelected(!data.isNoteListCollapsed); - foldersTreeCollapsedOption.setOptionSelected(!data.isFoldersTreeCollapsed); - markdownEnabledOption.setOptionSelected(!data.isMarkdownDisabled); - stayOnTopOption.setOptionSelected(data.isStayOnTop); - } - - onFontsChanged: (data) => { - settingsContainer.listOfSansSerifFonts = data.listOfSansSerifFonts; - settingsContainer.listOfSerifFonts = data.listOfSerifFonts; - settingsContainer.listOfMonoFonts = data.listOfMonoFonts; - settingsContainer.chosenSansSerifFontIndex = data.chosenSansSerifFontIndex; - settingsContainer.chosenSerifFontIndex = data.chosenSerifFontIndex; - settingsContainer.chosenMonoFontIndex = data.chosenMonoFontIndex; - settingsContainer.currentFontTypeface = data.currentFontTypeface; - } - } - - Connections { - target: noteEditorLogic - - onTextShown: { - textView.viewSelected(); - kanbanView.viewUnclicked(); - } - - onKanbanShown: { - kanbanView.viewSelected(); - textView.viewUnclicked(); - } - } - - FontIconLoader { - id: fontIconLoader - } - - PropertyAnimation { - id: revealSettingsAnimation - target: settingsContainer - property: "opacity" - from: 0.3 - to: 1.0 - duration: 100 - easing.type: Easing.InOutQuad - } - - function upadteScrollBarPosition () { - editorSettingsVerticalScrollBar.position = settingsContainer.latestScrollBarPosition; - } - - Pane { - id: settingsPane - visible: true - padding: 0 - width: 240 - height: 500 - contentWidth: 240 - Material.elevation: 10 - Material.background: settingsContainer.mainBackgroundColor -// Material.roundedScale: Material.MediumScale - x: settingsContainer.extraWidthForQWidgets === 0 ? 0 : 20 - y: settingsContainer.extraHeightForQWidgets === 0 ? 0 : 20 - - Rectangle { - visible: settingsContainer.qtVersion < 6 - anchors.fill: parent - color: settingsContainer.mainBackgroundColor - } - - ScrollView { - id: scrollViewControl - anchors.fill: parent - clip: true - - ScrollBar.vertical: CustomVerticalScrollBar { - id: editorSettingsVerticalScrollBar - themeData: settingsContainer.themeData - isDarkGray: false - showBackground: true - - onPositionChanged: { - mainWindow.setEditorSettingsScrollBarPosition(editorSettingsVerticalScrollBar.position); - - } - } - - Column { - Item { - width: 1 - height: settingsContainer.paddingRightLeft - } - - Text { - text: qsTr("Style") - color: settingsContainer.categoriesFontColor - font.pointSize: settingsContainer.platform === "Apple" ? 12 : 12 + settingsContainer.pointSizeOffset - font.family: settingsContainer.displayFontFamily - x: settingsContainer.paddingRightLeft - } - - Item { - width: 1 - height: 5 - } - - Row { - x: settingsContainer.paddingRightLeft - FontChooserButton { - id: fontChooserSans - displayFontFamily: settingsContainer.displayFontFamily - platform: settingsContainer.platform - mainFontColor: settingsContainer.mainFontColor - highlightBackgroundColor: settingsContainer.highlightBackgroundColor - pressedBackgroundColor: settingsContainer.pressedBackgroundColor - themeData: settingsContainer.themeData - categoriesFontColor: settingsContainer.categoriesFontColor - fontTypeface: "Sans" - fontsModel: settingsContainer.listOfSansSerifFonts - currentlyChosenFontIndex: settingsContainer.chosenSansSerifFontIndex - qtVersion: settingsContainer.qtVersion - mainBackgroundColor: settingsContainer.mainBackgroundColor - - onClicked: (chosenFontIndex) => { - if (chosenFontIndex === -1) { - if (settingsContainer.currentFontTypeface === "SansSerif") { - chosenFontIndex = currentlyChosenFontIndex < fontsModel.length - 1 ? currentlyChosenFontIndex + 1 : 0; - } else { - chosenFontIndex = currentlyChosenFontIndex; - } - } - mainWindow.changeEditorFontTypeFromStyleButtons(FontTypeface.SansSerif, chosenFontIndex); - fontChooserSerif.checked = false; - fontChooserMono.checked = false; - } - - Connections { - target: settingsContainer - - function onThemeChanged () { - fontChooserSans.themeChanged(); - } - } - } - - FontChooserButton { - id: fontChooserSerif - displayFontFamily: settingsContainer.displayFontFamily - platform: settingsContainer.platform - mainFontColor: settingsContainer.mainFontColor - highlightBackgroundColor: settingsContainer.highlightBackgroundColor - pressedBackgroundColor: settingsContainer.pressedBackgroundColor - themeData: settingsContainer.themeData - categoriesFontColor: settingsContainer.categoriesFontColor - fontTypeface: "Serif" - fontsModel: settingsContainer.listOfSerifFonts - currentlyChosenFontIndex: settingsContainer.chosenSerifFontIndex - qtVersion: settingsContainer.qtVersion - mainBackgroundColor: settingsContainer.mainBackgroundColor - enabled: settingsContainer.currentlySelectedView === "TextView" - - onClicked: (chosenFontIndex) => { - if (chosenFontIndex === -1) { - if (settingsContainer.currentFontTypeface === "Serif") { - chosenFontIndex = currentlyChosenFontIndex < fontsModel.length - 1 ? currentlyChosenFontIndex + 1 : 0; - } else { - chosenFontIndex = currentlyChosenFontIndex; - } - } - mainWindow.changeEditorFontTypeFromStyleButtons(FontTypeface.Serif, chosenFontIndex); - fontChooserSans.checked = false; - fontChooserMono.checked = false; - } - - Connections { - target: settingsContainer - - function onThemeChanged () { - fontChooserSerif.themeChanged(); - } - } - } - - FontChooserButton { - id: fontChooserMono - displayFontFamily: settingsContainer.displayFontFamily - platform: settingsContainer.platform - mainFontColor: settingsContainer.mainFontColor - highlightBackgroundColor: settingsContainer.highlightBackgroundColor - pressedBackgroundColor: settingsContainer.pressedBackgroundColor - themeData: settingsContainer.themeData - categoriesFontColor: settingsContainer.categoriesFontColor - fontTypeface: "Mono" - fontsModel: settingsContainer.listOfMonoFonts - currentlyChosenFontIndex: settingsContainer.chosenMonoFontIndex - qtVersion: settingsContainer.qtVersion - mainBackgroundColor: settingsContainer.mainBackgroundColor - enabled: settingsContainer.currentlySelectedView === "TextView" - - onClicked: (chosenFontIndex) => { - if (chosenFontIndex === -1) { - if (settingsContainer.currentFontTypeface === "Mono") { - chosenFontIndex = currentlyChosenFontIndex < fontsModel.length - 1 ? currentlyChosenFontIndex + 1 : 0; - } else { - chosenFontIndex = currentlyChosenFontIndex; - } - } - mainWindow.changeEditorFontTypeFromStyleButtons(FontTypeface.Mono, chosenFontIndex); - fontChooserSans.checked = false; - fontChooserSerif.checked = false; - } - - Connections { - target: settingsContainer - - function onThemeChanged () { - fontChooserMono.themeChanged(); - } - } - } - } - - Item { - width: 1 - height: 10 - } - - Rectangle { - height: 1 - width: settingsPane.contentWidth - color: settingsContainer.separatorLineColors - } - - Column { - id: textSettingsGroup - visible: settingsContainer.currentlySelectedView === "TextView" - - Item { - width: 1 - height: 10 - } - - Text { - text: qsTr("Text") - color: settingsContainer.categoriesFontColor - font.pointSize: settingsContainer.platform === "Apple" ? 12 : 12 + settingsContainer.pointSizeOffset - font.family: settingsContainer.displayFontFamily - x: settingsContainer.paddingRightLeft - } - - Item { - width: 1 - height: 10 - } - - // Font size - Row { - id: fontSizeRow - x: settingsContainer.paddingRightLeft + 10 - Text { - id: fontSizeText - x: 20 - text: qsTr("Font size") - color: settingsContainer.mainFontColor - font.pointSize: settingsContainer.platform === "Apple" ? 14 : 14 + settingsContainer.pointSizeOffset - font.family: settingsContainer.displayFontFamily - opacity: settingsContainer.currentlySelectedView === "TextView" ? 1.0 : 0.2 - } - - Item { - width: settingsPane.contentWidth - fontSizePlusButton.width - fontSizeText.width - fontSizeMinusButton.width - 20 - fontSizeRow.x - height: 1 - } - - IconButton { - id: fontSizeMinusButton - icon: fontIconLoader.icons.fa_minus - anchors.verticalCenter: fontSizeText.verticalCenter - themeData: settingsContainer.themeData - platform: settingsContainer.platform - iconPointSizeOffset: -4 - enabled: settingsContainer.currentlySelectedView === "TextView" - - onClicked: { - mainWindow.changeEditorFontSizeFromStyleButtons(FontSizeAction.FontSizeDecrease); - } - } - - Item { - width: 10 - height: 1 - } - - IconButton { - id: fontSizePlusButton - icon: fontIconLoader.icons.fa_plus - anchors.verticalCenter: fontSizeText.verticalCenter - themeData: settingsContainer.themeData - platform: settingsContainer.platform - iconPointSizeOffset: -4 - enabled: settingsContainer.currentlySelectedView === "TextView" - - onClicked: { - mainWindow.changeEditorFontSizeFromStyleButtons(FontSizeAction.FontSizeIncrease); - } - } - } - - // Full width - OptionItemButton { - id: focusModeOption - x: settingsContainer.paddingRightLeft - contentWidth: settingsPane.contentWidth - settingsContainer.paddingRightLeft*2 - displayText: qsTr("Focus mode") - displayFontFamily: settingsContainer.displayFontFamily - platform: settingsContainer.platform - mainFontColor: settingsContainer.mainFontColor - highlightBackgroundColor: settingsContainer.highlightBackgroundColor - pressedBackgroundColor: settingsContainer.pressedBackgroundColor - themeData: settingsContainer.themeData - enabled: settingsContainer.currentlySelectedView === "TextView" - - onSwitched: { - mainWindow.changeEditorTextWidthFromStyleButtons(EditorTextWidth.TextWidthFullWidth) - } - - onUnswitched: { - mainWindow.changeEditorTextWidthFromStyleButtons(EditorTextWidth.TextWidthFullWidth) - } - } - - Item { - visible: settingsContainer.currentlySelectedView === "TextView" && focusModeOption.checked - width: 1 - height: 10 - } - - // Text width - Row { - id: textWidthRow - x: settingsContainer.paddingRightLeft + 10 - visible: settingsContainer.currentlySelectedView === "TextView" && focusModeOption.checked - Text { - id: textWidthText - text: qsTr("Text width") - color: settingsContainer.mainFontColor - font.pointSize: settingsContainer.platform === "Apple" ? 14 : 14 + settingsContainer.pointSizeOffset - font.family: settingsContainer.displayFontFamily - opacity: settingsContainer.currentlySelectedView === "TextView" ? 1.0 : 0.2 - } - - Item { - width: settingsPane.contentWidth - textWidthPlusButton.width - textWidthText.width - textWidthMinusButton.width - 20 - textWidthRow.x - height: 1 - } - - IconButton { - id: textWidthMinusButton - icon: fontIconLoader.icons.fa_minus - anchors.verticalCenter: textWidthText.verticalCenter - themeData: settingsContainer.themeData - platform: settingsContainer.platform - iconPointSizeOffset: -4 - enabled: settingsContainer.currentlySelectedView === "TextView" - - onClicked: { - mainWindow.changeEditorTextWidthFromStyleButtons(EditorTextWidth.TextWidthDecrease) - } - } - - Item { - width: 10 - height: 1 - } - - IconButton { - id: textWidthPlusButton - icon: fontIconLoader.icons.fa_plus - anchors.verticalCenter: textWidthText.verticalCenter - themeData: settingsContainer.themeData - platform: settingsContainer.platform - iconPointSizeOffset: -4 - enabled: settingsContainer.currentlySelectedView === "TextView" - - onClicked: { - mainWindow.changeEditorTextWidthFromStyleButtons(EditorTextWidth.TextWidthIncrease) - } - } - } - - Item { - width: 1 - height: 7 - } - - Rectangle { - height: 1 - width: settingsPane.contentWidth - color: settingsContainer.separatorLineColors - } - } - - - - Item { - width: 1 - height: 10 - } - - Text { - text: qsTr("Theme") - x: settingsContainer.paddingRightLeft - color: settingsContainer.categoriesFontColor - font.pointSize: settingsContainer.platform === "Apple" ? 12 : 12 + settingsContainer.pointSizeOffset - font.family: settingsContainer.displayFontFamily - } - - Item { - width: 1 - height: 5 - } - - // Theme buttons - Row { - x: settingsContainer.paddingRightLeft - ThemeChooserButton { - id: lightThemeChooserButton - displayFontFamily: settingsContainer.displayFontFamily - platform: settingsContainer.platform - mainFontColor: settingsContainer.mainFontColor - highlightBackgroundColor: settingsContainer.highlightBackgroundColor - pressedBackgroundColor: settingsContainer.pressedBackgroundColor - themeColor: "#f7f7f7" - themeName: "Light" - themeData: settingsContainer.themeData - qtVersion: settingsContainer.qtVersion - - onClicked: { - mainWindow.setTheme(Theme.Light); - darkThemeChooserButton.unclicked(); - sepiaThemeChooserButton.unclicked(); - } - - Connections { - target: settingsContainer - - function onThemeChanged () { - lightThemeChooserButton.themeChanged(); - } - } - } - - ThemeChooserButton { - id: darkThemeChooserButton - displayFontFamily: settingsContainer.displayFontFamily - platform: settingsContainer.platform - mainFontColor: settingsContainer.mainFontColor - highlightBackgroundColor: settingsContainer.highlightBackgroundColor - pressedBackgroundColor: settingsContainer.pressedBackgroundColor - themeColor: "#191919" - themeName: "Dark" - themeData: settingsContainer.themeData - qtVersion: settingsContainer.qtVersion - - onClicked: { - mainWindow.setTheme(Theme.Dark); - lightThemeChooserButton.unclicked(); - sepiaThemeChooserButton.unclicked(); - } - - Connections { - target: settingsContainer - - function onThemeChanged () { - darkThemeChooserButton.themeChanged(); - } - } - } - - ThemeChooserButton { - id: sepiaThemeChooserButton - displayFontFamily: settingsContainer.displayFontFamily - platform: settingsContainer.platform - mainFontColor: settingsContainer.mainFontColor - highlightBackgroundColor: settingsContainer.highlightBackgroundColor - pressedBackgroundColor: settingsContainer.pressedBackgroundColor - themeColor: "#f7cc6f" - themeName: "Sepia" - themeData: settingsContainer.themeData - qtVersion: settingsContainer.qtVersion - - onClicked: { - mainWindow.setTheme(Theme.Sepia); - lightThemeChooserButton.unclicked(); - darkThemeChooserButton.unclicked(); - } - - Connections { - target: settingsContainer - - function onThemeChanged () { - sepiaThemeChooserButton.themeChanged(); - } - } - } - } - - Item { - width: 1 - height: 15 - } - - Column { - id: viewSettingContainer - visible: settingsContainer.qtVersion > 5 - - Rectangle { - height: 1 - width: settingsPane.contentWidth - color: settingsContainer.separatorLineColors - } - - Item { - width: 1 - height: 10 - } - - Text { - text: qsTr("View") - x: settingsContainer.paddingRightLeft - color: settingsContainer.categoriesFontColor - font.pointSize: settingsContainer.platform === "Apple" ? 12 : 12 + settingsContainer.pointSizeOffset - font.family: settingsContainer.displayFontFamily - } - - Item { - width: 1 - height: 10 - } - - Row { - x: settingsContainer.paddingRightLeft - ViewChooserButton { - id: textView - currentViewType: ViewChooserButton.ViewType.Text - displayFontFamily: settingsContainer.displayFontFamily - platform: settingsContainer.platform - mainFontColor: settingsContainer.mainFontColor - highlightBackgroundColor: settingsContainer.highlightBackgroundColor - pressedBackgroundColor: settingsContainer.pressedBackgroundColor - - onViewClicked: { - mainWindow.setKanbanVisibility(false); - kanbanView.viewUnclicked(); - } - - Connections { - target: settingsContainer - - function onThemeChanged () { - textView.themeChanged(); - } - } - } - - Column { - ViewChooserButton { - id: kanbanView - currentViewType: ViewChooserButton.ViewType.Kanban - displayFontFamily: settingsContainer.displayFontFamily - platform: settingsContainer.platform - mainFontColor: settingsContainer.mainFontColor - highlightBackgroundColor: settingsContainer.highlightBackgroundColor - pressedBackgroundColor: settingsContainer.pressedBackgroundColor - - onViewClicked: { - mainWindow.setKanbanVisibility(true); - textView.viewUnclicked(); - } - - Connections { - target: settingsContainer - - function onThemeChanged () { - kanbanView.themeChanged(); - } - } - } - - Rectangle { - // anchors.horizontalCenter: kanbanView.horizontalCenter - x: kanbanView.x + kanbanView.width/2 - width/2 - 7 - width: 35 - height: 25 - radius: 5 - color: settingsContainer.themeData.theme === "Dark" ? "#342a3a" : "#f0f0f0" - - Text { - anchors.centerIn: parent - text: "PRO" - color: settingsContainer.themeData.theme === "Dark" ? "#a6a6a6" : "#787878" - font.pointSize: settingsContainer.platform === "Apple" ? 13 : 13 + settingsContainer.pointSizeOffset - font.family: settingsContainer.displayFontFamily - } - } - } - } - - Item { - width: 1 - height: 15 - } - } - - - - Rectangle { - height: 1 - width: settingsPane.contentWidth - color: settingsContainer.separatorLineColors - } - - Item { - width: 1 - height: 10 - } - - Text { - text: qsTr("Options") - x: settingsContainer.paddingRightLeft - color: settingsContainer.categoriesFontColor - font.pointSize: settingsContainer.platform === "Apple" ? 12 : 12 + settingsContainer.pointSizeOffset - font.family: settingsContainer.displayFontFamily - } - - Item { - width: 1 - height: 10 - } - - Column { - x: settingsContainer.paddingRightLeft - OptionItemButton { - id: notesListCollapsedOption - contentWidth: settingsPane.contentWidth - settingsContainer.paddingRightLeft*2 - displayText: qsTr("Show notes list") - displayFontFamily: settingsContainer.displayFontFamily - platform: settingsContainer.platform - mainFontColor: settingsContainer.mainFontColor - highlightBackgroundColor: settingsContainer.highlightBackgroundColor - pressedBackgroundColor: settingsContainer.pressedBackgroundColor - themeData: settingsContainer.themeData - - onSwitched: { - mainWindow.expandNoteList(); - } - - onUnswitched: { - mainWindow.collapseNoteList(); - } - } - - OptionItemButton { - id: foldersTreeCollapsedOption - contentWidth: settingsPane.contentWidth - settingsContainer.paddingRightLeft*2 - displayText: qsTr("Show folders tree") - displayFontFamily: settingsContainer.displayFontFamily - platform: settingsContainer.platform - mainFontColor: settingsContainer.mainFontColor - highlightBackgroundColor: settingsContainer.highlightBackgroundColor - pressedBackgroundColor: settingsContainer.pressedBackgroundColor - themeData: settingsContainer.themeData - - onSwitched: { - mainWindow.expandFolderTree(); - } - - onUnswitched: { - mainWindow.collapseFolderTree(); - } - } - - OptionItemButton { - id: markdownEnabledOption - visible: settingsContainer.currentlySelectedView === "TextView" - contentWidth: settingsPane.contentWidth - settingsContainer.paddingRightLeft*2 - displayText: qsTr("Markdown enabled") - displayFontFamily: settingsContainer.displayFontFamily - platform: settingsContainer.platform - mainFontColor: settingsContainer.mainFontColor - highlightBackgroundColor: settingsContainer.highlightBackgroundColor - pressedBackgroundColor: settingsContainer.pressedBackgroundColor - themeData: settingsContainer.themeData - enabled: settingsContainer.currentlySelectedView === "TextView" - - onSwitched: { - mainWindow.setMarkdownEnabled(true); - } - - onUnswitched: { - mainWindow.setMarkdownEnabled(false); - } - } - - OptionItemButton { - id: stayOnTopOption - visible: settingsContainer.platform === "Apple" - contentWidth: settingsPane.contentWidth - settingsContainer.paddingRightLeft*2 - displayText: qsTr("Always stay on top") - displayFontFamily: settingsContainer.displayFontFamily - platform: settingsContainer.platform - mainFontColor: settingsContainer.mainFontColor - highlightBackgroundColor: settingsContainer.highlightBackgroundColor - pressedBackgroundColor: settingsContainer.pressedBackgroundColor - themeData: settingsContainer.themeData - - onSwitched: { - mainWindow.stayOnTop(true); - } - - onUnswitched: { - mainWindow.stayOnTop(false); - } - } - } - - Item { - width: 1 - height: 15 - } - - Rectangle { - height: 1 - width: settingsPane.contentWidth - color: settingsContainer.separatorLineColors - } - - Item { - width: 1 - height: 10 - } - - TextButton { - id: deleteNoteButton - text: qsTr("Move to Trash") - icon: fontIconLoader.icons.fa_trash - highlightBackgroundColor: settingsContainer.highlightBackgroundColor - pressedBackgroundColor: settingsContainer.pressedBackgroundColor - backgroundWidth: settingsPane.contentWidth - settingsContainer.paddingRightLeft*2 - mainFontColorDefault: settingsContainer.mainFontColor - platform: settingsContainer.platform - displayFontFamily: settingsContainer.displayFontFamily - x: settingsContainer.paddingRightLeft - - onClicked: { - mainWindow.moveCurrentNoteToTrash(); - } - } - - Item { - width: 1 - height: 10 - } - - Rectangle { - height: 1 - width: settingsPane.contentWidth - color: settingsContainer.separatorLineColors - } - - Item { - width: 1 - height: 10 - } - - TextButton { - id: resetButton - text: qsTr("Reset all settings") - icon: fontIconLoader.icons.fa_undo_alt - highlightBackgroundColor: settingsContainer.highlightBackgroundColor - pressedBackgroundColor: settingsContainer.pressedBackgroundColor - backgroundWidth: settingsPane.contentWidth - settingsContainer.paddingRightLeft*2 - mainFontColorDefault: settingsContainer.mainFontColor - platform: settingsContainer.platform - displayFontFamily: settingsContainer.displayFontFamily - x: settingsContainer.paddingRightLeft - - onClicked: { - resetEditorSettingsDialog.visible = true - } - } - - Item { - width: 1 - height: 10 - } - } - } - } - - Dialog { - id: resetEditorSettingsDialog - visible: false - title: qsTr("Reset settings?") - standardButtons: Dialog.Yes | Dialog.Cancel - Material.accent: "#2383e2"; - Material.theme: settingsContainer.themeData.theme === "Dark" ? Material.Dark : Material.Light -// Material.roundedScale: Material.SmallScale - width: settingsPane.contentWidth - x: settingsContainer.extraWidthForQWidgets === 0 ? 0 : 25 - y: settingsPane.height - height/2 - 100 - font.family: settingsContainer.displayFontFamily - - Text { - width: settingsPane.contentWidth - 20 - wrapMode: Text.WordWrap - text: qsTr("Reset all editor settings to their defaults? This will not affect your data, only the app appearance.") - font.family: settingsContainer.displayFontFamily - color: settingsContainer.mainFontColor - } - - onAccepted: { - mainWindow.resetEditorSettings(); - } - onRejected: { - } - onDiscarded: { - } - } -} - diff --git a/src/updaterwindow.cpp b/src/updaterwindow.cpp index 1af4ba45d..9a0ea0459 100644 --- a/src/updaterwindow.cpp +++ b/src/updaterwindow.cpp @@ -62,9 +62,6 @@ UpdaterWindow::UpdaterWindow(QWidget *parent) /* Initialize the UI */ m_ui->setupUi(this); -#if QT_VERSION < QT_VERSION_CHECK(5, 10, 0) - setWindowFlag(Qt::WindowContextHelpButtonHint, false); -#endif setWindowTitle(qApp->applicationName() + " " + tr("Updater")); /* Change fonts */ @@ -557,11 +554,7 @@ void UpdaterWindow::mousePressEvent(QMouseEvent *event) if (event->position().x() < width() - 5 && event->position().x() > 5 && event->position().toPoint().y() < height() - 5 && event->position().toPoint().y() > 5) { -#if QT_VERSION >= QT_VERSION_CHECK(5, 15, 0) m_canMoveWindow = !window()->windowHandle()->startSystemMove(); -#else - m_canMoveWindow = true; -#endif m_mousePressX = event->position().toPoint().x(); m_mousePressY = event->position().toPoint().y(); }