summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNorwegian Rock Cat <qt-info@nokia.com>2009-07-14 09:09:06 (GMT)
committerNorwegian Rock Cat <qt-info@nokia.com>2009-07-14 09:18:23 (GMT)
commite3c1fdc994a3743f5c69d944003b1c67698ba6d8 (patch)
tree0cfd07703dd7e676e514a274a02272c4f87d44ce
parent43d2ed37baf0f5d05ffe06a91ea4782b9694a1d3 (diff)
downloadQt-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.
-rw-r--r--examples/mainwindows/application/main.cpp2
-rw-r--r--examples/mainwindows/application/mainwindow.cpp7
-rw-r--r--examples/mainwindows/recentfiles/main.cpp2
-rw-r--r--examples/mainwindows/recentfiles/mainwindow.cpp12
-rw-r--r--examples/mainwindows/sdi/main.cpp2
-rw-r--r--examples/mainwindows/sdi/mainwindow.cpp8
6 files changed, 15 insertions, 18 deletions
diff --git a/examples/mainwindows/application/main.cpp b/examples/mainwindows/application/main.cpp
index f83e709..2fe6d5f 100644
--- a/examples/mainwindows/application/main.cpp
+++ b/examples/mainwindows/application/main.cpp
@@ -49,6 +49,8 @@ int main(int argc, char *argv[])
Q_INIT_RESOURCE(application);
QApplication app(argc, argv);
+ app.setOrganizationName("Trolltech");
+ app.setApplicationName("Application Example");
MainWindow mainWin;
mainWin.show();
return app.exec();
diff --git a/examples/mainwindows/application/mainwindow.cpp b/examples/mainwindows/application/mainwindow.cpp
index a1eb9b6..16b18b4 100644
--- a/examples/mainwindows/application/mainwindow.cpp
+++ b/examples/mainwindows/application/mainwindow.cpp
@@ -369,13 +369,10 @@ void MainWindow::setCurrentFile(const QString &fileName)
textEdit->document()->setModified(false);
setWindowModified(false);
- QString shownName;
+ QString shownName = curFile;
if (curFile.isEmpty())
shownName = "untitled.txt";
- else
- shownName = strippedName(curFile);
-
- setWindowTitle(tr("%1[*] - %2").arg(shownName).arg(tr("Application")));
+ setWindowFilePath(shownName);
}
//! [47]
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);
diff --git a/examples/mainwindows/sdi/main.cpp b/examples/mainwindows/sdi/main.cpp
index a7e20d8..055d761 100644
--- a/examples/mainwindows/sdi/main.cpp
+++ b/examples/mainwindows/sdi/main.cpp
@@ -47,6 +47,8 @@ int main(int argc, char *argv[])
{
Q_INIT_RESOURCE(sdi);
QApplication app(argc, argv);
+ app.setApplicationName("SDI Example");
+ app.setOrganizationName("Trolltech");
MainWindow *mainWin = new MainWindow;
mainWin->show();
return app.exec();
diff --git a/examples/mainwindows/sdi/mainwindow.cpp b/examples/mainwindows/sdi/mainwindow.cpp
index 8710105..1e7f2c0 100644
--- a/examples/mainwindows/sdi/mainwindow.cpp
+++ b/examples/mainwindows/sdi/mainwindow.cpp
@@ -266,7 +266,7 @@ void MainWindow::createStatusBar()
void MainWindow::readSettings()
{
- QSettings settings("Trolltech", "SDI Example");
+ QSettings settings;
QPoint pos = settings.value("pos", QPoint(200, 200)).toPoint();
QSize size = settings.value("size", QSize(400, 400)).toSize();
move(pos);
@@ -275,7 +275,7 @@ void MainWindow::readSettings()
void MainWindow::writeSettings()
{
- QSettings settings("Trolltech", "SDI Example");
+ QSettings settings;
settings.setValue("pos", pos());
settings.setValue("size", size());
}
@@ -352,9 +352,7 @@ void MainWindow::setCurrentFile(const QString &fileName)
textEdit->document()->setModified(false);
setWindowModified(false);
-
- setWindowTitle(tr("%1[*] - %2").arg(strippedName(curFile))
- .arg(tr("SDI")));
+ setWindowFilePath(curFile);
}
QString MainWindow::strippedName(const QString &fullFileName)