Skip to content

Commit

Permalink
fixes for ghosting
Browse files Browse the repository at this point in the history
  • Loading branch information
Szybet committed Nov 16, 2023
1 parent 24511eb commit c6c975f
Show file tree
Hide file tree
Showing 9 changed files with 445 additions and 223 deletions.
37 changes: 26 additions & 11 deletions all/global.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -55,12 +55,12 @@ bool nickelApp = false;
QString buttonNoFlashStylesheet = "QPushButton:pressed { background: white; color: black } QPushButton:checked { background: white; color: black } QPushButton { background: white; color: black }";
int screenX = 1920;
int screenY = 1080;
bool playWaveFormSettings = false;
#ifdef EREADER
ereaderdev::device ereaderDevice;
#endif
}


bool renameDir(QDir & dir, const QString & newName) {
// https://stackoverflow.com/questions/39229177/qdirrename-redundant-parameters
auto src = QDir::cleanPath(dir.filePath("."));
Expand Down Expand Up @@ -161,16 +161,31 @@ void refreshRect(QRect rect) {
#endif
}

int loadWaveFormSetting() {
void loadWaveFormSetting() {
#ifdef EREADER
QSettings settingsGlobal(directories::globalSettings.fileName(), QSettings::IniFormat);
int waveform = settingsGlobal.value("deckPlayWaveForm").toInt();
qDebug() << "Setting waveform mode for deckPlay:" << waveform;
// Does this work?
WaveForm waveformBetter = static_cast<WaveForm>(waveform);
KoboPlatformFunctions::setFullScreenRefreshMode(waveformBetter);
settingsGlobal.deleteLater(); // Idk if needed
return waveform;
if(ereaderVars::playWaveFormSettings == true) {
QSettings settingsGlobal(directories::globalSettings.fileName(), QSettings::IniFormat);
{
int waveform = settingsGlobal.value("deckPlayWaveFormFullscreen").toInt();
qDebug() << "Setting full screen waveform mode for deckPlay:" << waveform;
WaveForm waveformBetter = static_cast<WaveForm>(waveform);
KoboPlatformFunctions::setFullScreenRefreshMode(waveformBetter);
}
{
int waveform = settingsGlobal.value("deckPlayWaveFormPartial").toInt();
qDebug() << "Setting full screen waveform mode for deckPlay:" << waveform;
WaveForm waveformBetter = static_cast<WaveForm>(waveform);
KoboPlatformFunctions::setPartialScreenRefreshMode(waveformBetter);
}
{
int waveform = settingsGlobal.value("deckPlayWaveFormFast").toInt();
qDebug() << "Setting full screen waveform mode for deckPlay:" << waveform;
WaveForm waveformBetter = static_cast<WaveForm>(waveform);
KoboPlatformFunctions::setFastScreenRefreshMode(waveformBetter);
}
settingsGlobal.deleteLater(); // Idk if needed
} else {
KoboPlatformFunctions::setDefaultWaveform();
}
#endif
return 0;
}
3 changes: 2 additions & 1 deletion all/global.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ namespace ereaderVars {
extern QString buttonNoFlashStylesheet;
extern int screenX;
extern int screenY;
extern bool playWaveFormSettings;
#ifdef EREADER
extern ereaderdev::device ereaderDevice;
#endif
Expand All @@ -60,6 +61,6 @@ int getWhiteBrightnessAlias();
QString exec(const char *cmd);
bool createDir(QString absolutePath);
void refreshRect(QRect rect);
int loadWaveFormSetting();
void loadWaveFormSetting();

#endif // GLOBALS_H
18 changes: 11 additions & 7 deletions cardView/deckPlay.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ DeckPlay::DeckPlay(QWidget *parent) :
ui->setupUi(this);

if(ereader) {
ereaderVars::playWaveFormSettings = true;

// This could be editable in settings
ui->scrollArea->verticalScrollBar()->setStyleSheet(
"QScrollBar:vertical { width: 50px; }");
Expand Down Expand Up @@ -376,6 +378,9 @@ void DeckPlay::exitIt() {
flashing = true;
}
#endif

ereaderVars::playWaveFormSettings = false;
loadWaveFormSetting();
}

void DeckPlay::showStats() {
Expand Down Expand Up @@ -426,12 +431,11 @@ void DeckPlay::reloadSettings() {
}
qDebug() << "refreshCardRate is (doubled):" << refreshCardRate;

refreshRect(QRect(0, 0, ereaderVars::screenX, ereaderVars::screenY));
currentWaveForm = loadWaveFormSetting();

this->repaint();
this->repaint();
this->repaint();
QTimer::singleShot(400, this, [this]() {
// Make once in a while a stronger refresh
refreshCard(true);
refreshCard(true);
});

settingsGlobal.deleteLater(); // Idk if needed
}
Expand Down Expand Up @@ -466,7 +470,7 @@ void DeckPlay::refreshCard(bool force) {
graphic->repaint();
QApplication::processEvents();
}
currentWaveForm = loadWaveFormSetting();
loadWaveFormSetting();
KoboPlatformFunctions::setFlashing(flashing);
} else {
refreshCardCount += 1;
Expand Down
1 change: 0 additions & 1 deletion cardView/deckPlay.h
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,6 @@ private slots:
int refreshCardRate = 20; // setText is called 2 times every card, so this is 2x then it is in reality to work
int refreshCardCount = 1;
void refreshCard(bool force = false);
int currentWaveForm; // Convert with WaveForm waveformBetter = static_cast<WaveForm>(waveform);
float zoomFactor = 1.0;
QElapsedTimer* gestureTimer;
QString previousFrontText;
Expand Down
103 changes: 69 additions & 34 deletions components/settings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@
#include "audiodialog.h"
#endif

bool previousPlay = false;

Settings::Settings(QWidget *parent) :
QDialog(parent),
ui(new Ui::Settings)
Expand Down Expand Up @@ -56,14 +58,9 @@ Settings::Settings(QWidget *parent) :
qDebug() << "Keys:" << settingsGlobal->allKeys();
settingsGlobal->setParent(this);

if(ereader) {
int waveform = settingsGlobal->value("deckPlayWaveForm").toInt();
ui->comboBoxEinkMode->setCurrentText(waveFormNumbToString(waveform));
}

// Set the default page
ui->stackedWidget->setCurrentIndex(1);
requestMenuPage();
requestPlayPage();

if(ereader) {
this->setFixedWidth(ereaderVars::screenX);
Expand All @@ -78,7 +75,9 @@ Settings::Settings(QWidget *parent) :

#ifdef EREADER
qDebug() << "Setting waveform mode";
KoboPlatformFunctions::setFullScreenRefreshMode(WaveForm_GC16);
previousPlay = ereaderVars::playWaveFormSettings;
ereaderVars::playWaveFormSettings = false;
loadWaveFormSetting();
#endif
}

Expand Down Expand Up @@ -119,22 +118,6 @@ void Settings::requestEreaderPage()
brightness_string.append(QString::number(brightness));
brightness_string.append("%");
ui->labelBrightness->setText(brightness_string);

int spinBoxValue = 10;
if(settingsGlobal->contains("refreshCard")) {
spinBoxValue = settingsGlobal->value("refreshCard").toInt();
}
qDebug() << "New refresh rate set:" << spinBoxValue;
ui->refreshSpinBox->setValue(spinBoxValue);


bool renderLayerBool = settingsGlobal->value("renderLayer").toBool();
bool flashing = settingsGlobal->value("disableFlashingEverywhere").toBool();

ignoreCheck = true;
ui->renderCheckBox->setChecked(renderLayerBool);
ui->flashingCheckBox->setChecked(flashing);
ignoreCheck = false;
}

void Settings::on_ScrollBarBrightness_valueChanged(int value)
Expand All @@ -154,6 +137,7 @@ void Settings::on_ScrollBarBrightness_valueChanged(int value)

void Settings::on_ButtonOk_clicked()
{
ereaderVars::playWaveFormSettings = previousPlay;
this->close();
}

Expand All @@ -165,7 +149,7 @@ void Settings::managePage(int newIndex, Direction fromWhere) {
newIndex = 0;
}

if(ereader != true && newIndex == 0) {
if(ereader != true && newIndex == 0 && newIndex == 3) {
if(fromWhere == Right) {
managePage(newIndex + 1, fromWhere);
return void();
Expand All @@ -179,14 +163,49 @@ void Settings::managePage(int newIndex, Direction fromWhere) {
if(newIndex == 0) {
requestEreaderPage();
} else if(newIndex == 1) {
requestMenuPage();
requestPlayPage();
} else if(newIndex == 2) {
requestSyncPage();
} else if(newIndex == 3) {
requestEinkPage();
}
}

void Settings::requestEinkPage() {
ui->labelPageName->setText("E-ink");

{
int waveform = settingsGlobal->value("deckPlayWaveFormFullscreen").toInt();
ui->fullscreenEinkModeComboBox->setCurrentText(waveFormNumbToString(waveform));
}
{
int waveform = settingsGlobal->value("deckPlayWaveFormPartial").toInt();
ui->PartialEinkModeComboBox->setCurrentText(waveFormNumbToString(waveform));
}
{
int waveform = settingsGlobal->value("deckPlayWaveFormFast").toInt();
ui->fastscreenEinkModeComboBox->setCurrentText(waveFormNumbToString(waveform));
}

int spinBoxValue = 10;
if(settingsGlobal->contains("refreshCard")) {
spinBoxValue = settingsGlobal->value("refreshCard").toInt();
}
qDebug() << "New refresh rate set:" << spinBoxValue;
ui->refreshSpinBox->setValue(spinBoxValue);


bool renderLayerBool = settingsGlobal->value("renderLayer").toBool();
bool flashing = settingsGlobal->value("disableFlashingEverywhere").toBool();

ignoreCheck = true;
ui->renderCheckBox->setChecked(renderLayerBool);
ui->flashingCheckBox->setChecked(flashing);
ignoreCheck = false;
}

void Settings::requestMenuPage() {
ui->labelPageName->setText("Menu");
void Settings::requestPlayPage() {
ui->labelPageName->setText("Play");

settingsGlobal->sync();

Expand Down Expand Up @@ -374,7 +393,7 @@ void Settings::on_ButtonFontChange_clicked()
currentFont = dialog->selectedFont();
qDebug() << "New current font:" << currentFont;
settingsGlobal->setValue("playFont", currentFont);
requestMenuPage();
requestPlayPage();
}
}

Expand All @@ -386,12 +405,6 @@ void Settings::on_buttonEinkInfo_clicked()
qInfo() << info;
}

void Settings::on_comboBoxEinkMode_currentTextChanged(const QString &arg1) {
int newWaveForm = waveFormStringToInt(arg1);
settingsGlobal->setValue("deckPlayWaveForm", newWaveForm);
settingsGlobal->sync();
}

QString Settings::waveFormNumbToString(int numb) {
switch (numb) {
case 1: return "WaveForm_DU";
Expand Down Expand Up @@ -494,3 +507,25 @@ void Settings::on_nightModeButton_clicked()
#endif
}

void Settings::on_fullscreenEinkModeComboBox_currentTextChanged(const QString &arg1)
{
int newWaveForm = waveFormStringToInt(arg1);
settingsGlobal->setValue("deckPlayWaveFormFullscreen", newWaveForm);
settingsGlobal->sync();
}


void Settings::on_PartialEinkModeComboBox_currentTextChanged(const QString &arg1)
{
int newWaveForm = waveFormStringToInt(arg1);
settingsGlobal->setValue("deckPlayWaveFormPartial", newWaveForm);
settingsGlobal->sync();
}


void Settings::on_fastscreenEinkModeComboBox_currentTextChanged(const QString &arg1)
{
int newWaveForm = waveFormStringToInt(arg1);
settingsGlobal->setValue("deckPlayWaveFormFast", newWaveForm);
settingsGlobal->sync();
}
11 changes: 8 additions & 3 deletions components/settings.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,9 @@ private slots:
void on_ScrollBarBrightness_valueChanged(int value);
void on_ButtonOk_clicked();
void requestEreaderPage();
void requestMenuPage();
void requestPlayPage();
void requestSyncPage();
void requestEinkPage();
void on_buttonSyncInfo_clicked();
void on_buttonSync_clicked();
void on_checkBox_stateChanged(int arg1);
Expand All @@ -32,8 +33,6 @@ private slots:

void on_buttonEinkInfo_clicked();

void on_comboBoxEinkMode_currentTextChanged(const QString &arg1);

void on_buttonDebuggingData_clicked();

void on_audioButton_clicked();
Expand All @@ -50,6 +49,12 @@ private slots:

void on_nightModeButton_clicked();

void on_fullscreenEinkModeComboBox_currentTextChanged(const QString &arg1);

void on_PartialEinkModeComboBox_currentTextChanged(const QString &arg1);

void on_fastscreenEinkModeComboBox_currentTextChanged(const QString &arg1);

private:
Ui::Settings *ui;
enum Direction{
Expand Down
Loading

0 comments on commit c6c975f

Please sign in to comment.