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

« back to all changes in this revision

Viewing changes to qt/toolbar-common-quimhelpertoolbar.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Masahito Omote
  • Date: 2005-12-04 13:10:42 UTC
  • mfrom: (1.1.2 upstream)
  • Revision ID: james.westby@ubuntu.com-20051204131042-ktzc8b17zi7a3cw8
Tags: 1:0.4.9.1-1
* New upstream release
* libuim0-nox, libuim-nox-dev, and libuim0-dbg-nox is now obsolete.
  Because libuim0 does not depends on X11. They now become dummy package,
  therefore you can safely remove them.
* Add --enable-debug in configure again.
* debian/patches/08_fix_privilage_escalation_CVE_2005_3149: disabled.
* Fix Error on purge because update-uim-config is not found.
  (closes: Bug#339345)
* uim-qt: New package for Qt utilities for uim. qt-immodule does not
  contained yet because of Debian's Qt3 does not support immodule and
  because uim does not recognize libqt4-dev's headers properly. 

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 
 
3
 Copyright (c) 2003,2004,2005 uim Project http://uim.freedesktop.org/
 
4
 
 
5
 All rights reserved.
 
6
 
 
7
 Redistribution and use in source and binary forms, with or without
 
8
 modification, are permitted provided that the following conditions
 
9
 are met:
 
10
 
 
11
 1. Redistributions of source code must retain the above copyright
 
12
    notice, this list of conditions and the following disclaimer.
 
13
 2. Redistributions in binary form must reproduce the above copyright
 
14
    notice, this list of conditions and the following disclaimer in the
 
15
    documentation and/or other materials provided with the distribution.
 
16
 3. Neither the name of authors nor the names of its contributors
 
17
    may be used to endorse or promote products derived from this software
 
18
    without specific prior written permission.
 
19
 
 
20
 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS'' AND
 
21
 ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
 
22
 IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
 
23
 ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE
 
24
 FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
 
25
 DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
 
26
 OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
 
27
 HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
 
28
 LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
 
29
 OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
 
30
 SUCH DAMAGE.
 
31
 
 
32
*/
 
33
#include "toolbar-common-quimhelpertoolbar.h"
 
34
#include "toolbar-common-uimstateindicator.h"
 
35
 
 
36
#include <qtooltip.h>
 
37
#include <qtoolbutton.h>
 
38
 
 
39
#include <stdlib.h>
 
40
 
 
41
#include "uim/uim-compat-scm.h"
 
42
#include "qtgettext.h"
 
43
 
 
44
static const QString ICONDIR = UIM_PIXMAPSDIR;
 
45
 
 
46
QUimHelperToolbar::QUimHelperToolbar( QWidget *parent, const char *name, WFlags f )
 
47
    : QHBox( parent, name, f )
 
48
{
 
49
    new UimStateIndicator( this );
 
50
 
 
51
    m_swicon = QPixmap( ICONDIR + "/switcher-icon.png" );
 
52
    m_preficon = QPixmap( ICONDIR + "/configure-qt.png");
 
53
 
 
54
    m_contextMenu = new QPopupMenu( this );
 
55
    m_contextMenu->insertItem( m_swicon,   _("Execute uim's input method switcher"), this, SLOT(slotExecImSwitcher()) );
 
56
    m_contextMenu->insertItem( m_preficon, _("Execute uim's preference tool"), this, SLOT(slotExecPref()) );
 
57
    m_contextMenu->insertItem( _("Execute uim's Japanese dictionary tool"), this, SLOT(slotExecDict()) );
 
58
    m_contextMenu->insertItem( _("Execute uim's input pad tool"), this, SLOT(slotExecInputPad()) );
 
59
    m_contextMenu->insertItem( _("Execute uim's handwriting input pad tool"), this, SLOT(slotExecHandwritingInputPad()) );
 
60
    m_contextMenu->insertItem( _("Execute uim's help tool"), this, SLOT(slotExecHelp()) );
 
61
    m_contextMenu->insertItem( _("Quit this toolbar"), this, SIGNAL(quitToolbar()) );
 
62
 
 
63
    // toolbar buttons    
 
64
    addExecImSwitcherButton();
 
65
    addExecPrefButton();
 
66
    addExecDictButton();
 
67
    addExecInputPadButton();
 
68
    addExecHandwritingInputPadButton();
 
69
    addExecHelpButton();
 
70
}
 
71
 
 
72
QUimHelperToolbar::~QUimHelperToolbar()
 
73
{
 
74
}
 
75
 
 
76
void QUimHelperToolbar::contextMenuEvent( QContextMenuEvent * e )
 
77
{
 
78
    if( !m_contextMenu->isShown() )
 
79
    {
 
80
        m_contextMenu->move( e->globalPos() );
 
81
        m_contextMenu->exec();
 
82
    }
 
83
}
 
84
 
 
85
void QUimHelperToolbar::addExecImSwitcherButton()
 
86
{
 
87
    uim_bool isShowSwitcher = uim_scm_symbol_value_bool("toolbar-show-switcher-button?");
 
88
    if( isShowSwitcher == UIM_FALSE )
 
89
        return;
 
90
 
 
91
    QToolButton * swButton = new QHelperToolbarButton( this );
 
92
    if( !m_swicon.isNull() )
 
93
        swButton->setPixmap( m_swicon );
 
94
    else
 
95
        swButton->setText( "Sw" );
 
96
 
 
97
    QObject::connect( swButton, SIGNAL( clicked() ),
 
98
                      this, SLOT( slotExecImSwitcher() ) );
 
99
    QToolTip::add( swButton, _( "exec im-switcher" ) );
 
100
}
 
101
 
 
102
 
 
103
void QUimHelperToolbar::slotExecImSwitcher()
 
104
{
 
105
    /* exec uim-im-switcher */
 
106
    system( "uim-im-switcher-qt &" );
 
107
}
 
108
 
 
109
void QUimHelperToolbar::addExecPrefButton()
 
110
{
 
111
    uim_bool isShowPref = uim_scm_symbol_value_bool("toolbar-show-pref-button?");
 
112
    if( isShowPref == UIM_FALSE )
 
113
        return;
 
114
    
 
115
    QToolButton * prefButton = new QHelperToolbarButton( this );
 
116
    if( !m_preficon.isNull() )
 
117
        prefButton->setPixmap( m_preficon );
 
118
    else
 
119
        prefButton->setText( "Pref" );
 
120
 
 
121
    QObject::connect( prefButton, SIGNAL( clicked() ),
 
122
                      this, SLOT( slotExecPref() ) );
 
123
    QToolTip::add( prefButton, _( "exec Preference Application" ) );
 
124
}
 
125
 
 
126
void QUimHelperToolbar::slotExecPref()
 
127
{
 
128
    /* exec uim-pref-qt */
 
129
    system( "uim-pref-qt &" );
 
130
}
 
131
 
 
132
void QUimHelperToolbar::addExecDictButton()
 
133
{
 
134
    uim_bool isShowDict = uim_scm_symbol_value_bool("toolbar-show-dict-button?");
 
135
    if( isShowDict == UIM_FALSE )
 
136
        return;
 
137
 
 
138
    QToolButton *dictButton = new QHelperToolbarButton( this );
 
139
    dictButton->setText( "Dic" );
 
140
 
 
141
    QObject::connect( dictButton, SIGNAL( clicked() ),
 
142
                      this, SLOT( slotExecDict() ) );
 
143
    QToolTip::add( dictButton, _( "exec Japanese dictionary Tool Application" ) );
 
144
}
 
145
 
 
146
void QUimHelperToolbar::slotExecDict()
 
147
{
 
148
    /* exec uim-dict */
 
149
    system( "uim-dict-gtk&" );
 
150
}
 
151
 
 
152
void QUimHelperToolbar::addExecInputPadButton()
 
153
{
 
154
    uim_bool isShowInputPad = uim_scm_symbol_value_bool("toolbar-show-input-pad-button?");
 
155
    if( isShowInputPad == UIM_FALSE )
 
156
        return;
 
157
 
 
158
    QToolButton *inputpadButton = new QHelperToolbarButton( this );
 
159
    inputpadButton->setText( "Pad" );
 
160
 
 
161
    QObject::connect( inputpadButton, SIGNAL( clicked() ),
 
162
                      this, SLOT( slotExecInputPad() ) );
 
163
    QToolTip::add( inputpadButton, _( "exec Input Pad Tool Application" ) );
 
164
}
 
165
 
 
166
void QUimHelperToolbar::slotExecInputPad()
 
167
{
 
168
    /* exec input pad */
 
169
    system( "uim-chardict-qt &");
 
170
}
 
171
 
 
172
void QUimHelperToolbar::addExecHandwritingInputPadButton()
 
173
{
 
174
    uim_bool isShowHandwritingInputPad = uim_scm_symbol_value_bool("toolbar-show-handwriting-input-pad-button?");
 
175
    if( isShowHandwritingInputPad == UIM_FALSE )
 
176
        return;
 
177
 
 
178
    QToolButton *inputpadButton = new QHelperToolbarButton( this );
 
179
    inputpadButton->setText( "Hand" );
 
180
 
 
181
    QObject::connect( inputpadButton, SIGNAL( clicked() ),
 
182
                      this, SLOT( slotExecHandwritingInputPad() ) );
 
183
    QToolTip::add( inputpadButton, _( "exec Handwriting Input Pad Tool Application" ) );
 
184
}
 
185
 
 
186
void QUimHelperToolbar::slotExecHandwritingInputPad()
 
187
{
 
188
    system( "uim-tomoe-gtk &" );
 
189
}
 
190
 
 
191
void QUimHelperToolbar::addExecHelpButton()
 
192
{
 
193
    uim_bool isShowHelp = uim_scm_symbol_value_bool("toolbar-show-help-button?");
 
194
    if( isShowHelp == UIM_FALSE )
 
195
        return;
 
196
 
 
197
    QToolButton *helpButton = new QHelperToolbarButton( this );
 
198
    helpButton->setText( "Help" );
 
199
 
 
200
    QObject::connect( helpButton, SIGNAL( clicked() ),
 
201
                      this, SLOT( slotExecHelp() ) );
 
202
    QToolTip::add( helpButton, _( "exec Help Application" ) );
 
203
}
 
204
 
 
205
void QUimHelperToolbar::slotExecHelp()
 
206
{
 
207
    system( "uim-help &" );
 
208
}
 
209
 
 
210
#include "toolbar-common-quimhelpertoolbar.moc"