diff options
author | Norwegian Rock Cat <qt-info@nokia.com> | 2009-07-14 09:09:06 (GMT) |
---|---|---|
committer | Norwegian Rock Cat <qt-info@nokia.com> | 2009-07-14 09:18:23 (GMT) |
commit | e3c1fdc994a3743f5c69d944003b1c67698ba6d8 (patch) | |
tree | 0cfd07703dd7e676e514a274a02272c4f87d44ce /examples/mainwindows/recentfiles | |
parent | 43d2ed37baf0f5d05ffe06a91ea4782b9694a1d3 (diff) | |
download | Qt-e3c1fdc994a3743f5c69d944003b1c67698ba6d8.zip Qt-e3c1fdc994a3743f5c69d944003b1c67698ba6d8.tar.gz Qt-e3c1fdc994a3743f5c69d944003b1c67698ba6d8.tar.bz2 |
Make the mainwindow examples use setWindowFilePath
Should have done this a while ago. Use setWindowFilePath
to get proxy icons on mac and simplify window
title handling on the other platforms. The only
downside is that we do have to specify the
application name to get the exact same behavior.
But on the other hand, QSettings handlig is a bit
better.
Diffstat (limited to 'examples/mainwindows/recentfiles')
-rw-r--r-- | examples/mainwindows/recentfiles/main.cpp | 2 | ||||
-rw-r--r-- | examples/mainwindows/recentfiles/mainwindow.cpp | 12 |
2 files changed, 6 insertions, 8 deletions
diff --git a/examples/mainwindows/recentfiles/main.cpp b/examples/mainwindows/recentfiles/main.cpp index 5417429..1dd3c1b 100644 --- a/examples/mainwindows/recentfiles/main.cpp +++ b/examples/mainwindows/recentfiles/main.cpp @@ -46,6 +46,8 @@ int main(int argc, char *argv[]) { QApplication app(argc, argv); + app.setOrganizationName("Trolltech"); + app.setApplicationName("Recent Files Example"); MainWindow *mainWin = new MainWindow; mainWin->show(); return app.exec(); diff --git a/examples/mainwindows/recentfiles/mainwindow.cpp b/examples/mainwindows/recentfiles/mainwindow.cpp index 1671f53..53d0d0e 100644 --- a/examples/mainwindows/recentfiles/mainwindow.cpp +++ b/examples/mainwindows/recentfiles/mainwindow.cpp @@ -54,7 +54,7 @@ MainWindow::MainWindow() createMenus(); (void)statusBar(); - setWindowTitle(tr("Recent Files")); + setWindowFilePath(QString()); resize(400, 300); } @@ -209,13 +209,9 @@ void MainWindow::saveFile(const QString &fileName) void MainWindow::setCurrentFile(const QString &fileName) { curFile = fileName; - if (curFile.isEmpty()) - setWindowTitle(tr("Recent Files")); - else - setWindowTitle(tr("%1 - %2").arg(strippedName(curFile)) - .arg(tr("Recent Files"))); + setWindowFilePath(curFile); - QSettings settings("Trolltech", "Recent Files Example"); + QSettings settings; QStringList files = settings.value("recentFileList").toStringList(); files.removeAll(fileName); files.prepend(fileName); @@ -233,7 +229,7 @@ void MainWindow::setCurrentFile(const QString &fileName) void MainWindow::updateRecentFileActions() { - QSettings settings("Trolltech", "Recent Files Example"); + QSettings settings; QStringList files = settings.value("recentFileList").toStringList(); int numRecentFiles = qMin(files.size(), (int)MaxRecentFiles); |