Changeset View
Changeset View
Standalone View
Standalone View
firsttimewizard.cpp
Show First 20 Lines • Show All 99 Lines • ▼ Show 20 Line(s) | 91 | { | |||
---|---|---|---|---|---|
100 | 100 | | |||
101 | existingInstallButton->setText(existingInstallButton->text()+QStringLiteral("(Arduino SDK " ARDUINO_SDK_MIN_VERSION_NAME " or superior)")); | 101 | existingInstallButton->setText(existingInstallButton->text()+QStringLiteral("(Arduino SDK " ARDUINO_SDK_MIN_VERSION_NAME " or superior)")); | ||
102 | automaticInstallButton->setText(automaticInstallButton->text()+QStringLiteral("(Arduino SDK " ARDUINO_SDK_VERSION_NAME ")")); | 102 | automaticInstallButton->setText(automaticInstallButton->text()+QStringLiteral("(Arduino SDK " ARDUINO_SDK_VERSION_NAME ")")); | ||
103 | 103 | | |||
104 | // Download mode is default | 104 | // Download mode is default | ||
105 | automaticInstallButton->setChecked(true); | 105 | automaticInstallButton->setChecked(true); | ||
106 | m_downloadRunning = false; | 106 | m_downloadRunning = false; | ||
107 | // Arduino path | 107 | // Arduino path | ||
108 | getArduinoPath(); | 108 | fetchArduinoPath(); | ||
109 | // Sketchbook path | 109 | // Sketchbook path | ||
110 | getSketchbookPath(); | 110 | fetchSketchbookPath(); | ||
111 | 111 | | |||
112 | //TODO support others OS | 112 | //TODO support others OS | ||
113 | QString mDownloadOs = QStringLiteral("Linux"); | 113 | QString mDownloadOs = QStringLiteral("Linux"); | ||
114 | 114 | | |||
115 | downloadLabel->setText(i18n("Arduino %1 for %2", QStringLiteral(ARDUINO_SDK_VERSION_NAME), mDownloadOs)); | 115 | downloadLabel->setText(i18n("Arduino %1 for %2", QStringLiteral(ARDUINO_SDK_VERSION_NAME), mDownloadOs)); | ||
116 | 116 | | |||
117 | connect(arduinoPathButton, &QToolButton::clicked, this, &FirstTimeWizard::chooseArduinoPath); | 117 | connect(arduinoPathButton, &QToolButton::clicked, this, &FirstTimeWizard::chooseArduinoPath); | ||
118 | connect(sketchbookPathButton, &QToolButton::clicked, this, &FirstTimeWizard::chooseSketchbookPath); | 118 | connect(sketchbookPathButton, &QToolButton::clicked, this, &FirstTimeWizard::chooseSketchbookPath); | ||
▲ Show 20 Lines • Show All 182 Lines • ▼ Show 20 Line(s) | 300 | { | |||
301 | if (currentId() == 0 && existingInstallButton->isChecked()) | 301 | if (currentId() == 0 && existingInstallButton->isChecked()) | ||
302 | { | 302 | { | ||
303 | return 2; | 303 | return 2; | ||
304 | } | 304 | } | ||
305 | 305 | | |||
306 | return QWizard::nextId(); | 306 | return QWizard::nextId(); | ||
307 | } | 307 | } | ||
308 | 308 | | |||
309 | QString FirstTimeWizard::getArduinoPath() | 309 | void FirstTimeWizard::fetchArduinoPath() | ||
310 | { | 310 | { | ||
311 | KConfigGroup settings = ICore::self()->activeSession()->config()->group("Embedded"); | ||||
312 | if (settings.hasKey("arduinoFolder")) | ||||
313 | { | ||||
314 | arduinoPathEdit->setText(settings.readEntry("arduinoFolder")); | ||||
315 | existingInstallButton->setChecked(true); | ||||
316 | return; | ||||
317 | } | ||||
318 | | ||||
311 | // Find Arduino path | 319 | // Find Arduino path | ||
312 | #ifdef Q_OS_DARWIN | 320 | #ifdef Q_OS_DARWIN | ||
313 | #elif defined(Q_OS_WIN32) || defined(Q_OS_WIN64) | 321 | #elif defined(Q_OS_WIN32) || defined(Q_OS_WIN64) | ||
314 | #else | 322 | #else | ||
315 | const QString applicationPath = QStandardPaths::writableLocation(QStandardPaths::DataLocation); | 323 | const QString applicationPath = QStandardPaths::writableLocation(QStandardPaths::DataLocation); | ||
316 | // Paths to search for an existing installation | 324 | // Paths to search for an existing installation | ||
317 | static QStringList defaultArduinoPaths = QStringList() | 325 | static QStringList defaultArduinoPaths = QStringList() | ||
318 | << QDir(applicationPath).filePath(QStringLiteral("arduino-") + QStringLiteral(ARDUINO_SDK_VERSION_NAME)) | 326 | << QDir(applicationPath).filePath(QStringLiteral("arduino-") + QStringLiteral(ARDUINO_SDK_VERSION_NAME)) | ||
319 | << QDir(applicationPath).filePath(QStringLiteral("arduino")) | 327 | << QDir(applicationPath).filePath(QStringLiteral("arduino")) | ||
320 | << QStringLiteral("/usr/local/share/arduino-") + QStringLiteral(ARDUINO_SDK_VERSION_NAME) | 328 | << QStringLiteral("/usr/local/share/arduino-") + QStringLiteral(ARDUINO_SDK_VERSION_NAME) | ||
321 | << QStringLiteral("/usr/local/share/arduino") | 329 | << QStringLiteral("/usr/local/share/arduino") | ||
322 | << QStringLiteral("/usr/share/arduino-") + QStringLiteral(ARDUINO_SDK_VERSION_NAME) | 330 | << QStringLiteral("/usr/share/arduino-") + QStringLiteral(ARDUINO_SDK_VERSION_NAME) | ||
323 | << QStringLiteral("/usr/share/arduino"); | 331 | << QStringLiteral("/usr/share/arduino"); | ||
324 | #endif | 332 | #endif | ||
325 | 333 | | |||
326 | foreach (const auto& path, defaultArduinoPaths) | 334 | foreach (const auto& path, defaultArduinoPaths) | ||
327 | { | 335 | { | ||
328 | if (Toolkit::instance().isValidArduinoPath(path)) | 336 | if (Toolkit::instance().isValidArduinoPath(path)) | ||
329 | { | 337 | { | ||
330 | qCDebug(FtwIo) << "Valid Arduino path at" << path; | 338 | qCDebug(FtwIo) << "Valid Arduino path at" << path; | ||
331 | arduinoPathEdit->setText(path); | 339 | arduinoPathEdit->setText(path); | ||
332 | existingInstallButton->setChecked(true); | 340 | existingInstallButton->setChecked(true); | ||
333 | return path; | | |||
334 | } | 341 | } | ||
335 | } | 342 | } | ||
336 | qCDebug(FtwIo) << "No valid Arduino path"; | 343 | qCDebug(FtwIo) << "No valid Arduino path"; | ||
337 | return QString(); | | |||
338 | } | 344 | } | ||
339 | 345 | | |||
340 | QString FirstTimeWizard::getSketchbookPath() | 346 | void FirstTimeWizard::fetchSketchbookPath() | ||
341 | { | 347 | { | ||
348 | KConfigGroup settings = ICore::self()->activeSession()->config()->group("Embedded"); | ||||
349 | if (settings.hasKey("sketchbookFolder")) | ||||
350 | { | ||||
351 | sketchbookPathEdit->setText(settings.readEntry("sketchbookFolder")); | ||||
352 | return; | ||||
353 | } | ||||
342 | // Find Sketchbook path | 354 | // Find Sketchbook path | ||
343 | QDir sketchbookPath; | 355 | QDir sketchbookPath; | ||
344 | #ifdef Q_OS_DARWIN | 356 | #ifdef Q_OS_DARWIN | ||
345 | #elif defined(Q_OS_WIN32) || defined(Q_OS_WIN64) | 357 | #elif defined(Q_OS_WIN32) || defined(Q_OS_WIN64) | ||
346 | #else | 358 | #else | ||
347 | sketchbookPath = QDir(QDir::homePath()).filePath(QStringLiteral("sketchbook")); | 359 | sketchbookPath = QDir(QDir::homePath()).filePath(QStringLiteral("sketchbook")); | ||
348 | #endif | 360 | #endif | ||
349 | 361 | | |||
350 | if (sketchbookPath.exists()) | 362 | if (sketchbookPath.exists()) | ||
351 | { | 363 | { | ||
352 | sketchbookPathEdit->setText(sketchbookPath.absolutePath()); | 364 | sketchbookPathEdit->setText(sketchbookPath.absolutePath()); | ||
353 | } | 365 | } | ||
354 | | ||||
355 | return QString(); | | |||
356 | } | 366 | } | ||
kfunk: Not needed | |||||
357 | 367 | | |||
358 | void FirstTimeWizard::chooseArduinoPath() | 368 | void FirstTimeWizard::chooseArduinoPath() | ||
359 | { | 369 | { | ||
360 | const QString path = QFileDialog::getExistingDirectory(this, i18n("Find Files"), QDir::currentPath()); | 370 | const QString path = QFileDialog::getExistingDirectory(this, i18n("Find Files"), QDir::currentPath()); | ||
361 | if (!path.isEmpty()) | 371 | if (!path.isEmpty()) | ||
362 | { | 372 | { | ||
363 | arduinoPathEdit->setText(path); | 373 | arduinoPathEdit->setText(path); | ||
364 | } | 374 | } | ||
▲ Show 20 Lines • Show All 65 Lines • Show Last 20 Lines |
Not needed