Skip to content

Commit

Permalink
Various critical bug fixes
Browse files Browse the repository at this point in the history
- Fix first-run path selector setup (IDE-188)
- Properly catch mouse-driven tab close (IDE-189)
- Remove Details+ tab from Build Manager
  • Loading branch information
bweir committed Apr 7, 2016
1 parent 4b7ff5a commit 0ac322b
Show file tree
Hide file tree
Showing 10 changed files with 47 additions and 84 deletions.
2 changes: 1 addition & 1 deletion src/projectview
44 changes: 12 additions & 32 deletions src/propelleride/buildmanager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,17 +12,13 @@ BuildManager::BuildManager(QWidget *parent)
{
ui.setupUi(this);

hideDetails();

ui.activeText->setText(" ");
setStage(0);

connect(&timer,SIGNAL(timeout()),this,SLOT(hideStatus()));
connect(&timer, SIGNAL(timeout()), this, SLOT(hideStatus()));

currentTheme = &Singleton<ColorScheme>::Instance();
updateColors();

connect(ui.label, SIGNAL(clicked()), this, SLOT(toggleDetails()));
}

BuildManager::~BuildManager()
Expand Down Expand Up @@ -61,15 +57,15 @@ void BuildManager::setConfiguration(BuildManager::Configuration config)

void BuildManager::handleCompilerError(QProcess::ProcessError e)
{
qCritical() << "Build failure" << config.compiler;
failure = true;
timer.stop();
hideStatus();

QString errorstring;
switch (e)
{
case QProcess::FailedToStart:
errorstring = tr("Could not start \"%1.\"\n"
"Please check Preferences.").arg(config.compiler);
errorstring = tr("Failed to start compiler: '%1'; check Preferences").arg(config.compiler);
break;
case QProcess::Crashed:
case QProcess::Timedout:
Expand All @@ -85,6 +81,9 @@ void BuildManager::handleCompilerError(QProcess::ProcessError e)
QMessageBox::critical((QWidget *) parent(),
tr("Build Failed"),
tr("%1").arg(errorstring));

emit buildError();
emit finished();
}

void BuildManager::compilerFinished(int exitCode, QProcess::ExitStatus status)
Expand All @@ -93,7 +92,6 @@ void BuildManager::compilerFinished(int exitCode, QProcess::ExitStatus status)
{
failure = true;
setText(tr("Build failed!"));
showDetails();
emit finished();
}
else
Expand Down Expand Up @@ -263,8 +261,12 @@ void BuildManager::build()
args.append("-L" + include);
}

QString actionstring = tr("Building '%1'...")
.arg(QFileInfo(config.file).fileName());

setStage(1);
setText(tr("Building %1...").arg(QFileInfo(config.file).fileName()));
print(actionstring, Qt::darkYellow);
setText(actionstring);

args.append(config.file);

Expand Down Expand Up @@ -329,28 +331,6 @@ void BuildManager::keyPressEvent(QKeyEvent * event)
}
}

void BuildManager::showDetails()
{
ui.label->setText("Details -");
ui.plainTextEdit->show();
adjustSize();
}

void BuildManager::hideDetails()
{
ui.label->setText("Details +");
ui.plainTextEdit->hide();
adjustSize();
}

void BuildManager::toggleDetails()
{
if (ui.plainTextEdit->isVisible())
hideDetails();
else
showDetails();
}

void BuildManager::setBuild(bool active)
{
ui.iconBuild->setEnabled(active);
Expand Down
4 changes: 1 addition & 3 deletions src/propelleride/buildmanager.h
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ class BuildManager : public QFrame
void terminalReceived(QString text);
void statusChanged(const QString & text);
void finished();
void buildError();

public slots:
void loadSuccess();
Expand Down Expand Up @@ -83,9 +84,6 @@ public slots:
void keyPressEvent(QKeyEvent * event);

public slots:
void toggleDetails();
void showDetails();
void hideDetails();
void updateColors();

void setStage(int stage);
Expand Down
44 changes: 19 additions & 25 deletions src/propelleride/filemanager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -291,35 +291,20 @@ void FileManager::saveFile(const QString & fileName, int index)

void FileManager::closeFile()
{
int index = currentIndex();

if (count() > 0)
{
if (getEditor(index)->contentChanged())
saveAndClose();
else
closeFile(index);
}
closeFile(currentIndex());
}

void FileManager::closeAll()
{
setCurrentIndex(0);
while (count() > 0)
{
if (getEditor(0)->contentChanged())
{
if (saveAndClose())
return;
}
else
{
closeFile(0);
}
if (!closeFile(0))
return;
}
}

int FileManager::saveAndClose()
bool FileManager::saveAndClose(int index)
{
QMessageBox dialog;
dialog.setText(tr("Your code has been modified."));
Expand All @@ -330,22 +315,29 @@ int FileManager::saveAndClose()
switch (dialog.exec())
{
case QMessageBox::Save:
save();
closeFile(currentIndex());
save(index);
return true;
break;
case QMessageBox::Discard:
closeFile(currentIndex());
return true;
break;
case QMessageBox::Cancel:
return 1;
default:
break;
}
return 0;
return false;
}

void FileManager::closeFile(int index)
bool FileManager::closeFile(int index)
{
if (getEditor(index)->contentChanged())
{
if (!saveAndClose(index))
{
return false;
}
}

if (count() > 0 && index >= 0 && index < count())
{
getEditor(index)->disconnect();
Expand All @@ -358,6 +350,8 @@ void FileManager::closeFile(int index)
createBackgroundImage();
emit closeAvailable(false);
}

return true;
}

void FileManager::createBackgroundImage()
Expand Down
4 changes: 2 additions & 2 deletions src/propelleride/filemanager.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,8 @@ public slots:

void closeAll();
void closeFile();
void closeFile(int index);
int saveAndClose();
bool closeFile(int index);
bool saveAndClose(int index);

void nextTab();
void previousTab();
Expand Down
14 changes: 0 additions & 14 deletions src/propelleride/forms/buildmanager.ui
Original file line number Diff line number Diff line change
Expand Up @@ -283,13 +283,6 @@
</property>
</layout>
</item>
<item>
<widget class="ClickableLabel" name="label">
<property name="text">
<string>Details +</string>
</property>
</widget>
</item>
<item>
<widget class="QPlainTextEdit" name="plainTextEdit">
<property name="enabled">
Expand Down Expand Up @@ -317,13 +310,6 @@
</item>
</layout>
</widget>
<customwidgets>
<customwidget>
<class>ClickableLabel</class>
<extends>QLabel</extends>
<header>clickable.h</header>
</customwidget>
</customwidgets>
<resources>
<include location="../icons/icons.qrc"/>
</resources>
Expand Down
10 changes: 5 additions & 5 deletions src/propelleride/mainwindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,9 @@ MainWindow::MainWindow(QWidget *parent)
// setup preferences dialog
connect(&preferences, SIGNAL(accepted()), this, SLOT(getApplicationSettings()));

connect(&builder, SIGNAL(compilerErrorInfo(QString,int)), this, SLOT(highlightFileLine(QString,int)));
connect(&builder, SIGNAL(finished()), this, SLOT(enableBuildControls()));
connect(&builder, SIGNAL(compilerErrorInfo(QString,int)), this, SLOT(highlightFileLine(QString,int)));
connect(&builder, SIGNAL(finished()), this, SLOT(enableBuildControls()));
connect(&builder, SIGNAL(buildError()), &preferences, SLOT(showPreferences()));

parser = language.getParser();
connect(&preferences,SIGNAL(updateColors()),this,SLOT(recolorProjectView()));
Expand Down Expand Up @@ -283,8 +284,6 @@ void MainWindow::openRecentFile()

void MainWindow::setProject()
{
QApplication::setOverrideCursor(QCursor(Qt::WaitCursor));

int index = ui.editorTabs->currentIndex();
QString shortname, filename;
if (index > -1)
Expand All @@ -308,7 +307,6 @@ void MainWindow::setProject()
parser->setLibraryPaths(spinIncludes);

recolorProjectView();
QApplication::restoreOverrideCursor();
}

void MainWindow::showBrowser()
Expand Down Expand Up @@ -433,6 +431,8 @@ void MainWindow::recolorProjectView()
parser->styleRule("constants",QIcon(),theme->getColor(ColorScheme::SyntaxKeywords));
parser->styleRule("_includes_",QIcon(),theme->getColor(ColorScheme::SyntaxText));
parser->setFont(theme->getFont());

qCDebug(logmainwindow) << "updating project view";
parser->buildModel();
ui.projectview->setModel(parser->treeModel());
}
Expand Down
1 change: 1 addition & 0 deletions src/propelleride/pathselector.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ PathSelector::PathSelector(QString language,
restore();

load();
save();

connect(ui.deletePath, SIGNAL(clicked()), this, SLOT(deletePath()));
connect(ui.addPath, SIGNAL(clicked()), this, SLOT(addPath()));
Expand Down
6 changes: 5 additions & 1 deletion src/propelleride/preferences.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,11 @@ void Preferences::setupLanguages()
PathSelector * spin;
QString app = QApplication::applicationDirPath();
spin = new PathSelector("spin",
app + QString(DEFAULT_COMPILER),
#if defined(Q_OS_MAC)
app + "/" + QString(DEFAULT_COMPILER),
#else
QString(DEFAULT_COMPILER),
#endif
QStringList() << app +
QString(APP_RESOURCES_PATH) +
QString("/library/library"));
Expand Down
2 changes: 1 addition & 1 deletion src/propelleride/preferences.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
#error "We don't support that OS yet..."
#endif

#define DEFAULT_COMPILER "/openspin" APP_EXTENSION
#define DEFAULT_COMPILER "openspin" APP_EXTENSION

class Preferences : public QDialog
{
Expand Down

0 comments on commit 0ac322b

Please sign in to comment.