Commit 897a840e authored by Martin Tobias Holmedahl Sandsmark's avatar Martin Tobias Holmedahl Sandsmark
Browse files

use an enum instead of magic numbers, which shows us bugs

parent 39c36163
......@@ -24,6 +24,20 @@
#include <QColor>
enum class Dirty
{
Other = 0,
LayoutChanged = 1,
// Antialias on or off, contrast changed
RepaintNeeded = 2,
ColorsChanged = 3,
RepaintNeeded2 = 4,
};
class File;
namespace RadialMap
......
......@@ -160,7 +160,7 @@ RadialMap::Widget::resizeTimeout() //slot
}
void
RadialMap::Widget::refresh(int filth)
RadialMap::Widget::refresh(const Dirty filth)
{
//TODO consider a more direct connection
......@@ -168,18 +168,18 @@ RadialMap::Widget::refresh(int filth)
{
switch (filth)
{
case 1:
case Dirty::LayoutChanged:
m_focus=nullptr;
m_map.make(m_tree, true); //true means refresh only
break;
case 2:
case Dirty::RepaintNeeded:
m_map.paint();
break;
case 3:
case Dirty::ColorsChanged:
m_map.colorise(); //FALL THROUGH!
case 4:
case Dirty::RepaintNeeded2:
m_map.paint();
default:
......
......@@ -35,6 +35,7 @@
#include <QTimer>
#include "map.h"
#include "radialMap.h" // Dirty
class Folder;
class File;
......@@ -73,7 +74,7 @@ public Q_SLOTS:
void zoomOut();
void create(const Folder*);
void invalidate();
void refresh(int);
void refresh(const Dirty filth);
private Q_SLOTS:
void resizeTimeout();
......
......@@ -206,41 +206,41 @@ void SettingsDialog::changeScheme(QAbstractButton *button)
if (button) {
const int s = m_schemaGroup->id(button);
Config::scheme = (Filelight::MapScheme)s;
Q_EMIT canvasIsDirty(1);
Q_EMIT canvasIsDirty(Dirty::LayoutChanged);
}
}
void SettingsDialog::changeContrast(int c)
{
Config::contrast = c;
Q_EMIT canvasIsDirty(3);
Q_EMIT canvasIsDirty(Dirty::ColorsChanged);
}
void SettingsDialog::toggleUseAntialiasing(bool b)
{
Config::antialias = b;
Q_EMIT canvasIsDirty(2);
Q_EMIT canvasIsDirty(Dirty::RepaintNeeded);
}
void SettingsDialog::toggleVaryLabelFontSizes(bool b)
{
Config::varyLabelFontSizes = b;
minFontPitchLabel->setEnabled(b);
minFontPitch->setEnabled(b);
Q_EMIT canvasIsDirty(0);
Q_EMIT canvasIsDirty(Dirty::Other);
}
void SettingsDialog::changeMinFontPitch(int p)
{
Config::minFontPitch = p;
Q_EMIT canvasIsDirty(0);
Q_EMIT canvasIsDirty(Dirty::Other);
}
void SettingsDialog::toggleShowSmallFiles(bool b)
{
Config::showSmallFiles = b;
Q_EMIT canvasIsDirty(1);
Q_EMIT canvasIsDirty(Dirty::LayoutChanged);
}
void SettingsDialog::slotSliderReleased()
{
Q_EMIT canvasIsDirty(2);
Q_EMIT canvasIsDirty(Dirty::RepaintNeeded);
}
......
......@@ -24,6 +24,8 @@
#include "ui_dialog.h" //generated by uic
#include "radialMap/radialMap.h" // for Dirty
#include <QTimer>
#include <QCloseEvent>
#include <QDialog>
......@@ -59,7 +61,7 @@ public Q_SLOTS:
Q_SIGNALS:
void mapIsInvalid();
void canvasIsDirty(int);
void canvasIsDirty(const Dirty filth);
private:
QTimer m_timer;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment