clean up AppConfig; eliminate unnecessary UI changes to MainWindow; MainWindow starts at smaller size
This commit is contained in:
parent
2a4382bac9
commit
b55fe3237a
|
@ -206,35 +206,21 @@ void AppConfig::setStartedBefore(bool b) { m_StartedBefore = b; }
|
||||||
|
|
||||||
void AppConfig::setElevateMode(ElevateMode em) { m_ElevateMode = em; }
|
void AppConfig::setElevateMode(ElevateMode em) { m_ElevateMode = em; }
|
||||||
|
|
||||||
void AppConfig::setAutoConfig(bool autoConfig)
|
void AppConfig::setAutoConfig(bool autoConfig) { m_AutoConfig = autoConfig; }
|
||||||
{
|
|
||||||
m_AutoConfig = autoConfig;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool AppConfig::autoConfigPrompted() { return m_AutoConfigPrompted; }
|
bool AppConfig::autoConfigPrompted() { return m_AutoConfigPrompted; }
|
||||||
|
|
||||||
void AppConfig::setAutoConfigPrompted(bool prompted)
|
void AppConfig::setAutoConfigPrompted(bool prompted) { m_AutoConfigPrompted = prompted; }
|
||||||
{
|
|
||||||
m_AutoConfigPrompted = prompted;
|
|
||||||
}
|
|
||||||
|
|
||||||
QString AppConfig::barriersName() const { return m_BarriersName; }
|
QString AppConfig::barriersName() const { return m_BarriersName; }
|
||||||
|
|
||||||
QString AppConfig::barriercName() const { return m_BarriercName; }
|
QString AppConfig::barriercName() const { return m_BarriercName; }
|
||||||
|
|
||||||
ElevateMode AppConfig::elevateMode()
|
ElevateMode AppConfig::elevateMode() { return m_ElevateMode; }
|
||||||
{
|
|
||||||
return m_ElevateMode;
|
|
||||||
}
|
|
||||||
|
|
||||||
void AppConfig::setCryptoEnabled(bool e) {
|
void AppConfig::setCryptoEnabled(bool e) { m_CryptoEnabled = e; }
|
||||||
m_CryptoEnabled = e;
|
|
||||||
emit sslToggled(e);
|
|
||||||
}
|
|
||||||
|
|
||||||
bool AppConfig::getCryptoEnabled() const {
|
bool AppConfig::getCryptoEnabled() const { return m_CryptoEnabled; }
|
||||||
return m_CryptoEnabled;
|
|
||||||
}
|
|
||||||
|
|
||||||
void AppConfig::setAutoHide(bool b) { m_AutoHide = b; }
|
void AppConfig::setAutoHide(bool b) { m_AutoHide = b; }
|
||||||
|
|
||||||
|
|
|
@ -85,7 +85,6 @@ class AppConfig: public QObject
|
||||||
QString barrierProgramDir() const;
|
QString barrierProgramDir() const;
|
||||||
QString barrierLogDir() const;
|
QString barrierLogDir() const;
|
||||||
|
|
||||||
bool detectPath(const QString& name, QString& path);
|
|
||||||
void persistLogDir();
|
void persistLogDir();
|
||||||
ElevateMode elevateMode();
|
ElevateMode elevateMode();
|
||||||
|
|
||||||
|
@ -136,9 +135,6 @@ protected:
|
||||||
static const char m_BarriersName[];
|
static const char m_BarriersName[];
|
||||||
static const char m_BarriercName[];
|
static const char m_BarriercName[];
|
||||||
static const char m_BarrierLogDir[];
|
static const char m_BarrierLogDir[];
|
||||||
|
|
||||||
signals:
|
|
||||||
void sslToggled(bool enabled);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -16,8 +16,6 @@
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#define DOWNLOAD_URL "http://github.com/debauchee/barrier/"
|
|
||||||
|
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
|
||||||
#include "MainWindow.h"
|
#include "MainWindow.h"
|
||||||
|
@ -117,10 +115,10 @@ MainWindow::MainWindow(QSettings& settings, AppConfig& appConfig) :
|
||||||
// change default size based on os
|
// change default size based on os
|
||||||
#if defined(Q_OS_MAC)
|
#if defined(Q_OS_MAC)
|
||||||
resize(720, 550);
|
resize(720, 550);
|
||||||
setMinimumSize(size());
|
setMinimumSize(720, 0);
|
||||||
#elif defined(Q_OS_LINUX)
|
#elif defined(Q_OS_LINUX)
|
||||||
resize(700, 530);
|
resize(700, 530);
|
||||||
setMinimumSize(size());
|
setMinimumSize(700, 0);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
m_SuppressAutoConfigWarning = true;
|
m_SuppressAutoConfigWarning = true;
|
||||||
|
@ -130,10 +128,10 @@ MainWindow::MainWindow(QSettings& settings, AppConfig& appConfig) :
|
||||||
m_pComboServerList->hide();
|
m_pComboServerList->hide();
|
||||||
m_pLabelPadlock->hide();
|
m_pLabelPadlock->hide();
|
||||||
|
|
||||||
sslToggled(appConfig.getCryptoEnabled());
|
updateSSLFingerprint();
|
||||||
|
|
||||||
connect (m_AppConfig, SIGNAL(sslToggled(bool)),
|
// resize window to smallest reasonable size
|
||||||
this, SLOT(sslToggled(bool)), Qt::QueuedConnection);
|
resize(0, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
MainWindow::~MainWindow()
|
MainWindow::~MainWindow()
|
||||||
|
@ -146,15 +144,8 @@ MainWindow::~MainWindow()
|
||||||
saveSettings();
|
saveSettings();
|
||||||
|
|
||||||
delete m_pZeroconfService;
|
delete m_pZeroconfService;
|
||||||
|
delete m_DownloadMessageBox;
|
||||||
if (m_DownloadMessageBox != NULL) {
|
delete m_BonjourInstall;
|
||||||
delete m_DownloadMessageBox;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (m_BonjourInstall != NULL) {
|
|
||||||
delete m_BonjourInstall;
|
|
||||||
}
|
|
||||||
|
|
||||||
delete m_pSslCertificate;
|
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)
|
bool MainWindow::clientArgs(QStringList& args, QString& app)
|
||||||
{
|
{
|
||||||
app = appPath(appConfig().barriercName());
|
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()) {
|
if (m_AppConfig->getCryptoEnabled() && m_pSslCertificate == nullptr) {
|
||||||
m_pLabelFingerprint->setVisible(true);
|
m_pSslCertificate = new SslCertificate(this);
|
||||||
m_pLabelLocalFingerprint->setVisible(true);
|
m_pSslCertificate->generateCertificate();
|
||||||
m_pLabelLocalFingerprint->setText(Fingerprint::local().readFirst());
|
|
||||||
}
|
}
|
||||||
else {
|
if (m_AppConfig->getCryptoEnabled() && Fingerprint::local().fileExists()) {
|
||||||
m_pLabelFingerprint->setVisible(false);
|
m_pLabelLocalFingerprint->setText(Fingerprint::local().readFirst());
|
||||||
m_pLabelLocalFingerprint->setVisible(false);
|
} else {
|
||||||
|
m_pLabelLocalFingerprint->setText("Disabled");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1004,13 +985,13 @@ bool MainWindow::on_m_pActionSave_triggered()
|
||||||
|
|
||||||
void MainWindow::on_m_pActionAbout_triggered()
|
void MainWindow::on_m_pActionAbout_triggered()
|
||||||
{
|
{
|
||||||
AboutDialog dlg(this, appPath(appConfig().barriercName()));
|
AboutDialog(this, appPath(appConfig().barriercName())).exec();
|
||||||
dlg.exec();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::on_m_pActionSettings_triggered()
|
void MainWindow::on_m_pActionSettings_triggered()
|
||||||
{
|
{
|
||||||
SettingsDialog(this, appConfig()).exec();
|
if (SettingsDialog(this, appConfig()).exec() == QDialog::Accepted)
|
||||||
|
updateSSLFingerprint();
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::autoAddScreen(const QString name)
|
void MainWindow::autoAddScreen(const QString name)
|
||||||
|
|
|
@ -113,7 +113,6 @@ class MainWindow : public QMainWindow, public Ui::MainWindowBase
|
||||||
void autoAddScreen(const QString name);
|
void autoAddScreen(const QString name);
|
||||||
void updateZeroconfService();
|
void updateZeroconfService();
|
||||||
void serverDetected(const QString name);
|
void serverDetected(const QString name);
|
||||||
void updateLocalFingerprint();
|
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
void appendLogRaw(const QString& text);
|
void appendLogRaw(const QString& text);
|
||||||
|
@ -123,7 +122,6 @@ public slots:
|
||||||
void startBarrier();
|
void startBarrier();
|
||||||
|
|
||||||
protected slots:
|
protected slots:
|
||||||
void sslToggled(bool enabled);
|
|
||||||
void on_m_pGroupClient_toggled(bool on);
|
void on_m_pGroupClient_toggled(bool on);
|
||||||
void on_m_pGroupServer_toggled(bool on);
|
void on_m_pGroupServer_toggled(bool on);
|
||||||
bool on_m_pButtonBrowseConfigFile_clicked();
|
bool on_m_pButtonBrowseConfigFile_clicked();
|
||||||
|
@ -173,9 +171,8 @@ public slots:
|
||||||
QString getTimeStamp();
|
QString getTimeStamp();
|
||||||
void restartBarrier();
|
void restartBarrier();
|
||||||
void proofreadInfo();
|
void proofreadInfo();
|
||||||
|
|
||||||
void windowStateChanged();
|
void windowStateChanged();
|
||||||
|
void updateSSLFingerprint();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QSettings& m_Settings;
|
QSettings& m_Settings;
|
||||||
|
|
|
@ -18,8 +18,8 @@
|
||||||
</property>
|
</property>
|
||||||
<property name="minimumSize">
|
<property name="minimumSize">
|
||||||
<size>
|
<size>
|
||||||
<width>500</width>
|
<width>600</width>
|
||||||
<height>400</height>
|
<height>0</height>
|
||||||
</size>
|
</size>
|
||||||
</property>
|
</property>
|
||||||
<property name="windowTitle">
|
<property name="windowTitle">
|
||||||
|
|
|
@ -65,26 +65,26 @@ SettingsDialog::SettingsDialog(QWidget* parent, AppConfig& config) :
|
||||||
|
|
||||||
void SettingsDialog::accept()
|
void SettingsDialog::accept()
|
||||||
{
|
{
|
||||||
appConfig().setScreenName(m_pLineEditScreenName->text());
|
m_appConfig.setScreenName(m_pLineEditScreenName->text());
|
||||||
appConfig().setPort(m_pSpinBoxPort->value());
|
m_appConfig.setPort(m_pSpinBoxPort->value());
|
||||||
appConfig().setNetworkInterface(m_pLineEditInterface->text());
|
m_appConfig.setNetworkInterface(m_pLineEditInterface->text());
|
||||||
appConfig().setLogLevel(m_pComboLogLevel->currentIndex());
|
m_appConfig.setCryptoEnabled(m_pCheckBoxEnableCrypto->isChecked());
|
||||||
appConfig().setLogToFile(m_pCheckBoxLogToFile->isChecked());
|
m_appConfig.setLogLevel(m_pComboLogLevel->currentIndex());
|
||||||
appConfig().setLogFilename(m_pLineEditLogFilename->text());
|
m_appConfig.setLogToFile(m_pCheckBoxLogToFile->isChecked());
|
||||||
appConfig().setLanguage(m_pComboLanguage->itemData(m_pComboLanguage->currentIndex()).toString());
|
m_appConfig.setLogFilename(m_pLineEditLogFilename->text());
|
||||||
appConfig().setElevateMode(static_cast<ElevateMode>(m_pComboElevate->currentIndex()));
|
m_appConfig.setLanguage(m_pComboLanguage->itemData(m_pComboLanguage->currentIndex()).toString());
|
||||||
appConfig().setAutoHide(m_pCheckBoxAutoHide->isChecked());
|
m_appConfig.setElevateMode(static_cast<ElevateMode>(m_pComboElevate->currentIndex()));
|
||||||
appConfig().setMinimizeToTray(m_pCheckBoxMinimizeToTray->isChecked());
|
m_appConfig.setAutoHide(m_pCheckBoxAutoHide->isChecked());
|
||||||
appConfig().saveSettings();
|
m_appConfig.setMinimizeToTray(m_pCheckBoxMinimizeToTray->isChecked());
|
||||||
|
m_appConfig.saveSettings();
|
||||||
QDialog::accept();
|
QDialog::accept();
|
||||||
}
|
}
|
||||||
|
|
||||||
void SettingsDialog::reject()
|
void SettingsDialog::reject()
|
||||||
{
|
{
|
||||||
if (appConfig().language() != m_pComboLanguage->itemData(m_pComboLanguage->currentIndex()).toString()) {
|
if (m_appConfig.language() != m_pComboLanguage->itemData(m_pComboLanguage->currentIndex()).toString()) {
|
||||||
QBarrierApplication::getInstance()->switchTranslator(appConfig().language());
|
QBarrierApplication::getInstance()->switchTranslator(m_appConfig.language());
|
||||||
}
|
}
|
||||||
|
|
||||||
QDialog::reject();
|
QDialog::reject();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -137,16 +137,4 @@ void SettingsDialog::on_m_pComboLanguage_currentIndexChanged(int index)
|
||||||
{
|
{
|
||||||
QString ietfCode = m_pComboLanguage->itemData(index).toString();
|
QString ietfCode = m_pComboLanguage->itemData(index).toString();
|
||||||
QBarrierApplication::getInstance()->switchTranslator(ietfCode);
|
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();
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -33,8 +33,6 @@ class SettingsDialog : public QDialog, public Ui::SettingsDialogBase
|
||||||
|
|
||||||
public:
|
public:
|
||||||
SettingsDialog(QWidget* parent, AppConfig& config);
|
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:
|
protected:
|
||||||
void accept();
|
void accept();
|
||||||
|
@ -48,7 +46,6 @@ class SettingsDialog : public QDialog, public Ui::SettingsDialogBase
|
||||||
CoreInterface m_CoreInterface;
|
CoreInterface m_CoreInterface;
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void on_m_pCheckBoxEnableCrypto_toggled(bool checked);
|
|
||||||
void on_m_pComboLanguage_currentIndexChanged(int index);
|
void on_m_pComboLanguage_currentIndexChanged(int index);
|
||||||
void on_m_pCheckBoxLogToFile_stateChanged(int );
|
void on_m_pCheckBoxLogToFile_stateChanged(int );
|
||||||
void on_m_pButtonBrowseLog_clicked();
|
void on_m_pButtonBrowseLog_clicked();
|
||||||
|
|
Loading…
Reference in New Issue