Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Display preview in level select

Currently, QLabel seems to have an issue when switching from a pixmap to
text. The sequence pixmap 1 -> pixmap 2 -> text flickers to pixmap 1 for
a short time after calling setText().
  • Loading branch information...
commit 618a4dfb9c8e235b5ec2bb107f7946c2c0f9f2f0 1 parent 16b391c
Jakob Gruber authored
1  TODO
View
@@ -1,4 +1,3 @@
-* display board in selection window if solved
* frontend to save states - menu items, maybe an extra pane
* improve level selection window (sorting, filtering)
* refactoring
15 src/gui/selectboardwindow.cpp
View
@@ -125,6 +125,16 @@ SelectBoardWindow::SelectBoardWindow(QWidget *parent)
}
}
+void SelectBoardWindow::showEvent(QShowEvent *event) {
+ updateDetails(selectedBoard());
+ KDialog::showEvent(event);
+}
+
+void SelectBoardWindow::resizeEvent(QResizeEvent *event) {
+ updateDetails(selectedBoard());
+ KDialog::resizeEvent(event);
+}
+
SelectBoardWindow::~SelectBoardWindow() {
delete ui;
}
@@ -161,8 +171,13 @@ void SelectBoardWindow::updateDetails(std::shared_ptr<Level> level) {
ui->labelDifficulty->setText(QString("%1: %2").arg(ki18n("Difficulty").toString()).arg(diffString(level->difficulty())));
if (level->solved()) {
ui->labelSolved->setText(QString("%1: %2").arg(ki18n("Solved").toString()).arg(Time(level->solvedTime()).toString()));
+ QPixmap scaled = level->preview().scaled(ui->labelImage->size(),
+ Qt::KeepAspectRatio,
+ Qt::FastTransformation);
+ ui->labelImage->setPixmap(scaled);
} else {
ui->labelSolved->setText(QString("%1: %2").arg(ki18n("Solved").toString(), "-"));
+ ui->labelImage->setText("?");
}
}
4 src/gui/selectboardwindow.h
View
@@ -36,6 +36,10 @@ class SelectBoardWindow : public KDialog
std::shared_ptr<Level> selectedBoard() const;
+protected:
+ void resizeEvent(QResizeEvent *event);
+ void showEvent(QShowEvent *event);
+
private slots:
void selectedLevelChanged(const QModelIndex &current, const QModelIndex &previous);
Please sign in to comment.
Something went wrong with that request. Please try again.