diff --git a/src/MainWindow.cpp b/src/MainWindow.cpp
index 9eaf5733e..dd270d231 100644
--- a/src/MainWindow.cpp
+++ b/src/MainWindow.cpp
@@ -1,5 +1,6 @@
/*
* Copyright (c) 2006 Sean C. Rhea (srhea@srhea.net)
+ * Copyright (c) 2013 Mark Liversedge (liversedge@gmail.com)
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the Free
@@ -243,7 +244,15 @@ MainWindow::MainWindow(const QDir &home) :
QHBoxLayout *pp = new QHBoxLayout(acts);
pp->setContentsMargins(0,0,0,0);
pp->setContentsMargins(0,0,0,0);
- pp->setSpacing(0);
+ pp->setSpacing(5);
+ sidebar = new QtMacButton(this, QtMacButton::TexturedRounded);
+ QPixmap *sidebarImg = new QPixmap(":images/mac/sidebar.png");
+ sidebar->setImage(sidebarImg);
+ sidebar->setMinimumSize(25, 25);
+ sidebar->setMaximumSize(25, 25);
+ sidebar->setToolTip("Sidebar");
+ sidebar->setSelected(true); // assume always start up with sidebar selected
+
QtMacSegmentedButton *actbuttons = new QtMacSegmentedButton(3, acts);
actbuttons->setWidth(115);
actbuttons->setNoSelect();
@@ -261,12 +270,14 @@ MainWindow::MainWindow(const QDir &home) :
viewsel->setContentsMargins(0,0,0,0);
QHBoxLayout *pq = new QHBoxLayout(viewsel);
pq->setContentsMargins(0,0,0,0);
- pq->setSpacing(0);
+ pq->setSpacing(5);
+ pq->addWidget(sidebar);
styleSelector = new QtMacSegmentedButton(2, viewsel);
styleSelector->setWidth(80); // actually its 80 but we want a 30px space between is and the searchbox
styleSelector->setImage(0, new QPixmap(":images/mac/tabbed.png"), 24);
styleSelector->setImage(1, new QPixmap(":images/mac/tiled.png"), 24);
pq->addWidget(styleSelector);
+ connect(sidebar, SIGNAL(clicked(bool)), this, SLOT(toggleSidebar()));
connect(styleSelector, SIGNAL(clicked(int,bool)), this, SLOT(toggleStyle()));
// setup Mac thetoolbar
@@ -1022,6 +1033,9 @@ void
MainWindow::toggleSidebar()
{
showSidebar(!toolBox->isVisible());
+#ifdef Q_OS_MAC
+ sidebar->setSelected(toolBox->isVisible());
+#endif
}
void
diff --git a/src/MainWindow.h b/src/MainWindow.h
index 9b1c0738b..a5bfcb72b 100644
--- a/src/MainWindow.h
+++ b/src/MainWindow.h
@@ -448,6 +448,7 @@ class MainWindow : public QMainWindow
// Mac Native Support
QWidget *macAnalButtons;
QtMacButton *import, *compose;
+ QtMacButton *sidebar;
QtMacSegmentedButton *styleSelector;
QToolBar *head;
GcScopeBar *scopebar;
diff --git a/src/QtMacButton.h b/src/QtMacButton.h
index 28f68edbb..e9af10a69 100644
--- a/src/QtMacButton.h
+++ b/src/QtMacButton.h
@@ -58,6 +58,7 @@ public slots:
void setImage(const QPixmap *image);
void setChecked(bool checked);
void setWidth(int x);
+ void setSelected(bool x);
void setIconAndText();
public:
diff --git a/src/QtMacButton.mm b/src/QtMacButton.mm
index 9f799fa6d..42894b01c 100644
--- a/src/QtMacButton.mm
+++ b/src/QtMacButton.mm
@@ -232,6 +232,15 @@ void QtMacButton::setText(const QString &text)
[qtw->nsButton setTitle:fromQString(text)];
}
+void QtMacButton::setSelected(bool x)
+{
+ Q_ASSERT(qtw);
+ if (qtw) {
+ [qtw->nsButton setButtonType:NSOnOffButton];
+ [qtw->nsButton setState:(x ? NSOnState : NSOffState)];
+ }
+}
+
void QtMacButton::setImage(const QPixmap *image)
{
Q_ASSERT(qtw);
diff --git a/src/application.qrc b/src/application.qrc
index 17a342ebc..d92413035 100644
--- a/src/application.qrc
+++ b/src/application.qrc
@@ -124,6 +124,7 @@
images/mac/scope-inactive.png
images/mac/hide.png
images/mac/show.png
+ images/mac/sidebar.png
images/analysis.png
images/home.png
images/diary.png