File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1- # include " ParameterApp.h "
1+
22#include < QSettings>
33#include < QDir>
44#include " RabbitCommonDir.h"
55#ifdef HAVE_ICE
66 #include " Ice.h"
77#endif
8+ #include " ParameterGlobal.h"
9+ #include " ParameterApp.h"
810
911CParameterApp::CParameterApp (QObject *parent) : CParameter(parent, " MainWindow" ),
10- m_Database( this ),
12+ m_pGloablParamter( nullptr ),
1113 m_bReceiveShortCut(false ),
1214 m_bSaveMainWindowStatus(true ),
1315 m_ViewType(ViewType::Tab),
@@ -172,6 +174,16 @@ int CParameterApp::OnSave(QSettings &set)
172174 return 0 ;
173175}
174176
177+ CParameterGlobal* CParameterApp::GetGlobalParameters () const
178+ {
179+ return m_pGloablParamter;
180+ }
181+
182+ void CParameterApp::SetGlobalParameters (CParameterGlobal* para)
183+ {
184+ m_pGloablParamter = para;
185+ }
186+
175187bool CParameterApp::GetReceiveShortCut () const
176188{
177189 return m_bReceiveShortCut;
Original file line number Diff line number Diff line change 55#include " Parameter.h"
66#include " ParameterDatabase.h"
77
8+ class CParameterGlobal ;
89class CParameterApp : public CParameter
910{
1011 Q_OBJECT
@@ -14,6 +15,11 @@ class CParameterApp : public CParameter
1415 virtual ~CParameterApp ();
1516
1617 CParameterDatabase m_Database;
18+ CParameterGlobal* GetGlobalParameters () const ;
19+
20+ private:
21+ Q_INVOKABLE void SetGlobalParameters (CParameterGlobal* pGlobal);
22+ CParameterGlobal* m_pGloablParamter;
1723
1824protected:
1925 virtual int OnLoad (QSettings &set);
Original file line number Diff line number Diff line change 44#include < QLoggingCategory>
55#include " RecentModel.h"
66#include " ParameterApp.h"
7+ #include " ParameterGlobal.h"
78
89static Q_LOGGING_CATEGORY (log, " App.Recent.Model" )
910CRecentModel::CRecentModel(CParameterApp *pPara, CRecentDatabase *pDb, QObject *parent)
@@ -23,11 +24,21 @@ Qt::ItemFlags CRecentModel::flags(const QModelIndex &index) const
2324 return f;
2425
2526 auto item = m_Items.at (index.row ());
26- QFileInfo fi (item.GetFile ());
27- if (fi.exists ())
28- f |= Qt::ItemIsEnabled;
29- else
30- f &= ~Qt::ItemIsEnabled;
27+ QString szFile = item.GetFile ();
28+ if (szFile.isEmpty ()) {
29+ return f;
30+ }
31+
32+ QFileInfo fi (szFile);
33+ if (m_pParameterApp->GetGlobalParameters ()->GetSaveSettingsType ()
34+ == CParameterGlobal::SaveSettingsType::File) {
35+ if (fi.exists ())
36+ f |= Qt::ItemIsEnabled;
37+ else
38+ f &= ~Qt::ItemIsEnabled;
39+ return f;
40+ }
41+
3142 return f;
3243}
3344
Original file line number Diff line number Diff line change @@ -424,8 +424,21 @@ int MainWindow::Initial()
424424 }
425425 m_Manager.EnumPlugins (this );
426426
427- if (m_Manager.GetGlobalParameters ())
427+ if (m_Manager.GetGlobalParameters ()) {
428+ // m_Parameter.SetGlobalParameters(m_Manager.GetGlobalParameters());
429+ bool bRet = QMetaObject::invokeMethod (
430+ &m_Parameter,
431+ " SetGlobalParameters" ,
432+ Qt::DirectConnection,
433+ Q_ARG (CParameterGlobal*, m_Manager.GetGlobalParameters ()));
434+ if (!bRet) {
435+ szErr = tr (" Failed to set global parameters" );
436+ qCritical (log) << szErr;
437+ nRet = -1 ;
438+ break ;
439+ }
428440 m_Parameter.m_Database = m_Manager.GetGlobalParameters ()->m_Database ;
441+ }
429442
430443 if (m_pRecent) {
431444 szMsg = tr (" Load list recent dock ......" );
Original file line number Diff line number Diff line change @@ -59,10 +59,13 @@ CBookmarkDatabase::~CBookmarkDatabase()
5959
6060bool CBookmarkDatabase::OnInitializeDatabase ()
6161{
62+ bool bRet = false ;
6263 m_UrlDB.SetDatabase (GetDatabase (), m_pPara);
63- m_UrlDB.OnInitializeDatabase ();
64+ bRet = m_UrlDB.OnInitializeDatabase ();
65+ if (!bRet) return false ;
6466 m_TreeDB.SetDatabase (GetDatabase (), m_pPara);
65- m_TreeDB.OnInitializeDatabase ();
67+ bRet = m_TreeDB.OnInitializeDatabase ();
68+ if (!bRet) return false ;
6669
6770 if (m_TreeDB.GetNodeCount () == 0 ) {
6871 m_TreeDB.AddNode (tr (" Bookmarks" ), 0 );
Original file line number Diff line number Diff line change @@ -74,7 +74,7 @@ bool CHistoryDatabase::OnInitializeDatabase()
7474 success = CDatabase::OnInitializeDatabase ();
7575 if (!success) return false ;
7676 m_UrlDB.SetDatabase (GetDatabase (), m_pPara);
77- m_UrlDB.OnInitializeDatabase ();
77+ success = m_UrlDB.OnInitializeDatabase ();
7878 return success;
7979}
8080
You can’t perform that action at this time.
0 commit comments