Skip to content

Commit

Permalink
update navigator
Browse files Browse the repository at this point in the history
  • Loading branch information
irascible committed Dec 10, 2013
1 parent 3736af4 commit 94412e5
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 11 deletions.
6 changes: 6 additions & 0 deletions src/dock/miniviewcontainer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,12 @@ void MiniViewContainer::setView(QGraphicsView * view)
forceResize();
}

QGraphicsView * MiniViewContainer::view() {
if (m_miniView == NULL) return NULL;

return m_miniView->view();
}

void MiniViewContainer::forceResize() {
// force a resize on a view change because otherwise some size or sceneRect isn't updated and the navigator is off
m_miniView->resize(this->size() / 2.0);
Expand Down
1 change: 1 addition & 0 deletions src/dock/miniviewcontainer.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ class MiniViewContainer : public QWidget
public:
MiniViewContainer(QWidget * parent = 0);
void setView(QGraphicsView *);
QGraphicsView * view();
void resizeEvent ( QResizeEvent * event );
void filterMousePress();
void hideHandle(bool hide);
Expand Down
29 changes: 20 additions & 9 deletions src/mainwindow/mainwindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1197,10 +1197,12 @@ void MainWindow::tabWidget_currentChanged(int index) {
setTitle();

// triggers a signal to the navigator widget
if (m_navigators.count() > index) {
m_navigators[index]->miniViewMousePressedSlot();
foreach (MiniViewContainer * navigator, m_navigators) {
if (navigator != NULL && navigator->view() != NULL && navigator->view() == m_currentGraphicsView) {
navigator->miniViewMousePressedSlot();
break;
}
}
emit viewSwitched(index);

if (m_infoView) {
m_currentGraphicsView->updateInfoView();
Expand Down Expand Up @@ -1957,9 +1959,22 @@ void MainWindow::applyReadOnlyChange(bool isReadOnly) {
//m_saveAct->setDisabled(isReadOnly);
}

void MainWindow::currentNavigatorChanged(MiniViewContainer * miniView)
void MainWindow::currentNavigatorChanged(MiniViewContainer * miniViewContainer)
{
int index = m_navigators.indexOf(miniView);
QTabWidget * tabWidget = qobject_cast<QTabWidget *>(m_tabWidget);
if (tabWidget == NULL) return;

int index = -1;
for (int i = 0; i < tabWidget->count(); i++) {
SketchAreaWidget * sketchAreaWidget = qobject_cast<SketchAreaWidget *>(tabWidget->widget(i));
if (sketchAreaWidget == NULL) continue;

if (sketchAreaWidget->contentView() == miniViewContainer->view()) {
index = i;
break;
}
}

if (index < 0) return;

int oldIndex = currentTabIndex();
Expand All @@ -1968,10 +1983,6 @@ void MainWindow::currentNavigatorChanged(MiniViewContainer * miniView)
setCurrentTabIndex(index);
}

void MainWindow::viewSwitchedTo(int viewIndex) {
setCurrentTabIndex(viewIndex);
}

const QString MainWindow::fritzingTitle() {
if (m_currentGraphicsView == NULL) {
return FritzingWindow::fritzingTitle();
Expand Down
2 changes: 0 additions & 2 deletions src/mainwindow/mainwindow.h
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,6 @@ class MainWindow : public FritzingWindow

signals:
void alienPartsDismissed();
void viewSwitched(int);
void mainWindowMoved(QWidget *);
void changeActivationSignal(bool activate, QWidget * originator);
void externalProcessSignal(QString & name, QString & path, QStringList & args);
Expand Down Expand Up @@ -387,7 +386,6 @@ protected slots:

void applyReadOnlyChange(bool isReadOnly);
void currentNavigatorChanged(class MiniViewContainer *);
void viewSwitchedTo(int viewIndex);

void raiseAndActivate();
void activateWindowAux();
Expand Down
1 change: 1 addition & 0 deletions src/mainwindow/sketchareawidget.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ along with Fritzing. If not, see <http://www.gnu.org/licenses/>.
#include <QMainWindow>

class SketchAreaWidget : public QFrame {
Q_OBJECT
public:
SketchAreaWidget(QWidget *contentView, QMainWindow *parent);
virtual ~SketchAreaWidget();
Expand Down

0 comments on commit 94412e5

Please sign in to comment.