| 1 | /* |
| 2 | Copyright (C) 2010 Andres Cabrera |
| 3 | [email protected] |
| 4 | |
| 5 | This file is part of CsoundQt. |
| 6 | |
| 7 | CsoundQt is free software; you can redistribute it |
| 8 | and/or modify it under the terms of the GNU Lesser General Public |
| 9 | License as published by the Free Software Foundation; either |
| 10 | version 2.1 of the License, or (at your option) any later version. |
| 11 | |
| 12 | CsoundQt is distributed in the hope that it will be useful, |
| 13 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 15 | GNU Lesser General Public License for more details. |
| 16 | |
| 17 | You should have received a copy of the GNU Lesser General Public |
| 18 | License along with Csound; if not, write to the Free Software |
| 19 | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA |
| 20 | 02111-1307 USA |
| 21 | */ |
| 22 | |
| 23 | #include "appdetailspage.h" |
| 24 | #include "ui_appdetailspage.h" |
| 25 | |
| 26 | #include <QFileDialog> |
| 27 | |
| 28 | AppDetailsPage::AppDetailsPage(QWidget *parent) : |
| 29 | QWizardPage(parent), |
| 30 | ui(new Ui::AppDetailsPage) |
| 31 | { |
| 32 | ui->setupUi(this); |
| 33 | ui->tabWidget->setCurrentIndex(0); |
| 34 | registerField("appName", ui->appNameLineEdit); |
| 35 | |
| 36 | registerField("targetDir", ui->targetDirLineEdit); |
| 37 | registerField("autorun", ui->autorunCheckBox); |
| 38 | registerField("useSdk", ui->platformComboBox); |
| 39 | registerField("runMode", ui->runModeComboBox); |
| 40 | registerField("saveState", ui->saveStatecheckBox); |
| 41 | registerField("newParser", ui->newParserCheckBox); |
| 42 | registerField("showRun", ui->showRunCheckBox); |
| 43 | |
| 44 | registerField("author", ui->authorLineEdit); |
| 45 | registerField("version", ui->versionLineEdit); |
| 46 | registerField("email", ui->emailLineEdit); |
| 47 | registerField("website", ui->websiteLineEdit); |
| 48 | registerField("instructions", ui->instructionsTextEdit); |
| 49 | |
| 50 | registerField("libDir", ui->libLineEdit); |
| 51 | registerField("opcodeDir", ui->opcodeLineEdit); |
| 52 | registerField("qtLibsDir", ui->qtLibsLineEdit); |
| 53 | registerField("customPaths", ui->customPathsCheckBox); |
| 54 | |
| 55 | connect(ui->browseTargetButton,SIGNAL(released()), |
| 56 | this, SLOT(browseTarget())); |
| 57 | connect(ui->browseLibraryButton,SIGNAL(released()), |
| 58 | this, SLOT(browseLibrary())); |
| 59 | connect(ui->browseOpcodesButton,SIGNAL(released()), |
| 60 | this, SLOT(browseOpcodes())); |
| 61 | connect(ui->browseQtLibsButton,SIGNAL(released()), |
| 62 | this, SLOT(browseQtLibs())); |
| 63 | connect(ui->opcodeLineEdit, SIGNAL(textChanged(QString)), |
| 64 | this, SLOT(opcodeDirChanged())); |
| 65 | connect(ui->libLineEdit, SIGNAL(textChanged(QString)), |
| 66 | this, SLOT(libDirChanged())); |
| 67 | connect(ui->platformComboBox, SIGNAL(currentIndexChanged(int)), |
| 68 | SLOT(platformChanged(int))); |
| 69 | //#ifdef Q_OS_MAC |
| 70 | // ui->libLabel->setText("Framework Dir"); |
| 71 | // ui->opcodeLineEdit->hide(); |
| 72 | // ui->browseOpcodesButton->hide(); |
| 73 | // ui->opcodeDirLabel->hide(); |
| 74 | //#endif |
| 75 | } |
| 76 | |
| 77 | AppDetailsPage::~AppDetailsPage() |
| 78 | { |
| 79 | delete ui; |
| 80 | } |
| 81 | |
| 82 | void AppDetailsPage::changeEvent(QEvent *e) |
| 83 | { |
| 84 | QWizardPage::changeEvent(e); |
| 85 | switch (e->type()) { |
| 86 | case QEvent::LanguageChange: |
| 87 | ui->retranslateUi(this); |
| 88 | break; |
| 89 | default: |
| 90 | break; |
| 91 | } |
| 92 | } |
| 93 | |
| 94 | void AppDetailsPage::browseTarget() |
| 95 | { |
| 96 | QString destination = field("targetDir").toString(); |
| 97 | QString dir = QFileDialog::getExistingDirectory(this,tr("Select Target Directory"),destination); |
| 98 | if (dir!="") { |
| 99 | setField("targetDir", dir); |
| 100 | } |
| 101 | } |
| 102 | |
| 103 | void AppDetailsPage::browseLibrary() |
| 104 | { |
| 105 | QString destination = field("libDir").toString(); |
| 106 | QString dir = QFileDialog::getExistingDirectory(this,tr("Select Csound Library Directory"),destination); |
| 107 | if (dir!="") { |
| 108 | setField("libDir", dir); |
| 109 | } |
| 110 | } |
| 111 | |
| 112 | void AppDetailsPage::browseOpcodes() |
| 113 | { |
| 114 | QString destination = field("opcodeDir").toString(); |
| 115 | QString dir = QFileDialog::getExistingDirectory(this,tr("Select Csound Opcodes Directory"),destination); |
| 116 | if (dir!="") { |
| 117 | setField("opcodeDir", dir); |
| 118 | } |
| 119 | } |
| 120 | |
| 121 | void AppDetailsPage::browseQtLibs() |
| 122 | { |
| 123 | QString destination = field("qtLibsDir").toString(); |
| 124 | QString dir = QFileDialog::getExistingDirectory(this,tr("Select Qt Libraries Directory"),destination); |
| 125 | if (dir!="") { |
| 126 | setField("qtLibsDir", dir); |
| 127 | } |
| 128 | } |
| 129 | |
| 130 | void AppDetailsPage::browseSdk() |
| 131 | { |
| 132 | QString destination = field("sdkDir").toString(); |
| 133 | QString dir = QFileDialog::getExistingDirectory(this,tr("Select CsoundQt SDK Directory"),destination); |
| 134 | if (dir!="") { |
| 135 | setField("sdkDir", dir); |
| 136 | } |
| 137 | } |
| 138 | |
| 139 | |
| 140 | void AppDetailsPage::platformChanged(int index) |
| 141 | { |
| 142 | if (index == 0) { |
| 143 | ui->tab_2->setEnabled(true); |
| 144 | ui->tab_3->setEnabled(true); |
| 145 | } else { |
| 146 | ui->tab_2->setEnabled(false); |
| 147 | ui->tab_3->setEnabled(false); |
| 148 | } |
| 149 | } |
| 150 | |
| 151 | void AppDetailsPage::opcodeDirChanged() |
| 152 | { |
| 153 | emit opcodeDirChangedSignal(); |
| 154 | } |
| 155 | |
| 156 | void AppDetailsPage::libDirChanged() |
| 157 | { |
| 158 | emit libDirChangedSignal(); |
| 159 | } |
| 160 |