summaryrefslogtreecommitdiffstats
path: root/kregexpeditor/qt-only/compat.cpp
blob: 2d3315a0ab25d66ec5cb441d217109e9b2fb6511 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
/*
 *  Copyright (c) 2002-2004 Jesper K. Pedersen <blackie@kde.org>
 *
 *  This library is free software; you can redistribute it and/or
 *  modify it under the terms of the GNU Library General Public
 *  License version 2 as published by the Free Software Foundation.
 *
 *  This library 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
 *  Library General Public License for more details.
 *
 *  You should have received a copy of the GNU Library General Public License
 *  along with this library; see the file COPYING.LIB.  If not, write to
 *  the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
 *  Boston, MA 02110-1301, USA.
 **/

#include "compat.h"

TQString i18n( const TQString& a) {
    return TQObject::tr(a);
}

TQString i18n( const TQString& a, const TQString& b) {
    return TQObject::tr(b,a);
}

KDialogBase::KDialogBase( int /*dialogFace*/, const TQString &caption, int buttonMask,
                          ButtonCode defaultButton, TQWidget *parent, const char *name,
                          bool modal )
    :TQDialog( parent, name, modal )
{
    init( buttonMask, defaultButton, caption );
}

KDialogBase::KDialogBase( TQWidget* parent, const char* name, bool modal,
                          const TQString& caption, int buttonMask )
        : TQDialog( parent, name, modal )
{
    init( buttonMask, Ok, caption );
}

void KDialogBase::init( int buttonMask, ButtonCode /*defaultButton*/, const TQString& caption )
{
    setCaption( caption );
    _layout = new TQVBoxLayout( this, 6 );
    TQHBoxLayout* buts = new TQHBoxLayout( _layout, 6 );
    TQPushButton* but;
    if ( buttonMask & Help ) {
        but = new TQPushButton( tr("Help"), this );
        buts->addWidget( but );
        connect( but, TQ_SIGNAL( clicked() ), this, TQ_SIGNAL( helpClicked() ) );
    }
    buts->addStretch(1);
    if ( buttonMask & Ok ) {
        but = new TQPushButton( tr("OK"), this );
        buts->addWidget( but );
        connect( but, TQ_SIGNAL( clicked() ), this, TQ_SLOT( slotOk() ) );
    }
    if ( buttonMask & Cancel ) {
        but = new TQPushButton( tr("Cancel"), this );
        buts->addWidget( but );
        connect( but, TQ_SIGNAL( clicked() ), this, TQ_SLOT( slotCancel() ) );
    }
}

void KDialogBase::setMainWidget( TQWidget* top )
{
    top->reparent( this, 0, TQPoint(0,0) );
    _layout->insertWidget( 0, top );
}

TQFrame* KDialogBase::plainPage()
{
    TQFrame* frame = new TQFrame( this );
    setMainWidget( frame );
    return frame;
}

void KDialogBase::slotOk()
{
    accept();
    emit okClicked();
    emit finished();
}

void KDialogBase::slotCancel()
{
    reject();
    emit cancelClicked();
    emit finished();
}

int KMessageBox::warningYesNo(TQWidget *parent, const TQString &text, const TQString &caption )
{
    int code = warning( parent, caption, text, tr("No"), tr("Yes") );
    if ( code == 0 )
        return Yes;
    else
        return No;
}

int KMessageBox::information( TQWidget* parent, const TQString& text, const TQString& caption,
                              const TQString& /*dontShowAgainName*/ )
{
    return TQMessageBox::information( parent, caption, text );
}

int KMessageBox::sorry( TQWidget* parent, const TQString& text, const TQString& caption )
{
    return TQMessageBox::information( parent, caption, text );
}