Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MainWindow/PaletteWidget: Move palette/translation handling to PaletteWidget #155

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 12 additions & 2 deletions source/d1formats/d1trn.cpp
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
#include "d1trn.h"

D1Trn::D1Trn(D1Pal *pal)
: palette(QPointer<D1Pal>(pal))
: palette(pal)
{
}

bool D1Trn::load(QString filePath)
{
if (this->palette.isNull())
if (this->palette == nullptr)
return false;

QFile file = QFile(filePath);
Expand Down Expand Up @@ -73,6 +73,16 @@ QString D1Trn::getFilePath()
return this->trnFilePath;
}

QString D1Trn::getDefaultPath() const
{
return IDENTITY_PATH;
}

QString D1Trn::getDefaultName() const
{
return IDENTITY_NAME;
}

quint8 D1Trn::getTranslation(quint8 index)
{
return this->translations[index];
Expand Down
16 changes: 10 additions & 6 deletions source/d1formats/d1trn.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

#define D1TRN_TRANSLATIONS 256

class D1Trn : public QObject {
class D1Trn final : public D1Pal {
Q_OBJECT

public:
Expand All @@ -17,15 +17,19 @@ class D1Trn : public QObject {
D1Trn(D1Pal *pal);
~D1Trn() = default;

bool load(QString);
bool save(QString);
bool load(QString filepath) override;
bool save(QString filepath) override;

bool isModified() const;
[[nodiscard]] bool isModified() const override;

void refreshResultingPalette();
QColor getResultingColor(quint8);

QString getFilePath();
QString getFilePath() override;

[[nodiscard]] QString getDefaultPath() const override;
[[nodiscard]] QString getDefaultName() const override;

quint8 getTranslation(quint8);
void setTranslation(quint8, quint8);
void setPalette(D1Pal *pal);
Expand All @@ -35,6 +39,6 @@ class D1Trn : public QObject {
QString trnFilePath;
bool modified;
quint8 translations[D1TRN_TRANSLATIONS];
QPointer<D1Pal> palette;
D1Pal *palette = nullptr;
D1Pal resultingPalette;
};
Loading
Loading