2009-02-05 14:21:47 +00:00
|
|
|
/* This file is (c) 2008-2009 Konstantin Isakov <ikm@users.berlios.de>
|
2009-01-28 20:55:45 +00:00
|
|
|
* Part of GoldenDict. Licensed under GPLv3 or later, see the LICENSE file */
|
|
|
|
|
|
|
|
#ifndef __MAINWINDOW_HH_INCLUDED__
|
|
|
|
#define __MAINWINDOW_HH_INCLUDED__
|
|
|
|
|
|
|
|
#include <QMainWindow>
|
|
|
|
#include <QThread>
|
|
|
|
#include <QToolButton>
|
2009-02-05 20:55:00 +00:00
|
|
|
#include <QSystemTrayIcon>
|
2009-03-26 19:00:08 +00:00
|
|
|
#include <QNetworkAccessManager>
|
2009-01-28 20:55:45 +00:00
|
|
|
#include "ui_mainwindow.h"
|
|
|
|
#include "folding.hh"
|
|
|
|
#include "config.hh"
|
|
|
|
#include "dictionary.hh"
|
|
|
|
#include "initializing.hh"
|
|
|
|
#include "article_netmgr.hh"
|
|
|
|
#include "instances.hh"
|
|
|
|
#include "article_maker.hh"
|
|
|
|
#include "scanpopup.hh"
|
|
|
|
#include "articleview.hh"
|
2009-01-29 19:16:25 +00:00
|
|
|
#include "wordfinder.hh"
|
2009-01-28 20:55:45 +00:00
|
|
|
|
|
|
|
using std::string;
|
|
|
|
using std::vector;
|
|
|
|
|
2009-03-26 19:00:08 +00:00
|
|
|
class LoadDictionaries: public QThread, public Dictionary::Initializing
|
2009-01-28 20:55:45 +00:00
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
|
2009-03-28 22:37:03 +00:00
|
|
|
Config::Paths const & paths;
|
2009-01-28 20:55:45 +00:00
|
|
|
vector< sptr< Dictionary::Class > > dictionaries;
|
2009-03-29 13:34:39 +00:00
|
|
|
string exceptionText;
|
2009-01-28 20:55:45 +00:00
|
|
|
|
|
|
|
public:
|
|
|
|
|
2009-03-28 22:37:03 +00:00
|
|
|
LoadDictionaries( Config::Paths const & paths );
|
2009-01-28 20:55:45 +00:00
|
|
|
|
|
|
|
virtual void run();
|
|
|
|
|
|
|
|
vector< sptr< Dictionary::Class > > const & getDictionaries() const
|
|
|
|
{ return dictionaries; }
|
|
|
|
|
2009-03-29 13:34:39 +00:00
|
|
|
/// Empty string means to exception occured
|
|
|
|
string const & getExceptionText() const
|
|
|
|
{ return exceptionText; }
|
|
|
|
|
2009-01-28 20:55:45 +00:00
|
|
|
signals:
|
|
|
|
|
|
|
|
void indexingDictionarySignal( QString dictionaryName );
|
|
|
|
|
2009-03-26 19:00:08 +00:00
|
|
|
public:
|
2009-01-28 20:55:45 +00:00
|
|
|
|
|
|
|
virtual void indexingDictionary( string const & dictionaryName ) throw();
|
2009-03-28 22:37:03 +00:00
|
|
|
|
|
|
|
private:
|
|
|
|
|
|
|
|
void handlePath( Config::Path const & );
|
2009-01-28 20:55:45 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
class MainWindow: public QMainWindow
|
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
|
|
|
MainWindow();
|
2009-02-06 17:04:11 +00:00
|
|
|
~MainWindow();
|
2009-01-28 20:55:45 +00:00
|
|
|
|
|
|
|
private:
|
|
|
|
|
2009-02-05 20:55:00 +00:00
|
|
|
QSystemTrayIcon * trayIcon;
|
|
|
|
|
2009-01-28 20:55:45 +00:00
|
|
|
Ui::MainWindow ui;
|
|
|
|
QToolBar * navToolbar;
|
2009-02-08 20:20:02 +00:00
|
|
|
QAction * navBack, * navForward, * enableScanPopup;
|
|
|
|
QMenu trayIconMenu;
|
2009-01-28 20:55:45 +00:00
|
|
|
QToolButton addTab;
|
|
|
|
Config::Class cfg;
|
|
|
|
vector< sptr< Dictionary::Class > > dictionaries;
|
|
|
|
vector< Instances::Group > groupInstances;
|
|
|
|
ArticleMaker articleMaker;
|
|
|
|
ArticleNetworkAccessManager articleNetMgr;
|
2009-03-26 19:00:08 +00:00
|
|
|
QNetworkAccessManager dictNetMgr; // We give dictionaries a separate manager,
|
|
|
|
// since their requests can be destroyed
|
|
|
|
// in a separate thread
|
2009-01-28 20:55:45 +00:00
|
|
|
|
2009-01-29 19:16:25 +00:00
|
|
|
WordFinder wordFinder;
|
2009-01-28 20:55:45 +00:00
|
|
|
|
2009-02-01 00:08:08 +00:00
|
|
|
sptr< ScanPopup > scanPopup;
|
2009-01-28 20:55:45 +00:00
|
|
|
|
|
|
|
::Initializing * initializing;
|
|
|
|
|
2009-02-05 20:55:00 +00:00
|
|
|
/// Creates, destroys or otherwise updates tray icon, according to the
|
|
|
|
/// current configuration and situation.
|
|
|
|
void updateTrayIcon();
|
|
|
|
|
|
|
|
void closeEvent( QCloseEvent * );
|
|
|
|
|
2009-04-03 17:10:27 +00:00
|
|
|
void applyProxySettings();
|
2009-01-28 20:55:45 +00:00
|
|
|
void makeDictionaries();
|
|
|
|
void updateStatusLine();
|
|
|
|
void updateGroupList();
|
2009-02-01 00:08:08 +00:00
|
|
|
void makeScanPopup();
|
2009-01-28 20:55:45 +00:00
|
|
|
|
2009-03-26 19:00:08 +00:00
|
|
|
void updateMatchResults( bool finished );
|
|
|
|
|
2009-03-29 17:38:54 +00:00
|
|
|
virtual bool eventFilter( QObject *, QEvent * );
|
|
|
|
|
2009-01-28 20:55:45 +00:00
|
|
|
/// Returns the reference to dictionaries stored in the currently active
|
|
|
|
/// group, or to all dictionaries if there are no groups.
|
|
|
|
vector< sptr< Dictionary::Class > > const & getActiveDicts();
|
|
|
|
|
|
|
|
private slots:
|
|
|
|
|
|
|
|
// Executed in response to a user click on an 'add tab' tool button
|
|
|
|
void addNewTab();
|
|
|
|
// Executed in response to a user click on an 'close' button on a tab
|
|
|
|
void tabCloseRequested( int );
|
|
|
|
|
|
|
|
/// Triggered by the actions in the nav toolbar
|
|
|
|
void backClicked();
|
|
|
|
void forwardClicked();
|
|
|
|
|
|
|
|
/// ArticleView's title has changed
|
|
|
|
void titleChanged( ArticleView *, QString const & );
|
|
|
|
/// ArticleView's icon has changed
|
|
|
|
void iconChanged( ArticleView *, QIcon const & );
|
|
|
|
|
|
|
|
void editSources();
|
|
|
|
void editGroups();
|
2009-02-05 20:55:00 +00:00
|
|
|
void editPreferences();
|
2009-01-28 20:55:45 +00:00
|
|
|
void indexingDictionary( QString dictionaryName );
|
|
|
|
|
2009-02-06 17:04:11 +00:00
|
|
|
void currentGroupChanged( QString const & );
|
2009-01-28 20:55:45 +00:00
|
|
|
void translateInputChanged( QString const & );
|
2009-02-08 14:02:27 +00:00
|
|
|
void translateInputFinished();
|
2009-03-26 19:00:08 +00:00
|
|
|
|
|
|
|
void prefixMatchUpdated();
|
|
|
|
void prefixMatchFinished();
|
|
|
|
|
2009-01-28 20:55:45 +00:00
|
|
|
void wordListItemActivated( QListWidgetItem * );
|
2009-02-08 14:02:27 +00:00
|
|
|
void wordListSelectionChanged();
|
2009-01-28 20:55:45 +00:00
|
|
|
|
2009-02-08 15:49:17 +00:00
|
|
|
void openLinkInNewTab( QUrl const &, QUrl const & );
|
|
|
|
void showDefinitionInNewTab( QString const & word, QString const & group );
|
|
|
|
|
2009-01-28 20:55:45 +00:00
|
|
|
void showTranslationFor( QString const & );
|
2009-02-05 20:55:00 +00:00
|
|
|
|
|
|
|
void trayIconActivated( QSystemTrayIcon::ActivationReason );
|
2009-02-08 14:02:27 +00:00
|
|
|
|
2009-02-08 20:20:02 +00:00
|
|
|
void scanEnableToggled( bool );
|
|
|
|
|
|
|
|
void showMainWindow();
|
|
|
|
|
2009-02-08 14:02:27 +00:00
|
|
|
void visitHomepage();
|
|
|
|
void visitForum();
|
|
|
|
void showAbout();
|
2009-01-28 20:55:45 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|