Repository: nuttyartist/notes
File: src/styleeditorwindow.cpp (C++)

Code before:
#include "styleeditorwindow.h"
#include "ui_styleeditorwindow.h"

#include <QDebug>
#include <QTimer>
#include <QShortcut>

/**
 * Initializes the window components and configures the StyleEditorWindow
 */
StyleEditorWindow::StyleEditorWindow(QWidget *parent)
    : QWidget(parent),
      m_ui(new Ui::StyleEditorWindow),
      m_currentlyClickedButton(Q_NULLPTR),
      m_currentSelectedFontButton(Q_NULLPTR),
      m_currentSelectedThemeButton(Q_NULLPTR),
      m_isFullWidthClicked(false)
{
    m_ui->setupUi(this);
    this->setWindowTitle(tr("Editor Settings"));
    this->setWindowFlags(Qt::Tool | Qt::WindowStaysOnTopHint);

    m_ui->serifButton->setToolTip(
            "Change the text editor font to a serif font.\nClick again to try different fonts");
    m_ui->sansSerifButton->setToolTip("Change the text editor font to a sans-serif font.\nClick "
                                      "again to try different fonts");
    m_ui->monoButton->setToolTip(
            "Change the text editor font to a monospace font.\nClick again to try different fonts");
    m_ui->decreaseButton->setToolTip("Decrease font size");
    m_ui->increaseButton->setToolTip("Increase font size");
    m_ui->fullWidthButton->setToolTip("Make text stretch to the full width of the text editor");
    m_ui->increaseWidthButton->setToolTip("Increase the text width by one character");
    m_ui->decreaseWidthButton->setToolTip("Decrease the text width by one character");
    m_ui->lightButton->setToolTip("Change app theme to Light");
    m_ui->darkButton->setToolTip("Change app theme to Dark");
    m_ui->sepiaButton->setToolTip("Chaneg app theme to Sepia");
    m_ui->resetDefaultButton->setToolTip("Reset all to default settings");

    connect(m_ui->serifButton, &QPushButton::clicked, this, [this] {
        emit StyleEditorWindow::changeFontType(FontTypeface::Serif);
        buttonClicked(m_ui->serifButton);
    });
    connect(m_ui->sansSerifButton, &QPushButton::clicked, this, [this] {
        emit StyleEditorWindow::changeFontType(FontTypeface::SansSerif);
        buttonClicked(m_ui->sansSerifButton);
    });

Review comment (bug):
The existing `Qt::WindowStaysOnTopHint` seems wrong. On Xfce, this results in a window that will stay on top by itself, even if another application is brought to the foreground. We really only want the `StyleEditorWindow` to stay on top of the main Notes window (which is achieved by `Qt::Tool` btw, so that change seems appropriate).

Code after:
#include "styleeditorwindow.h"
#include "ui_styleeditorwindow.h"

#include <QDebug>
#include <QTimer>
#include <QShortcut>

/**
 * Initializes the window components and configures the StyleEditorWindow
 */
StyleEditorWindow::StyleEditorWindow(QWidget *parent)
    : QDialog(parent, Qt::Tool),
      m_ui(new Ui::StyleEditorWindow),
      m_currentlyClickedButton(Q_NULLPTR),
      m_currentSelectedFontButton(Q_NULLPTR),
      m_currentSelectedThemeButton(Q_NULLPTR),
      m_isFullWidthClicked(false)
{
    m_ui->setupUi(this);
    setWindowTitle(tr("Editor Settings"));

    m_ui->serifButton->setToolTip(
            "Change the text editor font to a serif font.\nClick again to try different fonts");
    m_ui->sansSerifButton->setToolTip("Change the text editor font to a sans-serif font.\nClick "
                                      "again to try different fonts");
    m_ui->monoButton->setToolTip(
            "Change the text editor font to a monospace font.\nClick again to try different fonts");
    m_ui->decreaseButton->setToolTip("Decrease font size");
    m_ui->increaseButton->setToolTip("Increase font size");
    m_ui->fullWidthButton->setToolTip("Make text stretch to the full width of the text editor");
    m_ui->increaseWidthButton->setToolTip("Increase the text width by one character");
    m_ui->decreaseWidthButton->setToolTip("Decrease the text width by one character");
    m_ui->lightButton->setToolTip("Change app theme to Light");
    m_ui->darkButton->setToolTip("Change app theme to Dark");
    m_ui->sepiaButton->setToolTip("Chaneg app theme to Sepia");
    m_ui->resetDefaultButton->setToolTip("Reset all to default settings");

    connect(m_ui->serifButton, &QPushButton::clicked, this, [this] {
        emit StyleEditorWindow::changeFontType(FontTypeface::Serif);
        buttonClicked(m_ui->serifButton);
    });
    connect(m_ui->sansSerifButton, &QPushButton::clicked, this, [this] {
        emit StyleEditorWindow::changeFontType(FontTypeface::SansSerif);
        buttonClicked(m_ui->sansSerifButton);
    });
    connect(m_ui->monoButton, &QPushButton::clicked, this, [this] {