diff options
| author | Tannin <devnull@localhost> | 2014-01-05 18:50:56 +0100 |
|---|---|---|
| committer | Tannin <devnull@localhost> | 2014-01-05 18:50:56 +0100 |
| commit | db09b806b9e765b5cb49a9a80f74a4440fff3027 (patch) | |
| tree | 47d8bc442416698d2e5b34c49d7ddd3b6efd04ce /src/previewdialog.cpp | |
| parent | 859c0aed984240467e9e59f72aa4c9714df9fb0b (diff) | |
- Mod Organizer can now display most image types (including dds) and txt files from the data
tree, presenting a comparison of variants in case of overwritten files
Diffstat (limited to 'src/previewdialog.cpp')
| -rw-r--r-- | src/previewdialog.cpp | 57 |
1 files changed, 57 insertions, 0 deletions
diff --git a/src/previewdialog.cpp b/src/previewdialog.cpp new file mode 100644 index 00000000..de33cdd0 --- /dev/null +++ b/src/previewdialog.cpp @@ -0,0 +1,57 @@ +#include "previewdialog.h"
+#include "ui_previewdialog.h"
+#include <QFileInfo>
+
+PreviewDialog::PreviewDialog(const QString &fileName, QWidget *parent) :
+ QDialog(parent),
+ ui(new Ui::PreviewDialog)
+{
+ ui->setupUi(this);
+ ui->nameLabel->setText(QFileInfo(fileName).fileName());
+ ui->nextButton->setEnabled(false);
+ ui->previousButton->setEnabled(false);
+}
+
+PreviewDialog::~PreviewDialog()
+{
+ delete ui;
+}
+
+void PreviewDialog::addVariant(const QString &modName, QWidget *widget)
+{
+ widget->setProperty("modName", modName);
+ ui->variantsStack->addWidget(widget);
+ if (ui->variantsStack->count() > 1) {
+ ui->nextButton->setEnabled(true);
+ ui->previousButton->setEnabled(true);
+ }
+}
+
+int PreviewDialog::numVariants() const
+{
+ return ui->variantsStack->count();
+}
+
+void PreviewDialog::on_variantsStack_currentChanged(int index)
+{
+ ui->modLabel->setText(ui->variantsStack->widget(index)->property("modName").toString());
+}
+
+void PreviewDialog::on_closeButton_clicked()
+{
+ this->accept();
+}
+
+void PreviewDialog::on_previousButton_clicked()
+{
+ int i = ui->variantsStack->currentIndex() - 1;
+ if (i < 0) {
+ i = ui->variantsStack->count() - 1;
+ }
+ ui->variantsStack->setCurrentIndex(i);
+}
+
+void PreviewDialog::on_nextButton_clicked()
+{
+ ui->variantsStack->setCurrentIndex((ui->variantsStack->currentIndex() + 1) % ui->variantsStack->count());
+}
|
