Show fingerprint only when file exists #4526

This commit is contained in:
XinyuHou 2015-04-16 17:12:42 +01:00
parent 88538e5ee6
commit 59d013ac6a
3 changed files with 33 additions and 11 deletions

View File

@ -88,6 +88,26 @@ bool Fingerprint::exists(const QString& fingerprintText)
return false;
}
bool Fingerprint::localFingerprintExists()
{
CoreInterface coreInterface;
QString profileDir = coreInterface.getProfileDir();
QString dirName = QString("%1/%2")
.arg(profileDir)
.arg(kDirName);
QString path = QString("%1/%2").arg(dirName).arg(kLocalFilename);
QFile file(path);
bool exist = false;
if (file.exists()) {
exist = true;
}
return exist;
}
Fingerprint Fingerprint::local()
{
return Fingerprint(kLocalFilename);

View File

@ -34,6 +34,7 @@ public:
static Fingerprint trustedClients();
static QString localFingerprint();
static bool localFingerprintExists();
private:
QString m_Filename;

View File

@ -23,6 +23,7 @@
#include "MainWindow.h"
#include "Fingerprint.h"
#include "PluginManager.h"
#include "AboutDialog.h"
#include "ServerConfigDialog.h"
#include "SettingsDialog.h"
@ -133,6 +134,17 @@ MainWindow::MainWindow(QSettings& settings, AppConfig& appConfig) :
updateEdition();
m_pLabelPadlock->hide();
if (Fingerprint::localFingerprintExists()) {
m_pLabelFingerprint->setVisible(true);
m_pLabelLocalFingerprint->setVisible(true);
m_pLabelLocalFingerprint->setText(
Fingerprint::localFingerprint());
}
else {
m_pLabelFingerprint->setVisible(false);
m_pLabelLocalFingerprint->setVisible(false);
}
}
MainWindow::~MainWindow()
@ -941,17 +953,6 @@ void MainWindow::setEdition(int type)
}
setWindowTitle(title);
if (type == Pro) {
m_pLabelFingerprint->setVisible(true);
m_pLabelLocalFingerprint->setVisible(true);
m_pLabelLocalFingerprint->setText(
Fingerprint::localFingerprint());
}
else {
m_pLabelFingerprint->setVisible(false);
m_pLabelLocalFingerprint->setVisible(false);
}
}
void MainWindow::on_m_pGroupClient_toggled(bool on)