diff options
author | Lukáš Lalinský <lalinsky@gmail.com> | 2008-12-07 20:22:25 +0100 |
---|---|---|
committer | Lukáš Lalinský <lalinsky@gmail.com> | 2008-12-07 20:22:25 +0100 |
commit | e180ea6a919eced6a6a2bfa6dab7ece0f37f79f6 (patch) | |
tree | 4fcbc04e204b1e8a61a319118b35ba0b6f80b200 | |
parent | e95d6d7b4adc644ba67d2eae7ed42d189749e005 (diff) | |
download | dbmodel-e180ea6a919eced6a6a2bfa6dab7ece0f37f79f6.tar.xz |
Add current document filename to the window title
-rw-r--r-- | src/mainwindow.cpp | 25 | ||||
-rw-r--r-- | src/mainwindow.h | 2 |
2 files changed, 25 insertions, 2 deletions
diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index 660df3f..4ece140 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -53,6 +53,8 @@ MainWindow::MainWindow() connect(QApplication::clipboard(), SIGNAL(changed(QClipboard::Mode)), this, SLOT(updateClipboard(QClipboard::Mode))); updateClipboard(QClipboard::Clipboard); updateSelection(); + + connect(m_undoGroup, SIGNAL(cleanChanged(bool)), SLOT(updateWindowTitle())); } MainWindow::~MainWindow() @@ -125,8 +127,6 @@ MainWindow::saveWindowState() void MainWindow::setupUi() { - setWindowTitle(tr("Database Modeller")); - setupToolBar(); setupMenuBar(); @@ -343,6 +343,7 @@ MainWindow::saveFile(const QString &fileName) m_model->save(fileName); m_model->undoStack()->setClean(); addRecentFile(fileName); + updateWindowTitle(); } bool @@ -448,6 +449,8 @@ MainWindow::newModel(DiagramDocument *newModel) SIGNAL(modeChanged(DiagramDocument::Mode)), SLOT(updateMode(DiagramDocument::Mode))); connect(m_model, SIGNAL(selectionChanged()), SLOT(updateSelection())); + + updateWindowTitle(); } void @@ -594,3 +597,21 @@ MainWindow::about() "</p>\n" )); } + +void +MainWindow::updateWindowTitle() +{ + if (m_model) { + QString fileName = m_model->fileName(); + if (fileName.isEmpty()) + fileName = tr("Untitled"); + else + fileName = QFileInfo(fileName).fileName(); + if (!m_model->undoStack()->isClean()) + fileName += "*"; + setWindowTitle(fileName + " - " + qApp->applicationName()); + } + else { + setWindowTitle(qApp->applicationName()); + } +} diff --git a/src/mainwindow.h b/src/mainwindow.h index dca7a7e..a80220d 100644 --- a/src/mainwindow.h +++ b/src/mainwindow.h @@ -63,6 +63,8 @@ public slots: void openRecentFile(); void updateRecentFileActions(); + void updateWindowTitle(); + void cut(); void copy(); void paste(); |