aboutsummaryrefslogtreecommitdiff
path: root/libs/installer_fomod_csharp/src/installer_fomod_predialog.h
blob: 5c57fdfcff15d7b46dae776606639865bb3af2af (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
#ifndef INSTALLER_FOMOD_PREDIALOG_H
#define INSTALLER_FOMOD_PREDIALOG_H

#include "ui_installer_fomod_csharp_predialog.h"

#include <uibase/guessedvalue.h>

#include <QCompleter>

/**
 * @brief Dialog for the installation of a simple archive
 * a simple archive is one that doesn't require any manual changes to work correctly
 **/
class InstallerFomodPredialog : public QDialog
{
  Q_OBJECT

public:
  /**
   * @brief constructor
   *
   * @param preset suggested name for the mod
   * @param parent parent widget
   **/
  explicit InstallerFomodPredialog(const MOBase::GuessedValue<QString>& preset,
                                   QWidget* parent = 0)
      : QDialog(parent), ui(new Ui::FomodCSharpPredialog), m_Manual(false)
  {

    ui->setupUi(this);
    setWindowTitle(preset + " - " + windowTitle());

    for (auto iter = preset.variants().begin(); iter != preset.variants().end();
         ++iter) {
      ui->nameCombo->addItem(*iter);
    }

    ui->nameCombo->setCurrentIndex(ui->nameCombo->findText(preset));
    setWindowFlags(windowFlags() & (~Qt::WindowContextHelpButtonHint));
    ui->nameCombo->completer()->setCaseSensitivity(Qt::CaseSensitive);
  }

  ~InstallerFomodPredialog() {}

  /**
   * @return true if the user requested a manual installation.
   **/
  bool manualRequested() const { return m_Manual; }

  /**
   * @return the (user-modified) mod name
   **/
  QString getName() const { return ui->nameCombo->currentText(); }

private slots:

  void on_okBtn_clicked() { this->accept(); }

  void on_cancelBtn_clicked() { this->reject(); }

  void on_manualBtn_clicked()
  {
    m_Manual = true;
    this->reject();
  }

private:
  std::unique_ptr<Ui::FomodCSharpPredialog> ui;
  bool m_Manual;
};

#endif