add preference to hide the toolbars

This commit is contained in:
Jean-Francois Dockes 2020-11-18 18:20:24 +01:00
parent 0445302350
commit a244983b3a
6 changed files with 67 additions and 30 deletions

View File

@ -293,6 +293,7 @@ void rwSettings(bool writing)
SETTING_RW(prefs.fileTypesByCats, "/Recoll/prefs/query/asearchFilTypByCat",
Bool, false);
SETTING_RW(prefs.noToolbars, "/Recoll/prefs/noToolbars", Bool, false);
SETTING_RW(prefs.showTrayIcon, "/Recoll/prefs/showTrayIcon", Bool, false);
SETTING_RW(prefs.closeToTray, "/Recoll/prefs/closeToTray", Bool, false);
SETTING_RW(prefs.trayMessages, "/Recoll/prefs/trayMessages", Bool, false);

View File

@ -140,6 +140,7 @@ class PrefsPack {
// Suppress all noises
bool noBeeps;
bool noToolbars{false};
bool showTrayIcon{false};
bool closeToTray{false};
bool trayMessages{false};

View File

@ -198,21 +198,7 @@ void RclMain::init()
}
}
curid->setChecked(true);
m_toolsTB = new QToolBar(tr("Tools"), this);
m_toolsTB->setObjectName(QString::fromUtf8("m_toolsTB"));
m_toolsTB->addAction(toolsAdvanced_SearchAction);
m_toolsTB->addAction(toolsDoc_HistoryAction);
m_toolsTB->addAction(toolsSpellAction);
m_toolsTB->addAction(actionQuery_Fragments);
QSettings settings;
int val = settings.value(settingskey_toolarea).toInt();
this->addToolBar(int2area(val), m_toolsTB);
m_resTB = new QToolBar(tr("Results"), this);
m_resTB->setObjectName(QString::fromUtf8("m_resTB"));
val = settings.value(settingskey_resarea).toInt();
this->addToolBar(int2area(val), m_resTB);
setupToolbars();
// Document filter buttons and combobox
// Combobox version of the document filter control
@ -452,6 +438,7 @@ void RclMain::init()
onSortDataChanged(m_sortspec);
emit sortDataChanged(m_sortspec);
}
QSettings settings;
restoreGeometry(settings.value("/Recoll/geometry/maingeom").toByteArray());
enableTrayIcon(prefs.showTrayIcon);
@ -464,6 +451,38 @@ void RclMain::init()
periodictimer->start(1000);
}
void RclMain::setupToolbars()
{
if (nullptr == m_toolsTB) {
m_toolsTB = new QToolBar(tr("Tools"), this);
m_toolsTB->setObjectName(QString::fromUtf8("m_toolsTB"));
m_toolsTB->addAction(toolsAdvanced_SearchAction);
m_toolsTB->addAction(toolsDoc_HistoryAction);
m_toolsTB->addAction(toolsSpellAction);
m_toolsTB->addAction(actionQuery_Fragments);
}
QSettings settings;
int val;
if (!prefs.noToolbars) {
val = settings.value(settingskey_toolarea).toInt();
this->addToolBar(int2area(val), m_toolsTB);
m_toolsTB->show();
} else {
m_toolsTB->hide();
}
if (nullptr == m_resTB) {
m_resTB = new QToolBar(tr("Results"), this);
m_resTB->setObjectName(QString::fromUtf8("m_resTB"));
}
if (!prefs.noToolbars) {
val = settings.value(settingskey_resarea).toInt();
this->addToolBar(int2area(val), m_resTB);
m_resTB->show();
} else {
m_resTB->hide();
}
}
void RclMain::enableTrayIcon(bool on)
{
on = on && QSystemTrayIcon::isSystemTrayAvailable();
@ -750,8 +769,10 @@ void RclMain::fileExit()
if (!isMaximized()) {
settings.setValue("/Recoll/geometry/maingeom", saveGeometry());
}
settings.setValue(settingskey_toolarea, toolBarArea(m_toolsTB));
settings.setValue(settingskey_resarea, toolBarArea(m_resTB));
if (!prefs.noToolbars) {
settings.setValue(settingskey_toolarea, toolBarArea(m_toolsTB));
settings.setValue(settingskey_resarea, toolBarArea(m_resTB));
}
restable->saveColState();
if (prefs.ssearchTypSav) {

View File

@ -89,7 +89,8 @@ public:
}
void enableTrayIcon(bool onoff);
QString readDarkCSS();
void setupToolbars();
public slots:
virtual void fileExit();
virtual void periodic100();

View File

@ -35,7 +35,7 @@
</widget>
</item>
<item>
<widget class="Line" name="line">
<widget class="Line" name="line1">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
@ -112,7 +112,7 @@
</widget>
</item>
<item>
<widget class="Line" name="line">
<widget class="Line" name="line2">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
@ -163,12 +163,12 @@
</layout>
</item>
<item>
<widget class="QCheckBox" name="showTempFileWarningCB">
<widget class="QCheckBox" name="noToolbarsCB">
<property name="text">
<string>Show warning when opening temporary file.</string>
<string>Hide toolbars.</string>
</property>
<property name="checked">
<bool>true</bool>
<bool>false</bool>
</property>
</widget>
</item>
@ -212,6 +212,16 @@
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="showTempFileWarningCB">
<property name="text">
<string>Show warning when opening temporary file.</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="ssNoCompleteCB">
<property name="text">
@ -233,7 +243,7 @@
</widget>
</item>
<item>
<widget class="Line" name="line">
<widget class="Line" name="line3">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
@ -346,7 +356,7 @@
</layout>
</item>
<item>
<widget class="Line" name="line">
<widget class="Line" name="line4">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
@ -732,7 +742,7 @@
</layout>
</item>
<item>
<widget class="Line" name="lineX">
<widget class="Line" name="line5">
<property name="frameShape">
<enum>QFrame::HLine</enum>
</property>
@ -789,7 +799,7 @@ The default value is 2 (percent). </string>
</layout>
</item>
<item>
<widget class="Line" name="line2">
<widget class="Line" name="line6">
<property name="frameShape">
<enum>QFrame::HLine</enum>
</property>
@ -895,7 +905,7 @@ May be slow for big documents.</string>
</layout>
</item>
<item>
<widget class="Line" name="line3">
<widget class="Line" name="line7">
<property name="frameShape">
<enum>QFrame::HLine</enum>
</property>
@ -945,7 +955,7 @@ May be slow for big documents.</string>
</layout>
</item>
<item>
<widget class="Line" name="line31">
<widget class="Line" name="line8">
<property name="frameShape">
<enum>QFrame::HLine</enum>
</property>
@ -1064,7 +1074,7 @@ May be slow for big documents.</string>
</layout>
</item>
<item>
<widget class="Line" name="line2_2">
<widget class="Line" name="line9">
<property name="frameShape">
<enum>QFrame::HLine</enum>
</property>

View File

@ -144,6 +144,7 @@ void UIPrefsDialog::setFromPrefs()
keepSortCB->setChecked(prefs.keepSort);
noToolbarsCB->setChecked(prefs.noToolbars);
showTrayIconCB->setChecked(prefs.showTrayIcon);
if (!prefs.showTrayIcon) {
prefs.closeToTray = false;
@ -347,6 +348,8 @@ void UIPrefsDialog::accept()
prefs.startWithAdvSearchOpen = initStartAdvCB->isChecked();
prefs.keepSort = keepSortCB->isChecked();
prefs.noToolbars = noToolbarsCB->isChecked();
m_mainWindow->setupToolbars();
prefs.showTrayIcon = showTrayIconCB->isChecked();
m_mainWindow->enableTrayIcon(prefs.showTrayIcon);
prefs.closeToTray = closeToTrayCB->isChecked();