mirror of
https://github.com/debauchee/barrier.git
synced 2024-11-27 00:42:30 +03:00
implemented minize to tray
This commit is contained in:
parent
ccb02372bf
commit
9240cc12df
@ -59,7 +59,8 @@ AppConfig::AppConfig(QSettings* settings) :
|
|||||||
m_ElevateMode(defaultElevateMode),
|
m_ElevateMode(defaultElevateMode),
|
||||||
m_AutoConfigPrompted(false),
|
m_AutoConfigPrompted(false),
|
||||||
m_CryptoEnabled(false),
|
m_CryptoEnabled(false),
|
||||||
m_AutoHide(false)
|
m_AutoHide(false),
|
||||||
|
m_MinimizeToTray(false)
|
||||||
{
|
{
|
||||||
Q_ASSERT(m_pSettings);
|
Q_ASSERT(m_pSettings);
|
||||||
|
|
||||||
@ -157,6 +158,7 @@ void AppConfig::loadSettings()
|
|||||||
m_AutoConfigPrompted = settings().value("autoConfigPrompted", false).toBool();
|
m_AutoConfigPrompted = settings().value("autoConfigPrompted", false).toBool();
|
||||||
m_CryptoEnabled = settings().value("cryptoEnabled", true).toBool();
|
m_CryptoEnabled = settings().value("cryptoEnabled", true).toBool();
|
||||||
m_AutoHide = settings().value("autoHide", false).toBool();
|
m_AutoHide = settings().value("autoHide", false).toBool();
|
||||||
|
m_MinimizeToTray = settings().value("minimizeToTray", false).toBool();
|
||||||
}
|
}
|
||||||
|
|
||||||
void AppConfig::saveSettings()
|
void AppConfig::saveSettings()
|
||||||
@ -178,6 +180,7 @@ void AppConfig::saveSettings()
|
|||||||
settings().setValue("autoConfigPrompted", m_AutoConfigPrompted);
|
settings().setValue("autoConfigPrompted", m_AutoConfigPrompted);
|
||||||
settings().setValue("cryptoEnabled", m_CryptoEnabled);
|
settings().setValue("cryptoEnabled", m_CryptoEnabled);
|
||||||
settings().setValue("autoHide", m_AutoHide);
|
settings().setValue("autoHide", m_AutoHide);
|
||||||
|
settings().setValue("minimizeToTray", m_MinimizeToTray);
|
||||||
settings().sync();
|
settings().sync();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -236,3 +239,7 @@ bool AppConfig::getCryptoEnabled() const {
|
|||||||
void AppConfig::setAutoHide(bool b) { m_AutoHide = b; }
|
void AppConfig::setAutoHide(bool b) { m_AutoHide = b; }
|
||||||
|
|
||||||
bool AppConfig::getAutoHide() { return m_AutoHide; }
|
bool AppConfig::getAutoHide() { return m_AutoHide; }
|
||||||
|
|
||||||
|
void AppConfig::setMinimizeToTray(bool b) { m_MinimizeToTray = b; }
|
||||||
|
|
||||||
|
bool AppConfig::getMinimizeToTray() { return m_MinimizeToTray; }
|
||||||
|
@ -95,6 +95,9 @@ class AppConfig: public QObject
|
|||||||
void setAutoHide(bool b);
|
void setAutoHide(bool b);
|
||||||
bool getAutoHide();
|
bool getAutoHide();
|
||||||
|
|
||||||
|
void setMinimizeToTray(bool b);
|
||||||
|
bool getMinimizeToTray();
|
||||||
|
|
||||||
void saveSettings();
|
void saveSettings();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
@ -128,6 +131,7 @@ protected:
|
|||||||
bool m_AutoConfigPrompted;
|
bool m_AutoConfigPrompted;
|
||||||
bool m_CryptoEnabled;
|
bool m_CryptoEnabled;
|
||||||
bool m_AutoHide;
|
bool m_AutoHide;
|
||||||
|
bool m_MinimizeToTray;
|
||||||
|
|
||||||
static const char m_BarriersName[];
|
static const char m_BarriersName[];
|
||||||
static const char m_BarriercName[];
|
static const char m_BarriercName[];
|
||||||
|
@ -190,28 +190,6 @@ void MainWindow::open()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::onModeChanged(bool startDesktop, bool applyService)
|
|
||||||
{
|
|
||||||
if (appConfig().processMode() == Service)
|
|
||||||
{
|
|
||||||
// ensure that the apply button actually does something, since desktop
|
|
||||||
// mode screws around with connecting/disconnecting the action.
|
|
||||||
disconnect(m_pButtonToggleStart, SIGNAL(clicked()), m_pActionStartBarrier, SLOT(trigger()));
|
|
||||||
connect(m_pButtonToggleStart, SIGNAL(clicked()), m_pActionStartBarrier, SLOT(trigger()));
|
|
||||||
|
|
||||||
if (applyService)
|
|
||||||
{
|
|
||||||
stopDesktop();
|
|
||||||
startBarrier();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else if ((appConfig().processMode() == Desktop) && startDesktop)
|
|
||||||
{
|
|
||||||
stopService();
|
|
||||||
startBarrier();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void MainWindow::setStatus(const QString &status)
|
void MainWindow::setStatus(const QString &status)
|
||||||
{
|
{
|
||||||
m_pStatusLabel->setText(status);
|
m_pStatusLabel->setText(status);
|
||||||
@ -958,10 +936,15 @@ void MainWindow::changeEvent(QEvent* event)
|
|||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
default:
|
case QEvent::WindowStateChange:
|
||||||
QMainWindow::changeEvent(event);
|
{
|
||||||
|
windowStateChanged();
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
// all that do not return are allowing the event to propagate
|
||||||
|
QMainWindow::changeEvent(event);
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::updateZeroconfService()
|
void MainWindow::updateZeroconfService()
|
||||||
@ -1057,15 +1040,7 @@ void MainWindow::on_m_pActionAbout_triggered()
|
|||||||
|
|
||||||
void MainWindow::on_m_pActionSettings_triggered()
|
void MainWindow::on_m_pActionSettings_triggered()
|
||||||
{
|
{
|
||||||
ProcessMode lastProcessMode = appConfig().processMode();
|
SettingsDialog(this, appConfig()).exec();
|
||||||
|
|
||||||
SettingsDialog dlg(this, appConfig());
|
|
||||||
dlg.exec();
|
|
||||||
|
|
||||||
if (lastProcessMode != appConfig().processMode())
|
|
||||||
{
|
|
||||||
onModeChanged(true, true);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::autoAddScreen(const QString name)
|
void MainWindow::autoAddScreen(const QString name)
|
||||||
@ -1334,3 +1309,9 @@ QString MainWindow::getProfileRootForArg()
|
|||||||
|
|
||||||
return QString("\"%1\"").arg(dir);
|
return QString("\"%1\"").arg(dir);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void MainWindow::windowStateChanged()
|
||||||
|
{
|
||||||
|
if (windowState() == Qt::WindowMinimized && appConfig().getMinimizeToTray())
|
||||||
|
hide();
|
||||||
|
}
|
||||||
|
@ -157,7 +157,6 @@ public slots:
|
|||||||
bool serverArgs(QStringList& args, QString& app);
|
bool serverArgs(QStringList& args, QString& app);
|
||||||
void setStatus(const QString& status);
|
void setStatus(const QString& status);
|
||||||
void sendIpcMessage(qIpcMessageType type, const char* buffer, bool showErrors);
|
void sendIpcMessage(qIpcMessageType type, const char* buffer, bool showErrors);
|
||||||
void onModeChanged(bool startDesktop, bool applyService);
|
|
||||||
void updateFromLogLine(const QString& line);
|
void updateFromLogLine(const QString& line);
|
||||||
QString getIPAddresses();
|
QString getIPAddresses();
|
||||||
void stopService();
|
void stopService();
|
||||||
@ -181,6 +180,9 @@ public slots:
|
|||||||
|
|
||||||
void showEvent (QShowEvent*);
|
void showEvent (QShowEvent*);
|
||||||
|
|
||||||
|
void windowStateChanged();
|
||||||
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QSettings& m_Settings;
|
QSettings& m_Settings;
|
||||||
AppConfig* m_AppConfig;
|
AppConfig* m_AppConfig;
|
||||||
|
@ -51,6 +51,8 @@ SettingsDialog::SettingsDialog(QWidget* parent, AppConfig& config) :
|
|||||||
m_pLineEditLogFilename->setText(appConfig().logFilename());
|
m_pLineEditLogFilename->setText(appConfig().logFilename());
|
||||||
setIndexFromItemData(m_pComboLanguage, appConfig().language());
|
setIndexFromItemData(m_pComboLanguage, appConfig().language());
|
||||||
m_pCheckBoxAutoHide->setChecked(appConfig().getAutoHide());
|
m_pCheckBoxAutoHide->setChecked(appConfig().getAutoHide());
|
||||||
|
m_pCheckBoxMinimizeToTray->setChecked(appConfig().getMinimizeToTray());
|
||||||
|
m_pCheckBoxEnableCrypto->setChecked(m_appConfig.getCryptoEnabled());
|
||||||
|
|
||||||
#if defined(Q_OS_WIN)
|
#if defined(Q_OS_WIN)
|
||||||
m_pComboElevate->setCurrentIndex(static_cast<int>(appConfig().elevateMode()));
|
m_pComboElevate->setCurrentIndex(static_cast<int>(appConfig().elevateMode()));
|
||||||
@ -59,8 +61,6 @@ SettingsDialog::SettingsDialog(QWidget* parent, AppConfig& config) :
|
|||||||
m_pLabelElevate->hide();
|
m_pLabelElevate->hide();
|
||||||
m_pComboElevate->hide();
|
m_pComboElevate->hide();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
m_pCheckBoxEnableCrypto->setChecked(m_appConfig.getCryptoEnabled());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void SettingsDialog::accept()
|
void SettingsDialog::accept()
|
||||||
@ -72,8 +72,9 @@ void SettingsDialog::accept()
|
|||||||
appConfig().setLogToFile(m_pCheckBoxLogToFile->isChecked());
|
appConfig().setLogToFile(m_pCheckBoxLogToFile->isChecked());
|
||||||
appConfig().setLogFilename(m_pLineEditLogFilename->text());
|
appConfig().setLogFilename(m_pLineEditLogFilename->text());
|
||||||
appConfig().setLanguage(m_pComboLanguage->itemData(m_pComboLanguage->currentIndex()).toString());
|
appConfig().setLanguage(m_pComboLanguage->itemData(m_pComboLanguage->currentIndex()).toString());
|
||||||
appConfig().setElevateMode(static_cast<ElevateMode>(m_pComboElevate->currentIndex()));
|
appConfig().setElevateMode(static_cast<ElevateMode>(m_pComboElevate->currentIndex()));
|
||||||
appConfig().setAutoHide(m_pCheckBoxAutoHide->isChecked());
|
appConfig().setAutoHide(m_pCheckBoxAutoHide->isChecked());
|
||||||
|
appConfig().setMinimizeToTray(m_pCheckBoxMinimizeToTray->isChecked());
|
||||||
appConfig().saveSettings();
|
appConfig().saveSettings();
|
||||||
QDialog::accept();
|
QDialog::accept();
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user