Skip to content

Commit

Permalink
Disabling toolbar until file load
Browse files Browse the repository at this point in the history
Fixing null reference exception by clearing the undo stack on file/project load
  • Loading branch information
hpshelton committed Sep 24, 2010
1 parent 565bd41 commit 4e158db
Show file tree
Hide file tree
Showing 6 changed files with 37 additions and 0 deletions.
1 change: 1 addition & 0 deletions qmake_script
Expand Up @@ -21,6 +21,7 @@ QMakeFile.puts "\nmacx{"
QMakeFile.puts " ICON = ../images/icon.icns\n"
QMakeFile.puts " CONFIG += x86\n"
QMakeFile.puts " LIBS += -llapack -lblas\n"
QMakeFile.puts " QMAKE_INFO_PLIST = ../chemvp.plist"
QMakeFile.puts "}"
QMakeFile.puts "\nwin32{"
QMakeFile.puts " RC_FILE = ../images/icon.rc"
Expand Down
1 change: 1 addition & 0 deletions src/mainwindow.h
Expand Up @@ -82,6 +82,7 @@ private slots:
void disableLabelSignals();
void enableLabelSignals();
void resetToolBox(QMap<QString, QString>* options);
void activateToolBar();

QWidget *createAppearanceWidget(QMap<QString, QString>* options);
QWidget *createBondsAndAnglesWidget(QMap<QString, QString>* options);
Expand Down
7 changes: 7 additions & 0 deletions src/mainwindow_actions.cpp
Expand Up @@ -17,6 +17,7 @@ void MainWindow::createActions()
deleteAction = new QAction(QIcon(":/images/delete.png"),
tr("&Delete"), this);
deleteAction->setShortcut(tr("Delete"));
deleteAction->setEnabled(false);
deleteAction->setStatusTip(tr("Delete selected item(s) from drawing"));
connect(deleteAction, SIGNAL(triggered()), this, SLOT(deleteItem()));

Expand All @@ -40,28 +41,34 @@ void MainWindow::createActions()
saveAction = new QAction(QIcon(":/images/save.png"), tr("&Save"), this);
saveAction->setShortcut(tr("Ctrl+S"));
saveAction->setStatusTip(tr("Save"));
saveAction->setEnabled(false);
connect(saveAction, SIGNAL(triggered()), this, SLOT(save()));

saveAsAction = new QAction(QIcon(":/images/saveas.png"), tr("&Save As"), this);
saveAsAction->setShortcut(tr("Ctrl+Shift+S"));
saveAsAction->setEnabled(false);
saveAsAction->setStatusTip(tr("Save under a new name"));
connect(saveAsAction, SIGNAL(triggered()), this, SLOT(saveAs()));

selectAllAction = new QAction(this);
selectAllAction->setShortcut(tr("Ctrl+A"));
selectAllAction->setEnabled(false);
selectAllAction->setStatusTip(tr("Select All"));
selectAllAction->setText(tr("Select All"));

unselectAllAction = new QAction(this);
unselectAllAction->setShortcut(tr("Ctrl+Shift+A"));
unselectAllAction->setEnabled(false);
unselectAllAction->setStatusTip(tr("Unselect All"));
unselectAllAction->setText(tr("Unselect All"));

addArrowAction = new QAction(QIcon(":/images/addarrow.png"), tr("Add Arrow"), this);
addArrowAction->setStatusTip(tr("Add Arrow"));
addArrowAction->setEnabled(false);
connect(addArrowAction, SIGNAL(triggered(bool)), this, SLOT(setAddArrowMode()));

insertTextActionGroup = new QActionGroup(this);
insertTextActionGroup->setEnabled(false);

insertAngstromAction = new QAction(insertTextActionGroup);
insertAngstromAction->setIconText(QChar((ushort)0x00C5));
Expand Down
4 changes: 4 additions & 0 deletions src/mainwindow_filesave.cpp
Expand Up @@ -312,6 +312,8 @@ void MainWindow::loadFile()
delete old_view;
delete old_splitter;
delete old_canvas;

activateToolBar();
}
}

Expand Down Expand Up @@ -451,4 +453,6 @@ void MainWindow::openProject(QString filename)
delete old_view;
delete old_splitter;
delete old_canvas;

activateToolBar();
}
4 changes: 4 additions & 0 deletions src/mainwindow_menus.cpp
Expand Up @@ -49,6 +49,10 @@ void MainWindow::createMenus()
insertSymbolMenu->addAction(insertAngstromAction);
insertSymbolMenu->addAction(insertDegreeAction);
insertSymbolMenu->addAction(insertPlusMinusAction);

editMenu->setEnabled(false);
itemMenu->setEnabled(false);
insertMenu->setEnabled(false);
}

void MainWindow::updateMenus()
Expand Down
20 changes: 20 additions & 0 deletions src/mainwindow_toolbar.cpp
Expand Up @@ -97,6 +97,7 @@ void MainWindow::createToolbars()
boldTextButton->setEnabled(false);
italicTextButton->setEnabled(false);
underlineTextButton->setEnabled(false);
mouseModeToolBar->setEnabled(false);
enableLabelSignals();
}

Expand Down Expand Up @@ -285,3 +286,22 @@ void MainWindow::updateTextLabelToolbar()

enableLabelSignals();
}

void MainWindow::activateToolBar()
{
editMenu->setEnabled(true);
itemMenu->setEnabled(true);
insertMenu->setEnabled(true);
mouseModeToolBar->setEnabled(true);

deleteAction->setEnabled(true);
saveAction->setEnabled(true);
saveAsAction->setEnabled(true);
selectAllAction->setEnabled(true);
unselectAllAction->setEnabled(true);
addArrowAction->setEnabled(true);
insertTextActionGroup->setEnabled(true);

if(undoStack->count() > 0)
undoStack->clear();
}

0 comments on commit 4e158db

Please sign in to comment.