Skip to content

Commit

Permalink
Reduce list of known factors
Browse files Browse the repository at this point in the history
  • Loading branch information
leplatrem committed May 13, 2020
1 parent a1d0e3b commit a86e587
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 16 deletions.
23 changes: 10 additions & 13 deletions src/mainwindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -148,17 +148,12 @@ MainWindow::MainWindow(QWidget *parent)
ui->tableWidget->setFocus();
setAcceptDrops(true);

// Build the list of known factors (all combinations).
// Build the list of known factors.
ui->knownFactors->addItem("", 100.0);
for (int i = 0; i < FACTORS_LABELS.size(); i++) {
for (int j = 0; j < FACTORS_LABELS.size(); j++) {
if (i == j) {
continue;
}
ui->knownFactors->addItem(
QString("%1 → %2").arg(FACTORS_LABELS[i]).arg(FACTORS_LABELS[j]),
FACTORS_VALUES[j] / FACTORS_VALUES[i] * 100.0);
}
foreach (Factor conv, FACTORS_VALUES) {
ui->knownFactors->addItem(
QString("%1 fps → %2 fps").arg(conv.first).arg(conv.second),
conv.first * 100.0 / conv.second);
}

// Disable print out by default.
Expand Down Expand Up @@ -1130,14 +1125,16 @@ void MainWindow::actionShowHelp() {
}

void MainWindow::speedFactorChanged(double p_factor) {
if (FACTORS_VALUES.indexOf(p_factor) >= 0) {
if (qAbs(p_factor - ui->knownFactors->currentData().toDouble()) > 0.001) {
ui->knownFactors->setCurrentIndex(-1);
}
}

void MainWindow::knownFactorChosen(int) {
void MainWindow::knownFactorChosen(int p_chosen) {
// Adjust spinbox to known factor.
ui->speedFactor->setValue(ui->knownFactors->currentData().toDouble());
if (p_chosen >= 0) {
ui->speedFactor->setValue(ui->knownFactors->itemData(p_chosen).toDouble());
}
}

void MainWindow::enableKnownFactors(bool p_state) {
Expand Down
9 changes: 6 additions & 3 deletions src/mainwindow.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
#include <QMainWindow>
#include <QMap>
#include <QModelIndex>
#include <QPair>
#include <QString>
#include <QTableWidget>
#include <QTime>
Expand All @@ -38,9 +39,11 @@

#define MAX_RECENT_FILES 7

static QList<double> FACTORS_VALUES = {23.976, 24, 25, 29.97, 30};
static QStringList FACTORS_LABELS = {"23,976 fps", "24 fps", "25 fps",
"29,97 fps", "30 fps"};
typedef QPair<double, double> Factor;
static QList<Factor> FACTORS_VALUES = {
{23.976, 24}, {23.976, 25}, {24, 23.976}, {24, 25},
{25, 23.976}, {25, 24}, {29.97, 30}, {30, 29.97},
};

class ConfigEditor;
class ShortcutEditor;
Expand Down

0 comments on commit a86e587

Please sign in to comment.