~jl2/Google-Translate-Qt-GUI

5049c90757bdc4d3d280e504cdf59bfaa5848292 — Jeremiah LaRocco 12 years ago
Initial import.
8 files changed, 757 insertions(+), 0 deletions(-)

A Makefile
A gtrans.cpp
A gtrans.h
A gtrans.pl
A main.cpp
A moc_gtrans.cpp
A qgtrans
A qgtrans.pro
A  => Makefile +211 -0
@@ 1,211 @@
#############################################################################
# Makefile for building: qgtrans
# Generated by qmake (2.01a) (Qt 4.5.3) on: Thu Mar 18 18:56:43 2010
# Project:  qgtrans.pro
# Template: app
# Command: /usr/bin/qmake -unix -o Makefile qgtrans.pro
#############################################################################

####### Compiler, tools and options

CC            = gcc
CXX           = g++
DEFINES       = -DQT_NO_DEBUG -DQT_GUI_LIB -DQT_NETWORK_LIB -DQT_CORE_LIB -DQT_SHARED
CFLAGS        = -pipe -O2 -Wall -W -D_REENTRANT $(DEFINES)
CXXFLAGS      = -pipe -O2 -Wall -W -D_REENTRANT $(DEFINES)
INCPATH       = -I/usr/share/qt4/mkspecs/linux-g++ -I. -I/usr/include/qt4/QtCore -I/usr/include/qt4/QtNetwork -I/usr/include/qt4/QtGui -I/usr/include/qt4 -I. -I.
LINK          = g++
LFLAGS        = -Wl,-O1
LIBS          = $(SUBLIBS)  -L/usr/lib -lQtGui -lQtNetwork -lQtCore -lpthread
AR            = ar cqs
RANLIB        = 
QMAKE         = /usr/bin/qmake
TAR           = tar -cf
COMPRESS      = gzip -9f
COPY          = cp -f
SED           = sed
COPY_FILE     = $(COPY)
COPY_DIR      = $(COPY) -r
INSTALL_FILE  = install -m 644 -p
INSTALL_DIR   = $(COPY_DIR)
INSTALL_PROGRAM = install -m 755 -p
DEL_FILE      = rm -f
SYMLINK       = ln -sf
DEL_DIR       = rmdir
MOVE          = mv -f
CHK_DIR_EXISTS= test -d
MKDIR         = mkdir -p

####### Output directory

OBJECTS_DIR   = ./

####### Files

SOURCES       = gtrans.cpp \
		main.cpp moc_gtrans.cpp
OBJECTS       = gtrans.o \
		main.o \
		moc_gtrans.o
DIST          = /usr/share/qt4/mkspecs/common/g++.conf \
		/usr/share/qt4/mkspecs/common/unix.conf \
		/usr/share/qt4/mkspecs/common/linux.conf \
		/usr/share/qt4/mkspecs/qconfig.pri \
		/usr/share/qt4/mkspecs/features/qt_functions.prf \
		/usr/share/qt4/mkspecs/features/qt_config.prf \
		/usr/share/qt4/mkspecs/features/exclusive_builds.prf \
		/usr/share/qt4/mkspecs/features/default_pre.prf \
		/usr/share/qt4/mkspecs/features/release.prf \
		/usr/share/qt4/mkspecs/features/default_post.prf \
		/usr/share/qt4/mkspecs/features/warn_on.prf \
		/usr/share/qt4/mkspecs/features/qt.prf \
		/usr/share/qt4/mkspecs/features/unix/thread.prf \
		/usr/share/qt4/mkspecs/features/moc.prf \
		/usr/share/qt4/mkspecs/features/resources.prf \
		/usr/share/qt4/mkspecs/features/uic.prf \
		/usr/share/qt4/mkspecs/features/yacc.prf \
		/usr/share/qt4/mkspecs/features/lex.prf \
		/usr/share/qt4/mkspecs/features/include_source_dir.prf \
		qgtrans.pro
QMAKE_TARGET  = qgtrans
DESTDIR       = 
TARGET        = qgtrans

first: all
####### Implicit rules

.SUFFIXES: .o .c .cpp .cc .cxx .C

.cpp.o:
	$(CXX) -c $(CXXFLAGS) $(INCPATH) -o "$@" "$<"

.cc.o:
	$(CXX) -c $(CXXFLAGS) $(INCPATH) -o "$@" "$<"

.cxx.o:
	$(CXX) -c $(CXXFLAGS) $(INCPATH) -o "$@" "$<"

.C.o:
	$(CXX) -c $(CXXFLAGS) $(INCPATH) -o "$@" "$<"

.c.o:
	$(CC) -c $(CFLAGS) $(INCPATH) -o "$@" "$<"

####### Build rules

all: Makefile $(TARGET)

$(TARGET):  $(OBJECTS)  
	$(LINK) $(LFLAGS) -o $(TARGET) $(OBJECTS) $(OBJCOMP) $(LIBS)

Makefile: qgtrans.pro  /usr/share/qt4/mkspecs/linux-g++/qmake.conf /usr/share/qt4/mkspecs/common/g++.conf \
		/usr/share/qt4/mkspecs/common/unix.conf \
		/usr/share/qt4/mkspecs/common/linux.conf \
		/usr/share/qt4/mkspecs/qconfig.pri \
		/usr/share/qt4/mkspecs/features/qt_functions.prf \
		/usr/share/qt4/mkspecs/features/qt_config.prf \
		/usr/share/qt4/mkspecs/features/exclusive_builds.prf \
		/usr/share/qt4/mkspecs/features/default_pre.prf \
		/usr/share/qt4/mkspecs/features/release.prf \
		/usr/share/qt4/mkspecs/features/default_post.prf \
		/usr/share/qt4/mkspecs/features/warn_on.prf \
		/usr/share/qt4/mkspecs/features/qt.prf \
		/usr/share/qt4/mkspecs/features/unix/thread.prf \
		/usr/share/qt4/mkspecs/features/moc.prf \
		/usr/share/qt4/mkspecs/features/resources.prf \
		/usr/share/qt4/mkspecs/features/uic.prf \
		/usr/share/qt4/mkspecs/features/yacc.prf \
		/usr/share/qt4/mkspecs/features/lex.prf \
		/usr/share/qt4/mkspecs/features/include_source_dir.prf \
		/usr/lib/libQtGui.prl \
		/usr/lib/libQtNetwork.prl \
		/usr/lib/libQtCore.prl
	$(QMAKE) -unix -o Makefile qgtrans.pro
/usr/share/qt4/mkspecs/common/g++.conf:
/usr/share/qt4/mkspecs/common/unix.conf:
/usr/share/qt4/mkspecs/common/linux.conf:
/usr/share/qt4/mkspecs/qconfig.pri:
/usr/share/qt4/mkspecs/features/qt_functions.prf:
/usr/share/qt4/mkspecs/features/qt_config.prf:
/usr/share/qt4/mkspecs/features/exclusive_builds.prf:
/usr/share/qt4/mkspecs/features/default_pre.prf:
/usr/share/qt4/mkspecs/features/release.prf:
/usr/share/qt4/mkspecs/features/default_post.prf:
/usr/share/qt4/mkspecs/features/warn_on.prf:
/usr/share/qt4/mkspecs/features/qt.prf:
/usr/share/qt4/mkspecs/features/unix/thread.prf:
/usr/share/qt4/mkspecs/features/moc.prf:
/usr/share/qt4/mkspecs/features/resources.prf:
/usr/share/qt4/mkspecs/features/uic.prf:
/usr/share/qt4/mkspecs/features/yacc.prf:
/usr/share/qt4/mkspecs/features/lex.prf:
/usr/share/qt4/mkspecs/features/include_source_dir.prf:
/usr/lib/libQtGui.prl:
/usr/lib/libQtNetwork.prl:
/usr/lib/libQtCore.prl:
qmake:  FORCE
	@$(QMAKE) -unix -o Makefile qgtrans.pro

dist: 
	@$(CHK_DIR_EXISTS) .tmp/qgtrans1.0.0 || $(MKDIR) .tmp/qgtrans1.0.0 
	$(COPY_FILE) --parents $(SOURCES) $(DIST) .tmp/qgtrans1.0.0/ && $(COPY_FILE) --parents gtrans.h .tmp/qgtrans1.0.0/ && $(COPY_FILE) --parents gtrans.cpp main.cpp .tmp/qgtrans1.0.0/ && (cd `dirname .tmp/qgtrans1.0.0` && $(TAR) qgtrans1.0.0.tar qgtrans1.0.0 && $(COMPRESS) qgtrans1.0.0.tar) && $(MOVE) `dirname .tmp/qgtrans1.0.0`/qgtrans1.0.0.tar.gz . && $(DEL_FILE) -r .tmp/qgtrans1.0.0


clean:compiler_clean 
	-$(DEL_FILE) $(OBJECTS)
	-$(DEL_FILE) *~ core *.core


####### Sub-libraries

distclean: clean
	-$(DEL_FILE) $(TARGET) 
	-$(DEL_FILE) Makefile


mocclean: compiler_moc_header_clean compiler_moc_source_clean

mocables: compiler_moc_header_make_all compiler_moc_source_make_all

compiler_moc_header_make_all: moc_gtrans.cpp
compiler_moc_header_clean:
	-$(DEL_FILE) moc_gtrans.cpp
moc_gtrans.cpp: gtrans.h
	/usr/bin/moc-qt4 $(DEFINES) $(INCPATH) gtrans.h -o moc_gtrans.cpp

compiler_rcc_make_all:
compiler_rcc_clean:
compiler_image_collection_make_all: qmake_image_collection.cpp
compiler_image_collection_clean:
	-$(DEL_FILE) qmake_image_collection.cpp
compiler_moc_source_make_all:
compiler_moc_source_clean:
compiler_uic_make_all:
compiler_uic_clean:
compiler_yacc_decl_make_all:
compiler_yacc_decl_clean:
compiler_yacc_impl_make_all:
compiler_yacc_impl_clean:
compiler_lex_make_all:
compiler_lex_clean:
compiler_clean: compiler_moc_header_clean 

####### Compile

gtrans.o: gtrans.cpp gtrans.h
	$(CXX) -c $(CXXFLAGS) $(INCPATH) -o gtrans.o gtrans.cpp

main.o: main.cpp gtrans.h
	$(CXX) -c $(CXXFLAGS) $(INCPATH) -o main.o main.cpp

moc_gtrans.o: moc_gtrans.cpp 
	$(CXX) -c $(CXXFLAGS) $(INCPATH) -o moc_gtrans.o moc_gtrans.cpp

####### Install

install:   FORCE

uninstall:   FORCE

FORCE:


A  => gtrans.cpp +214 -0
@@ 1,214 @@
// gtrans.cpp

// Copyright (c) 2010, Jeremiah LaRocco jlarocco@jlarocco.com

// Permission to use, copy, modify, and/or distribute this software for any
// purpose with or without fee is hereby granted, provided that the above
// copyright notice and this permission notice appear in all copies.

// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
// WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
// MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
// ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
// WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
// ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
// OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.

#include "gtrans.h"

#include <QtGui>
#include <QMap>

#include <QNetworkAccessManager>
#include <QUrl>
#include <QNetworkRequest>
#include <QNetworkReply>

void GTrans::fillInLanguages() {
    if (languages.size()==0) {
        languages[tr("French")] = tr("fr");
        languages[tr("Spanish")] = tr("es");
        languages[tr("Afrikaans")] = tr("af");
        languages[tr("Albanian")] = tr("sq");
                         
        languages[tr("Arabic")] = tr("ar");
        languages[tr("Belarusian")] = tr("be");
        languages[tr("Bulgarian")] = tr("bg");
        languages[tr("Catalan")] = tr("ca");
        languages[tr("Chinese")] = tr("zh-cn");
                         
        languages[tr("Croatian")] = tr("hr");
        languages[tr("Czech")] = tr("cs");
        languages[tr("Danish")] = tr("da");
        languages[tr("Dutch")] = tr("nl");
        languages[tr("English")] = tr("en");
        languages[tr("Estonian")] = tr("et");
                         
        languages[tr("Filipino")] = tr("tl");
        languages[tr("Finnish")] = tr("fi");
        languages[tr("French")] = tr("fr");
        languages[tr("Galician")] = tr("gl");
        languages[tr("German")] = tr("de");
        languages[tr("Greek")] = tr("el");
                         
        languages[tr("Haitian creole alpha")] = tr("ht");
        languages[tr("Hebrew")] = tr("iw");
        languages[tr("Hindi")] = tr("hi");
        languages[tr("Hungarian")] = tr("hu");
        languages[tr("Icelandic")] = tr("is");
                         
        languages[tr("Indonesian")] = tr("id");
        languages[tr("Irish")] = tr("ga");
        languages[tr("Italian")] = tr("it");
        languages[tr("Japanese")] = tr("ja");
        languages[tr("Korean")] = tr("ko");
                         
        languages[tr("Latvian")] = tr("lv");
        languages[tr("Lithuanian")] = tr("lt");
        languages[tr("Macedonian")] = tr("mk");
        languages[tr("Malay")] = tr("ms");
        languages[tr("Maltese")] = tr("mt");
                         
        languages[tr("Norwegian")] = tr("no");
        languages[tr("Persian")] = tr("fa");
        languages[tr("Polish")] = tr("pl");
        languages[tr("Portuguese")] = tr("pt");
        languages[tr("Romanian")] = tr("ro");
                         
        languages[tr("Russian")] = tr("ru");
        languages[tr("Serbian")] = tr("sr");
        languages[tr("Slovak")] = tr("sk");
        languages[tr("Slovenian")] = tr("sl");
        languages[tr("Spanish")] = tr("es");
                         
        languages[tr("Swahili")] = tr("sw");
        languages[tr("Swedish")] = tr("sv");
        languages[tr("Thai")] = tr("th");
        languages[tr("Turkish")] = tr("tr");
        languages[tr("Ukrainian")] = tr("uk");
                         
        languages[tr("Vietnamese")] = tr("vi");
        languages[tr("Welsh")] = tr("cy");
        languages[tr("Yiddish")]= tr("yi");
    }
    fromLang->addItems(languages.keys());
    toLang->addItems(languages.keys());

    fromLang->setCurrentIndex(fromLang->findText(tr("English")));
    toLang->setCurrentIndex(toLang->findText(tr("French")));
}

GTrans::GTrans() {
    QLayout *mainLayout = new QVBoxLayout;

    // The input section
    QLayout *top = new QHBoxLayout;
    QBoxLayout *tl = new QVBoxLayout;
    QLabel *inLabel = new QLabel(tr("Input:"));
    fromLang = new QComboBox;
    tl->addWidget(inLabel);
    tl->addSpacing(10);
    tl->addWidget(fromLang);
    tl->addStretch();
    top->addItem(tl);
    inputTxt = new QTextEdit;

    top->addWidget(inputTxt);

    // The output section
    QLayout *bottom = new QHBoxLayout;
    QBoxLayout *bl = new QVBoxLayout;
    QLabel *outLabel = new QLabel(tr("Output:"));
    toLang = new QComboBox;
    bl->addWidget(outLabel);
    bl->addSpacing(10);
    bl->addWidget(toLang);
    bl->addStretch();
    bottom->addItem(bl);
    outputTxt = new QTextEdit;
    outputTxt->setReadOnly(true);
    bottom->addWidget(outputTxt);

    mainLayout->addItem(top);
    mainLayout->addItem(bottom);

    // Translate button
    trans_b = new QPushButton(tr("Translate"));
    mainLayout->addWidget(trans_b);

    fillInLanguages();

    setLayout(mainLayout);
    setWindowTitle(tr("Translate"));
    
    trans_b->setDefault(true);
    connect(trans_b, SIGNAL(clicked()), this, SLOT(doTrans()));

    // Setup foxus and tab order.
    inputTxt->setTabChangesFocus(true);
    inputTxt->setFocus(Qt::ActiveWindowFocusReason);
    setTabOrder(inputTxt, toLang);
    setTabOrder(toLang, trans_b);
    setTabOrder(trans_b, fromLang);
    setTabOrder(fromLang, inputTxt);
    outputTxt->setFocusProxy(trans_b);
}

void GTrans::doTrans() {
    nam = new QNetworkAccessManager(this);

    // Figure out the URL for translate.google.com
    QStringList words = inputTxt->toPlainText().split(QRegExp("\\s+"));
    QString gtUrl = tr("http://translate.google.com/translate_t?langpair=%1|%2&text=").arg(languages[fromLang->currentText()]).arg(languages[toLang->currentText()]) + words.join("+");

    QUrl url(gtUrl);

    QNetworkRequest qnr(url);

    // Google checks for certain user agents, so spoof one
    qnr.setRawHeader("User-Agent", "");

    // Make the request.
    nam->get(qnr);

    // Tell it to get back to us...
    connect(nam, SIGNAL(finished(QNetworkReply*)),
            this, SLOT(finishedSlot(QNetworkReply*)));

    // Go back to the text input
    inputTxt->selectAll();
    inputTxt->setFocus();
}

void GTrans::finishedSlot(QNetworkReply* reply) {

    // The request finished, so check for an error
    if (reply->error() == QNetworkReply::NoError) {

        
        // Find the translated string - this is a bit of a hack, but works and is easier than parsing the HTML...
        QRegExp rx(tr("input type=hidden name=gtrans value=\"(.*)\"><div id=sug_exp>"));
        QString rep(reply->readAll());
        rep.replace("\n", " ");

        // Check that the translated text was found
        if (rx.indexIn(rep) != -1) {
            // The text in rx.cap(1) is html character encoded so that "&" => "&amp;"
            // That f's up QTextEdit's "setHtml", so fix it
            QString tmp = rx.cap(1);
            tmp.replace(tr("&amp;"), tr("&"));
            
            // Display the results
            outputTxt->setHtml(tmp);
            
        } else {
            outputTxt->setPlainText(tr("Could not find translated string in result..."));
        }
    } else {
        outputTxt->setPlainText(tr("A network error occured."));
    }
    
    // Schedule old network stuff for deletion
    reply->deleteLater();
    nam->deleteLater();
}

A  => gtrans.h +53 -0
@@ 1,53 @@
// gtrans.h

// Copyright (c) 2010, Jeremiah LaRocco jlarocco@jlarocco.com

// Permission to use, copy, modify, and/or distribute this software for any
// purpose with or without fee is hereby granted, provided that the above
// copyright notice and this permission notice appear in all copies.

// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
// WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
// MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
// ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
// WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
// ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
// OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.

#ifndef GTRANS_H
#define GTRANS_H

#include <QMap>
#include <QString>
#include <QWidget>

class QComboBox;
class QTextEdit;
class QPushButton;
class QNetworkReply;
class QNetworkAccessManager;

class GTrans : public QWidget {
    Q_OBJECT;

public:
    GTrans();

public slots:
    void doTrans();
    void finishedSlot(QNetworkReply* reply);

private:
    QTextEdit *inputTxt;
    QTextEdit *outputTxt;
    QComboBox *toLang;
    QComboBox *fromLang;

    QPushButton *trans_b;
    QMap<QString, QString> languages;

    void fillInLanguages();
    QNetworkAccessManager* nam;
};

#endif

A  => gtrans.pl +96 -0
@@ 1,96 @@
#!/usr/bin/perl

use strict;
use warnings;

require LWP::UserAgent;
use Getopt::Long qw(:config pass_through);
use URI::Escape;
use HTML::Entities;

my %languages = ('french'=>'fr', 'spanish'=>'es', 'afrikaans'=>'af', 'albanian'=>'sq',
'arabic'=>'ar', 'belarusian'=>'be', 'bulgarian'=>'bg', 'catalan'=>'ca', 'chinese'=>'zh-cn',
'croatian'=>'hr', 'czech'=>'cs', 'danish'=>'da', 'dutch'=>'nl', 'english'=>'en', 'estonian'=>'et',
'filipino'=>'tl', 'finnish'=>'fi', 'french'=>'fr', 'galician'=>'gl', 'german'=>'de', 'greek'=>'el',
'haitian creole alpha'=>'ht', 'hebrew'=>'iw', 'hindi'=>'hi', 'hungarian'=>'hu', 'icelandic'=>'is',
'indonesian'=>'id', 'irish'=>'ga', 'italian'=>'it', 'japanese'=>'ja', 'korean'=>'ko',
'latvian'=>'lv', 'lithuanian'=>'lt', 'macedonian'=>'mk', 'malay'=>'ms', 'maltese'=>'mt',
'norwegian'=>'no', 'persian'=>'fa', 'polish'=>'pl', 'portuguese'=>'pt', 'romanian'=>'ro',
'russian'=>'ru', 'serbian'=>'sr', 'slovak'=>'sk', 'slovenian'=>'sl', 'spanish'=>'es',
'swahili'=>'sw', 'swedish'=>'sv', 'thai'=>'th', 'turkish'=>'tr', 'ukrainian'=>'uk',
'vietnamese'=>'vi', 'welsh'=>'cy', 'yiddish'=>'yi', );

sub usage {
    my $usage_str = <<END;

Valid command line arguments are:

   $0  [--to <language>] [--from <language>] text...

Optional arguments controlling translation languages:

   --to     Sets the language to translate to
            The default value is English (en)

   --from   Sets the language to translate from
            The default value is French (fr)

Languages can be specified by name (i.e. French) or by their abbreviation (i.e. fr).

Valid languages are:

END
    print $usage_str;
    my $curLine = '';
    
    for my $key (sort keys %languages) {
        $curLine = sprintf('%s %20s %7s  ', $curLine, $key, '('.$languages{$key}.')');
        if (length($curLine)>100) {
            print "$curLine\n";
            $curLine = '';
        }
    }
    print "$curLine\n";
}

sub main {
    my $help;
    my $to = 'en';
    my $from = 'fr';
    
    GetOptions('help!'=>\$help,
               'to=s'=>\$to,
               'from=s'=>\$from);

    if ($help || $#ARGV==-1) {
        usage;
        exit(0);
    }

    if ($languages{lc $from}) {
        $from = $languages{lc $from};
    }
    if ($languages{lc $to}) {
        $to = $languages{lc $to};
    }

    my @words = @ARGV;
    map uri_escape, @words;
    my $url = "http://translate.google.com/translate_t?langpair=$from|$to&text=" . join('+', @words);

    my $ua = LWP::UserAgent->new;
    $ua->agent('');

    my $res = $ua->get($url);
    if ($res->is_success) {
        if ($res->content =~ /<textarea name=utrans wrap=SOFT dir="ltr" id=suggestion style="width:80%;margin:5px 0;overflow:auto">(.*?)<\/textarea>/) {
            my $translated = decode_entities($1);
            print "$translated\n";
        }
    }
    else {
        die $res->status_line;
    }
}

main;

A  => main.cpp +93 -0
@@ 1,93 @@
// main.cpp

// Copyright (c) 2010, Jeremiah LaRocco jlarocco@jlarocco.com

// Permission to use, copy, modify, and/or distribute this software for any
// purpose with or without fee is hereby granted, provided that the above
// copyright notice and this permission notice appear in all copies.

// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
// WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
// MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
// ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
// WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
// ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
// OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.

#include <QApplication>

#include "gtrans.h"

// Boiler plate Qt...

int main(int argc, char *argv[]) {
    QApplication app(argc, argv);

    GTrans window;
    window.show();

    return app.exec();
}
































































A  => moc_gtrans.cpp +76 -0
@@ 1,76 @@
/****************************************************************************
** Meta object code from reading C++ file 'gtrans.h'
**
** Created: Thu Mar 18 18:56:47 2010
**      by: The Qt Meta Object Compiler version 61 (Qt 4.5.3)
**
** WARNING! All changes made in this file will be lost!
*****************************************************************************/

#include "gtrans.h"
#if !defined(Q_MOC_OUTPUT_REVISION)
#error "The header file 'gtrans.h' doesn't include <QObject>."
#elif Q_MOC_OUTPUT_REVISION != 61
#error "This file was generated using the moc from 4.5.3. It"
#error "cannot be used with the include files from this version of Qt."
#error "(The moc has changed too much.)"
#endif

QT_BEGIN_MOC_NAMESPACE
static const uint qt_meta_data_GTrans[] = {

 // content:
       2,       // revision
       0,       // classname
       0,    0, // classinfo
       2,   12, // methods
       0,    0, // properties
       0,    0, // enums/sets
       0,    0, // constructors

 // slots: signature, parameters, type, tag, flags
       8,    7,    7,    7, 0x0a,
      24,   18,    7,    7, 0x0a,

       0        // eod
};

static const char qt_meta_stringdata_GTrans[] = {
    "GTrans\0\0doTrans()\0reply\0"
    "finishedSlot(QNetworkReply*)\0"
};

const QMetaObject GTrans::staticMetaObject = {
    { &QWidget::staticMetaObject, qt_meta_stringdata_GTrans,
      qt_meta_data_GTrans, 0 }
};

const QMetaObject *GTrans::metaObject() const
{
    return &staticMetaObject;
}

void *GTrans::qt_metacast(const char *_clname)
{
    if (!_clname) return 0;
    if (!strcmp(_clname, qt_meta_stringdata_GTrans))
        return static_cast<void*>(const_cast< GTrans*>(this));
    return QWidget::qt_metacast(_clname);
}

int GTrans::qt_metacall(QMetaObject::Call _c, int _id, void **_a)
{
    _id = QWidget::qt_metacall(_c, _id, _a);
    if (_id < 0)
        return _id;
    if (_c == QMetaObject::InvokeMetaMethod) {
        switch (_id) {
        case 0: doTrans(); break;
        case 1: finishedSlot((*reinterpret_cast< QNetworkReply*(*)>(_a[1]))); break;
        default: ;
        }
        _id -= 2;
    }
    return _id;
}
QT_END_MOC_NAMESPACE

A  => qgtrans +0 -0
A  => qgtrans.pro +14 -0
@@ 1,14 @@
######################################################################
# Automatically generated by qmake (2.01a) Tue Mar 16 16:41:30 2010
######################################################################

TEMPLATE = app
TARGET = 
DEPENDPATH += .
INCLUDEPATH += .

QT += network

# Input
HEADERS += gtrans.h
SOURCES += gtrans.cpp main.cpp