From add9ba1234815543a8dd12b1cded14e2034929f1 Mon Sep 17 00:00:00 2001 From: dockes Date: Wed, 16 Nov 2005 08:17:10 +0000 Subject: [PATCH] about dialog, remember previous mainwin geometry --- src/Makefile | 9 +- src/VERSION | 4 +- src/qtgui/main.cpp | 75 ++++++-- src/qtgui/preview/preview.ui | 3 + src/qtgui/preview/preview.ui.h | 41 ++++ src/qtgui/recoll_fr.ts | 329 +++++++++++++++++---------------- src/qtgui/recollmain.ui | 28 ++- src/qtgui/recollmain.ui.h | 143 +++++++------- 8 files changed, 374 insertions(+), 258 deletions(-) diff --git a/src/Makefile b/src/Makefile index 1424b138..779a7dcf 100644 --- a/src/Makefile +++ b/src/Makefile @@ -1,11 +1,11 @@ -# @(#$Id: Makefile,v 1.14 2005-11-12 14:31:39 dockes Exp $ (C) 2005 J.F.Dockes +# @(#$Id: Makefile,v 1.15 2005-11-16 08:17:10 dockes Exp $ (C) 2005 J.F.Dockes # Default values. These can be overridden on the command line ie: # make PREFIX=/usr PREFIX=/usr/local INSTALL = install -c -all: mk/sysconf +all: mk/sysconf common/rclversion.h cd lib; ${MAKE} cd bincimapmime; ${MAKE} cd index; rm -f recollindex; ${MAKE} recollindex @@ -16,6 +16,11 @@ all: mk/sysconf mk/sysconf: ./configure +common/rclversion.h: VERSION + (echo -n "static const char *rclversion= \"" && \ + echo -n `cat VERSION` && \ + echo "\";") > common/rclversion.h + static: cd lib; ${MAKE} cd bincimapmime; ${MAKE} diff --git a/src/VERSION b/src/VERSION index 90a27f9c..9ae5581a 100644 --- a/src/VERSION +++ b/src/VERSION @@ -1 +1,3 @@ -1.0.5 +1.0.6 + + diff --git a/src/qtgui/main.cpp b/src/qtgui/main.cpp index c426cf79..b4ef8156 100644 --- a/src/qtgui/main.cpp +++ b/src/qtgui/main.cpp @@ -1,22 +1,21 @@ #ifndef lint -static char rcsid[] = "@(#$Id: main.cpp,v 1.13 2005-11-06 15:07:09 dockes Exp $ (C) 2005 J.F.Dockes"; +static char rcsid[] = "@(#$Id: main.cpp,v 1.14 2005-11-16 08:17:10 dockes Exp $ (C) 2005 J.F.Dockes"; #endif #include #include - -#include -#include - + +#include +#include #include #include - #include +#include + #include "rcldb.h" using Rcl::AdvSearchData; - #include "rclconfig.h" #include "pathut.h" #include "recoll.h" @@ -62,8 +61,19 @@ bool maybeOpenDb(string &reason) return true; } +RecollMain *mainWindow; + void recollCleanup() { + QSettings settings; + if (mainWindow) { + int width = mainWindow->width(); + int height = mainWindow->height(); + settings.setPath("Recoll.org", "Recoll"); + settings.writeEntry( "/Recoll/geometry/width", width); + settings.writeEntry("/Recoll/geometry/height", height); + } + stop_idxthread(); delete rcldb; rcldb = 0; @@ -85,17 +95,44 @@ static void sigcleanup(int) recollNeedsExit = 1; } + int main( int argc, char ** argv ) { QApplication a(argc, argv); + // translation file for Qt + QTranslator qt( 0 ); + qt.load( QString( "qt_" ) + QTextCodec::locale(), "." ); + a.installTranslator( &qt ); + + // Translations for Recoll QTranslator translator( 0 ); - // QTextCodec::locale() return $LANG + // QTextCodec::locale() returns $LANG translator.load( QString("recoll_") + QTextCodec::locale(), "." ); a.installTranslator( &translator ); + // Restore some settings from previous session + QSettings settings; + settings.setPath("Recoll.org", "Recoll"); + int width = settings.readNumEntry( "/Recoll/geometry/width", 590); + int height = settings.readNumEntry( "/Recoll/geometry/height", 810); + QSize s(width, height); + + // Create main window and set its size to previous session's RecollMain w; - w.show(); + mainWindow = &w; + w.resize(s); + + +#if 0 + // Once tried to set a lighter background but this doesn;t seem to work + // (no inheritance from buttons and popups) + QPalette palette = w.palette(); + palette.setColor(QColorGroup::Background, QColor(239,239,239)); + w.setPalette(palette); +#endif + + // Connect exit handlers etc.. a.connect(&a, SIGNAL(lastWindowClosed()), &a, SLOT(quit())); QTimer *timer = new QTimer(&a); w.connect(timer, SIGNAL(timeout()), &w, SLOT(periodic100())); @@ -105,10 +142,9 @@ int main( int argc, char ** argv ) rclconfig = recollinit(recollCleanup, sigcleanup, reason); if (!rclconfig || !rclconfig->ok()) { - string msg = "Configuration problem: "; + QString msg = a.translate("Main", "Configuration problem: "); msg += reason; - QMessageBox::critical(0, "Recoll", - QString(msg.c_str())); + QMessageBox::critical(0, "Recoll", msg); exit(1); } @@ -117,13 +153,15 @@ int main( int argc, char ** argv ) // Note: this will have to be replaced by a call to a // configuration buildin dialog for initial configuration QMessageBox::critical(0, "Recoll", - QString("No db directory in configuration")); + a.translate("Main", + "No db directory in configuration")); exit(1); } if (!maketmpdir(tmpdir)) { QMessageBox::critical(0, "Recoll", - QString("Cannot create temporary directory")); + a.translate("Main", + "Cannot create temporary directory")); exit(1); } @@ -134,11 +172,16 @@ int main( int argc, char ** argv ) if (!rcldb || !rcldb->open(dbdir, Rcl::Db::DbRO)) { startindexing = 1; QMessageBox::information(0, "Recoll", - QString("Could not open database in ") + - QString(dbdir) + ". Starting indexation"); + a.translate("Main", + "Could not open database in ") + + QString(dbdir) + + a.translate("Main", + ". Starting indexation")); } start_idxthread(rclconfig); + // Let's go + w.show(); return a.exec(); } diff --git a/src/qtgui/preview/preview.ui b/src/qtgui/preview/preview.ui index 99e682c1..cf7b5967 100644 --- a/src/qtgui/preview/preview.ui +++ b/src/qtgui/preview/preview.ui @@ -187,6 +187,7 @@ qapplication.h + rcldb.h preview.ui.h @@ -205,11 +206,13 @@ prevPressed() currentChanged( QWidget * tw ) closeCurrentTab() + setCurTabProps( const Rcl::Doc & doc ) init() closeEvent( QCloseEvent * e ) eventFilter( QObject * target, QEvent * event ) + addEditorTab() diff --git a/src/qtgui/preview/preview.ui.h b/src/qtgui/preview/preview.ui.h index 40b5b584..e9eafd32 100644 --- a/src/qtgui/preview/preview.ui.h +++ b/src/qtgui/preview/preview.ui.h @@ -184,3 +184,44 @@ void Preview::closeCurrentTab() close(); } } + + +QTextEdit * Preview::addEditorTab() +{ + QWidget *anon = new QWidget((QWidget *)pvTab); + QVBoxLayout *anonLayout = new QVBoxLayout(anon, 1, 1, "anonLayout"); + QTextEdit *editor = new QTextEdit(anon, "pvEdit"); + editor->setReadOnly( TRUE ); + editor->setUndoRedoEnabled( FALSE ); + anonLayout->addWidget(editor); + pvTab->addTab(anon, "Tab"); + pvTab->showPage(anon); + return editor; +} + +using std::string; + +void Preview::setCurTabProps(const Rcl::Doc &doc) +{ + QString title = QString::fromUtf8(doc.title.c_str(), + doc.title.length()); + if (title.length() > 20) { + title = title.left(10) + "..." + title.right(10); + } + pvTab->changeTab(pvTab->currentPage(), title); + + char datebuf[100]; + datebuf[0] = 0; + if (!doc.fmtime.empty() || !doc.dmtime.empty()) { + time_t mtime = doc.dmtime.empty() ? + atol(doc.fmtime.c_str()) : atol(doc.dmtime.c_str()); + struct tm *tm = localtime(&mtime); + strftime(datebuf, 99, "%F %T", tm); + } + string tiptxt = doc.url + string("\n"); + tiptxt += doc.mimetype + " " + string(datebuf) + "\n"; + if (!doc.title.empty()) + tiptxt += doc.title + "\n"; + pvTab->setTabToolTip(pvTab->currentPage(), + QString::fromUtf8(tiptxt.c_str(), tiptxt.length())); +} diff --git a/src/qtgui/recoll_fr.ts b/src/qtgui/recoll_fr.ts index 01eee1f5..c1b0d146 100644 --- a/src/qtgui/recoll_fr.ts +++ b/src/qtgui/recoll_fr.ts @@ -1,155 +1,174 @@ - - - Preview - - Preview - Previsualisation - - - Preview 1 - Previsualisation 1 - - - &Search for: - &Rechercher: - - - &Next - &Suivant - - - Alt+N - Alt+S - - - &Previous - &Precédent - - - Alt+P - Alt+P - - - Match &Case - Respecter la &casse - - - Alt+C - Alt+C - - - Close Tab - Fermer la tabulation - - - - RecollMain - - recoll - recoll - - - Search - Rechercher - - - Clear - Effacer - - - Ctrl+S - Ctrl+S - - - Previous page - Page précedente - - - Next page - Page suivante - - - Advanced search - Recherche avancée - - - &File - &Fichier - - - Exit - Quitter - - - E&xit - &Quitter - - - Start Indexing - Commencer l'indexation - - - - advsearch - - Advanced search - Recherche avancée - - - Search For - Rechercher - - - All these words - Tous les mots - - - This exact phrase - Cette phrase exactement - - - Any of these words - N'importe lequel de ces mots - - - None of these words - Aucun parmi ces mots - - - Restrict file types - Restraindre le type de fichier - - - Searched file types - Type de fichier recherché - - - --------> - --------> - - - <--------- - <--------- - - - Ignored file types - Types de fichier ignorés - - - Browse - ButinerParcourir - - - Restrict results to files in subtree: - Restraindre les résultats aux fichiers de l'arborescenc: - - - Start Search - Lancer la recherche - - - Dismiss - Annuler - - - + + + Main + + Configuration problem: + Problème de configuration: + + + + Preview + + Preview + Previsualisation + + + Preview 1 + Previsualisation 1 + + + &Search for: + &Rechercher: + + + &Next + &Suivant + + + Alt+N + Alt+S + + + &Previous + &Precédent + + + Alt+P + Alt+P + + + Match &Case + Respecter la &casse + + + Alt+C + Alt+C + + + Close Tab + Fermer la tabulation + + + Clear + Effacer + + + + RecollMain + + recoll + recoll + + + Search + Rechercher + + + Clear + Effacer + + + Ctrl+S + Ctrl+S + + + Previous page + Page précedente + + + Next page + Page suivante + + + Advanced search + Recherche avancée + + + &File + &Fichier + + + Exit + Quitter + + + E&xit + &Quitter + + + Start Indexing + Commencer l'indexation + + + Help + Aide + + + About Recoll + À propos de Recoll + + + + advsearch + + Advanced search + Recherche avancée + + + Search For + Rechercher + + + All these words + Tous les mots + + + This exact phrase + Cette phrase exactement + + + Any of these words + N'importe lequel de ces mots + + + None of these words + Aucun parmi ces mots + + + Restrict file types + Restraindre le type de fichier + + + Searched file types + Type de fichier recherché + + + --------> + --------> + + + <--------- + <--------- + + + Ignored file types + Types de fichier ignorés + + + Browse + ButinerParcourir + + + Restrict results to files in subtree: + Restraindre les résultats aux fichiers de l'arborescenc: + + + Start Search + Lancer la recherche + + + Dismiss + Annuler + + + diff --git a/src/qtgui/recollmain.ui b/src/qtgui/recollmain.ui index 6128f17e..63e64617 100644 --- a/src/qtgui/recollmain.ui +++ b/src/qtgui/recollmain.ui @@ -8,8 +8,8 @@ 0 0 - 590 - 810 + 631 + 212 @@ -181,12 +181,16 @@ MenuBar - + + + + + @@ -216,6 +220,17 @@ Start Indexing + + + helpAbout_RecollAction + + + About Recoll + + + About Recoll + + @@ -278,6 +293,12 @@ RecollMain advSearchPB_clicked() + + helpAbout_RecollAction + activated() + RecollMain + showAboutDialog() + preview.h @@ -314,6 +335,7 @@ advSearchPB_clicked() startAdvSearch( Rcl::AdvSearchData sdata ) reslistTE_delayedclick() + showAboutDialog() init() diff --git a/src/qtgui/recollmain.ui.h b/src/qtgui/recollmain.ui.h index 19b3c561..78085b5b 100644 --- a/src/qtgui/recollmain.ui.h +++ b/src/qtgui/recollmain.ui.h @@ -38,6 +38,7 @@ using std::pair; #include "plaintorich.h" #include "unacpp.h" #include "advsearch.h" +#include "rclversion.h" extern "C" int XFlush(void *); @@ -49,7 +50,6 @@ extern "C" int XFlush(void *); // with the default window size and font, most of the time. static const int respagesize = 8; - void RecollMain::init() { reslist_current = -1; @@ -212,7 +212,7 @@ void RecollMain::periodic100() rcldb->close(); } else if (indexingdone == 0) { if (toggle < 9) { - statusBar()->message("Indexing in progress"); + statusBar()->message(tr("Indexing in progress")); } else { statusBar()->message(""); } @@ -251,9 +251,8 @@ void RecollMain::reslistTE_doubleClicked(int par, int) string cmd = getMimeViewer(doc.mimetype, rclconfig->getMimeConf()); if (cmd.length() == 0) { QMessageBox::warning(0, "Recoll", - QString("No external viewer configured for mime" - " type ") + - doc.mimetype.c_str()); + tr("No external viewer configured for mime type ") + + doc.mimetype.c_str()); return; } @@ -281,8 +280,8 @@ void RecollMain::reslistTE_doubleClicked(int par, int) ncmd += " &"; QStatusBar *stb = statusBar(); if (stb) { - string msg = string("Executing: [") + ncmd.c_str() + "]"; - stb->message(msg.c_str(), 5000); + QString msg = tr("Executing: [") + ncmd.c_str() + "]"; + stb->message(msg, 5000); stb->repaint(false); XFlush(qt_xdisplay()); } @@ -399,10 +398,10 @@ void RecollMain::listNextPB_clicked() } if (i == 0) { reslistTE->append("

"); - char line[80]; - sprintf(line, "

Displaying results starting at index" - " %d (maximum set size %d)
", - reslist_winfirst+1, resCnt); + QString line = tr("

Displaying results starting at index" + " %1 (maximum set size %2)
") + .arg(reslist_winfirst+1) + .arg(resCnt); reslistTE->append(line); } @@ -448,7 +447,7 @@ void RecollMain::listNextPB_clicked() reslistTE->ensureCursorVisible(); } else { // Restore first in win parameter that we shouln't have incremented - reslistTE->append("

No results found
"); + reslistTE->append(tr("

No results found
")); reslist_winfirst -= respagesize; if (reslist_winfirst < 0) reslist_winfirst = -1; @@ -473,7 +472,7 @@ void RecollMain::previewClosed(Preview *w) void RecollMain::advSearchPB_clicked() { if (asearchform == 0) { - asearchform = new advsearch(0, "Advanced search", FALSE, + asearchform = new advsearch(0, tr("Advanced search"), FALSE, WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu); asearchform->setSizeGripEnabled(FALSE); @@ -540,14 +539,18 @@ void RecollMain::reslistTE_delayedclick() } -// Open a preview window for a given document -// docnum is a db query index +/** + * Open a preview window for a given document, or load it into new tab of + * existing window. + * + * @param docnum db query index + */ void RecollMain::startPreview(int docnum) { Rcl::Doc doc; if (!rcldb->getDoc(docnum, doc, 0)) { QMessageBox::warning(0, "Recoll", - QString("Cannot retrieve document info" + tr("Cannot retrieve document info" " from database")); return; } @@ -558,28 +561,57 @@ void RecollMain::startPreview(int docnum) struct stat st; if (stat(fn.c_str(), &st) < 0) { QMessageBox::warning(0, "Recoll", - QString("Cannot access document file: ") + + tr("Cannot access document file: ") + fn.c_str()); return; } QStatusBar *stb = statusBar(); + + stb->message(tr("Creating preview window")); + qApp->processEvents(); + QTextEdit *editor; + if (curPreview == 0) { + curPreview = new Preview(0, tr("Preview")); + curPreview->setCaption(queryText->text()); + connect(curPreview, SIGNAL(previewClosed(Preview *)), + this, SLOT(previewClosed(Preview *))); + if (curPreview == 0) { + QMessageBox::warning(0, tr("Warning"), + tr("Can't create preview window"), + QMessageBox::Ok, + QMessageBox::NoButton); + return; + } + editor = curPreview->pvEdit; + curPreview->show(); + } else { + editor = curPreview->addEditorTab(); + } + + if (doc.title.empty()) + doc.title = path_getsimple(doc.url); + + curPreview->setCurTabProps(doc); + char csz[20]; sprintf(csz, "%lu", (unsigned long)st.st_size); - string msg = string("Loading: ") + fn + " (size " + csz + " bytes)"; - stb->message(msg.c_str()); + QString msg = QString("Loading: %1 (size %2 bytes)") + .arg(fn) + .arg(csz); + stb->message(msg); qApp->processEvents(); Rcl::Doc fdoc; FileInterner interner(fn, rclconfig, tmpdir, &doc.mimetype); if (interner.internfile(fdoc, doc.ipath) != FileInterner::FIDone) { QMessageBox::warning(0, "Recoll", - QString("Can't turn doc into internal rep for ") + + tr("Can't turn doc into internal rep for ") + doc.mimetype.c_str()); return; } - stb->message("Creating preview text"); + stb->message(tr("Creating preview text")); qApp->processEvents(); list terms; @@ -587,72 +619,13 @@ void RecollMain::startPreview(int docnum) list > termoffsets; string rich = plaintorich(fdoc.text, terms, termoffsets); - stb->message("Creating preview window"); - qApp->processEvents(); - QTextEdit *editor; - if (curPreview == 0) { - curPreview = new Preview(0, "Preview"); - curPreview->setCaption(queryText->text()); - connect(curPreview, SIGNAL(previewClosed(Preview *)), - this, SLOT(previewClosed(Preview *))); - if (curPreview == 0) { - QMessageBox::warning(0, "Warning", - "Can't create preview window", - QMessageBox::Ok, - QMessageBox::NoButton); - return; - } - curPreview->show(); - editor = curPreview->pvEdit; - } else { - QWidget *anon = new QWidget((QWidget *)curPreview->pvTab); - QVBoxLayout *anonLayout = new QVBoxLayout(anon, 1, 1, "anonLayout"); - editor = new QTextEdit(anon, "pvEdit"); - editor->setReadOnly( TRUE ); - editor->setUndoRedoEnabled( FALSE ); - anonLayout->addWidget(editor); - curPreview->pvTab->addTab(anon, "Tab"); - curPreview->pvTab->showPage(anon); - } - string tabname; - if (!doc.title.empty()) { - tabname = doc.title; - } else { - tabname = path_getsimple(doc.url); - } - if (tabname.length() > 20) { - tabname = tabname.substr(0, 10) + "..." + - tabname.substr(tabname.length()-10); - } - curPreview->pvTab->changeTab(curPreview->pvTab->currentPage(), - QString::fromUtf8(tabname.c_str(), - tabname.length())); - - if (doc.title.empty()) - doc.title = path_getsimple(doc.url); - char datebuf[100]; - datebuf[0] = 0; - if (!doc.fmtime.empty() || !doc.dmtime.empty()) { - time_t mtime = doc.dmtime.empty() ? - atol(doc.fmtime.c_str()) : atol(doc.dmtime.c_str()); - struct tm *tm = localtime(&mtime); - strftime(datebuf, 99, "%F %T", tm); - } - string tiptxt = doc.url + string("\n"); - tiptxt += doc.mimetype + " " + string(datebuf) + "\n"; - if (!doc.title.empty()) - tiptxt += doc.title + "\n"; - curPreview->pvTab->setTabToolTip(curPreview->pvTab->currentPage(), - QString::fromUtf8(tiptxt.c_str(), - tiptxt.length())); - QStyleSheetItem *item = new QStyleSheetItem(editor->styleSheet(), "termtag" ); item->setColor("blue"); item->setFontWeight(QFont::Bold); QString str = QString::fromUtf8(rich.c_str(), rich.length()); - stb->message("Loading preview text"); + stb->message(tr("Loading preview text")); qApp->processEvents(); editor->setText(str); @@ -669,3 +642,11 @@ void RecollMain::startPreview(int docnum) editor->length(), editor->paragraphs(), para, index)); stb->clear(); } + + +void RecollMain::showAboutDialog() +{ + string vstring = string("Recoll ") + rclversion + + "
" + "http://www.recoll.org"; + QMessageBox::information(this, tr("About Recoll"), vstring.c_str()); +}