Changeset View
Changeset View
Standalone View
Standalone View
projectmanagers/qmake/qmakebuilddirchooser.cpp
Show First 20 Lines • Show All 50 Lines • ▼ Show 20 Line(s) | 49 | { | |||
---|---|---|---|---|---|
51 | 51 | | |||
52 | status->hide(); | 52 | status->hide(); | ||
53 | status->setCloseButtonVisible(false); | 53 | status->setCloseButtonVisible(false); | ||
54 | status->setMessageType(KMessageWidget::Error); | 54 | status->setMessageType(KMessageWidget::Error); | ||
55 | status->setWordWrap(true); | 55 | status->setWordWrap(true); | ||
56 | 56 | | |||
57 | kcfg_buildDir->setMode(KFile::Directory | KFile::LocalOnly); | 57 | kcfg_buildDir->setMode(KFile::Directory | KFile::LocalOnly); | ||
58 | kcfg_installPrefix->setMode(KFile::Directory | KFile::LocalOnly); | 58 | kcfg_installPrefix->setMode(KFile::Directory | KFile::LocalOnly); | ||
59 | kcfg_qmakeBin->setMode(KFile::File | KFile::ExistingOnly | KFile::LocalOnly); | 59 | kcfg_qmakeExecutable->setMode(KFile::File | KFile::ExistingOnly | KFile::LocalOnly); | ||
60 | 60 | | |||
61 | connect(kcfg_qmakeBin, &KUrlRequester::textChanged, this, &QMakeBuildDirChooser::changed); | 61 | connect(kcfg_qmakeExecutable, &KUrlRequester::textChanged, this, &QMakeBuildDirChooser::changed); | ||
62 | connect(kcfg_buildDir, &KUrlRequester::textChanged, this, &QMakeBuildDirChooser::changed); | 62 | connect(kcfg_buildDir, &KUrlRequester::textChanged, this, &QMakeBuildDirChooser::changed); | ||
63 | connect(kcfg_installPrefix, &KUrlRequester::textChanged, this, &QMakeBuildDirChooser::changed); | 63 | connect(kcfg_installPrefix, &KUrlRequester::textChanged, this, &QMakeBuildDirChooser::changed); | ||
64 | connect(kcfg_buildType, static_cast<void (QComboBox::*)(int)>(&QComboBox::currentIndexChanged), this, | 64 | connect(kcfg_buildType, static_cast<void (QComboBox::*)(int)>(&QComboBox::currentIndexChanged), this, | ||
65 | &QMakeBuildDirChooser::changed); | 65 | &QMakeBuildDirChooser::changed); | ||
66 | connect(kcfg_extraArgs, &KLineEdit::textChanged, this, &QMakeBuildDirChooser::changed); | 66 | connect(kcfg_extraArgs, &KLineEdit::textChanged, this, &QMakeBuildDirChooser::changed); | ||
67 | } | 67 | } | ||
68 | 68 | | |||
69 | QMakeBuildDirChooser::~QMakeBuildDirChooser() | 69 | QMakeBuildDirChooser::~QMakeBuildDirChooser() | ||
Show All 27 Lines | 96 | { | |||
97 | KConfigGroup config = KConfigGroup(m_project->projectConfiguration(), QMakeConfig::CONFIG_GROUP).group(buildDir()); | 97 | KConfigGroup config = KConfigGroup(m_project->projectConfiguration(), QMakeConfig::CONFIG_GROUP).group(buildDir()); | ||
98 | saveConfig(config); | 98 | saveConfig(config); | ||
99 | } | 99 | } | ||
100 | 100 | | |||
101 | void QMakeBuildDirChooser::saveConfig(KConfigGroup& config) | 101 | void QMakeBuildDirChooser::saveConfig(KConfigGroup& config) | ||
102 | { | 102 | { | ||
103 | qCDebug(KDEV_QMAKE) << "Writing config for" << buildDir() << "to config" << config.name(); | 103 | qCDebug(KDEV_QMAKE) << "Writing config for" << buildDir() << "to config" << config.name(); | ||
104 | 104 | | |||
105 | config.writeEntry(QMakeConfig::QMAKE_BINARY, qmakeBin()); | 105 | config.writeEntry(QMakeConfig::QMAKE_EXECUTABLE, qmakeExecutable()); | ||
106 | config.writeEntry(QMakeConfig::INSTALL_PREFIX, installPrefix()); | 106 | config.writeEntry(QMakeConfig::INSTALL_PREFIX, installPrefix()); | ||
107 | config.writeEntry(QMakeConfig::EXTRA_ARGUMENTS, extraArgs()); | 107 | config.writeEntry(QMakeConfig::EXTRA_ARGUMENTS, extraArgs()); | ||
108 | config.writeEntry(QMakeConfig::BUILD_TYPE, buildType()); | 108 | config.writeEntry(QMakeConfig::BUILD_TYPE, buildType()); | ||
109 | config.sync(); | 109 | config.sync(); | ||
110 | } | 110 | } | ||
111 | 111 | | |||
112 | void QMakeBuildDirChooser::loadConfig() | 112 | void QMakeBuildDirChooser::loadConfig() | ||
113 | { | 113 | { | ||
114 | KConfigGroup cg(m_project->projectConfiguration(), QMakeConfig::CONFIG_GROUP); | 114 | KConfigGroup cg(m_project->projectConfiguration(), QMakeConfig::CONFIG_GROUP); | ||
115 | loadConfig(cg.readEntry(QMakeConfig::BUILD_FOLDER, KDevelop::proposedBuildFolder(m_project->path()).toLocalFile())); | 115 | loadConfig(cg.readEntry(QMakeConfig::BUILD_FOLDER, KDevelop::proposedBuildFolder(m_project->path()).toLocalFile())); | ||
116 | } | 116 | } | ||
117 | 117 | | |||
118 | void QMakeBuildDirChooser::loadConfig(const QString& config) | 118 | void QMakeBuildDirChooser::loadConfig(const QString& config) | ||
119 | { | 119 | { | ||
120 | // get correct group | 120 | // get correct group | ||
121 | KConfigGroup cg(m_project->projectConfiguration(), QMakeConfig::CONFIG_GROUP); | 121 | KConfigGroup cg(m_project->projectConfiguration(), QMakeConfig::CONFIG_GROUP); | ||
122 | const KConfigGroup build = cg.group(config); | 122 | const KConfigGroup build = cg.group(config); | ||
123 | 123 | | |||
124 | { | 124 | { | ||
125 | QSignalBlocker blocker(this); // only emit changed once | 125 | QSignalBlocker blocker(this); // only emit changed once | ||
126 | 126 | | |||
127 | // sets values into fields | 127 | // sets values into fields | ||
128 | setQMakeBin(QMakeConfig::qmakeBinary(m_project)); | 128 | setQMakeExecutable(QMakeConfig::qmakeExecutable(m_project)); | ||
129 | setBuildDir(config); | 129 | setBuildDir(config); | ||
130 | setInstallPrefix(build.readEntry(QMakeConfig::INSTALL_PREFIX, QString())); | 130 | setInstallPrefix(build.readEntry(QMakeConfig::INSTALL_PREFIX, QString())); | ||
131 | setExtraArgs(build.readEntry(QMakeConfig::EXTRA_ARGUMENTS, QString())); | 131 | setExtraArgs(build.readEntry(QMakeConfig::EXTRA_ARGUMENTS, QString())); | ||
132 | setBuildType(build.readEntry(QMakeConfig::BUILD_TYPE, 0)); | 132 | setBuildType(build.readEntry(QMakeConfig::BUILD_TYPE, 0)); | ||
133 | } | 133 | } | ||
134 | emit changed(); | 134 | emit changed(); | ||
135 | } | 135 | } | ||
136 | 136 | | |||
137 | bool QMakeBuildDirChooser::validate(QString* message) | 137 | bool QMakeBuildDirChooser::validate(QString* message) | ||
138 | { | 138 | { | ||
139 | bool valid = true; | 139 | bool valid = true; | ||
140 | QString msg; | 140 | QString msg; | ||
141 | if (qmakeBin().isEmpty()) { | 141 | if (qmakeExecutable().isEmpty()) { | ||
142 | msg = i18n("Please specify path to QMake binary."); | 142 | msg = i18n("Please specify path to QMake executable."); | ||
143 | valid = false; | 143 | valid = false; | ||
144 | } else { | 144 | } else { | ||
145 | QFileInfo info(qmakeBin()); | 145 | QFileInfo info(qmakeExecutable()); | ||
146 | if (!info.exists()) { | 146 | if (!info.exists()) { | ||
147 | msg = i18n("QMake binary \"%1\" does not exist.", qmakeBin()); | 147 | msg = i18n("QMake executable \"%1\" does not exist.", qmakeExecutable()); | ||
148 | valid = false; | 148 | valid = false; | ||
149 | } else if (!info.isFile()) { | 149 | } else if (!info.isFile()) { | ||
150 | msg = i18n("QMake binary is not a file."); | 150 | msg = i18n("QMake executable is not a file."); | ||
151 | valid = false; | 151 | valid = false; | ||
152 | } else if (!info.isExecutable()) { | 152 | } else if (!info.isExecutable()) { | ||
153 | msg = i18n("QMake binary is not executable."); | 153 | msg = i18n("QMake executable is not executable."); | ||
154 | valid = false; | 154 | valid = false; | ||
155 | } else { | 155 | } else { | ||
156 | const QHash<QString, QString> vars = QMakeConfig::queryQMake(info.absoluteFilePath()); | 156 | const QHash<QString, QString> vars = QMakeConfig::queryQMake(info.absoluteFilePath()); | ||
157 | if (vars.isEmpty()) { | 157 | if (vars.isEmpty()) { | ||
158 | msg = i18n("QMake binary cannot be queried for variables."); | 158 | msg = i18n("QMake executable cannot be queried for variables."); | ||
159 | valid = false; | 159 | valid = false; | ||
160 | } else if (QMakeConfig::findBasicMkSpec(vars).isEmpty()) { | 160 | } else if (QMakeConfig::findBasicMkSpec(vars).isEmpty()) { | ||
161 | msg = i18n("No basic MkSpec file could be found for the given QMake binary."); | 161 | msg = i18n("No basic MkSpec file could be found for the given QMake executable."); | ||
162 | valid = false; | 162 | valid = false; | ||
163 | } | 163 | } | ||
164 | } | 164 | } | ||
165 | } | 165 | } | ||
166 | 166 | | |||
167 | if (buildDir().isEmpty()) { | 167 | if (buildDir().isEmpty()) { | ||
168 | msg = i18n("Please specify a build folder."); | 168 | msg = i18n("Please specify a build folder."); | ||
169 | valid = false; | 169 | valid = false; | ||
170 | } | 170 | } | ||
171 | if (message) { | 171 | if (message) { | ||
172 | *message = msg; | 172 | *message = msg; | ||
173 | } | 173 | } | ||
174 | setErrorString(msg); | 174 | setErrorString(msg); | ||
175 | qCDebug(KDEV_QMAKE) << "VALID == " << valid; | 175 | qCDebug(KDEV_QMAKE) << "VALID == " << valid; | ||
176 | return valid; | 176 | return valid; | ||
177 | } | 177 | } | ||
178 | 178 | | |||
179 | QString QMakeBuildDirChooser::qmakeBin() const | 179 | QString QMakeBuildDirChooser::qmakeExecutable() const | ||
180 | { | 180 | { | ||
181 | return kcfg_qmakeBin->url().toLocalFile(); | 181 | return kcfg_qmakeExecutable->url().toLocalFile(); | ||
182 | } | 182 | } | ||
183 | 183 | | |||
184 | QString QMakeBuildDirChooser::buildDir() const | 184 | QString QMakeBuildDirChooser::buildDir() const | ||
185 | { | 185 | { | ||
186 | return kcfg_buildDir->url().toLocalFile(); | 186 | return kcfg_buildDir->url().toLocalFile(); | ||
187 | } | 187 | } | ||
188 | 188 | | |||
189 | QString QMakeBuildDirChooser::installPrefix() const | 189 | QString QMakeBuildDirChooser::installPrefix() const | ||
190 | { | 190 | { | ||
191 | return kcfg_installPrefix->url().toLocalFile(); | 191 | return kcfg_installPrefix->url().toLocalFile(); | ||
192 | } | 192 | } | ||
193 | 193 | | |||
194 | int QMakeBuildDirChooser::buildType() const | 194 | int QMakeBuildDirChooser::buildType() const | ||
195 | { | 195 | { | ||
196 | return kcfg_buildType->currentIndex(); | 196 | return kcfg_buildType->currentIndex(); | ||
197 | } | 197 | } | ||
198 | 198 | | |||
199 | QString QMakeBuildDirChooser::extraArgs() const | 199 | QString QMakeBuildDirChooser::extraArgs() const | ||
200 | { | 200 | { | ||
201 | return kcfg_extraArgs->text(); | 201 | return kcfg_extraArgs->text(); | ||
202 | } | 202 | } | ||
203 | 203 | | |||
204 | void QMakeBuildDirChooser::setQMakeBin(const QString& binary) | 204 | void QMakeBuildDirChooser::setQMakeExecutable(const QString& executable) | ||
205 | { | 205 | { | ||
206 | kcfg_qmakeBin->setUrl(QUrl::fromLocalFile(binary)); | 206 | kcfg_qmakeExecutable->setUrl(QUrl::fromLocalFile(executable)); | ||
207 | } | 207 | } | ||
208 | 208 | | |||
209 | void QMakeBuildDirChooser::setBuildDir(const QString& buildDir) | 209 | void QMakeBuildDirChooser::setBuildDir(const QString& buildDir) | ||
210 | { | 210 | { | ||
211 | kcfg_buildDir->setUrl(QUrl::fromLocalFile(buildDir)); | 211 | kcfg_buildDir->setUrl(QUrl::fromLocalFile(buildDir)); | ||
212 | } | 212 | } | ||
213 | 213 | | |||
214 | void QMakeBuildDirChooser::setInstallPrefix(const QString& prefix) | 214 | void QMakeBuildDirChooser::setInstallPrefix(const QString& prefix) | ||
Show All 13 Lines |