implement QCocoaWindow::setWindowIcon
Code taken from Qt 4.8. Task-number: QTBUG-27175 Change-Id: I0f7a1add3ea63761c956e43d591cd1b26f25760e Reviewed-by: Friedemann Kleint <Friedemann.Kleint@digia.com> Reviewed-by: Morten Johan Sørvig <morten.sorvig@digia.com>
This commit is contained in:
parent
08748f147b
commit
77308b4678
@ -102,6 +102,7 @@ public:
|
|||||||
Qt::WindowState setWindowState(Qt::WindowState state);
|
Qt::WindowState setWindowState(Qt::WindowState state);
|
||||||
void setWindowTitle(const QString &title);
|
void setWindowTitle(const QString &title);
|
||||||
void setWindowFilePath(const QString &filePath);
|
void setWindowFilePath(const QString &filePath);
|
||||||
|
void setWindowIcon(const QIcon &icon);
|
||||||
void raise();
|
void raise();
|
||||||
void lower();
|
void lower();
|
||||||
void propagateSizeHints();
|
void propagateSizeHints();
|
||||||
|
@ -429,6 +429,26 @@ void QCocoaWindow::setWindowFilePath(const QString &filePath)
|
|||||||
[m_nsWindow setRepresentedFilename: fi.exists() ? QCFString::toNSString(filePath) : @""];
|
[m_nsWindow setRepresentedFilename: fi.exists() ? QCFString::toNSString(filePath) : @""];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void QCocoaWindow::setWindowIcon(const QIcon &icon)
|
||||||
|
{
|
||||||
|
QCocoaAutoReleasePool pool;
|
||||||
|
|
||||||
|
NSButton *iconButton = [m_nsWindow standardWindowButton:NSWindowDocumentIconButton];
|
||||||
|
if (iconButton == nil) {
|
||||||
|
NSString *title = QCFString::toNSString(window()->windowTitle());
|
||||||
|
[m_nsWindow setRepresentedURL:[NSURL fileURLWithPath:title]];
|
||||||
|
iconButton = [m_nsWindow standardWindowButton:NSWindowDocumentIconButton];
|
||||||
|
}
|
||||||
|
if (icon.isNull()) {
|
||||||
|
[iconButton setImage:nil];
|
||||||
|
} else {
|
||||||
|
QPixmap pixmap = icon.pixmap(QSize(22, 22));
|
||||||
|
NSImage *image = static_cast<NSImage *>(qt_mac_create_nsimage(pixmap));
|
||||||
|
[iconButton setImage:image];
|
||||||
|
[image release];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void QCocoaWindow::raise()
|
void QCocoaWindow::raise()
|
||||||
{
|
{
|
||||||
//qDebug() << "raise" << this;
|
//qDebug() << "raise" << this;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user