Commit 8d76db1f authored by Boudewijn Rempt's avatar Boudewijn Rempt

Fix showing the zoomed items in the popups; now I'm going to try

and fix the disappearing popup when you open te color dialog. Thanks
to Matthias Ettrich for helping me out here.

svn path=/trunk/koffice/; revision=443045
parent e6c7f76b
......@@ -2,6 +2,12 @@ Toolbox
* crash when opening second view
* crash when using wacom pad
Bugs
* On opening a second image after loading first image but not changing it,
the second image should be loaded in a second view and not replace the
first image in the first view.
Transform tool (CBR)
......
......@@ -39,57 +39,11 @@
#include <kis_canvas_subject.h>
#include <kis_colorspace_registry.h>
#include <kis_color.h>
#include <kis_color_cup.h>
#include "kis_colorspace_wet.h"
#include "kis_wet_palette_widget.h"
KisColorCup::KisColorCup(const QColor & c, QWidget * parent, const char * name)
: QPushButton(parent, name)
{
m_color = c;
connect(this, SIGNAL(clicked()), this, SLOT(slotClicked()));
}
void KisColorCup::slotClicked()
{
emit changed(m_color);
}
QSize KisColorCup::sizeHint() const
{
return style().sizeFromContents(QStyle::CT_PushButton, this, QSize(24, 24)).
expandedTo(QApplication::globalStrut());
}
void KisColorCup::drawButtonLabel( QPainter *painter )
{
int x, y, w, h;
QRect r = style().subRect( QStyle::SR_PushButtonContents, this );
r.rect(&x, &y, &w, &h);
int margin = 2; //style().pixelMetric( QStyle::PM_ButtonMargin, this );
x += margin;
y += margin;
w -= 2*margin;
h -= 2*margin;
if (isOn() || isDown()) {
x += style().pixelMetric( QStyle::PM_ButtonShiftHorizontal, this );
y += style().pixelMetric( QStyle::PM_ButtonShiftVertical, this );
}
qDrawShadePanel( painter, x, y, w, h, colorGroup(), true, 1, NULL);
if ( m_color.isValid() )
painter->fillRect( x+1, y+1, w-2, h-2, m_color );
if ( hasFocus() ) {
QRect focusRect = style().subRect( QStyle::SR_PushButtonFocusRect, this );
style().drawPrimitive( QStyle::PE_FocusRect, painter, focusRect, colorGroup() );
}
}
KisWetPaletteWidget::KisWetPaletteWidget(QWidget *parent, const char *name) : super(parent, name)
{
m_subject = 0;
......
......@@ -36,36 +36,6 @@ class QColor;
class KIntNumInput;
class KDoubleNumInput;
class KisColorCup : public QPushButton {
Q_OBJECT
public:
KisColorCup(const QColor & c, QWidget * parent, const char * name = 0);
virtual ~KisColorCup() {};
signals:
void changed(const QColor &);
public:
QSize sizeHint() const;
private slots:
void slotClicked();
protected:
virtual void drawButtonLabel( QPainter *p );
private:
QColor m_color;
};
class KRITAUI_EXPORT KisWetPaletteWidget
: public QWidget,
public KisCanvasObserver
......
......@@ -22,8 +22,13 @@
#include <stdlib.h>
#include <qapplication.h>
#include <qlayout.h>
#include <qtabwidget.h>
#include <qframe.h>
#include <qwidget.h>
#include <qevent.h>
#include <qtimer.h>
#include <kmainwindow.h>
#include <kglobalsettings.h>
......@@ -50,6 +55,41 @@
#include "kis_autobrush.h"
#include "kis_autogradient.h"
KisPopupFrame::KisPopupFrame(QWidget * parent, const char* name, WFlags)
: QFrame(parent, name, WStyle_Customize | WType_Popup | WStyle_NoBorder)
{
setFocusPolicy(StrongFocus);
}
void KisPopupFrame::keyPressEvent(QKeyEvent * e)
{
if (e->key()== Qt::Key_Escape)
{
hide();
e->accept();
}
else {
e->ignore();
}
}
#if 0
void KisPopupFrame::checkWhoHasGotFocus()
{
kdDebug() << "We are: " << this << "\n";
QObject * w = qApp->focusWidget();
while (w != 0) {
kdDebug() << "Widget " << w << " has focus, it has parent " << w->parent() << "\n";
w = w->parent();
if (w==this) return;
}
hide();
}
#endif
KisControlFrame::KisControlFrame( KisView * view, QWidget* parent, const char* name )
: QFrame( parent, name )
, m_brushWidget(0)
......@@ -119,24 +159,43 @@ void KisControlFrame::slotSetGradient(KoIconItem *item)
}
void KisControlFrame::slotShowBrushChooser()
{
if (!m_brushChooserPopup) return;
if (!m_brushWidget) return;
m_brushChooserPopup->move( this->mapToGlobal( m_brushWidget->rect().bottomLeft() ) );
m_brushChooserPopup->show();
if (!m_brushChooserPopup->isShown()) {
m_patternChooserPopup->hide();
m_gradientChooserPopup->hide();
m_brushChooserPopup->move( m_brushWidget->mapToGlobal( m_brushWidget->rect().topRight() ) );
m_brushChooserPopup->show();
}
else {
m_brushChooserPopup->hide();
}
}
void KisControlFrame::slotShowPatternChooser()
{
if (!m_patternChooserPopup ) return;
if (!m_patternWidget) return;
m_patternChooserPopup ->move( this->mapToGlobal( m_patternWidget->rect().bottomLeft() ) );
m_patternChooserPopup ->show();
if (!m_patternChooserPopup->isShown()) {
m_brushChooserPopup->hide();
m_gradientChooserPopup->hide();
m_patternChooserPopup ->move( m_patternWidget->mapToGlobal( m_patternWidget->rect().topRight() ) );
m_patternChooserPopup ->show();
}
else {
m_patternChooserPopup->hide();
}
}
......@@ -145,8 +204,17 @@ void KisControlFrame::slotShowGradientChooser()
if (!m_gradientChooserPopup ) return;
if (!m_gradientWidget) return;
m_gradientChooserPopup ->move( this->mapToGlobal( m_gradientWidget->rect().bottomLeft() ) );
m_gradientChooserPopup ->show();
if (!m_gradientChooserPopup->isShown()) {
m_brushChooserPopup->hide();
m_patternChooserPopup->hide();
m_gradientChooserPopup ->move( m_gradientWidget->mapToGlobal( m_gradientWidget->rect().topRight() ) );
m_gradientChooserPopup ->show();
}
else {
m_gradientChooserPopup->hide();
}
}
......
......@@ -28,6 +28,7 @@
#include <koFrameButton.h>
class QWidget;
class QTimer;
class KToolBar;
......@@ -52,8 +53,8 @@ class KisPopupFrame : public QFrame {
public:
KisPopupFrame(QWidget * parent, const char * name = 0, WFlags f = 0)
: QFrame(parent, name, f) {};
KisPopupFrame(QWidget * parent, const char * name = 0, WFlags f = 0);
virtual void keyPressEvent(QKeyEvent *);
public:
......
......@@ -37,6 +37,7 @@ libkisui_la_SOURCES = \
kis_guide.cc \
kis_paintop_box.cc \
kis_toolbox.cc \
kis_color_cup.cc \
wdgmatrix.ui \
kis_previewwidgetbase.ui \
wdgselectionoptions.ui \
......@@ -73,6 +74,7 @@ noinst_HEADERS = kis_dlg_preferences.h \
wdgmatrix.h \
kis_previewwidgetbase.h \
kis_previewdialog.h \
kis_color_cup.h \
wdgnewimage.h \
wdgcolorsettings.h \
wdgapplyprofile.h \
......
/*
* This file is part of Krita
*
* Copyright (c) 1999 Matthias Elter (me@kde.org)
* Copyright (c) 2001-2002 Igor Jansen (rm@kde.org)
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
#include <qpushbutton.h>
#include <qapplication.h>
#include <qclipboard.h>
#include <qcolor.h>
#include <qdrawutil.h>
#include <qhbox.h>
#include <qlabel.h>
#include <qlayout.h>
#include <qpainter.h>
#include <qspinbox.h>
#include <qstyle.h>
#include <qtooltip.h>
#include <klocale.h>
#include <knuminput.h>
#include <koFrameButton.h>
#include <kis_canvas_subject.h>
#include <kis_colorspace_registry.h>
#include <kis_color.h>
#include <kis_color_cup.h>
KisColorCup::KisColorCup(QWidget * parent, const char * name)
: QPushButton(parent, name)
{
m_color = Qt::black;
connect(this, SIGNAL(clicked()), this, SLOT(slotClicked()));
}
KisColorCup::KisColorCup(const QColor & c, QWidget * parent, const char * name)
: QPushButton(parent, name)
{
m_color = c;
connect(this, SIGNAL(clicked()), this, SLOT(slotClicked()));
}
void KisColorCup::slotClicked()
{
emit changed(m_color);
}
QSize KisColorCup::sizeHint() const
{
return style().sizeFromContents(QStyle::CT_PushButton, this, QSize(24, 24)).
expandedTo(QApplication::globalStrut());
}
void KisColorCup::drawButtonLabel( QPainter *painter )
{
int x, y, w, h;
QRect r = style().subRect( QStyle::SR_PushButtonContents, this );
r.rect(&x, &y, &w, &h);
int margin = 2; //style().pixelMetric( QStyle::PM_ButtonMargin, this );
x += margin;
y += margin;
w -= 2*margin;
h -= 2*margin;
if (isOn() || isDown()) {
x += style().pixelMetric( QStyle::PM_ButtonShiftHorizontal, this );
y += style().pixelMetric( QStyle::PM_ButtonShiftVertical, this );
}
qDrawShadePanel( painter, x, y, w, h, colorGroup(), true, 1, NULL);
if ( m_color.isValid() )
painter->fillRect( x+1, y+1, w-2, h-2, m_color );
if ( hasFocus() ) {
QRect focusRect = style().subRect( QStyle::SR_PushButtonFocusRect, this );
style().drawPrimitive( QStyle::PE_FocusRect, painter, focusRect, colorGroup() );
}
}
#include "kis_color_cup.moc"
/* This file is part of the KDE project
*
* Copyright (c) 2005 Boudewijn Rempt <boud@valdyas.org>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
#ifndef KIS_COLOR_CUP_H
#define KIS_COLOR_CUP_H
#include "qpushbutton.h"
#include "qcolor.h"
#include <koffice_export.h>
class QSize;
class QPainter;
class KisColorCup : public QPushButton {
Q_OBJECT
public:
KisColorCup(QWidget * parent, const char * name = 0);
KisColorCup(const QColor & c, QWidget * parent, const char * name = 0);
virtual ~KisColorCup() {};
void setColor(const QColor & c) {m_color = c; };
QColor color() { return m_color; };
signals:
void changed(const QColor &);
public:
QSize sizeHint() const;
private slots:
void slotClicked();
protected:
virtual void drawButtonLabel( QPainter *p );
private:
QColor m_color;
};
#endif
......@@ -168,7 +168,8 @@ void KisToolBox::enableTools(bool enable)
ToolList::Iterator it;
for ( it = tl->begin(); it != tl->end(); ++it )
it.data()->setEnabled(enable);
if (it != 0 && it.data())
it.data()->setEnabled(enable);
}
m_buttonGroup->setEnabled(enable);
for (Q_UINT32 i = 0; i < m_numberOfButtons; ++i) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment