Skip to content

Commit

Permalink
Refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
darktorres committed Sep 13, 2022
1 parent 7e701e7 commit 8248c99
Show file tree
Hide file tree
Showing 6 changed files with 9 additions and 9 deletions.
1 change: 1 addition & 0 deletions app/globalproperties.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,5 @@ class GlobalProperties
inline static bool verbose = true;
inline static const double version = QString(APP_VERSION).toDouble();
inline static const int gridSize = 16;
inline static const int maxRecentFiles = 10;
};
2 changes: 2 additions & 0 deletions app/graphicelement.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ namespace
int id = qRegisterMetaType<GraphicElement>();
}

const int maximumValidInputSize = 256;

GraphicElement::GraphicElement(ElementType type, ElementGroup group, const QString &pixmapPath, const QString &titleText, const QString &translatedName, const int minInputSize, const int maxInputSize, const int minOutputSize, const int maxOutputSize, QGraphicsItem *parent)
: QGraphicsObject(parent)
, m_pixmapPath(pixmapPath)
Expand Down
2 changes: 0 additions & 2 deletions app/graphicelement.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@
#include <QPixmapCache>
#include <memory>

constexpr int maximumValidInputSize = 256;

class GraphicElement;
class QNEInputPort;
class QNEOutputPort;
Expand Down
6 changes: 3 additions & 3 deletions app/mainwindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -890,7 +890,7 @@ void MainWindow::zoomChanged()
void MainWindow::updateRecentFileActions()
{
const auto files = m_recentFiles->recentFiles();
const int numRecentFiles = qMin(files.size(), RecentFiles::MaxRecentFiles);
const int numRecentFiles = qMin(files.size(), GlobalProperties::maxRecentFiles);

if (numRecentFiles > 0) {
m_ui->menuRecentFiles->setEnabled(true);
Expand All @@ -905,7 +905,7 @@ void MainWindow::updateRecentFileActions()
actions.at(i)->setVisible(true);
}

for (int i = numRecentFiles; i < RecentFiles::MaxRecentFiles; ++i) {
for (int i = numRecentFiles; i < GlobalProperties::maxRecentFiles; ++i) {
actions.at(i)->setVisible(false);
}
}
Expand All @@ -921,7 +921,7 @@ void MainWindow::createRecentFileActions()
{
m_ui->menuRecentFiles->clear();

for (int i = 0; i < RecentFiles::MaxRecentFiles; ++i) {
for (int i = 0; i < GlobalProperties::maxRecentFiles; ++i) {
auto *action = new QAction(this);
action->setVisible(false);
connect(action, &QAction::triggered, this, &MainWindow::openRecentFile);
Expand Down
5 changes: 3 additions & 2 deletions app/recentfiles.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
#include "recentfiles.h"

#include "common.h"
#include "globalproperties.h"
#include "settings.h"

#include <QApplication>
Expand All @@ -30,8 +31,8 @@ void RecentFiles::addRecentFile(const QString &filePath)
m_files.removeAll(filePath);
m_files.prepend(filePath);

if (m_files.size() > MaxRecentFiles) {
m_files.erase(m_files.begin() + MaxRecentFiles, m_files.end());
if (m_files.size() > GlobalProperties::maxRecentFiles) {
m_files.erase(m_files.begin() + GlobalProperties::maxRecentFiles, m_files.end());
}

emit recentFilesUpdated();
Expand Down
2 changes: 0 additions & 2 deletions app/recentfiles.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,6 @@ class RecentFiles : public QObject
public:
explicit RecentFiles(QObject *parent = nullptr);

static constexpr int MaxRecentFiles = 10;

QStringList recentFiles();
void addRecentFile(const QString &filePath);

Expand Down

0 comments on commit 8248c99

Please sign in to comment.