~ubuntu-branches/ubuntu/hardy/uim/hardy

« back to all changes in this revision

Viewing changes to qt/toolbar-standalone-qt.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Masahito Omote
  • Date: 2007-04-21 03:46:09 UTC
  • mfrom: (1.1.6 upstream)
  • Revision ID: james.westby@ubuntu.com-20070421034609-gpcurkutp8vaysqj
Tags: 1:1.4.1-3
* Switch to dh_gtkmodules for the gtk 2.10 transition (Closes:
  #419318)
  - debian/control: Add ${misc:Depends} and remove libgtk2.0-bin on
    uim-gtk2.0.
  - debian/uim-gtk2.0.post{inst,rm}: Removed.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/*
2
2
 
3
 
 Copyright (c) 2003-2006 uim Project http://uim.freedesktop.org/
 
3
 Copyright (c) 2003-2007 uim Project http://uim.freedesktop.org/
4
4
 
5
5
 All rights reserved.
6
6
 
34
34
 
35
35
#include "toolbar-standalone-qt.h"
36
36
#include "toolbar-common-quimhelpertoolbar.h"
 
37
#include "toolbar-common-uimstateindicator.h"
37
38
 
38
39
#include <qapplication.h>
39
40
#include <qpoint.h>
46
47
#include "uim/uim.h"
47
48
#include "qtgettext.h"
48
49
 
 
50
#define TOOLBAR_MARGIN_SIZE     2
 
51
 
49
52
UimStandaloneToolbar::UimStandaloneToolbar( QWidget *parent, const char *name )
50
53
    : QHBox( parent, name, Qt::WStyle_NoBorder | Qt::WX11BypassWM )
51
54
{
55
58
    UimToolbarDraggingHandler *h = new UimToolbarDraggingHandler( this );
56
59
    h->adjustSize();
57
60
    h->show();
 
61
    QObject::connect( h, SIGNAL( handleDoubleClicked() ),
 
62
                      this, SLOT( slotToolbarDoubleClicked() ) );
 
63
 
58
64
    
59
 
    QUimHelperToolbar *b = new QUimHelperToolbar( this );
60
 
    b->adjustSize();
61
 
    b->show();
62
 
    QObject::connect( b, SIGNAL( toolbarResized() ), this, SLOT( slotToolbarResized() ) );
 
65
    toolbar = new QUimHelperToolbar( this );
 
66
    toolbar->adjustSize();
 
67
    toolbar->show();
 
68
    QObject::connect( toolbar, SIGNAL( toolbarResized() ), this, SLOT( slotToolbarResized() ) );
 
69
    toolbar->setMargin(TOOLBAR_MARGIN_SIZE);
63
70
 
64
71
    // Move
65
72
    int panelHeight = 64; // FIXME!
73
80
                      this, SLOT( move( const QPoint & ) ) );
74
81
 
75
82
    // Quit
76
 
    QObject::connect( b, SIGNAL( quitToolbar() ),
 
83
    QObject::connect( toolbar, SIGNAL( quitToolbar() ),
77
84
                      qApp, SLOT( quit() ) );
78
85
 
79
86
    show();
89
96
    adjustSize();
90
97
}
91
98
 
 
99
void
 
100
UimStandaloneToolbar::slotToolbarDoubleClicked()
 
101
{
 
102
    if (toolbar->isVisible())
 
103
      toolbar->hide();
 
104
    else
 
105
      toolbar->show();
 
106
    adjustSize();
 
107
}
 
108
 
92
109
UimToolbarDraggingHandler::UimToolbarDraggingHandler( QWidget *parent,
93
110
        const char* name )
94
111
        : QFrame( parent, name ),
111
128
 
112
129
QSize UimToolbarDraggingHandler::sizeHint() const
113
130
{
114
 
    const int dim = style().pixelMetric( QStyle::PM_DockWindowSeparatorExtent, this );
115
 
    return QSize( dim, 0 );
 
131
    int width, height;
 
132
    
 
133
    width = style().pixelMetric( QStyle::PM_DockWindowSeparatorExtent, this );
 
134
    height = BUTTON_SIZE + TOOLBAR_MARGIN_SIZE * 2;
 
135
 
 
136
    return QSize( width, height );
116
137
}
117
138
 
118
139
QSizePolicy UimToolbarDraggingHandler::sizePolicy() const
123
144
void UimToolbarDraggingHandler::mousePressEvent( QMouseEvent * /* e */ )
124
145
{
125
146
    isDragging = true;
 
147
    grabMouse( QCursor( Qt::SizeAllCursor) );
 
148
 
 
149
    offsetX = QCursor::pos().x() - this->parentWidget()->x();
 
150
    offsetY = QCursor::pos().y() - this->parentWidget()->y();
126
151
}
127
152
 
128
153
void UimToolbarDraggingHandler::mouseReleaseEvent( QMouseEvent * /* e */ )
129
154
{
130
155
    isDragging = false;
 
156
    releaseMouse();
131
157
}
132
158
 
133
159
void UimToolbarDraggingHandler::mouseMoveEvent( QMouseEvent * /* e */ )
134
160
{
135
 
    if ( isDragging )
136
 
        emit moveTo( QCursor::pos() );
 
161
    if ( isDragging ) {
 
162
        QPoint pos = QCursor::pos();
 
163
        pos -= QPoint(offsetX, offsetY);
 
164
        emit moveTo( pos );
 
165
    }
 
166
}
 
167
 
 
168
void UimToolbarDraggingHandler::mouseDoubleClickEvent( QMouseEvent * /* e */ )
 
169
{
 
170
    isDragging = false;
 
171
    emit handleDoubleClicked();
137
172
}
138
173
 
139
174
int main( int argc, char *argv[] )