System tray icon basics
This commit is contained in:
parent
7319240391
commit
9176cdd147
@ -252,6 +252,8 @@ void rwSettings(bool writing)
|
|||||||
|
|
||||||
SETTING_RW(prefs.fileTypesByCats, "/Recoll/prefs/query/asearchFilTypByCat",
|
SETTING_RW(prefs.fileTypesByCats, "/Recoll/prefs/query/asearchFilTypByCat",
|
||||||
Bool, false);
|
Bool, false);
|
||||||
|
SETTING_RW(prefs.showTrayIcon, "/Recoll/prefs/showTrayIcon", Bool, false);
|
||||||
|
SETTING_RW(prefs.closeToTray, "/Recoll/prefs/closeToTray", Bool, false);
|
||||||
|
|
||||||
if (g_dynconf == 0) {
|
if (g_dynconf == 0) {
|
||||||
// Happens
|
// Happens
|
||||||
|
|||||||
@ -124,6 +124,9 @@ class PrefsPack {
|
|||||||
// of the case where we might need an incompatible change
|
// of the case where we might need an incompatible change
|
||||||
int rclVersion;
|
int rclVersion;
|
||||||
|
|
||||||
|
bool showTrayIcon;
|
||||||
|
bool closeToTray;
|
||||||
|
|
||||||
// Advanced search window clause list state
|
// Advanced search window clause list state
|
||||||
vector<int> advSearchClauses;
|
vector<int> advSearchClauses;
|
||||||
|
|
||||||
@ -140,8 +143,10 @@ class PrefsPack {
|
|||||||
queryReplaceAbstract(false),
|
queryReplaceAbstract(false),
|
||||||
startWithAdvSearchOpen(false),
|
startWithAdvSearchOpen(false),
|
||||||
termMatchType(0),
|
termMatchType(0),
|
||||||
rclVersion(1505)
|
rclVersion(1505),
|
||||||
{ }
|
showTrayIcon(false),
|
||||||
|
closeToTray(false)
|
||||||
|
{}
|
||||||
};
|
};
|
||||||
|
|
||||||
/** Global preferences record */
|
/** Global preferences record */
|
||||||
|
|||||||
@ -84,6 +84,7 @@ using std::pair;
|
|||||||
#include "fileudi.h"
|
#include "fileudi.h"
|
||||||
#include "snippets_w.h"
|
#include "snippets_w.h"
|
||||||
#include "fragbuts.h"
|
#include "fragbuts.h"
|
||||||
|
#include "systray.h"
|
||||||
|
|
||||||
using namespace confgui;
|
using namespace confgui;
|
||||||
|
|
||||||
@ -440,6 +441,14 @@ void RclMain::init()
|
|||||||
emit sortDataChanged(m_sortspec);
|
emit sortDataChanged(m_sortspec);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (prefs.showTrayIcon && QSystemTrayIcon::isSystemTrayAvailable()) {
|
||||||
|
m_trayicon = new RclTrayIcon(this,
|
||||||
|
QIcon(QString(":/images/recoll.png")));
|
||||||
|
m_trayicon->show();
|
||||||
|
} else {
|
||||||
|
m_trayicon = 0;
|
||||||
|
}
|
||||||
|
|
||||||
fileRebuildIndexAction->setEnabled(FALSE);
|
fileRebuildIndexAction->setEnabled(FALSE);
|
||||||
fileToggleIndexingAction->setEnabled(FALSE);
|
fileToggleIndexingAction->setEnabled(FALSE);
|
||||||
// Start timer on a slow period (used for checking ^C). Will be
|
// Start timer on a slow period (used for checking ^C). Will be
|
||||||
@ -659,19 +668,22 @@ void RclMain::adjustPrefsMenu()
|
|||||||
setStemLang(prefs.queryStemLang);
|
setStemLang(prefs.queryStemLang);
|
||||||
}
|
}
|
||||||
|
|
||||||
void RclMain::closeEvent( QCloseEvent * )
|
void RclMain::showTrayMessage(const QString& text)
|
||||||
{
|
{
|
||||||
fileExit();
|
if (m_trayicon)
|
||||||
|
m_trayicon->showMessage("Recoll", text,
|
||||||
|
QSystemTrayIcon::Information, 1000);
|
||||||
}
|
}
|
||||||
|
|
||||||
// We also want to get rid of the advanced search form and previews
|
void RclMain::closeEvent(QCloseEvent *ev)
|
||||||
// when we exit (not our children so that it's not systematically
|
|
||||||
// created over the main form).
|
|
||||||
bool RclMain::close()
|
|
||||||
{
|
{
|
||||||
LOGDEB(("RclMain::close\n"));
|
LOGDEB(("RclMain::closeEvent\n"));
|
||||||
fileExit();
|
if (prefs.closeToTray && m_trayicon && m_trayicon->isVisible()) {
|
||||||
return false;
|
hide();
|
||||||
|
ev->ignore();
|
||||||
|
} else {
|
||||||
|
fileExit();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void RclMain::fileExit()
|
void RclMain::fileExit()
|
||||||
@ -776,6 +788,7 @@ void RclMain::periodic100()
|
|||||||
}
|
}
|
||||||
// Update the "start/stop indexing" menu entry, can't be done from
|
// Update the "start/stop indexing" menu entry, can't be done from
|
||||||
// the "start/stop indexing" slot itself
|
// the "start/stop indexing" slot itself
|
||||||
|
IndexerState prevstate = m_indexerState;
|
||||||
if (m_idxproc) {
|
if (m_idxproc) {
|
||||||
m_indexerState = IXST_RUNNINGMINE;
|
m_indexerState = IXST_RUNNINGMINE;
|
||||||
fileToggleIndexingAction->setText(tr("Stop &Indexing"));
|
fileToggleIndexingAction->setText(tr("Stop &Indexing"));
|
||||||
@ -800,6 +813,11 @@ void RclMain::periodic100()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ((prevstate == IXST_RUNNINGMINE || prevstate == IXST_RUNNINGNOTMINE)
|
||||||
|
&& m_indexerState == IXST_NOTRUNNING) {
|
||||||
|
showTrayMessage("Indexing done");
|
||||||
|
}
|
||||||
|
|
||||||
// Possibly cleanup the dead viewers
|
// Possibly cleanup the dead viewers
|
||||||
for (vector<ExecCmd*>::iterator it = m_viewers.begin();
|
for (vector<ExecCmd*>::iterator it = m_viewers.begin();
|
||||||
it != m_viewers.end(); it++) {
|
it != m_viewers.end(); it++) {
|
||||||
@ -871,12 +889,15 @@ void RclMain::toggleIndexing()
|
|||||||
m_idxproc->startExec("recollindex", args, false, false);
|
m_idxproc->startExec("recollindex", args, false, false);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
case IXST_UNKNOWN:
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void RclMain::rebuildIndex()
|
void RclMain::rebuildIndex()
|
||||||
{
|
{
|
||||||
switch (m_indexerState) {
|
switch (m_indexerState) {
|
||||||
|
case IXST_UNKNOWN:
|
||||||
case IXST_RUNNINGMINE:
|
case IXST_RUNNINGMINE:
|
||||||
case IXST_RUNNINGNOTMINE:
|
case IXST_RUNNINGNOTMINE:
|
||||||
return; //?? Should not have been called
|
return; //?? Should not have been called
|
||||||
|
|||||||
@ -49,12 +49,15 @@ namespace confgui {
|
|||||||
|
|
||||||
using confgui::ConfIndexW;
|
using confgui::ConfIndexW;
|
||||||
|
|
||||||
|
class RclTrayIcon;
|
||||||
|
|
||||||
class RclMain : public QMainWindow, public Ui::RclMainBase
|
class RclMain : public QMainWindow, public Ui::RclMainBase
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
enum IndexerState {IXST_NOTRUNNING, IXST_RUNNINGMINE, IXST_RUNNINGNOTMINE};
|
enum IndexerState {IXST_UNKNOWN, IXST_NOTRUNNING,
|
||||||
|
IXST_RUNNINGMINE, IXST_RUNNINGNOTMINE};
|
||||||
RclMain(QWidget * parent = 0)
|
RclMain(QWidget * parent = 0)
|
||||||
: QMainWindow(parent),
|
: QMainWindow(parent),
|
||||||
curPreview(0),
|
curPreview(0),
|
||||||
@ -77,7 +80,7 @@ public:
|
|||||||
m_idxkilled(false),
|
m_idxkilled(false),
|
||||||
m_catgbutvecidx(0),
|
m_catgbutvecidx(0),
|
||||||
m_sortspecnochange(false),
|
m_sortspecnochange(false),
|
||||||
m_indexerState(IXST_RUNNINGNOTMINE),
|
m_indexerState(IXST_UNKNOWN),
|
||||||
m_queryActive(false),
|
m_queryActive(false),
|
||||||
m_firstIndexing(false),
|
m_firstIndexing(false),
|
||||||
m_searchIsSimple(false)
|
m_searchIsSimple(false)
|
||||||
@ -104,7 +107,6 @@ public:
|
|||||||
void newDupsW(const Rcl::Doc doc, const std::vector<Rcl::Doc> dups);
|
void newDupsW(const Rcl::Doc doc, const std::vector<Rcl::Doc> dups);
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
virtual bool close();
|
|
||||||
virtual void fileExit();
|
virtual void fileExit();
|
||||||
virtual void idxStatus();
|
virtual void idxStatus();
|
||||||
virtual void periodic100();
|
virtual void periodic100();
|
||||||
@ -163,6 +165,7 @@ public slots:
|
|||||||
virtual void resultCount(int);
|
virtual void resultCount(int);
|
||||||
virtual void applyStyleSheet();
|
virtual void applyStyleSheet();
|
||||||
virtual void setFilterCtlStyle(int stl);
|
virtual void setFilterCtlStyle(int stl);
|
||||||
|
virtual void showTrayMessage(const QString& text);
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void docSourceChanged(RefCntr<DocSequence>);
|
void docSourceChanged(RefCntr<DocSequence>);
|
||||||
@ -215,6 +218,8 @@ private:
|
|||||||
// preview (if no ext app set)
|
// preview (if no ext app set)
|
||||||
QString m_urltoview;
|
QString m_urltoview;
|
||||||
|
|
||||||
|
RclTrayIcon *m_trayicon;
|
||||||
|
|
||||||
virtual void init();
|
virtual void init();
|
||||||
virtual void setupResTB(bool combo);
|
virtual void setupResTB(bool combo);
|
||||||
virtual void previewPrevOrNextInTab(Preview *, int sid, int docnum,
|
virtual void previewPrevOrNextInTab(Preview *, int sid, int docnum,
|
||||||
|
|||||||
@ -33,6 +33,7 @@ HEADERS += \
|
|||||||
snippets_w.h \
|
snippets_w.h \
|
||||||
spell_w.h \
|
spell_w.h \
|
||||||
ssearch_w.h \
|
ssearch_w.h \
|
||||||
|
systray.h \
|
||||||
uiprefs_w.h \
|
uiprefs_w.h \
|
||||||
viewaction_w.h \
|
viewaction_w.h \
|
||||||
|
|
||||||
@ -59,6 +60,7 @@ SOURCES += \
|
|||||||
snippets_w.cpp \
|
snippets_w.cpp \
|
||||||
spell_w.cpp \
|
spell_w.cpp \
|
||||||
ssearch_w.cpp \
|
ssearch_w.cpp \
|
||||||
|
systray.cpp \
|
||||||
uiprefs_w.cpp \
|
uiprefs_w.cpp \
|
||||||
viewaction_w.cpp \
|
viewaction_w.cpp \
|
||||||
|
|
||||||
|
|||||||
42
src/qtgui/systray.cpp
Normal file
42
src/qtgui/systray.cpp
Normal file
@ -0,0 +1,42 @@
|
|||||||
|
/*
|
||||||
|
* This program is free software; you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation; either version 2 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program 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 General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program; if not, write to the
|
||||||
|
* Free Software Foundation, Inc.,
|
||||||
|
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||||
|
*/
|
||||||
|
#include <QAction>
|
||||||
|
#include <QMenu>
|
||||||
|
|
||||||
|
#include "systray.h"
|
||||||
|
#include "rclmain_w.h"
|
||||||
|
|
||||||
|
void RclTrayIcon::init()
|
||||||
|
{
|
||||||
|
QAction *restoreAction = new QAction(tr("Restore"), this);
|
||||||
|
QAction *quitAction = new QAction(tr("Quit"), this);
|
||||||
|
|
||||||
|
connect(restoreAction, SIGNAL(triggered()), this, SLOT(onRestore()));
|
||||||
|
connect(quitAction, SIGNAL(triggered()), m_mainw, SLOT(fileExit()));
|
||||||
|
|
||||||
|
QMenu *trayIconMenu = new QMenu(0);
|
||||||
|
trayIconMenu->addAction(restoreAction);
|
||||||
|
trayIconMenu->addAction(quitAction);
|
||||||
|
setContextMenu(trayIconMenu);
|
||||||
|
}
|
||||||
|
|
||||||
|
void RclTrayIcon::onRestore()
|
||||||
|
{
|
||||||
|
// Hide and show to restore on current desktop
|
||||||
|
m_mainw->hide();
|
||||||
|
m_mainw->show();
|
||||||
|
}
|
||||||
42
src/qtgui/systray.h
Normal file
42
src/qtgui/systray.h
Normal file
@ -0,0 +1,42 @@
|
|||||||
|
/*
|
||||||
|
* This program is free software; you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation; either version 2 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program 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 General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program; if not, write to the
|
||||||
|
* Free Software Foundation, Inc.,
|
||||||
|
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||||
|
*/
|
||||||
|
#ifndef _SYSTRAY_H_INCLUDED_
|
||||||
|
#define _SYSTRAY_H_INCLUDED_
|
||||||
|
|
||||||
|
#include <QSystemTrayIcon>
|
||||||
|
#include <QIcon>
|
||||||
|
|
||||||
|
class RclMain;
|
||||||
|
|
||||||
|
class RclTrayIcon : public QSystemTrayIcon {
|
||||||
|
Q_OBJECT
|
||||||
|
|
||||||
|
public:
|
||||||
|
|
||||||
|
RclTrayIcon(RclMain *mainw, const QIcon& icon, QObject* parent = 0)
|
||||||
|
: QSystemTrayIcon(icon, parent), m_mainw(mainw) {
|
||||||
|
init();
|
||||||
|
}
|
||||||
|
public slots:
|
||||||
|
void onRestore();
|
||||||
|
|
||||||
|
private:
|
||||||
|
void init();
|
||||||
|
RclMain *m_mainw;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif /* _SYSTRAY_H_INCLUDED_ */
|
||||||
@ -277,6 +277,26 @@
|
|||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QCheckBox" name="showTrayIconCB">
|
||||||
|
<property name="text">
|
||||||
|
<string>Show system tray icon.</string>
|
||||||
|
</property>
|
||||||
|
<property name="checked">
|
||||||
|
<bool>false</bool>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QCheckBox" name="closeToTrayCB">
|
||||||
|
<property name="text">
|
||||||
|
<string>Close to tray instead of exiting.</string>
|
||||||
|
</property>
|
||||||
|
<property name="checked">
|
||||||
|
<bool>false</bool>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<spacer name="spacer4">
|
<spacer name="spacer4">
|
||||||
<property name="orientation">
|
<property name="orientation">
|
||||||
|
|||||||
@ -92,7 +92,6 @@ void UIPrefsDialog::init()
|
|||||||
ssAutoSpaceCB, SLOT(setDisabled(bool)));
|
ssAutoSpaceCB, SLOT(setDisabled(bool)));
|
||||||
connect(ssAutoAllCB, SIGNAL(toggled(bool)),
|
connect(ssAutoAllCB, SIGNAL(toggled(bool)),
|
||||||
ssAutoSpaceCB, SLOT(setChecked(bool)));
|
ssAutoSpaceCB, SLOT(setChecked(bool)));
|
||||||
|
|
||||||
setFromPrefs();
|
setFromPrefs();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -126,6 +125,8 @@ void UIPrefsDialog::setFromPrefs()
|
|||||||
initStartAdvCB->setChecked(prefs.startWithAdvSearchOpen);
|
initStartAdvCB->setChecked(prefs.startWithAdvSearchOpen);
|
||||||
|
|
||||||
keepSortCB->setChecked(prefs.keepSort);
|
keepSortCB->setChecked(prefs.keepSort);
|
||||||
|
showTrayIconCB->setChecked(prefs.showTrayIcon);
|
||||||
|
closeToTrayCB->setChecked(prefs.closeToTray);
|
||||||
previewHtmlCB->setChecked(prefs.previewHtml);
|
previewHtmlCB->setChecked(prefs.previewHtml);
|
||||||
switch (prefs.previewPlainPre) {
|
switch (prefs.previewPlainPre) {
|
||||||
case PrefsPack::PP_BR:
|
case PrefsPack::PP_BR:
|
||||||
@ -289,6 +290,8 @@ void UIPrefsDialog::accept()
|
|||||||
prefs.startWithAdvSearchOpen = initStartAdvCB->isChecked();
|
prefs.startWithAdvSearchOpen = initStartAdvCB->isChecked();
|
||||||
|
|
||||||
prefs.keepSort = keepSortCB->isChecked();
|
prefs.keepSort = keepSortCB->isChecked();
|
||||||
|
prefs.showTrayIcon = showTrayIconCB->isChecked();
|
||||||
|
prefs.closeToTray = closeToTrayCB->isChecked();
|
||||||
prefs.previewHtml = previewHtmlCB->isChecked();
|
prefs.previewHtml = previewHtmlCB->isChecked();
|
||||||
|
|
||||||
if (plainBRRB->isChecked()) {
|
if (plainBRRB->isChecked()) {
|
||||||
@ -520,6 +523,11 @@ static bool samedir(const string& dir1, const string& dir2)
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void UIPrefsDialog::on_showTrayIconCB_clicked()
|
||||||
|
{
|
||||||
|
closeToTrayCB->setEnabled(showTrayIconCB->checkState());
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Browse to add another index.
|
* Browse to add another index.
|
||||||
* We do a textual comparison to check for duplicates, except for
|
* We do a textual comparison to check for duplicates, except for
|
||||||
|
|||||||
@ -57,6 +57,7 @@ public slots:
|
|||||||
virtual void addExtraDbPB_clicked();
|
virtual void addExtraDbPB_clicked();
|
||||||
virtual void delExtraDbPB_clicked();
|
virtual void delExtraDbPB_clicked();
|
||||||
virtual void togExtraDbPB_clicked();
|
virtual void togExtraDbPB_clicked();
|
||||||
|
virtual void on_showTrayIconCB_clicked();
|
||||||
virtual void actAllExtraDbPB_clicked();
|
virtual void actAllExtraDbPB_clicked();
|
||||||
virtual void unacAllExtraDbPB_clicked();
|
virtual void unacAllExtraDbPB_clicked();
|
||||||
virtual void setStemLang(const QString& lang);
|
virtual void setStemLang(const QString& lang);
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user