Guest User

Untitled

a guest
Nov 21st, 2013
55
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. /****************************************************************************
  2. **
  3. ** Copyright (c) 2013 Samuel Aaron
  4. **
  5. ** Permission is hereby granted, free of charge, to any person obtaining a copy
  6. ** of this software and associated documentation files (the "Software"), to deal
  7. ** in the Software without restriction, including without limitation the rights
  8. ** to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  9. ** copies of the Software, and to permit persons to whom the Software is
  10. ** furnished to do so, subject to the following conditions:
  11. **
  12. ** The above copyright notice and this permission notice shall be included in
  13. ** all copies or substantial portions of the Software.
  14. **
  15. ** THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  16. ** IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  17. ** FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  18. ** AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  19. ** LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  20. ** OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  21. ** THE SOFTWARE.
  22. **
  23. ****************************************************************************/
  24.  
  25. #include <QMap>
  26. #include <QAction>
  27. #include <QApplication>
  28. #include <QCloseEvent>
  29. #include <QFile>
  30. #include <QFileInfo>
  31. #include <QFileDialog>
  32. #include <QIcon>
  33. #include <QMenu>
  34. #include <QMenuBar>
  35. #include <QMessageBox>
  36. #include <QDockWidget>
  37. #include <QPoint>
  38. #include <QSettings>
  39. #include <QSize>
  40. #include <QStatusBar>
  41. #include <QTextStream>
  42. #include <QTextEdit>
  43. #include <QToolBar>
  44. #include <QProcess>
  45. #include <QFont>
  46. #include <QTabWidget>
  47. #include <QString>
  48. #include <QTextStream>
  49. #include <QFile>
  50. #include <Qsci/qsciscintilla.h>
  51. #include <Qsci/qscilexerruby.h>
  52.  
  53. #include "mainwindow.h"
  54.  
  55. MainWindow::MainWindow(QApplication &app)
  56. {
  57.  
  58. ensureWorkspaces();
  59.  
  60. runProcess = NULL;
  61. groupName = "default";
  62. QFile file("/tmp/sonic-pi/group-name");
  63. bool ret = file.open(QIODevice::ReadOnly | QIODevice::Text);
  64. if( ret )
  65. {
  66. QTextStream stream(&file);
  67. groupName = stream.readAll().trimmed();
  68. }
  69.  
  70. QMap<QString, QString> map;
  71. tabs = new QTabWidget();
  72. tabs->setTabsClosable(false);
  73. tabs->setMovable(false);
  74. setCentralWidget(tabs);
  75.  
  76. workspace1 = new QsciScintilla;
  77. workspace2 = new QsciScintilla;
  78. workspace3 = new QsciScintilla;
  79. workspace4 = new QsciScintilla;
  80. workspace5 = new QsciScintilla;
  81. workspace6 = new QsciScintilla;
  82. workspace7 = new QsciScintilla;
  83. workspace8 = new QsciScintilla;
  84.  
  85. QString w1 = "Workspace 1";
  86. QString w2 = "Workspace 2";
  87. QString w3 = "Workspace 3";
  88. QString w4 = "Workspace 4";
  89. QString w5 = "Workspace 5";
  90. QString w6 = "Workspace 6";
  91. QString w7 = "Workspace 7";
  92. QString w8 = "Workspace 8";
  93.  
  94.  
  95. tabs->addTab(workspace1, w1);
  96. tabs->addTab(workspace2, w2);
  97. tabs->addTab(workspace3, w3);
  98. tabs->addTab(workspace4, w4);
  99. tabs->addTab(workspace5, w5);
  100. tabs->addTab(workspace6, w6);
  101. tabs->addTab(workspace7, w7);
  102. tabs->addTab(workspace8, w8);
  103.  
  104. QString one = "one";
  105. QString two = "two";
  106. QString three = "three";
  107. QString four = "four";
  108. QString five = "five";
  109. QString six = "six";
  110. QString seven = "seven";
  111. QString eight = "eight";
  112.  
  113. map.insert(w1, one);
  114. map.insert(w2, two);
  115. map.insert(w3, three);
  116. map.insert(w4, four);
  117. map.insert(w5, five);
  118. map.insert(w6, six);
  119. map.insert(w7, seven);
  120. map.insert(w8, eight);
  121.  
  122. workspace1->setUtf8(true);
  123. workspace2->setUtf8(true);
  124. workspace3->setUtf8(true);
  125. workspace4->setUtf8(true);
  126. workspace5->setUtf8(true);
  127. workspace6->setUtf8(true);
  128. workspace7->setUtf8(true);
  129. workspace8->setUtf8(true);
  130.  
  131. lexer = new QsciLexerRuby;
  132.  
  133. QFont font("Monospace");
  134. font.setStyleHint(QFont::Monospace);
  135. lexer->setDefaultFont(font);
  136.  
  137. workspace1->setLexer(lexer);
  138. workspace1->zoomIn(13);
  139.  
  140. workspace2->setLexer(lexer);
  141. workspace2->zoomIn(13);
  142.  
  143. workspace3->setLexer(lexer);
  144. workspace3->zoomIn(13);
  145.  
  146. workspace4->setLexer(lexer);
  147. workspace4->zoomIn(13);
  148.  
  149. workspace5->setLexer(lexer);
  150. workspace5->zoomIn(13);
  151.  
  152. workspace6->setLexer(lexer);
  153. workspace6->zoomIn(13);
  154.  
  155. workspace7->setLexer(lexer);
  156. workspace7->zoomIn(13);
  157.  
  158. workspace8->setLexer(lexer);
  159. workspace8->zoomIn(13);
  160.  
  161. outputPane = new QTextEdit;
  162. errorPane = new QsciScintilla;
  163.  
  164. outputPane->zoomIn(7);
  165. errorPane->zoomIn(3);
  166.  
  167. QDockWidget *outputWidget = new QDockWidget(tr("Output"), this);
  168. outputWidget->setAllowedAreas(Qt::RightDockWidgetArea);
  169. outputWidget->setWidget(outputPane);
  170. addDockWidget(Qt::RightDockWidgetArea, outputWidget);
  171.  
  172. QDockWidget *dockWidget = new QDockWidget(tr("Errors"), this);
  173. dockWidget->setAllowedAreas(Qt::RightDockWidgetArea);
  174. dockWidget->setWidget(errorPane);
  175. addDockWidget(Qt::RightDockWidgetArea, dockWidget);
  176.  
  177. createActions();
  178. createMenus();
  179. createToolBars();
  180. createStatusBar();
  181.  
  182. readSettings();
  183.  
  184. // connect(textEdit, SIGNAL(textChanged()),
  185. // this, SLOT(documentWasModified()));
  186.  
  187. // setWindowTitle(tr("Sonic Pi"));
  188. setWindowTitle("Sonic Pi - " + groupName);
  189. callInitScript();
  190. loadWorkspaces();
  191.  
  192. // connect(runProcess, SIGNAL(readyReadStandardOutput()),
  193. // this, SLOT(updateOutput()));
  194.  
  195. connect(&app, SIGNAL( aboutToQuit() ), this, SLOT( onExitCleanup() ) );
  196. }
  197.  
  198. void MainWindow::ensureWorkspaces()
  199. {
  200. QString program = QCoreApplication::applicationDirPath() + "/../../app/scripts/ensure-workspaces.rb";
  201. QStringList arguments;
  202. QObject *parent;
  203. runProcess = new QProcess(parent);
  204. runProcess->start(program, arguments);
  205. runProcess->waitForFinished();
  206. }
  207.  
  208. void MainWindow::onExitCleanup()
  209. {
  210. QString program = QCoreApplication::applicationDirPath() + "/../../app/scripts/shutdown.rb";
  211. QStringList arguments;
  212. QObject *parent;
  213. runProcess = new QProcess(parent);
  214. runProcess->start(program, arguments);
  215. }
  216.  
  217. void MainWindow::loadWorkspaces()
  218. {
  219. loadFile(QDir::homePath() + "/.sonic-pi/workspaces/" + groupName + "/one/1.spi", workspace1);
  220. loadFile(QDir::homePath() + "/.sonic-pi/workspaces/" + groupName + "/two/1.spi", workspace2);
  221. loadFile(QDir::homePath() + "/.sonic-pi/workspaces/" + groupName + "/three/1.spi", workspace3);
  222. loadFile(QDir::homePath() + "/.sonic-pi/workspaces/" + groupName + "/four/1.spi", workspace4);
  223. loadFile(QDir::homePath() + "/.sonic-pi/workspaces/" + groupName + "/five/1.spi", workspace5);
  224. loadFile(QDir::homePath() + "/.sonic-pi/workspaces/" + groupName + "/six/1.spi", workspace6);
  225. loadFile(QDir::homePath() + "/.sonic-pi/workspaces/" + groupName + "/seven/1.spi", workspace7);
  226. loadFile(QDir::homePath() + "/.sonic-pi/workspaces/" + groupName + "/eight/1.spi", workspace8);
  227. }
  228.  
  229. void MainWindow::saveWorkspaces()
  230. {
  231. saveFile(QDir::homePath() + "/.sonic-pi/workspaces/" + groupName + "/one/1.spi", workspace1);
  232. saveFile(QDir::homePath() + "/.sonic-pi/workspaces/" + groupName + "/two/1.spi", workspace2);
  233. saveFile(QDir::homePath() + "/.sonic-pi/workspaces/" + groupName + "/three/1.spi", workspace3);
  234. saveFile(QDir::homePath() + "/.sonic-pi/workspaces/" + groupName + "/four/1.spi", workspace4);
  235. saveFile(QDir::homePath() + "/.sonic-pi/workspaces/" + groupName + "/five/1.spi", workspace5);
  236. saveFile(QDir::homePath() + "/.sonic-pi/workspaces/" + groupName + "/six/1.spi", workspace6);
  237. saveFile(QDir::homePath() + "/.sonic-pi/workspaces/" + groupName + "/seven/1.spi", workspace7);
  238. saveFile(QDir::homePath() + "/.sonic-pi/workspaces/" + groupName + "/eight/1.spi", workspace8);
  239. }
  240.  
  241. void MainWindow::closeEvent(QCloseEvent *event)
  242. {
  243. if (maybeSave()) {
  244. writeSettings();
  245. event->accept();
  246. } else {
  247. event->ignore();
  248. }
  249. }
  250.  
  251. void MainWindow::newFile()
  252. {
  253.  
  254. }
  255.  
  256. QString MainWindow::currentTabLabel()
  257. {
  258. return tabs->tabText(tabs->currentIndex());
  259. }
  260.  
  261.  
  262. bool MainWindow::saveAs()
  263. {
  264. QString fileName = QFileDialog::getSaveFileName(this, tr("Save Current Workspace"), QDir::homePath() + "/Desktop");
  265. saveFile(fileName, (QsciScintilla*)tabs->currentWidget());
  266. }
  267.  
  268. void MainWindow::runCode()
  269. {
  270. // printf("running code");
  271. killSynths();
  272. saveWorkspace( (QsciScintilla*)tabs->currentWidget());
  273. saveFile("/tmp/sonic-pi-current-code.rb", (QsciScintilla*)tabs->currentWidget());
  274. outputPane->clear();
  275. errorPane->clear();
  276. lexer->setPaper(Qt::lightGray);
  277. QString emptyText = "";
  278. statusBar()->showMessage(tr("Running..."), 2000);
  279.  
  280. // clearOutputPanels();
  281.  
  282. // printf((QCoreApplication::applicationDirPath() + "/../../app/scripts/run-code.rb").toAscii().data());
  283. QString program = QCoreApplication::applicationDirPath() + "/../../app/scripts/run-code.rb";
  284. QStringList arguments;
  285. arguments << "/tmp/sonic-pi-current-code.rb";
  286. QObject *parent;
  287. runProcess = new QProcess(parent);
  288.  
  289. connect(runProcess, SIGNAL(readyReadStandardOutput()),
  290. this, SLOT(updateOutput()));
  291.  
  292. connect(runProcess, SIGNAL(readyReadStandardError()),
  293. this, SLOT(updateError()));
  294.  
  295.  
  296.  
  297. runProcess->start(program, arguments);
  298. //runProcess->write(tabs->currentWidget()->text().toAscii());
  299. // runProcess->waitForFinished();
  300. lexer->setPaper(Qt::white);
  301. }
  302.  
  303. void MainWindow::killSynths()
  304. {
  305. if (runProcess)
  306. {
  307. runProcess->kill();
  308. }
  309. stopRunningSynths();
  310. }
  311.  
  312. void MainWindow::stopCode()
  313. {
  314. outputPane->clear();
  315. errorPane->clear();
  316. lexer->setPaper(Qt::red);
  317. statusBar()->showMessage(tr("Stopping..."), 2000);
  318. killSynths();
  319. // clearOutputPanels();
  320. // QString program = QCoreApplication::applicationDirPath() + "/../../app/scripts/stop-code.rb";
  321. // QStringList arguments;
  322. // arguments << "/tmp/sonic-pi";
  323. // QObject *parent;
  324. // runProcess = new QProcess(parent);
  325.  
  326. // connect(runProcess, SIGNAL(readyReadStandardOutput()),
  327. // this, SLOT(updateOutput()));
  328.  
  329. // connect(runProcess, SIGNAL(readyReadStandardError()),
  330. // this, SLOT(updateError()));
  331.  
  332. // runProcess->start(program, arguments);
  333. //runProcess->write(currentTextArea()->text().toAscii());
  334. // runProcess->waitForFinished();
  335. lexer->setPaper(Qt::white);
  336. }
  337.  
  338. void MainWindow::updateError()
  339. {
  340. QByteArray output = runProcess->readAllStandardError();
  341. errorPane->append(output);
  342. }
  343.  
  344. void MainWindow::updateOutput()
  345. {
  346. QByteArray output = runProcess->readAllStandardOutput();
  347. outputPane->append(output);
  348. }
  349.  
  350. void MainWindow::open()
  351. {
  352.  
  353. }
  354.  
  355. bool MainWindow::save()
  356. {
  357.  
  358. }
  359.  
  360. void MainWindow::about()
  361. {
  362. QMessageBox::about(this, tr("About Sonic Pi"),
  363. tr("<b>Sonic Pi</b> is an experimental language and application"
  364. "for using creative processes to engage students with a"
  365. "computer science curriculum."));
  366. }
  367.  
  368. void MainWindow::documentWasModified()
  369. {
  370. // setWindowModified(textEdit->isModified());
  371. }
  372.  
  373. // void MainWindow::textChanged()
  374. // {
  375. // printf("changed!");
  376. // }
  377.  
  378. void MainWindow::callInitScript()
  379. {
  380. QString program = QCoreApplication::applicationDirPath() + "/../../app/scripts/boot.rb";
  381. QStringList arguments;
  382. QObject *parent;
  383. QProcess *myProcess = new QProcess(parent);
  384. myProcess->start(program, arguments);
  385. myProcess->waitForFinished();
  386. }
  387.  
  388. void MainWindow::stopRunningSynths()
  389. {
  390. QString program = QCoreApplication::applicationDirPath() + "/../../app/scripts/stop-running-synths.rb";
  391. QStringList arguments;
  392. QObject *parent;
  393. QProcess *myProcess = new QProcess(parent);
  394. myProcess->start(program, arguments);
  395. myProcess->waitForFinished();
  396. }
  397.  
  398. void MainWindow::clearOutputPanels()
  399. {
  400. outputPane->clear();
  401. errorPane->clear();
  402. }
  403.  
  404. void MainWindow::createActions()
  405. {
  406.  
  407. runAct = new QAction(QIcon(":/images/save.png"), tr("&Run"), this);
  408. runAct->setShortcut(tr("Ctrl+R"));
  409. runAct->setStatusTip(tr("Run code"));
  410. connect(runAct, SIGNAL(triggered()), this, SLOT(runCode()));
  411.  
  412. stopAct = new QAction(QIcon(":/images/new.png"), tr("&Stop"), this);
  413. stopAct->setShortcut(tr("Ctrl+Q"));
  414. stopAct->setStatusTip(tr("Stop code"));
  415. connect(stopAct, SIGNAL(triggered()), this, SLOT(stopCode()));
  416.  
  417. // newAct = new QAction(QIcon(":/images/new.png"), tr("&New"), this);
  418. // newAct->setShortcut(tr("Ctrl+N"));
  419. // newAct->setStatusTip(tr("Create a new file"));
  420. // connect(newAct, SIGNAL(triggered()), this, SLOT(newFile()));
  421.  
  422. // openAct = new QAction(QIcon(":/images/open.png"), tr("&Open..."), this);
  423. // openAct->setShortcut(tr("Ctrl+O"));
  424. // openAct->setStatusTip(tr("Open an existing file"));
  425. // connect(openAct, SIGNAL(triggered()), this, SLOT(open()));
  426. saveAsAct = new QAction(QIcon(":/images/open.png"), tr("&Save &As..."), this);
  427. saveAsAct->setStatusTip(tr("Save the document under a new name"));
  428. connect(saveAsAct, SIGNAL(triggered()), this, SLOT(saveAs()));
  429.  
  430. // exitAct = new QAction(tr("E&xit"), this);
  431. // exitAct->setShortcut(tr("Ctrl+Q"));
  432. // exitAct->setStatusTip(tr("Exit the application"));
  433. // connect(exitAct, SIGNAL(triggered()), this, SLOT(close()));
  434.  
  435. // cutAct = new QAction(QIcon(":/images/cut.png"), tr("Cu&t"), this);
  436. // cutAct->setShortcut(tr("Ctrl+X"));
  437. // cutAct->setStatusTip(tr("Cut the current selection's contents to the "
  438. // "clipboard"));
  439. // connect(cutAct, SIGNAL(triggered()), textEdit, SLOT(cut()));
  440.  
  441. // copyAct = new QAction(QIcon(":/images/copy.png"), tr("&Copy"), this);
  442. // copyAct->setShortcut(tr("Ctrl+C"));
  443. // copyAct->setStatusTip(tr("Copy the current selection's contents to the "
  444. // "clipboard"));
  445. // connect(copyAct, SIGNAL(triggered()), textEdit, SLOT(copy()));
  446.  
  447. // pasteAct = new QAction(QIcon(":/images/paste.png"), tr("&Paste"), this);
  448. // pasteAct->setShortcut(tr("Ctrl+V"));
  449. // pasteAct->setStatusTip(tr("Paste the clipboard's contents into the current "
  450. // "selection"));
  451. // connect(pasteAct, SIGNAL(triggered()), textEdit, SLOT(paste()));
  452.  
  453. aboutAct = new QAction(tr("&About"), this);
  454. aboutAct->setStatusTip(tr("Show the application's About box"));
  455. connect(aboutAct, SIGNAL(triggered()), this, SLOT(about()));
  456.  
  457. aboutQtAct = new QAction(tr("About &Qt"), this);
  458. aboutQtAct->setStatusTip(tr("Show the Qt library's About box"));
  459. connect(aboutQtAct, SIGNAL(triggered()), qApp, SLOT(aboutQt()));
  460.  
  461. // cutAct->setEnabled(false);
  462. // copyAct->setEnabled(false);
  463. // connect(textEdit, SIGNAL(copyAvailable(bool)),
  464. // cutAct, SLOT(setEnabled(bool)));
  465. // connect(textEdit, SIGNAL(copyAvailable(bool)),
  466. // copyAct, SLOT(setEnabled(bool)));
  467. }
  468.  
  469. void MainWindow::createMenus()
  470. {
  471. // fileMenu = menuBar()->addMenu(tr("&File"));
  472. // fileMenu->addAction(newAct);
  473. // fileMenu->addAction(openAct);
  474. // fileMenu->addAction(saveAct);
  475. // fileMenu->addAction(saveAsAct);
  476. // fileMenu->addSeparator();
  477. // fileMenu->addAction(exitAct);
  478.  
  479. // editMenu = menuBar()->addMenu(tr("&Edit"));
  480. // editMenu->addAction(cutAct);
  481. // editMenu->addAction(copyAct);
  482. // editMenu->addAction(pasteAct);
  483.  
  484. // menuBar()->addSeparator();
  485.  
  486. // helpMenu = menuBar()->addMenu(tr("&Help"));
  487. // helpMenu->addAction(aboutAct);
  488. // helpMenu->addAction(aboutQtAct);f
  489. }
  490.  
  491. void MainWindow::createToolBars()
  492. {
  493. fileToolBar = addToolBar(tr("Run"));
  494. fileToolBar->addAction(runAct);
  495. fileToolBar->addAction(stopAct);
  496. // fileToolBar->addAction(newAct);
  497. // fileToolBar->addAction(openAct);
  498. fileToolBar->addAction(saveAsAct);
  499. }
  500.  
  501. void MainWindow::createStatusBar()
  502. {
  503. statusBar()->showMessage(tr("Ready"));
  504. }
  505.  
  506. void MainWindow::readSettings()
  507. {
  508. QSettings settings("Trolltech", "Application Example");
  509. QPoint pos = settings.value("pos", QPoint(200, 200)).toPoint();
  510. QSize size = settings.value("size", QSize(400, 400)).toSize();
  511. resize(size);
  512. move(pos);
  513. }
  514.  
  515. void MainWindow::writeSettings()
  516. {
  517. QSettings settings("Trolltech", "Application Example");
  518. settings.setValue("pos", pos());
  519. settings.setValue("size", size());
  520. }
  521.  
  522. bool MainWindow::maybeSave()
  523. {
  524. // if (textEdit->isModified()) {
  525. // int ret = QMessageBox::warning(this, tr("Application"),
  526. // tr("The document has been modified.\n"
  527. // "Do you want to save your changes?"),
  528. // QMessageBox::Yes | QMessageBox::Default,
  529. // QMessageBox::No,
  530. // QMessageBox::Cancel | QMessageBox::Escape);
  531. // if (ret == QMessageBox::Yes)
  532. // return save();
  533. // else if (ret == QMessageBox::Cancel)
  534. // return false;
  535. // }
  536. return true;
  537. }
  538.  
  539. void MainWindow::loadFile(const QString &fileName, QsciScintilla* &text)
  540. {
  541. QFile file(fileName);
  542. if (!file.open(QFile::ReadOnly)) {
  543. QMessageBox::warning(this, tr("Sonic Pi"),
  544. tr("Cannot read file %1:\n%2.")
  545. .arg(fileName)
  546. .arg(file.errorString()));
  547. return;
  548. }
  549.  
  550. QTextStream in(&file);
  551. QApplication::setOverrideCursor(Qt::WaitCursor);
  552. text->setText(in.readAll());
  553. QApplication::restoreOverrideCursor();
  554. statusBar()->showMessage(tr("File loaded"), 2000);
  555. }
  556.  
  557. bool MainWindow::saveFile(const QString &fileName, QsciScintilla* text)
  558. {
  559. QFile file(fileName);
  560. if (!file.open(QFile::WriteOnly)) {
  561. QMessageBox::warning(this, tr("Sonic Pi"),
  562. tr("Cannot write file %1:\n%2.")
  563. .arg(fileName)
  564. .arg(file.errorString()));
  565. return false;
  566. }
  567.  
  568. QTextStream out(&file);
  569. QApplication::setOverrideCursor(Qt::WaitCursor);
  570. out << text->text();
  571. QApplication::restoreOverrideCursor();
  572. // statusBar()->showMessage(tr("File saved"), 2000);
  573. return true;
  574. }
  575.  
  576. QString MainWindow::workspaceFilename(QsciScintilla* text)
  577. {
  578. if(text == workspace1) {return QDir::homePath() + "/.sonic-pi/workspaces/" + groupName + "/one/1.spi";}
  579. else if(text == workspace2) {return QDir::homePath() + "/.sonic-pi/workspaces/" + groupName + "/two/1.spi";}
  580. else if(text == workspace3) {return QDir::homePath() + "/.sonic-pi/workspaces/" + groupName + "/three/1.spi";}
  581. else if(text == workspace4) {return QDir::homePath() + "/.sonic-pi/workspaces/" + groupName + "/four/1.spi";}
  582. else if(text == workspace5) {return QDir::homePath() + "/.sonic-pi/workspaces/" + groupName + "/five/1.spi";}
  583. else if(text == workspace6) {return QDir::homePath() + "/.sonic-pi/workspaces/" + groupName + "/six/1.spi";}
  584. else if(text == workspace7) {return QDir::homePath() + "/.sonic-pi/workspaces/" + groupName + "/seven/1.spi";}
  585. else if(text == workspace8) {return QDir::homePath() + "/.sonic-pi/workspaces/" + groupName + "/eight/1.spi";}
  586. else {return QDir::homePath() + "/.sonic-pi/workspaces/" + groupName + "/one/1.spi";}
  587. }
  588.  
  589. bool MainWindow::saveWorkspace(QsciScintilla* text)
  590. {
  591. QString label = currentTabLabel();
  592. saveFile(workspaceFilename(text), text);
  593. return true;
  594. }
  595.  
  596. // void MainWindow::switchWorkspace(const QString &fileName)
  597. // {
  598. // //curWorkspace = filename;
  599. // }
  600.  
  601. void MainWindow::setCurrentFile(const QString &fileName)
  602. {
  603. curFile = fileName;
  604. // textEdit->setModified(false);
  605. setWindowModified(false);
  606.  
  607. }
  608.  
  609. QString MainWindow::strippedName(const QString &fullFileName)
  610. {
  611. return QFileInfo(fullFileName).fileName();
  612. }
RAW Paste Data

Adblocker detected! Please consider disabling it...

We've detected AdBlock Plus or some other adblocking software preventing Pastebin.com from fully loading.

We don't have any obnoxious sound, or popup ads, we actively block these annoying types of ads!

Please add Pastebin.com to your ad blocker whitelist or disable your adblocking software.

×