#include <QPushButton>
#include <QStackedWidget>
#include <QStatusBar>
-#include <QTabBar>
#include <QToolBar>
-#include <QTabWidget>
#include <QUrl>
using std::endl;
QPixmap * splash_;
};
-
-class TabWidget : public QTabWidget {
-public:
- void showBar(bool show) { tabBar()->setVisible(show); }
};
-} // namespace anon
-
-
struct GuiViewBase::GuiViewPrivate
{
string cur_title;
int posx_offset;
int posy_offset;
- TabWidget * tab_widget_;
+ TabWorkArea * tab_widget_;
QStackedWidget * stack_widget_;
BackgroundWidget * bg_widget_;
/// view's menubar
setWindowIcon(QPixmap(toqstr(iconname.absFilename())));
#endif
- d.tab_widget_ = new TabWidget;
-
- QPushButton * closeTabButton = new QPushButton(this);
- FileName const file = support::libFileSearch("images", "closetab", "png");
- if (!file.empty()) {
- QPixmap pm(toqstr(file.absFilename()));
- closeTabButton->setIcon(QIcon(pm));
- closeTabButton->setMaximumSize(pm.size());
- closeTabButton->setFlat(true);
- } else {
- closeTabButton->setText("Close");
- }
- closeTabButton->setCursor(Qt::ArrowCursor);
- closeTabButton->setToolTip(tr("Close tab"));
- closeTabButton->setEnabled(true);
-
- QObject::connect(d.tab_widget_, SIGNAL(currentChanged(int)),
- this, SLOT(currentTabChanged(int)));
- QObject::connect(closeTabButton, SIGNAL(clicked()),
- this, SLOT(closeCurrentTab()));
-
- d.tab_widget_->setCornerWidget(closeTabButton);
-#if QT_VERSION >= 0x040200
- d.tab_widget_->setUsesScrollButtons(true);
-#endif
+ d.tab_widget_ = new TabWorkArea;
+ QObject::connect(d.tab_widget_, SIGNAL(currentWorkAreaChanged(GuiWorkArea *)),
+ this, SLOT(on_currentWorkAreaChanged(GuiWorkArea *)));
d.initBackground();
if (d.bg_widget_) {
}
-void GuiViewBase::closeCurrentTab()
-{
- dispatch(FuncRequest(LFUN_BUFFER_CLOSE));
-}
-
-
-void GuiViewBase::currentTabChanged(int i)
+void GuiViewBase::on_currentWorkAreaChanged(GuiWorkArea * wa)
{
disconnectBuffer();
disconnectBufferView();
- GuiWorkArea * wa = dynamic_cast<GuiWorkArea *>(d.tab_widget_->widget(i));
- BOOST_ASSERT(wa);
- BufferView & bv = wa->bufferView();
- connectBufferView(bv);
- connectBuffer(bv.buffer());
- bv.updateMetrics(false);
- bv.cursor().fixIfBroken();
- wa->setUpdatesEnabled(true);
- wa->redraw();
- wa->setFocus();
+ connectBufferView(wa->bufferView());
+ connectBuffer(wa->bufferView().buffer());
updateToc();
// Buffer-dependent dialogs should be updated or
updateLayoutChoice();
updateWindowTitle();
updateStatusBar();
-
- LYXERR(Debug::GUI) << "currentTabChanged " << i
- << "File" << bv.buffer().fileName() << endl;
}
d.tab_widget_->setCurrentWidget(wa);
else
// Make sure the work area is up to date.
- currentTabChanged(d.tab_widget_->currentIndex());
+ d.tab_widget_->on_currentTabChanged(d.tab_widget_->currentIndex());
wa->setFocus();
}
#include "frontends/LyXView.h"
+#include "Buffer.h"
#include "BufferView.h"
#include "Color.h"
#include "debug.h"
#include "FuncRequest.h"
+#include "LyXFunc.h"
#include "LyXRC.h"
#include "version.h"
#include <QLayout>
#include <QMainWindow>
#include <QPainter>
+#include <QPushButton>
#include <QScrollBar>
+#include <QTabBar>
#include <QTimer>
#include <boost/bind.hpp>
}
}
+////////////////////////////////////////////////////////////////////
+// TabWorkArea implementation.
+////////////////////////////////////////////////////////////////////
+TabWorkArea::TabWorkArea(QWidget * parent): QTabWidget(parent)
+{
+ QPushButton * closeTabButton = new QPushButton(this);
+ FileName const file = support::libFileSearch("images", "closetab", "png");
+ if (!file.empty()) {
+ QPixmap pm(toqstr(file.absFilename()));
+ closeTabButton->setIcon(QIcon(pm));
+ closeTabButton->setMaximumSize(pm.size());
+ closeTabButton->setFlat(true);
+ } else {
+ closeTabButton->setText("Close");
+ }
+ closeTabButton->setCursor(Qt::ArrowCursor);
+ closeTabButton->setToolTip(tr("Close tab"));
+ closeTabButton->setEnabled(true);
+
+ QObject::connect(this, SIGNAL(currentChanged(int)),
+ this, SLOT(on_currentTabChanged(int)));
+ QObject::connect(closeTabButton, SIGNAL(clicked()),
+ this, SLOT(closeCurrentTab()));
+
+ setCornerWidget(closeTabButton);
+#if QT_VERSION >= 0x040200
+ setUsesScrollButtons(true);
+#endif
+}
+
+
+void TabWorkArea::showBar(bool show)
+{
+ tabBar()->setVisible(show);
+}
+
+
+void TabWorkArea::on_currentTabChanged(int i)
+{
+ GuiWorkArea * wa = dynamic_cast<GuiWorkArea *>(widget(i));
+ BOOST_ASSERT(wa);
+ BufferView & bv = wa->bufferView();
+ bv.updateMetrics(false);
+ bv.cursor().fixIfBroken();
+ wa->setUpdatesEnabled(true);
+ wa->redraw();
+ wa->setFocus();
+ ///
+ currentWorkAreaChanged(wa);
+
+ LYXERR(Debug::GUI) << "currentTabChanged " << i
+ << "File" << bv.buffer().fileName() << endl;
+}
+
+
+void TabWorkArea::closeCurrentTab()
+{
+ lyx::dispatch(FuncRequest(LFUN_BUFFER_CLOSE));
+}
+
} // namespace frontend
} // namespace lyx