mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-03 07:35:48 +08:00
refs #830, use settings in views
also avoid changing style when not needed
This commit is contained in:
@@ -75,9 +75,9 @@ namespace BlackGui
|
||||
CGuiApplication::registerMetadata();
|
||||
CApplication::init(false); // base class without metadata
|
||||
this->setWindowIcon(icon);
|
||||
this->settingsChanged();
|
||||
sGui = this;
|
||||
connect(&this->m_styleSheetUtility, &CStyleSheetUtility::styleSheetsChanged, this, &CGuiApplication::styleSheetsChanged);
|
||||
reloadWidgetStyleFromSettings();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -89,6 +89,7 @@ using namespace BlackGui;
|
||||
using namespace BlackGui::Menus;
|
||||
using namespace BlackGui::Models;
|
||||
using namespace BlackGui::Filters;
|
||||
using namespace BlackGui::Settings;
|
||||
|
||||
namespace BlackGui
|
||||
{
|
||||
@@ -262,6 +263,19 @@ namespace BlackGui
|
||||
return ma;
|
||||
}
|
||||
|
||||
void CViewBaseNonTemplate::settingsChanged()
|
||||
{
|
||||
if (this->allowsMultipleSelectedRows())
|
||||
{
|
||||
const CGeneralGuiSettings settings = this->m_guiSettings.getThreadLocal();
|
||||
this->m_originalSelectionMode = settings.getPreferredSelection();
|
||||
if (this->isCurrentlyAllowingMultipleRowSelections())
|
||||
{
|
||||
this->setSelectionMode(settings.getPreferredSelection());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void CViewBaseNonTemplate::customMenu(CMenuActions &menuActions)
|
||||
{
|
||||
// delegate?
|
||||
@@ -405,6 +419,17 @@ namespace BlackGui
|
||||
return this->selectedRowCount() > 1;
|
||||
}
|
||||
|
||||
bool CViewBaseNonTemplate::allowsMultipleSelectedRows() const
|
||||
{
|
||||
return this->m_originalSelectionMode == ExtendedSelection || this->m_originalSelectionMode == MultiSelection;
|
||||
}
|
||||
|
||||
bool CViewBaseNonTemplate::isCurrentlyAllowingMultipleRowSelections() const
|
||||
{
|
||||
QAbstractItemView::SelectionMode m = this->selectionMode();
|
||||
return m == QAbstractItemView::MultiSelection || m == QAbstractItemView::ExtendedSelection;
|
||||
}
|
||||
|
||||
void CViewBaseNonTemplate::init()
|
||||
{
|
||||
const int fh = qRound(1.5 * this->getHorizontalHeaderFontHeight());
|
||||
@@ -421,6 +446,8 @@ namespace BlackGui
|
||||
Q_ASSERT_X(false, Q_FUNC_INFO, "wrong resize mode");
|
||||
break;
|
||||
}
|
||||
|
||||
this->settingsChanged();
|
||||
}
|
||||
|
||||
QString CViewBaseNonTemplate::getDefaultFilename(bool load) const
|
||||
@@ -652,7 +679,7 @@ namespace BlackGui
|
||||
|
||||
void CViewBaseNonTemplate::ps_setSingleSelection()
|
||||
{
|
||||
if (this->m_originalSelectionMode == ExtendedSelection || this->m_originalSelectionMode == MultiSelection)
|
||||
if (this->allowsMultipleSelectedRows())
|
||||
{
|
||||
this->setSelectionMode(SingleSelection);
|
||||
}
|
||||
@@ -660,7 +687,7 @@ namespace BlackGui
|
||||
|
||||
void CViewBaseNonTemplate::ps_setExtendedSelection()
|
||||
{
|
||||
if (this->m_originalSelectionMode == ExtendedSelection || this->m_originalSelectionMode == MultiSelection)
|
||||
if (this->allowsMultipleSelectedRows())
|
||||
{
|
||||
this->setSelectionMode(ExtendedSelection);
|
||||
}
|
||||
@@ -668,7 +695,7 @@ namespace BlackGui
|
||||
|
||||
void CViewBaseNonTemplate::ps_setMultiSelection()
|
||||
{
|
||||
if (this->m_originalSelectionMode == ExtendedSelection || this->m_originalSelectionMode == MultiSelection)
|
||||
if (this->allowsMultipleSelectedRows())
|
||||
{
|
||||
this->setSelectionMode(MultiSelection);
|
||||
}
|
||||
|
||||
@@ -12,11 +12,11 @@
|
||||
#ifndef BLACKGUI_VIEWBASE_H
|
||||
#define BLACKGUI_VIEWBASE_H
|
||||
|
||||
#include "blackgui/blackguiexport.h"
|
||||
#include "blackgui/components/enablefordockwidgetinfoarea.h"
|
||||
#include "blackgui/menus/menuaction.h"
|
||||
#include "blackgui/models/modelfilter.h"
|
||||
#include "blackmisc/namevariantpair.h"
|
||||
#include "blackgui/settings/guisettings.h"
|
||||
#include "blackgui/blackguiexport.h"
|
||||
#include "blackmisc/namevariantpairlist.h"
|
||||
#include "blackmisc/propertyindex.h"
|
||||
#include "blackmisc/propertyindexvariantmap.h"
|
||||
@@ -197,6 +197,12 @@ namespace BlackGui
|
||||
//! Multiple selected rows
|
||||
bool hasMultipleSelectedRows() const;
|
||||
|
||||
//! Allows to select multiple rows
|
||||
bool allowsMultipleSelectedRows() const;
|
||||
|
||||
//! Is the current selection mode allow multiple selection
|
||||
bool isCurrentlyAllowingMultipleRowSelections() const;
|
||||
|
||||
//! Filter dialog
|
||||
void setFilterDialog(BlackGui::Filters::CFilterDialog *filterDialog);
|
||||
|
||||
@@ -376,6 +382,9 @@ namespace BlackGui
|
||||
//! Draw drop indicator
|
||||
virtual void drawDropIndicator(bool indicator) = 0;
|
||||
|
||||
//! Settings have been changed
|
||||
void settingsChanged();
|
||||
|
||||
QString m_saveFileName; //!< save file name (JSON)
|
||||
ResizeMode m_resizeMode = PresizeSubset; //!< mode
|
||||
RowsResizeMode m_rowResizeMode = Interactive; //!< row resize mode for row height
|
||||
@@ -397,6 +406,7 @@ namespace BlackGui
|
||||
BlackGui::Menus::IMenuDelegate *m_menu = nullptr; //!< custom menu if any
|
||||
BlackGui::CLoadIndicator *m_loadIndicator = nullptr; //!< load indicator if needed
|
||||
QMap<MenuFlag, BlackGui::Menus::CMenuActions> m_menuFlagActions; //!< initialized actions
|
||||
BlackMisc::CSettingReadOnly<BlackGui::Settings::TGeneralGui> m_guiSettings { this, &CViewBaseNonTemplate::settingsChanged }; //!< general GUI settings
|
||||
|
||||
protected slots:
|
||||
//! Helper method with template free signature serving as callback from threaded worker
|
||||
|
||||
Reference in New Issue
Block a user