Skip to content

Commit 46f4375

Browse files
committed
App: modify recent menu to add icon
1 parent e736f55 commit 46f4375

4 files changed

Lines changed: 32 additions & 15 deletions

File tree

App/Client/mainwindow.cpp

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -421,7 +421,7 @@ void MainWindow::slotInitial()
421421
auto recents = m_pRecentDb->GetRecents(m_Parameter.GetRecentMenuMaxCount());
422422
//qDebug(log) << "recents totaol:" << recents.size() << m_Parameter.GetRecentMenuMaxCount();
423423
for(auto it = recents.rbegin(); it != recents.rend(); it++) {
424-
m_pRecentMenu->addRecentFile(it->szFile, it->szName);
424+
m_pRecentMenu->addRecentFile(it->szFile, it->szName, it->icon);
425425
}
426426
}
427427

@@ -939,7 +939,7 @@ int MainWindow::Start(COperate *pOperate, bool set, QString szFile)
939939
if(bSave)
940940
nRet = m_Manager.SaveOperate(pOperate);
941941
if(0 == nRet) {
942-
m_pRecentMenu->addRecentFile(szFile, pOperate->Name());
942+
m_pRecentMenu->addRecentFile(szFile, pOperate->Name(), pOperate->Icon());
943943
CRecentDatabase::RecentItem item;
944944
item.szOperateId = pOperate->Id();
945945
item.icon = pOperate->Icon();
@@ -1241,19 +1241,31 @@ void MainWindow::slotUpdateName(const QString& szName)
12411241
{
12421242
COperate* p = qobject_cast<COperate*>(sender());
12431243
if(!p) return;
1244+
// Update view
12441245
m_pView->SetWidowsTitle(p->GetViewer(), szName,
12451246
p->Icon(), p->Description());
1247+
1248+
// Update recent menu
1249+
if(m_pRecentMenu)
1250+
m_pRecentMenu->updateRecentFile(p->GetSettingsFile(), szName, p->Icon());
1251+
1252+
// Update recent list view dock widget
12461253
if(m_pRecentDb) {
12471254
m_pRecentDb->UpdateRecent(
12481255
p->GetSettingsFile(), p->Name(), p->Description());
12491256
}
1257+
1258+
// Update activity menu
12501259
foreach(auto a, ui->menuActivity->actions()) {
12511260
if(a->data().value<COperate*>() == p) {
12521261
a->setText(szName);
12531262
a->setIcon(p->Icon());
12541263
break;
12551264
}
12561265
}
1266+
1267+
//Update activity list view dock widget
1268+
m_pFrmActive->slotLoad();
12571269
}
12581270

12591271
QAction* MainWindow::GetStartAction(QMenu* pMenu, CPlugin *pPlug)

Plugins/TigerVnc/Client/BackendVnc.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -588,7 +588,7 @@ void CBackendVnc::slotChannelError(int nErr, const QString& szErr)
588588
void CBackendVnc::initDone()
589589
{
590590
Q_ASSERT(m_pPara);
591-
qDebug(log, "initDone:\n%s", ConnectInformation().toStdString().c_str());
591+
qDebug(log, "initDone: %s", ConnectInformation().toStdString().c_str());
592592

593593
emit sigSetDesktopSize(server.width(), server.height());
594594
QString szName = QString::fromUtf8(server.name());

Src/Database.cpp

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,9 @@ CDatabase::~CDatabase()
2424

2525
void CDatabase::SetDatabase(QSqlDatabase db)
2626
{
27+
QString szErr = "Only one of OpenDatabase and SetDatabase can be called, and it can only be called once";
28+
qCritical(log) << szErr;
29+
Q_ASSERT_X(!IsOpen(), "Database", szErr.toStdString().c_str());
2730
m_database = db;
2831
}
2932

@@ -47,8 +50,9 @@ bool CDatabase::OpenDatabase(const QString &connectionName, const QString &dbPat
4750
databasePath = dbPath;
4851
}
4952

50-
if(IsOpen())
51-
CloseDatabase();
53+
QString szErr = "Only one of OpenDatabase and SetDatabase can be called, and it can only be called once";
54+
qCritical(log) << szErr;
55+
Q_ASSERT_X(!IsOpen(), "Database", szErr.toStdString().c_str());
5256

5357
if(!connectionName.isEmpty())
5458
m_szConnectName = connectionName;

Src/OperateDesktop.cpp

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -634,16 +634,17 @@ QString COperateDesktop::ServerName()
634634

635635
void COperateDesktop::slotSetServerName(const QString& szName)
636636
{
637-
if(m_szServerName == szName)
638-
return;
639-
640-
m_szServerName = szName;
641-
if(GetParameter())
642-
{
643-
if(GetParameter()->GetServerName() == szName)
644-
return;
645-
GetParameter()->SetServerName(szName);
646-
}
637+
do{
638+
if(m_szServerName == szName)
639+
break;;
647640

641+
m_szServerName = szName;
642+
if(GetParameter())
643+
{
644+
if(GetParameter()->GetServerName() == szName)
645+
break;
646+
GetParameter()->SetServerName(szName);
647+
}
648+
} while(0);
648649
slotUpdateName();
649650
}

0 commit comments

Comments
 (0)