replace the hard-coded close button with a standard one.

the whole widget needs more loving, though.

svn path=/trunk/playground/graphics/okular/; revision=585241
remotes/origin/KDE/4.0
Pino Toscano 20 years ago
parent 7ee4cbcae9
commit 6c2ea7b63d
  1. 46
      ui/annotwindow.cpp
  2. 17
      ui/annotwindow.h

@ -8,12 +8,33 @@
***************************************************************************/
// qt/kde includes
#include <qframe.h>
#include <QPainter>
#include <qpushbutton.h>
#include <qstyle.h>
#include <qtextedit.h>
#include <kglobal.h>
#include <klocale.h>
// local includes
#include "annotwindow.h"
#include "core/annotations.h"
class CloseButton
: public QPushButton
{
public:
CloseButton( QWidget * parent = 0 )
: QPushButton( parent )
{
setSizePolicy( QSizePolicy::Fixed, QSizePolicy::Fixed );
setFixedSize( 14, 14 );
setIcon( style()->standardIcon( QStyle::SP_DockWidgetCloseButton ) );
setIconSize( QSize( 14, 14 ) );
setToolTip( i18n( "Close" ) );
}
};
MouseBox::MouseBox( QWidget * parent)
: QWidget(parent),pointpressed(0,0)//pointpressed(QPoint(0,0))// m_parent(parent)
@ -61,11 +82,8 @@ AnnotWindow::AnnotWindow( QWidget * parent, Annotation * annot)
this,SLOT(slotResizerMouseMove(QMouseEvent*)));
connect( resizerBox,SIGNAL(paintevent(QPaintEvent*)),
this,SLOT(slotResizerPaint(QPaintEvent*)));
btnClose=new MouseBox(this);
connect( btnClose,SIGNAL(mousereleaseevent( QMouseEvent* )),
this,SLOT(slotCloseBtn( QMouseEvent* )));
connect( btnClose,SIGNAL(paintevent( QPaintEvent* )),
this,SLOT(slotPaintCloseBtn( QPaintEvent* )));
btnClose = new CloseButton(this);
connect( btnClose, SIGNAL( clicked() ), this, SLOT( hide() ) );
btnOption=new MouseBox(this);
connect( btnOption,SIGNAL(mousereleaseevent( QMouseEvent* )),
@ -115,7 +133,7 @@ void AnnotWindow::paintEvent(QPaintEvent *)
void AnnotWindow::resizeEvent ( QResizeEvent * e )
{ //size:
QSize sz=e->size();
btnClose->setGeometry( sz.width()-16,2,14,14);
btnClose->move( sz.width() - 16, 2 );
btnOption->setGeometry( sz.width()-80,16,75,16);
titleBox->setGeometry(0,0,sz.width(),32);
textEdit->setGeometry(0,32,sz.width(),sz.height()-32-14);
@ -151,22 +169,6 @@ void AnnotWindow::slotResizerPaint(QPaintEvent* )
}
}
void AnnotWindow::slotPaintCloseBtn(QPaintEvent* )
{
//draw close button
QPainter pnter(btnClose);
QRect rc=btnClose->rect();
rc.moveTo( 0,0);
pnter.drawRect(rc.left(),rc.top(),rc.width()-1,rc.height()-1);
pnter.drawLine(rc.topLeft(),rc.bottomRight());
pnter.drawLine(rc.topRight(),rc.bottomLeft());
}
void AnnotWindow::slotCloseBtn( QMouseEvent* )
{
this->hide();
}
void AnnotWindow::slotOptionBtn( QMouseEvent* )
{
//TODO: call context menu in pageview

@ -6,18 +6,17 @@
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
***************************************************************************/
//annotwindow.h
#ifndef _ANNOTWINDOW_H_
#define _ANNOTWINDOW_H_
#include <QtGui/qwidget.h>
#include <QtCore/QVariant>
#include <QtGui/QAction>
#include <QtGui/QApplication>
#include <QtGui/QButtonGroup>
#include <QtGui/QTextEdit>
#include "core/annotations.h"
class QFrame;
class QTextEdit;
class Annotation;
class CloseButton;
//this widget is for the titlebar and size griper
class MouseBox : public QWidget
{
@ -56,7 +55,7 @@ class AnnotWindow : public QWidget
//QSizeGrip *resizer;
MouseBox* titleBox;
MouseBox* resizerBox;
MouseBox* btnClose;
CloseButton* btnClose;
MouseBox* btnOption;
QString modTime;
@ -75,9 +74,7 @@ class AnnotWindow : public QWidget
void slotTitleMouseMove(QMouseEvent* e);
void slotResizerMouseMove(QMouseEvent* e);
void slotResizerPaint(QPaintEvent* e);
void slotPaintCloseBtn(QPaintEvent* e);
// void slotPaintOptionBtn(QPaintEvent* e);
void slotCloseBtn( QMouseEvent* e);
void slotOptionBtn( QMouseEvent* e);
void slotsaveWindowText();

Loading…
Cancel
Save