mirror of
https://github.com/tomahawk-player/tomahawk.git
synced 2025-08-05 13:47:26 +02:00
More OS X preferences fixes
This commit is contained in:
@@ -54,6 +54,7 @@
|
|||||||
#include "accounts/AccountFactoryWrapper.h"
|
#include "accounts/AccountFactoryWrapper.h"
|
||||||
#include "accounts/spotify/SpotifyAccount.h"
|
#include "accounts/spotify/SpotifyAccount.h"
|
||||||
#include "thirdparty/Qocoa/qtoolbartabdialog.h"
|
#include "thirdparty/Qocoa/qtoolbartabdialog.h"
|
||||||
|
#include "thirdparty/Qocoa/qbutton.h"
|
||||||
|
|
||||||
#include "ui_ProxyDialog.h"
|
#include "ui_ProxyDialog.h"
|
||||||
#include "ui_Settings_Accounts.h"
|
#include "ui_Settings_Accounts.h"
|
||||||
@@ -81,18 +82,12 @@ SettingsDialog::SettingsDialog(QObject *parent )
|
|||||||
m_collectionWidgetUi->setupUi( m_collectionWidget );
|
m_collectionWidgetUi->setupUi( m_collectionWidget );
|
||||||
m_advancedWidgetUi->setupUi( m_advancedWidget );
|
m_advancedWidgetUi->setupUi( m_advancedWidget );
|
||||||
|
|
||||||
|
m_accountsWidgetUi->accountsFilterCombo->setFocusPolicy( Qt::NoFocus );
|
||||||
|
|
||||||
m_dialog = new QToolbarTabDialog;
|
m_dialog = new QToolbarTabDialog;
|
||||||
|
|
||||||
TomahawkSettings* s = TomahawkSettings::instance();
|
TomahawkSettings* s = TomahawkSettings::instance();
|
||||||
|
|
||||||
// TomahawkUtils::unmarginLayout( layout() );
|
|
||||||
// TomahawkUtils::unmarginLayout( ui->horizontalLayout );
|
|
||||||
|
|
||||||
//#ifdef Q_WS_X11
|
|
||||||
// ui->stackedWidget->setContentsMargins( 4, 4, 4, 4 );
|
|
||||||
//#else
|
|
||||||
// ui->stackedWidget->setContentsMargins( 4, 4, 4, 0 );
|
|
||||||
//#endif
|
|
||||||
m_advancedWidgetUi->checkBoxReporter->setChecked( s->crashReporterEnabled() );
|
m_advancedWidgetUi->checkBoxReporter->setChecked( s->crashReporterEnabled() );
|
||||||
m_advancedWidgetUi->checkBoxHttp->setChecked( s->httpEnabled() );
|
m_advancedWidgetUi->checkBoxHttp->setChecked( s->httpEnabled() );
|
||||||
|
|
||||||
@@ -125,6 +120,8 @@ SettingsDialog::SettingsDialog(QObject *parent )
|
|||||||
p->setFixedSize( 0, 0 );
|
p->setFixedSize( 0, 0 );
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
m_accountsWidgetUi->installFromFileBtn->setText( tr( "Install from file" ) );
|
||||||
|
|
||||||
// Accounts
|
// Accounts
|
||||||
AccountDelegate* accountDelegate = new AccountDelegate( this );
|
AccountDelegate* accountDelegate = new AccountDelegate( this );
|
||||||
m_accountsWidgetUi->accountsView->setItemDelegate( accountDelegate );
|
m_accountsWidgetUi->accountsView->setItemDelegate( accountDelegate );
|
||||||
@@ -201,9 +198,16 @@ SettingsDialog::SettingsDialog(QObject *parent )
|
|||||||
m_advancedWidget->setMinimumSize( m_advancedWidget->sizeHint() );
|
m_advancedWidget->setMinimumSize( m_advancedWidget->sizeHint() );
|
||||||
m_accountsWidget->setMinimumWidth( 500 );
|
m_accountsWidget->setMinimumWidth( 500 );
|
||||||
#else
|
#else
|
||||||
m_accountsWidget->setMinimumSize( 500, 350 );
|
m_accountsWidget->setContentsMargins( 6, 6, 6, 6 );
|
||||||
m_collectionWidget->setMinimumHeight( m_collectionWidget->sizeHint().height() + 20 );
|
m_accountsWidgetUi->horizontalLayout->setContentsMargins( 0, 0, 0, 0 );
|
||||||
m_advancedWidget->setMinimumHeight( m_advancedWidget->sizeHint().height() + 4 );
|
m_accountsWidgetUi->installFromFileBtn->setContentsMargins( -4, 0, 0, 0 );
|
||||||
|
m_accountsWidget->setMinimumSize( 550, 400 );
|
||||||
|
|
||||||
|
m_collectionWidget->setContentsMargins( 6, 6, 6, 6 );
|
||||||
|
m_collectionWidget->setMinimumHeight( m_collectionWidgetUi->verticalLayout->sizeHint().height() + 20 );
|
||||||
|
|
||||||
|
m_advancedWidget->setContentsMargins( 6, 6, 6, 6 );
|
||||||
|
m_advancedWidget->setMinimumHeight( m_advancedWidgetUi->verticalLayout->sizeHint().height() );
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// NOW PLAYING
|
// NOW PLAYING
|
||||||
|
@@ -6,8 +6,8 @@
|
|||||||
<rect>
|
<rect>
|
||||||
<x>0</x>
|
<x>0</x>
|
||||||
<y>0</y>
|
<y>0</y>
|
||||||
<width>405</width>
|
<width>553</width>
|
||||||
<height>347</height>
|
<height>439</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<property name="windowTitle">
|
<property name="windowTitle">
|
||||||
@@ -20,9 +20,12 @@
|
|||||||
<item>
|
<item>
|
||||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||||
<item>
|
<item>
|
||||||
<widget class="QPushButton" name="installFromFileBtn">
|
<widget class="QButton" name="installFromFileBtn" native="true">
|
||||||
<property name="text">
|
<property name="sizePolicy">
|
||||||
<string>Install from file...</string>
|
<sizepolicy hsizetype="Expanding" vsizetype="Preferred">
|
||||||
|
<horstretch>0</horstretch>
|
||||||
|
<verstretch>0</verstretch>
|
||||||
|
</sizepolicy>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
@@ -66,6 +69,14 @@
|
|||||||
</item>
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</widget>
|
</widget>
|
||||||
|
<customwidgets>
|
||||||
|
<customwidget>
|
||||||
|
<class>QButton</class>
|
||||||
|
<extends>QWidget</extends>
|
||||||
|
<header>thirdparty/Qocoa/QButton.h</header>
|
||||||
|
<container>1</container>
|
||||||
|
</customwidget>
|
||||||
|
</customwidgets>
|
||||||
<resources/>
|
<resources/>
|
||||||
<connections/>
|
<connections/>
|
||||||
</ui>
|
</ui>
|
||||||
|
@@ -6,8 +6,8 @@
|
|||||||
<rect>
|
<rect>
|
||||||
<x>0</x>
|
<x>0</x>
|
||||||
<y>0</y>
|
<y>0</y>
|
||||||
<width>423</width>
|
<width>403</width>
|
||||||
<height>388</height>
|
<height>370</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<property name="sizePolicy">
|
<property name="sizePolicy">
|
||||||
|
@@ -391,6 +391,7 @@ IF( APPLE )
|
|||||||
SET( libSources ${libSources}
|
SET( libSources ${libSources}
|
||||||
utils/TomahawkUtils_Mac.mm
|
utils/TomahawkUtils_Mac.mm
|
||||||
mac/FileHelpers.mm
|
mac/FileHelpers.mm
|
||||||
|
thirdparty/Qocoa/qbutton_mac.mm
|
||||||
thirdparty/Qocoa/qsearchfield_mac.mm
|
thirdparty/Qocoa/qsearchfield_mac.mm
|
||||||
thirdparty/Qocoa/qtoolbartabdialog_mac.mm
|
thirdparty/Qocoa/qtoolbartabdialog_mac.mm
|
||||||
widgets/SourceTreePopupDialog_mac.mm )
|
widgets/SourceTreePopupDialog_mac.mm )
|
||||||
@@ -409,7 +410,7 @@ IF( APPLE )
|
|||||||
/System/Library/Frameworks/Security.framework
|
/System/Library/Frameworks/Security.framework
|
||||||
)
|
)
|
||||||
ELSE( APPLE )
|
ELSE( APPLE )
|
||||||
SET( libGuiSources ${libGuiSources} thirdparty/Qocoa/qsearchfield.cpp thirdparty/Qocoa/qtoolbartabdialog.cpp )
|
SET( libGuiSources ${libGuiSources} thirdparty/Qocoa/qbutton.cpp thirdparty/Qocoa/qsearchfield.cpp thirdparty/Qocoa/qtoolbartabdialog.cpp )
|
||||||
ENDIF( APPLE )
|
ENDIF( APPLE )
|
||||||
|
|
||||||
IF(LIBLASTFM_FOUND)
|
IF(LIBLASTFM_FOUND)
|
||||||
|
89
src/libtomahawk/thirdparty/Qocoa/qbutton.cpp
vendored
Normal file
89
src/libtomahawk/thirdparty/Qocoa/qbutton.cpp
vendored
Normal file
@@ -0,0 +1,89 @@
|
|||||||
|
/*
|
||||||
|
Copyright (C) 2011 by Mike McQuaid
|
||||||
|
|
||||||
|
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.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "qbutton.h"
|
||||||
|
|
||||||
|
#include <QToolBar>
|
||||||
|
#include <QToolButton>
|
||||||
|
#include <QPushButton>
|
||||||
|
#include <QVBoxLayout>
|
||||||
|
|
||||||
|
class QButtonPrivate : public QObject
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
QButtonPrivate(QButton *button, QAbstractButton *abstractButton)
|
||||||
|
: QObject(button), abstractButton(abstractButton) {}
|
||||||
|
QPointer<QAbstractButton> abstractButton;
|
||||||
|
};
|
||||||
|
|
||||||
|
QButton::QButton(QWidget *parent, BezelStyle) : QWidget(parent)
|
||||||
|
{
|
||||||
|
QAbstractButton *button = 0;
|
||||||
|
if (qobject_cast<QToolBar*>(parent))
|
||||||
|
button = new QToolButton(this);
|
||||||
|
else
|
||||||
|
button = new QPushButton(this);
|
||||||
|
connect(button, SIGNAL(clicked()),
|
||||||
|
this, SIGNAL(clicked()));
|
||||||
|
pimpl = new QButtonPrivate(this, button);
|
||||||
|
|
||||||
|
QVBoxLayout *layout = new QVBoxLayout(this);
|
||||||
|
layout->setMargin(0);
|
||||||
|
layout->addWidget(button);
|
||||||
|
}
|
||||||
|
|
||||||
|
void QButton::setText(const QString &text)
|
||||||
|
{
|
||||||
|
Q_ASSERT(pimpl);
|
||||||
|
if (pimpl)
|
||||||
|
pimpl->abstractButton->setText(text);
|
||||||
|
}
|
||||||
|
|
||||||
|
void QButton::setImage(const QPixmap &image)
|
||||||
|
{
|
||||||
|
Q_ASSERT(pimpl);
|
||||||
|
if (pimpl)
|
||||||
|
pimpl->abstractButton->setIcon(image);
|
||||||
|
}
|
||||||
|
|
||||||
|
void QButton::setChecked(bool checked)
|
||||||
|
{
|
||||||
|
Q_ASSERT(pimpl);
|
||||||
|
if (pimpl)
|
||||||
|
pimpl->abstractButton->setChecked(checked);
|
||||||
|
}
|
||||||
|
|
||||||
|
void QButton::setCheckable(bool checkable)
|
||||||
|
{
|
||||||
|
Q_ASSERT(pimpl);
|
||||||
|
if (pimpl)
|
||||||
|
pimpl->abstractButton->setCheckable(checkable);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool QButton::isChecked()
|
||||||
|
{
|
||||||
|
Q_ASSERT(pimpl);
|
||||||
|
if (!pimpl)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
return pimpl->abstractButton->isChecked();
|
||||||
|
}
|
51
src/libtomahawk/thirdparty/Qocoa/qbutton.h
vendored
Normal file
51
src/libtomahawk/thirdparty/Qocoa/qbutton.h
vendored
Normal file
@@ -0,0 +1,51 @@
|
|||||||
|
#ifndef QBUTTON_H
|
||||||
|
#define QBUTTON_H
|
||||||
|
|
||||||
|
#include <QWidget>
|
||||||
|
#include <QPointer>
|
||||||
|
|
||||||
|
#include "DllMacro.h"
|
||||||
|
|
||||||
|
class QButtonPrivate;
|
||||||
|
class DLLEXPORT QButton : public QWidget
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
public:
|
||||||
|
// Matches NSBezelStyle
|
||||||
|
enum BezelStyle {
|
||||||
|
Rounded = 1,
|
||||||
|
RegularSquare = 2,
|
||||||
|
Disclosure = 5,
|
||||||
|
ShadowlessSquare = 6,
|
||||||
|
Circular = 7,
|
||||||
|
TexturedSquare = 8,
|
||||||
|
HelpButton = 9,
|
||||||
|
SmallSquare = 10,
|
||||||
|
TexturedRounded = 11,
|
||||||
|
RoundRect = 12,
|
||||||
|
Recessed = 13,
|
||||||
|
RoundedDisclosure = 14,
|
||||||
|
#ifdef __MAC_10_7
|
||||||
|
Inline = 15
|
||||||
|
#endif
|
||||||
|
};
|
||||||
|
|
||||||
|
explicit QButton(QWidget *parent, BezelStyle bezelStyle = Rounded);
|
||||||
|
|
||||||
|
public slots:
|
||||||
|
void setText(const QString &text);
|
||||||
|
void setImage(const QPixmap &image);
|
||||||
|
void setChecked(bool checked);
|
||||||
|
|
||||||
|
public:
|
||||||
|
void setCheckable(bool checkable);
|
||||||
|
bool isChecked();
|
||||||
|
|
||||||
|
signals:
|
||||||
|
void clicked(bool checked = false);
|
||||||
|
|
||||||
|
private:
|
||||||
|
friend class QButtonPrivate;
|
||||||
|
QPointer<QButtonPrivate> pimpl;
|
||||||
|
};
|
||||||
|
#endif // QBUTTON_H
|
232
src/libtomahawk/thirdparty/Qocoa/qbutton_mac.mm
vendored
Normal file
232
src/libtomahawk/thirdparty/Qocoa/qbutton_mac.mm
vendored
Normal file
@@ -0,0 +1,232 @@
|
|||||||
|
/*
|
||||||
|
Copyright (C) 2011 by Mike McQuaid
|
||||||
|
|
||||||
|
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.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "qbutton.h"
|
||||||
|
|
||||||
|
#include "qocoa_mac.h"
|
||||||
|
|
||||||
|
#import "Foundation/NSAutoreleasePool.h"
|
||||||
|
#import "AppKit/NSButton.h"
|
||||||
|
#import "AppKit/NSFont.h"
|
||||||
|
|
||||||
|
class QButtonPrivate : public QObject
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
QButtonPrivate(QButton *qButton, NSButton *nsButton, QButton::BezelStyle bezelStyle)
|
||||||
|
: QObject(qButton), qButton(qButton), nsButton(nsButton)
|
||||||
|
{
|
||||||
|
switch(bezelStyle) {
|
||||||
|
case QButton::Disclosure:
|
||||||
|
case QButton::Circular:
|
||||||
|
#ifdef __MAC_10_7
|
||||||
|
case QButton::Inline:
|
||||||
|
#endif
|
||||||
|
case QButton::RoundedDisclosure:
|
||||||
|
case QButton::HelpButton:
|
||||||
|
[nsButton setTitle:@""];
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
NSFont* font = 0;
|
||||||
|
switch(bezelStyle) {
|
||||||
|
case QButton::RoundRect:
|
||||||
|
font = [NSFont fontWithName:@"Lucida Grande" size:12];
|
||||||
|
break;
|
||||||
|
|
||||||
|
case QButton::Recessed:
|
||||||
|
font = [NSFont fontWithName:@"Lucida Grande Bold" size:12];
|
||||||
|
break;
|
||||||
|
|
||||||
|
#ifdef __MAC_10_7
|
||||||
|
case QButton::Inline:
|
||||||
|
font = [NSFont boldSystemFontOfSize:[NSFont systemFontSizeForControlSize:NSSmallControlSize]];
|
||||||
|
break;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
default:
|
||||||
|
font = [NSFont systemFontOfSize:[NSFont systemFontSizeForControlSize:NSRegularControlSize]];
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
[nsButton setFont:font];
|
||||||
|
|
||||||
|
switch(bezelStyle) {
|
||||||
|
case QButton::Rounded:
|
||||||
|
qButton->setMinimumWidth(40);
|
||||||
|
qButton->setFixedHeight(24);
|
||||||
|
qButton->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Fixed);
|
||||||
|
break;
|
||||||
|
case QButton::RegularSquare:
|
||||||
|
case QButton::TexturedSquare:
|
||||||
|
qButton->setMinimumSize(14, 23);
|
||||||
|
qButton->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Minimum);
|
||||||
|
break;
|
||||||
|
case QButton::ShadowlessSquare:
|
||||||
|
qButton->setMinimumSize(5, 25);
|
||||||
|
qButton->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Minimum);
|
||||||
|
break;
|
||||||
|
case QButton::SmallSquare:
|
||||||
|
qButton->setMinimumSize(4, 21);
|
||||||
|
qButton->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Minimum);
|
||||||
|
break;
|
||||||
|
case QButton::TexturedRounded:
|
||||||
|
qButton->setMinimumSize(10, 22);
|
||||||
|
qButton->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Minimum);
|
||||||
|
break;
|
||||||
|
case QButton::RoundRect:
|
||||||
|
case QButton::Recessed:
|
||||||
|
qButton->setMinimumWidth(16);
|
||||||
|
qButton->setFixedHeight(18);
|
||||||
|
qButton->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Fixed);
|
||||||
|
break;
|
||||||
|
case QButton::Disclosure:
|
||||||
|
qButton->setMinimumWidth(13);
|
||||||
|
qButton->setFixedHeight(13);
|
||||||
|
qButton->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Fixed);
|
||||||
|
break;
|
||||||
|
case QButton::Circular:
|
||||||
|
qButton->setMinimumSize(16, 16);
|
||||||
|
qButton->setMaximumHeight(40);
|
||||||
|
qButton->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Minimum);
|
||||||
|
break;
|
||||||
|
case QButton::HelpButton:
|
||||||
|
case QButton::RoundedDisclosure:
|
||||||
|
qButton->setMinimumWidth(22);
|
||||||
|
qButton->setFixedHeight(22);
|
||||||
|
qButton->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Fixed);
|
||||||
|
break;
|
||||||
|
#ifdef __MAC_10_7
|
||||||
|
case QButton::Inline:
|
||||||
|
qButton->setMinimumWidth(10);
|
||||||
|
qButton->setFixedHeight(16);
|
||||||
|
qButton->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Fixed);
|
||||||
|
break;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
switch(bezelStyle) {
|
||||||
|
case QButton::Recessed:
|
||||||
|
[nsButton setButtonType:NSPushOnPushOffButton];
|
||||||
|
case QButton::Disclosure:
|
||||||
|
[nsButton setButtonType:NSOnOffButton];
|
||||||
|
default:
|
||||||
|
[nsButton setButtonType:NSMomentaryPushInButton];
|
||||||
|
}
|
||||||
|
|
||||||
|
[nsButton setBezelStyle:bezelStyle];
|
||||||
|
}
|
||||||
|
|
||||||
|
void clicked()
|
||||||
|
{
|
||||||
|
emit qButton->clicked(qButton->isChecked());
|
||||||
|
}
|
||||||
|
|
||||||
|
~QButtonPrivate() {
|
||||||
|
[[nsButton target] release];
|
||||||
|
[nsButton setTarget:nil];
|
||||||
|
}
|
||||||
|
|
||||||
|
QButton *qButton;
|
||||||
|
NSButton *nsButton;
|
||||||
|
};
|
||||||
|
|
||||||
|
@interface QButtonTarget : NSObject
|
||||||
|
{
|
||||||
|
@public
|
||||||
|
QPointer<QButtonPrivate> pimpl;
|
||||||
|
}
|
||||||
|
-(void)clicked;
|
||||||
|
@end
|
||||||
|
|
||||||
|
@implementation QButtonTarget
|
||||||
|
-(void)clicked {
|
||||||
|
Q_ASSERT(pimpl);
|
||||||
|
if (pimpl)
|
||||||
|
pimpl->clicked();
|
||||||
|
}
|
||||||
|
@end
|
||||||
|
|
||||||
|
QButton::QButton(QWidget *parent, BezelStyle bezelStyle) : QWidget(parent)
|
||||||
|
{
|
||||||
|
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
|
||||||
|
|
||||||
|
NSButton *button = [[NSButton alloc] init];
|
||||||
|
pimpl = new QButtonPrivate(this, button, bezelStyle);
|
||||||
|
|
||||||
|
QButtonTarget *target = [[QButtonTarget alloc] init];
|
||||||
|
target->pimpl = pimpl;
|
||||||
|
[button setTarget:target];
|
||||||
|
|
||||||
|
[button setAction:@selector(clicked)];
|
||||||
|
|
||||||
|
setupLayout(button, this);
|
||||||
|
|
||||||
|
[button release];
|
||||||
|
|
||||||
|
[pool drain];
|
||||||
|
}
|
||||||
|
|
||||||
|
void QButton::setText(const QString &text)
|
||||||
|
{
|
||||||
|
Q_ASSERT(pimpl);
|
||||||
|
if (!pimpl)
|
||||||
|
return;
|
||||||
|
|
||||||
|
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
|
||||||
|
[pimpl->nsButton setTitle:fromQString(text)];
|
||||||
|
[pool drain];
|
||||||
|
}
|
||||||
|
|
||||||
|
void QButton::setImage(const QPixmap &image)
|
||||||
|
{
|
||||||
|
Q_ASSERT(pimpl);
|
||||||
|
if (pimpl)
|
||||||
|
[pimpl->nsButton setImage:fromQPixmap(image)];
|
||||||
|
}
|
||||||
|
|
||||||
|
void QButton::setChecked(bool checked)
|
||||||
|
{
|
||||||
|
Q_ASSERT(pimpl);
|
||||||
|
if (pimpl)
|
||||||
|
[pimpl->nsButton setState:checked];
|
||||||
|
}
|
||||||
|
|
||||||
|
void QButton::setCheckable(bool checkable)
|
||||||
|
{
|
||||||
|
const NSInteger cellMask = checkable ? NSChangeBackgroundCellMask : NSNoCellMask;
|
||||||
|
|
||||||
|
Q_ASSERT(pimpl);
|
||||||
|
if (pimpl)
|
||||||
|
[[pimpl->nsButton cell] setShowsStateBy:cellMask];
|
||||||
|
}
|
||||||
|
|
||||||
|
bool QButton::isChecked()
|
||||||
|
{
|
||||||
|
Q_ASSERT(pimpl);
|
||||||
|
if (!pimpl)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
return [pimpl->nsButton state];
|
||||||
|
}
|
||||||
|
|
||||||
|
#include "moc_qbutton.cpp"
|
||||||
|
|
Reference in New Issue
Block a user