void Buffer::setReadOnly(bool on) const
{
- if (gui_)
- gui_->setReadOnly(on);
+ if (pimpl_->wa_)
+ pimpl_->wa_->setReadOnly(on);
}
void Buffer::updateTitles() const
{
- if (gui_)
- gui_->updateTitles();
+ if (pimpl_->wa_)
+ pimpl_->wa_->updateTitles();
}
virtual void message(docstring const &) = 0;
/// This function is called when the buffer busy status change.
virtual void setBusy(bool) = 0;
- /// This function is called when the buffer readonly status change.
- virtual void setReadOnly(bool) = 0;
- /// Update window titles of all users.
- virtual void updateTitles() = 0;
/// Reset autosave timers for all users.
virtual void resetAutosaveTimers() = 0;
};
}
-void LyXView::setReadOnly(bool)
-{
- updateWindowTitle();
- getDialogs().updateBufferDependent(false);
-}
-
-
BufferView * LyXView::view()
{
WorkArea * wa = currentWorkArea();
}
-void LyXView::updateWindowTitle()
-{
- docstring maximize_title = from_ascii("LyX");
- docstring minimize_title = from_ascii("LyX");
-
- Buffer * buf = buffer();
- if (buf) {
- string const cur_title = buf->absFileName();
- if (!cur_title.empty()) {
- maximize_title += ": " + makeDisplayPath(cur_title, 30);
- minimize_title = lyx::from_utf8(onlyFilename(cur_title));
- if (!buf->isClean()) {
- maximize_title += _(" (changed)");
- minimize_title += char_type('*');
- }
- if (buf->isReadonly())
- maximize_title += _(" (read only)");
- }
- }
-
- setWindowTitle(maximize_title, minimize_title);
-}
-
-
void LyXView::dispatch(FuncRequest const & cmd)
{
string const argument = to_utf8(cmd.argument());
/// clear any temporary message and replace with current status
virtual void clearMessage() = 0;
- /// updates the title of the window
- void updateWindowTitle();
-
/// reset autosave timer
void resetAutosaveTimer();
void structureChanged() { updateToc(); }
/// This function is called when some parsing error shows up.
void errors(std::string const & err) { showErrorList(err); }
- /// This function is called when the buffer readonly status change.
- void setReadOnly(bool on);
- /// Update window titles of all users.
- void updateTitles() { updateWindowTitle(); }
/// Reset autosave timers for all users.
void resetAutosaveTimers() { resetAutosaveTimer(); }
void disconnectBuffer();
private:
- /**
- * setWindowTitle - set title of window
- * @param t main window title
- * @param it iconified (short) title
- */
- virtual void setWindowTitle(docstring const & t, docstring const & it) = 0;
-
/// called on timeout
void autoSave();
#include "frontends/WorkArea.h"
#include "frontends/Application.h"
+#include "frontends/Dialogs.h"
#include "frontends/FontMetrics.h"
#include "frontends/LyXView.h"
#include "frontends/WorkAreaManager.h"
#include "MetricsInfo.h"
#include "gettext.h"
-#include "support/ForkedcallsController.h"
#include "support/FileName.h"
+#include "support/filetools.h"
+#include "support/ForkedcallsController.h"
#include <boost/noncopyable.hpp>
#include <boost/bind.hpp>
#include <boost/current_function.hpp>
-using lyx::support::ForkedcallsController;
-
using std::endl;
using std::min;
using std::max;
} // anon namespace
namespace lyx {
+
+using support::ForkedcallsController;
+using support::makeDisplayPath;
+using support::onlyFilename;
+
namespace frontend {
WorkArea::WorkArea(Buffer & buffer, LyXView & lv)
cursor_timeout_.restart();
}
+void WorkArea::updateWindowTitle()
+{
+ docstring maximize_title;
+ docstring minimize_title;
+
+ Buffer & buf = buffer_view_->buffer();
+ string const cur_title = buf.absFileName();
+ if (!cur_title.empty()) {
+ maximize_title = makeDisplayPath(cur_title, 30);
+ minimize_title = from_utf8(onlyFilename(cur_title));
+ if (!buf.isClean()) {
+ maximize_title += _(" (changed)");
+ minimize_title += char_type('*');
+ }
+ if (buf.isReadonly())
+ maximize_title += _(" (read only)");
+ }
+
+ setWindowTitle(maximize_title, minimize_title);
+}
+
+
+void WorkArea::setReadOnly(bool)
+{
+ updateWindowTitle();
+ if (this == lyx_view_->currentWorkArea())
+ lyx_view_->getDialogs().updateBufferDependent(false);
+}
+
} // namespace frontend
} // namespace lyx
/// Slot for Buffer::closing signal.
void close();
+ /// This function is called when the buffer readonly status change.
+ virtual void setReadOnly(bool);
+
+ /// Update window titles of all users.
+ virtual void updateWindowTitle();
+
protected:
/// cause the display of the given area of the work area
virtual void expose(int x, int y, int w, int h) = 0;
+
+ /// set title of window.
+ /**
+ * @param t main window title
+ * @param it iconified (short) title
+ */
+ virtual void setWindowTitle(docstring const & t, docstring const & it) = 0;
+
///
void dispatch(FuncRequest const & cmd0, KeyModifier = NoModifier);
(*work_areas_.begin())->close();
}
+
+void WorkAreaManager::setReadOnly(bool on)
+{
+ for (list<WorkArea *>::iterator it = work_areas_.begin();
+ it != work_areas_.end(); ) {
+ (*it)->setReadOnly(on);
+ ++it;
+ }
+}
+
+
+void WorkAreaManager::updateTitles()
+{
+ for (list<WorkArea *>::iterator it = work_areas_.begin();
+ it != work_areas_.end(); ) {
+ (*it)->updateWindowTitle();
+ ++it;
+ }
+}
+
} // namespace frontend
} // namespace lyx
///
void closeAll();
+ /// This function is called when the buffer readonly status change.
+ virtual void setReadOnly(bool);
+
+ /// Update window titles of all users.
+ virtual void updateTitles();
+
private:
std::list<WorkArea *> work_areas_;
};
namespace lyx {
-using support::makeDisplayPath;
-
extern bool quitting;
namespace frontend {
show();
- // For an unknown reason, the Window title update is not effective for
- // the second windows up until it is shown on screen (Qt bug?).
- updateWindowTitle();
-
// after show geometry() has changed (Qt bug?)
// we compensate the drift when storing the position
d.posx_offset = 0;
}
-void GuiView::setWindowTitle(docstring const & t, docstring const & it)
-{
- QString title = windowTitle();
- QString new_title = toqstr(t);
- if (title != new_title) {
- QMainWindow::setWindowTitle(new_title);
- QMainWindow::setWindowIconText(toqstr(it));
- }
- if (Buffer const * buf = buffer()) {
- QString tabtext = toqstr(buf->fileName().displayName(30));
- d.current_work_area_->setWindowTitle(tabtext);
- TabWorkArea * twa = d.currentTabWorkArea();
- twa->setTabText(twa->currentIndex(), tabtext);
- }
-}
-
-
void GuiView::message(docstring const & str)
{
statusBar()->showMessage(toqstr(str));
}
+void GuiView::updateWindowTitle(GuiWorkArea * wa)
+{
+ if (wa != d.current_work_area_)
+ return;
+ setWindowTitle(qt_("LyX: ") + wa->windowTitle());
+ setWindowIconText(wa->windowIconText());
+}
+
+
void GuiView::on_currentWorkAreaChanged(GuiWorkArea * wa)
{
disconnectBuffer();
disconnectBufferView();
connectBufferView(wa->bufferView());
connectBuffer(wa->bufferView().buffer());
+ d.current_work_area_ = wa;
+ QObject::connect(wa, SIGNAL(titleChanged(GuiWorkArea *)),
+ this, SLOT(updateWindowTitle(GuiWorkArea *)));
+ updateWindowTitle(wa);
updateToc();
// Buffer-dependent dialogs should be updated or
getDialogs().updateBufferDependent(true);
updateToolbars();
updateLayoutChoice(false);
- updateWindowTitle();
updateStatusBar();
}
connectBuffer(bv.buffer());
// The document structure, name and dialogs might have
// changed in another view.
- updateWindowTitle();
getDialogs().updateBufferDependent(true);
+ } else {
+ setWindowTitle(qt_("LyX"));
+ setWindowIconText(qt_("LyX"));
}
return QMainWindow::event(e);
}
void GuiView::showView()
{
- QMainWindow::setWindowTitle(qt_("LyX"));
- QMainWindow::show();
+ setWindowTitle(qt_("LyX"));
+ show();
updateFloatingGeometry();
}
addTabWorkArea();
TabWorkArea * tab_widget = d.currentTabWorkArea();
- tab_widget->addTab(wa, toqstr(buffer.fileName().displayName(30)));
+ tab_widget->addTab(wa, wa->windowTitle());
+ QObject::connect(wa, SIGNAL(titleChanged(GuiWorkArea *)),
+ tab_widget, SLOT(updateTabText(GuiWorkArea *)));
+
wa->bufferView().updateMetrics();
// Hide tabbar if there's only one tab.
/// idle timeout
void update_view_state_qt();
+ ///
+ void updateWindowTitle(GuiWorkArea * wa);
+
///
void on_currentWorkAreaChanged(GuiWorkArea *);
///
void dropEvent(QDropEvent * ev);
- /**
- * setWindowTitle - set title of window
- * @param t main window title
- * @param it iconified (short) title
- */
- virtual void setWindowTitle(docstring const & t, docstring const & it);
-
/// in order to catch Tab key press.
bool event(QEvent * e);
bool focusNextPrevChild(bool);
setAcceptDrops(true);
setMouseTracking(true);
setMinimumSize(100, 70);
+ updateWindowTitle();
viewport()->setAutoFillBackground(false);
// We don't need double-buffering nor SystemBackground on
}
+void GuiWorkArea::setWindowTitle(docstring const & t, docstring const & it)
+{
+ QString title = windowTitle();
+ QString new_title = toqstr(t);
+ if (title == new_title)
+ return;
+
+ QWidget::setWindowTitle(new_title);
+ QWidget::setWindowIconText(toqstr(it));
+ titleChanged(this);
+}
+
+
void GuiWorkArea::updateScreen()
{
GuiPainter pain(&screen_);
lyx::dispatch(FuncRequest(LFUN_BUFFER_CLOSE));
}
+
+void TabWorkArea::updateTabText(GuiWorkArea * wa)
+{
+ int const i = indexOf(wa);
+ if (i < 0)
+ return;
+ setTabText(i, wa->windowTitle());
+}
+
} // namespace frontend
} // namespace lyx
/// hide the cursor
virtual void removeCursor();
+ void setWindowTitle(docstring const & t, docstring const & it);
+
+Q_SIGNALS:
+ ///
+ void titleChanged(GuiWorkArea *);
+
private:
///
void focusInEvent(QFocusEvent *);
Q_OBJECT
public:
TabWorkArea(QWidget * parent = 0);
+
void showBar(bool show);
void closeAll();
bool setCurrentWorkArea(GuiWorkArea *);
void on_currentTabChanged(int index);
///
void closeCurrentTab();
+ ///
+ void updateTabText(GuiWorkArea *);
}; // TabWorkArea
} // namespace frontend