Skip to content

Commit

Permalink
Check caption after dash instead of the whole caption
Browse files Browse the repository at this point in the history
  • Loading branch information
matinlotfali committed Feb 2, 2025
1 parent ea730f8 commit 83172ba
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 2 deletions.
12 changes: 10 additions & 2 deletions src/Window.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ void ShapeCorners::Window::configChanged() {
isIncluded = false;
for (auto& exclusion: Config::exclusions()) {
if (w.windowClass().contains(exclusion, Qt::CaseInsensitive)
|| w.caption().contains(exclusion, Qt::CaseInsensitive)
|| captionAfterDash().contains(exclusion, Qt::CaseInsensitive)
) {
isExcluded = true;
#ifdef DEBUG_INCLUSIONS
Expand All @@ -184,7 +184,7 @@ void ShapeCorners::Window::configChanged() {
}
for (auto& inclusion: Config::inclusions()) {
if (w.windowClass().contains(inclusion, Qt::CaseInsensitive)
|| w.caption().contains(inclusion, Qt::CaseInsensitive)
|| captionAfterDash().contains(inclusion, Qt::CaseInsensitive)
) {
isIncluded = true;
#ifdef DEBUG_INCLUSIONS
Expand All @@ -201,3 +201,11 @@ QJsonObject ShapeCorners::Window::toJson() const {
json[QStringLiteral("caption")] = w.caption();
return json;
}

QString ShapeCorners::Window::captionAfterDash() const {
const auto sep = QStringLiteral("");
const auto index = w.caption().indexOf(sep);
if (index == -1)
return w.caption();
return w.caption().slice(index + sep.size());
}
8 changes: 8 additions & 0 deletions src/Window.h
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,14 @@ namespace ShapeCorners {

[[nodiscard]] QJsonObject toJson() const;

/**
* \brief Returns the windows caption after the " — ".
* \description This is useful for apps like Dolphin and Konsole that include the working file/directory in their title
* and we don't want that to be considered in the inclusion and exclusion rules.
* \example a window with the title "file — Dolphin" will have "Dolphin" returned.
*/
[[nodiscard]] QString captionAfterDash() const;

public Q_SLOTS:
void configChanged();

Expand Down

0 comments on commit 83172ba

Please sign in to comment.