mirror of
https://github.com/tomahawk-player/tomahawk.git
synced 2025-08-08 07:07:05 +02:00
Update to Qocoa fixes
This commit is contained in:
4
src/libtomahawk/thirdparty/Qocoa/qocoa_mac.h
vendored
4
src/libtomahawk/thirdparty/Qocoa/qocoa_mac.h
vendored
@@ -32,7 +32,7 @@ static inline NSString* fromQString(const QString &string)
|
|||||||
{
|
{
|
||||||
const QByteArray utf8 = string.toUtf8();
|
const QByteArray utf8 = string.toUtf8();
|
||||||
const char* cString = utf8.constData();
|
const char* cString = utf8.constData();
|
||||||
return [[NSString alloc] initWithUTF8String:cString];
|
return [[[NSString alloc] initWithUTF8String:cString] autorelease];
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline QString toQString(NSString *string)
|
static inline QString toQString(NSString *string)
|
||||||
@@ -45,7 +45,7 @@ static inline QString toQString(NSString *string)
|
|||||||
static inline NSImage* fromQPixmap(const QPixmap &pixmap)
|
static inline NSImage* fromQPixmap(const QPixmap &pixmap)
|
||||||
{
|
{
|
||||||
CGImageRef cgImage = pixmap.toMacCGImageRef();
|
CGImageRef cgImage = pixmap.toMacCGImageRef();
|
||||||
return [[NSImage alloc] initWithCGImage:cgImage size:NSZeroSize];
|
return [[[NSImage alloc] initWithCGImage:cgImage size:NSZeroSize] autorelease];
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline void setupLayout(void *cocoaView, QWidget *parent)
|
static inline void setupLayout(void *cocoaView, QWidget *parent)
|
||||||
|
@@ -1,3 +1,25 @@
|
|||||||
|
/*
|
||||||
|
Copyright (C) 2012 by Leo Franchi <lfranchi@kde.org>
|
||||||
|
|
||||||
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
of this software and associated documentation files (the "Software"), to deal
|
||||||
|
in the Software without restriction, including without limitation the rights
|
||||||
|
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
copies of the Software, and to permit persons to whom the Software is
|
||||||
|
furnished to do so, subject to the following conditions:
|
||||||
|
|
||||||
|
The above copyright notice and this permission notice shall be included in
|
||||||
|
all copies or substantial portions of the Software.
|
||||||
|
|
||||||
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||||
|
THE SOFTWARE.
|
||||||
|
*/
|
||||||
|
|
||||||
#ifndef QTOOLBARTABWIDGET_H
|
#ifndef QTOOLBARTABWIDGET_H
|
||||||
#define QTOOLBARTABWIDGET_H
|
#define QTOOLBARTABWIDGET_H
|
||||||
|
|
||||||
|
@@ -21,7 +21,6 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include "qtoolbartabdialog.h"
|
#include "qtoolbartabdialog.h"
|
||||||
#include "moc_qtoolbartabdialog.cpp"
|
|
||||||
|
|
||||||
#include "qocoa_mac.h"
|
#include "qocoa_mac.h"
|
||||||
|
|
||||||
@@ -90,7 +89,7 @@ class QToolbarTabDialogPrivate {
|
|||||||
public:
|
public:
|
||||||
QToolbarTabDialogPrivate(QToolbarTabDialog* dialog) : q(dialog),
|
QToolbarTabDialogPrivate(QToolbarTabDialog* dialog) : q(dialog),
|
||||||
currentPane(NULL),
|
currentPane(NULL),
|
||||||
minimumWidthForToolbar(0)
|
minimumWidth(0)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -116,7 +115,7 @@ public:
|
|||||||
[prefsWindow setFrame:windowFrame display:NO];
|
[prefsWindow setFrame:windowFrame display:NO];
|
||||||
[prefsWindow setMinSize: windowFrame.size];
|
[prefsWindow setMinSize: windowFrame.size];
|
||||||
}
|
}
|
||||||
minimumWidthForToolbar = windowFrame.size.width;
|
minimumWidth = windowFrame.size.width;
|
||||||
}
|
}
|
||||||
|
|
||||||
void showPaneWithIdentifier(NSString* ident) {
|
void showPaneWithIdentifier(NSString* ident) {
|
||||||
@@ -137,6 +136,8 @@ public:
|
|||||||
if (!newPage)
|
if (!newPage)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
const NSRect oldFrame = [[prefsWindow contentView] frame];
|
||||||
|
|
||||||
// Clear first responder on window and set a temporary NSView on the window
|
// Clear first responder on window and set a temporary NSView on the window
|
||||||
// while we change the widget out underneath
|
// while we change the widget out underneath
|
||||||
[prefsWindow makeFirstResponder:nil];
|
[prefsWindow makeFirstResponder:nil];
|
||||||
@@ -146,6 +147,8 @@ public:
|
|||||||
[tempView release];
|
[tempView release];
|
||||||
|
|
||||||
QSize sizeToUse = newPage->sizeHint().isNull() ? newPage->size() : newPage->sizeHint();
|
QSize sizeToUse = newPage->sizeHint().isNull() ? newPage->size() : newPage->sizeHint();
|
||||||
|
sizeToUse.setWidth(qMax(sizeToUse.width(), newPage->minimumWidth()));
|
||||||
|
sizeToUse.setHeight(qMax(sizeToUse.height(), newPage->minimumHeight()));
|
||||||
|
|
||||||
static const int spacing = 4;
|
static const int spacing = 4;
|
||||||
|
|
||||||
@@ -156,8 +159,10 @@ public:
|
|||||||
newFrame.size.height = sizeToUse.height() + ([prefsWindow frame].size.height - [[prefsWindow contentView] frame].size.height) + spacing;
|
newFrame.size.height = sizeToUse.height() + ([prefsWindow frame].size.height - [[prefsWindow contentView] frame].size.height) + spacing;
|
||||||
newFrame.size.width = sizeToUse.width() + spacing;
|
newFrame.size.width = sizeToUse.width() + spacing;
|
||||||
|
|
||||||
//Ensure the full toolbar still fits
|
// Don't resize the width---only the height, so use the maximum width for any page
|
||||||
if (newFrame.size.width < minimumWidthForToolbar) newFrame.size.width = minimumWidthForToolbar;
|
// or the same width as before, if the user already resized it to be larger.
|
||||||
|
newFrame.size.width < minimumWidth ? newFrame.size.width = minimumWidth
|
||||||
|
: newFrame.size.width = qMax(newFrame.size.width, oldFrame.size.width);
|
||||||
|
|
||||||
// Preserve upper left point of window during resize.
|
// Preserve upper left point of window during resize.
|
||||||
newFrame.origin.y += ([[prefsWindow contentView] frame].size.height - sizeToUse.height()) - spacing;
|
newFrame.origin.y += ([[prefsWindow contentView] frame].size.height - sizeToUse.height()) - spacing;
|
||||||
@@ -180,11 +185,11 @@ public:
|
|||||||
|
|
||||||
if (newPage->sizePolicy().horizontalPolicy() == QSizePolicy::Fixed) {
|
if (newPage->sizePolicy().horizontalPolicy() == QSizePolicy::Fixed) {
|
||||||
canResize = NO;
|
canResize = NO;
|
||||||
maxSize.width = minSize.width;
|
maxSize.width = sizeToUse.width();
|
||||||
}
|
}
|
||||||
if (newPage->sizePolicy().verticalPolicy() == QSizePolicy::Fixed) {
|
if (newPage->sizePolicy().verticalPolicy() == QSizePolicy::Fixed) {
|
||||||
canResize = NO;
|
canResize = NO;
|
||||||
maxSize.height = minSize.height;
|
maxSize.height = sizeToUse.height();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -192,6 +197,7 @@ public:
|
|||||||
[prefsWindow setShowsResizeIndicator:canResize];
|
[prefsWindow setShowsResizeIndicator:canResize];
|
||||||
|
|
||||||
[prefsWindow setTitle:ident];
|
[prefsWindow setTitle:ident];
|
||||||
|
[prefsWindow makeFirstResponder:[panes objectForKey:ident]];
|
||||||
|
|
||||||
[pool drain];
|
[pool drain];
|
||||||
}
|
}
|
||||||
@@ -220,7 +226,7 @@ public:
|
|||||||
NSToolbar *toolBar;
|
NSToolbar *toolBar;
|
||||||
NSString* currentPane;
|
NSString* currentPane;
|
||||||
|
|
||||||
int minimumWidthForToolbar;
|
int minimumWidth;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
@@ -320,11 +326,10 @@ public:
|
|||||||
|
|
||||||
-(NSSize)windowWillResize:(NSWindow *)sender toSize:(NSSize)frameSize
|
-(NSSize)windowWillResize:(NSWindow *)sender toSize:(NSSize)frameSize
|
||||||
{
|
{
|
||||||
Q_UNUSED(sender);
|
|
||||||
if (!pimpl)
|
if (!pimpl)
|
||||||
return frameSize;
|
return frameSize;
|
||||||
|
|
||||||
pimpl->resizeCurrentPageToSize(frameSize);
|
pimpl->resizeCurrentPageToSize([[sender contentView] frame].size);
|
||||||
|
|
||||||
return frameSize;
|
return frameSize;
|
||||||
}
|
}
|
||||||
@@ -398,6 +403,8 @@ void QToolbarTabDialog::addTab(QWidget* page, const QPixmap& icon, const QString
|
|||||||
[nativeView setAutoresizingMask:NSViewWidthSizable | NSViewHeightSizable];
|
[nativeView setAutoresizingMask:NSViewWidthSizable | NSViewHeightSizable];
|
||||||
[nativeView setAutoresizesSubviews:YES];
|
[nativeView setAutoresizesSubviews:YES];
|
||||||
|
|
||||||
|
pimpl->minimumWidth = qMax(pimpl->minimumWidth, page->sizeHint().width());
|
||||||
|
|
||||||
nativeWidget->show();
|
nativeWidget->show();
|
||||||
|
|
||||||
ItemData data;
|
ItemData data;
|
||||||
@@ -433,6 +440,11 @@ void QToolbarTabDialog::setCurrentIndex(int index)
|
|||||||
|
|
||||||
void QToolbarTabDialog::show()
|
void QToolbarTabDialog::show()
|
||||||
{
|
{
|
||||||
|
Q_ASSERT(pimpl);
|
||||||
|
if (!pimpl)
|
||||||
|
return;
|
||||||
|
|
||||||
|
[pimpl->prefsWindow center];
|
||||||
[pimpl->prefsWindow makeKeyAndOrderFront:nil];
|
[pimpl->prefsWindow makeKeyAndOrderFront:nil];
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -446,3 +458,4 @@ void QToolbarTabDialog::hide()
|
|||||||
emit accepted();
|
emit accepted();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#include "moc_qtoolbartabdialog.cpp"
|
||||||
|
Reference in New Issue
Block a user