summaryrefslogtreecommitdiffstats
path: root/kregexpeditor/qt-only/compat.cpp
blob: 7dbc7b48da63ed3708c2b6ce139a77a8d40279d9 (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"

QString i18n( const QString& a) {
    return QObject::tr(a);
}

QString i18n( const QString& a, const QString& b) {
    return QObject::tr(b,a);
}

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

KDialogBase::KDialogBase( QWidget* parent, const char* name, bool modal,
                          const QString& caption, int buttonMask )
        : QDialog( parent, name, modal )
{
    init( buttonMask, Ok, caption );
}

void KDialogBase::init( int buttonMask, ButtonCode /*defaultButton*/, const QString& caption )
{
    setCaption( caption );
    _layout = new QVBoxLayout( this, 6 );
    QHBoxLayout* buts = new QHBoxLayout( _layout, 6 );
    QPushButton* but;
    if ( buttonMask & Help ) {
        but = new QPushButton( tr("Help"), this );
        buts->addWidget( but );
        connect( but, SIGNAL( clicked() ), this, SIGNAL( helpClicked() ) );
    }
    buts->addStretch(1);
    if ( buttonMask & Ok ) {
        but = new QPushButton( tr("OK"), this );
        buts->addWidget( but );
        connect( but, SIGNAL( clicked() ), this, SLOT( slotOk() ) );
    }
    if ( buttonMask & Cancel ) {
        but = new QPushButton( tr("Cancel"), this );
        buts->addWidget( but );
        connect( but, SIGNAL( clicked() ), this, SLOT( slotCancel() ) );
    }
}

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

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

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

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

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

int KMessageBox::information( QWidget* parent, const QString& text, const QString& caption,
                              const QString& /*dontShowAgainName*/ )
{
    return QMessageBox::information( parent, caption, text );
}

int KMessageBox::sorry( QWidget* parent, const QString& text, const QString& caption )
{
    return QMessageBox::information( parent, caption, text );
}