clean up AppConfig; eliminate unnecessary UI changes to MainWindow; MainWindow starts at smaller size

This commit is contained in:
walker0643 2018-02-25 16:22:10 -05:00
parent 2a4382bac9
commit b55fe3237a
7 changed files with 41 additions and 96 deletions

View File

@ -206,35 +206,21 @@ void AppConfig::setStartedBefore(bool b) { m_StartedBefore = b; }
void AppConfig::setElevateMode(ElevateMode em) { m_ElevateMode = em; }
void AppConfig::setAutoConfig(bool autoConfig)
{
m_AutoConfig = autoConfig;
}
void AppConfig::setAutoConfig(bool autoConfig) { m_AutoConfig = autoConfig; }
bool AppConfig::autoConfigPrompted() { return m_AutoConfigPrompted; }
void AppConfig::setAutoConfigPrompted(bool prompted)
{
m_AutoConfigPrompted = prompted;
}
void AppConfig::setAutoConfigPrompted(bool prompted) { m_AutoConfigPrompted = prompted; }
QString AppConfig::barriersName() const { return m_BarriersName; }
QString AppConfig::barriercName() const { return m_BarriercName; }
ElevateMode AppConfig::elevateMode()
{
return m_ElevateMode;
}
ElevateMode AppConfig::elevateMode() { return m_ElevateMode; }
void AppConfig::setCryptoEnabled(bool e) {
m_CryptoEnabled = e;
emit sslToggled(e);
}
void AppConfig::setCryptoEnabled(bool e) { m_CryptoEnabled = e; }
bool AppConfig::getCryptoEnabled() const {
return m_CryptoEnabled;
}
bool AppConfig::getCryptoEnabled() const { return m_CryptoEnabled; }
void AppConfig::setAutoHide(bool b) { m_AutoHide = b; }

View File

@ -85,7 +85,6 @@ class AppConfig: public QObject
QString barrierProgramDir() const;
QString barrierLogDir() const;
bool detectPath(const QString& name, QString& path);
void persistLogDir();
ElevateMode elevateMode();
@ -136,9 +135,6 @@ protected:
static const char m_BarriersName[];
static const char m_BarriercName[];
static const char m_BarrierLogDir[];
signals:
void sslToggled(bool enabled);
};
#endif

View File

@ -16,8 +16,6 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#define DOWNLOAD_URL "http://github.com/debauchee/barrier/"
#include <iostream>
#include "MainWindow.h"
@ -117,10 +115,10 @@ MainWindow::MainWindow(QSettings& settings, AppConfig& appConfig) :
// change default size based on os
#if defined(Q_OS_MAC)
resize(720, 550);
setMinimumSize(size());
setMinimumSize(720, 0);
#elif defined(Q_OS_LINUX)
resize(700, 530);
setMinimumSize(size());
setMinimumSize(700, 0);
#endif
m_SuppressAutoConfigWarning = true;
@ -130,10 +128,10 @@ MainWindow::MainWindow(QSettings& settings, AppConfig& appConfig) :
m_pComboServerList->hide();
m_pLabelPadlock->hide();
sslToggled(appConfig.getCryptoEnabled());
updateSSLFingerprint();
connect (m_AppConfig, SIGNAL(sslToggled(bool)),
this, SLOT(sslToggled(bool)), Qt::QueuedConnection);
// resize window to smallest reasonable size
resize(0, 0);
}
MainWindow::~MainWindow()
@ -146,15 +144,8 @@ MainWindow::~MainWindow()
saveSettings();
delete m_pZeroconfService;
if (m_DownloadMessageBox != NULL) {
delete m_DownloadMessageBox;
}
if (m_BonjourInstall != NULL) {
delete m_BonjourInstall;
}
delete m_DownloadMessageBox;
delete m_BonjourInstall;
delete m_pSslCertificate;
}
@ -556,16 +547,6 @@ void MainWindow::startBarrier()
}
}
void
MainWindow::sslToggled (bool enabled)
{
if (enabled) {
m_pSslCertificate = new SslCertificate(this);
m_pSslCertificate->generateCertificate();
}
updateLocalFingerprint();
}
bool MainWindow::clientArgs(QStringList& args, QString& app)
{
app = appPath(appConfig().barriercName());
@ -947,16 +928,16 @@ void MainWindow::serverDetected(const QString name)
}
}
void MainWindow::updateLocalFingerprint()
void MainWindow::updateSSLFingerprint()
{
if (m_AppConfig->getCryptoEnabled() && Fingerprint::local().fileExists()) {
m_pLabelFingerprint->setVisible(true);
m_pLabelLocalFingerprint->setVisible(true);
m_pLabelLocalFingerprint->setText(Fingerprint::local().readFirst());
if (m_AppConfig->getCryptoEnabled() && m_pSslCertificate == nullptr) {
m_pSslCertificate = new SslCertificate(this);
m_pSslCertificate->generateCertificate();
}
else {
m_pLabelFingerprint->setVisible(false);
m_pLabelLocalFingerprint->setVisible(false);
if (m_AppConfig->getCryptoEnabled() && Fingerprint::local().fileExists()) {
m_pLabelLocalFingerprint->setText(Fingerprint::local().readFirst());
} else {
m_pLabelLocalFingerprint->setText("Disabled");
}
}
@ -1004,13 +985,13 @@ bool MainWindow::on_m_pActionSave_triggered()
void MainWindow::on_m_pActionAbout_triggered()
{
AboutDialog dlg(this, appPath(appConfig().barriercName()));
dlg.exec();
AboutDialog(this, appPath(appConfig().barriercName())).exec();
}
void MainWindow::on_m_pActionSettings_triggered()
{
SettingsDialog(this, appConfig()).exec();
if (SettingsDialog(this, appConfig()).exec() == QDialog::Accepted)
updateSSLFingerprint();
}
void MainWindow::autoAddScreen(const QString name)

View File

@ -113,7 +113,6 @@ class MainWindow : public QMainWindow, public Ui::MainWindowBase
void autoAddScreen(const QString name);
void updateZeroconfService();
void serverDetected(const QString name);
void updateLocalFingerprint();
public slots:
void appendLogRaw(const QString& text);
@ -123,7 +122,6 @@ public slots:
void startBarrier();
protected slots:
void sslToggled(bool enabled);
void on_m_pGroupClient_toggled(bool on);
void on_m_pGroupServer_toggled(bool on);
bool on_m_pButtonBrowseConfigFile_clicked();
@ -173,9 +171,8 @@ public slots:
QString getTimeStamp();
void restartBarrier();
void proofreadInfo();
void windowStateChanged();
void updateSSLFingerprint();
private:
QSettings& m_Settings;

View File

@ -18,8 +18,8 @@
</property>
<property name="minimumSize">
<size>
<width>500</width>
<height>400</height>
<width>600</width>
<height>0</height>
</size>
</property>
<property name="windowTitle">

View File

@ -65,26 +65,26 @@ SettingsDialog::SettingsDialog(QWidget* parent, AppConfig& config) :
void SettingsDialog::accept()
{
appConfig().setScreenName(m_pLineEditScreenName->text());
appConfig().setPort(m_pSpinBoxPort->value());
appConfig().setNetworkInterface(m_pLineEditInterface->text());
appConfig().setLogLevel(m_pComboLogLevel->currentIndex());
appConfig().setLogToFile(m_pCheckBoxLogToFile->isChecked());
appConfig().setLogFilename(m_pLineEditLogFilename->text());
appConfig().setLanguage(m_pComboLanguage->itemData(m_pComboLanguage->currentIndex()).toString());
appConfig().setElevateMode(static_cast<ElevateMode>(m_pComboElevate->currentIndex()));
appConfig().setAutoHide(m_pCheckBoxAutoHide->isChecked());
appConfig().setMinimizeToTray(m_pCheckBoxMinimizeToTray->isChecked());
appConfig().saveSettings();
m_appConfig.setScreenName(m_pLineEditScreenName->text());
m_appConfig.setPort(m_pSpinBoxPort->value());
m_appConfig.setNetworkInterface(m_pLineEditInterface->text());
m_appConfig.setCryptoEnabled(m_pCheckBoxEnableCrypto->isChecked());
m_appConfig.setLogLevel(m_pComboLogLevel->currentIndex());
m_appConfig.setLogToFile(m_pCheckBoxLogToFile->isChecked());
m_appConfig.setLogFilename(m_pLineEditLogFilename->text());
m_appConfig.setLanguage(m_pComboLanguage->itemData(m_pComboLanguage->currentIndex()).toString());
m_appConfig.setElevateMode(static_cast<ElevateMode>(m_pComboElevate->currentIndex()));
m_appConfig.setAutoHide(m_pCheckBoxAutoHide->isChecked());
m_appConfig.setMinimizeToTray(m_pCheckBoxMinimizeToTray->isChecked());
m_appConfig.saveSettings();
QDialog::accept();
}
void SettingsDialog::reject()
{
if (appConfig().language() != m_pComboLanguage->itemData(m_pComboLanguage->currentIndex()).toString()) {
QBarrierApplication::getInstance()->switchTranslator(appConfig().language());
if (m_appConfig.language() != m_pComboLanguage->itemData(m_pComboLanguage->currentIndex()).toString()) {
QBarrierApplication::getInstance()->switchTranslator(m_appConfig.language());
}
QDialog::reject();
}
@ -138,15 +138,3 @@ void SettingsDialog::on_m_pComboLanguage_currentIndexChanged(int index)
QString ietfCode = m_pComboLanguage->itemData(index).toString();
QBarrierApplication::getInstance()->switchTranslator(ietfCode);
}
void SettingsDialog::on_m_pCheckBoxEnableCrypto_toggled(bool checked)
{
m_appConfig.setCryptoEnabled(checked);
m_appConfig.saveSettings();
if (checked) {
SslCertificate sslCertificate;
sslCertificate.generateCertificate();
MainWindow& mainWindow = dynamic_cast<MainWindow&> (*this->parent());
mainWindow.updateLocalFingerprint();
}
}

View File

@ -33,8 +33,6 @@ class SettingsDialog : public QDialog, public Ui::SettingsDialogBase
public:
SettingsDialog(QWidget* parent, AppConfig& config);
static QString browseForBarrierc(QWidget* parent, const QString& programDir, const QString& barriercName);
static QString browseForBarriers(QWidget* parent, const QString& programDir, const QString& barriersName);
protected:
void accept();
@ -48,7 +46,6 @@ class SettingsDialog : public QDialog, public Ui::SettingsDialogBase
CoreInterface m_CoreInterface;
private slots:
void on_m_pCheckBoxEnableCrypto_toggled(bool checked);
void on_m_pComboLanguage_currentIndexChanged(int index);
void on_m_pCheckBoxLogToFile_stateChanged(int );
void on_m_pButtonBrowseLog_clicked();