1 /***************************************************************************
2 * Copyright (C) 2008 by András Bécsi *
3 * andrewbecsi @ yahoo . co . uk *
5 * This source file is part of the Qtdict project. *
7 * This program is free software; you can redistribute it and/or modify *
8 * it under the terms of the GNU General Public License as published by *
9 * the Free Software Foundation; either version 2 of the License, or *
10 * (at your option) any later version. *
12 * This program is distributed in the hope that it will be useful, *
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
15 * GNU General Public License for more details. *
17 * You should have received a copy of the GNU General Public License *
18 * along with this program; if not, write to the *
19 * Free Software Foundation, Inc., *
20 * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
21 ***************************************************************************/
26 Qtdict::Qtdict() : QMainWindow(){
28 //!Application version
29 appver
=QString("0.5.0");
32 settings
= new Settings(this);
34 stateFile
= settings
->fileName();
37 headerbg=QBrush(QColor(0, 200, 0, 200));
38 errorbg=QBrush(QColor(200, 0, 0, 200));
39 serifFont=QFont("Times", 13, QFont::Bold);
40 arialBold=QFont("Arial Narrow", 10, QFont::Bold);
42 setWindowTitle("Qtdict");
43 setWindowIcon(QIcon(QString::fromUtf8(":/pic/dic_small.png")));
44 central
= new CentralWidget(this);
45 setCentralWidget(central
);
49 setStatusBar(tr("Készenlét: <font color=green>Qtdict ")+appver
);
56 void Qtdict::createConnections() {
62 connect(aboutAct
, SIGNAL(triggered()),
64 connect(delHistoryAct
, SIGNAL(triggered()),
65 central
, SLOT(clearHistory()));
66 connect(central
, SIGNAL(enableHistoryClearing(bool)),
67 delHistoryAct
, SLOT(setEnabled(bool)));
69 connect(exitAct
, SIGNAL(triggered()),
71 connect(licenceAct
, SIGNAL(triggered()),
72 central
, SLOT(showLicence()));
75 void Qtdict::closeEvent(QCloseEvent
*event
) {
81 //! show information in the tableWidget area
83 void Qtdict::on_central_information(const QString
&info
, const QString
&dict
, const QString
&word
) {
84 qDebug() << "In function "+QString(Q_FUNC_INFO
);
85 setStatusBar(tr("Keresett szó: ")+word
+". "+info
);
87 //QString color=(err?"\"red\"":"\"black\"");
88 setWindowTitle(word
+" - "+dict
+ " - Qtdict" );
91 //! process errors which occured during download and data pocessing
93 void Qtdict::error(const QString& msg) {
94 qDebug() << "In function "+QString(Q_FUNC_INFO);
96 QMessageBox::information(this, tr("HTTP"),
97 tr("<font color=red>A letöltés meghiúsult:<br/> %1.")
100 information(tr("A letöltés meghiúsult:\n%1.")
105 void Qtdict::about() {
106 QMessageBox::about(this,"Qtdict Információ", "<b>Qtdict v"+appver
+"</b>"+tr("<br/><i>© Bécsi András, 2008</i><br/><a href=\"http://qtdict.oos.cc\">bandix.extra.hu/qtdict</a><br/><br/>Egyszerű szótár program, mely jelenleg online szótárak adatbázisát használva teljesíti a lekérdezéseket. A szótár adatbázisokat beépülö modulként (plug-in) kezelni, ezáltal dinamikusan bővíthető és transzparens a szótár globális elhelyezkedését tekintve, azaz offline szótárak kezelésére is képes.<br/><br/><i>Ez a program a GPL v2 jogi feltételeinek megfelelően használható.</i>"));
110 void Qtdict::updateUi() {
111 central->lineEdit->setText(state.word);
112 central->setCurrentLangPair(state.dict);
113 central->modeBox->setCurrentIndex(state.mode);
117 void Qtdict::on_delHistoryAct_triggered() {
118 qDebug()<<"delHistory";
119 statusBar()->showMessage(tr("Keresési előzmények törölve"),250);
120 delHistoryAct
->setEnabled(false);
121 central
->clearHistory();
124 void Qtdict::createActions() {
126 exitAct
= new QAction(tr("Ki&lépés"), this);
127 exitAct
->setShortcut(tr("Ctrl+Q"));
128 exitAct
-> setIcon(QIcon(QString::fromUtf8(":/pic/exit.png")));
129 exitAct
->setStatusTip(tr("Kilépés a programból"));
132 aboutAct
= new QAction(tr("Né&vjegy: Qtdict"), this);
133 aboutAct
->setStatusTip(tr("A Qtdict névjegyének megtekintése"));
134 aboutAct
->setIcon(QIcon(QString::fromUtf8(":/pic/info.png")));
136 delHistoryAct
= new QAction(tr("Ke&resési lista törlése"), this);
137 delHistoryAct
-> setIcon(QIcon(QString::fromUtf8(":/pic/delhist.png")));
138 delHistoryAct
-> setStatusTip(tr("Keresési előzmények törlése"));
140 configAct
= new QAction(tr("&Beállítás"), this);
141 configAct
-> setShortcut(tr("F1"));
142 configAct
-> setIcon(QIcon(QString::fromUtf8(":/pic/configure.png")));
143 configAct
-> setStatusTip(tr("A program beállításai"));
145 licenceAct
= new QAction(tr("&Licenc"), this);
146 licenceAct
-> setStatusTip(tr("A felhasználási feltételek megtekintése."));
149 void Qtdict::createMenus() {
150 fileMenu
= menuBar()->addMenu(tr("&Fájl"));
152 fileMenu->addAction(newAct);
153 fileMenu->addAction(openAct);
154 fileMenu->addAction(saveAct);
155 fileMenu->addAction(saveAsAct);
156 fileMenu->addSeparator();
158 fileMenu
->addAction(exitAct
);
159 fileMenu
->addAction(configAct
);
160 fileMenu
->setStatusTip(tr("Fájl"));
163 editMenu
= menuBar()->addMenu(tr("S&zerkesztés"));
164 editMenu
->setStatusTip(tr("Szerkesztés"));
166 editMenu
->addAction(delHistoryAct
);
168 menuBar()->addSeparator();
170 helpMenu
= menuBar()->addMenu(tr("&Segítség"));
171 helpMenu
->setStatusTip(tr("Segítség"));
172 helpMenu
->addAction(aboutAct
);
173 helpMenu
->addAction(licenceAct
);
178 void Qtdict::setStatusBar(const QString
& label
) {
179 statusBar()->removeWidget(status
);
180 status
=new QLabel(label
);
181 statusBar()->addWidget(status
);
186 void Qtdict::readSettings() {
187 QPoint pos = settings->value("pos", QPoint(200, 200)).toPoint();
188 QSize size = settings->value("size", QSize(600, 600)).toSize();
189 // state.dict=settings->value("dict").toInt();
190 state.mode=settings->value("mode").toInt();
191 state.word=settings->value("word").toString();
195 if(!state.word.isEmpty()){
197 central->pushButton->setEnabled(true);
202 void Qtdict::writeSettings() {
203 settings->setValue("pos", pos());
204 settings->setValue("size", size());
205 //settings->setValue("dict",state.dict);
206 settings->setValue("mode",state.mode);
207 settings->setValue("word",state.word);