- preferences dialog refactored
This commit is contained in:
parent
48cd3d0052
commit
37e70ab252
@ -2,7 +2,7 @@
|
|||||||
#define __APP_CONFIG_H
|
#define __APP_CONFIG_H
|
||||||
|
|
||||||
// Application name
|
// Application name
|
||||||
#define APPNAME "Noo"
|
#define APPNAME "noo"
|
||||||
|
|
||||||
// Company name
|
// Company name
|
||||||
#define COMPANY "voipobjects.com"
|
#define COMPANY "voipobjects.com"
|
||||||
|
|||||||
@ -12,13 +12,17 @@ int main(int argc, char *argv[])
|
|||||||
QApplication app(argc, argv);
|
QApplication app(argc, argv);
|
||||||
helper::theme::applyCurrent(Settings::instance());
|
helper::theme::applyCurrent(Settings::instance());
|
||||||
|
|
||||||
QFont f = app.font();
|
|
||||||
f.setPointSize(14);
|
|
||||||
app.setFont(f);
|
|
||||||
app.setApplicationName(APPNAME);
|
app.setApplicationName(APPNAME);
|
||||||
|
auto& settings = Settings::instance();
|
||||||
|
QFont f;
|
||||||
|
if (settings.data().count(KEY_APP_FONT) > 0)
|
||||||
|
{
|
||||||
|
if (f.fromString(settings.data()[KEY_APP_FONT].toString()))
|
||||||
|
app.setFont(f);
|
||||||
|
}
|
||||||
|
|
||||||
// Path to database.
|
// Path to database.
|
||||||
QString path = Settings::instance().getDatabasePath();
|
QString path = settings.getDatabasePath();
|
||||||
|
|
||||||
QString folder = QFileInfo(path).absoluteDir().path();
|
QString folder = QFileInfo(path).absoluteDir().path();
|
||||||
Storage::instance().setPath(path);
|
Storage::instance().setPath(path);
|
||||||
|
|||||||
@ -23,7 +23,7 @@ PreferencesDlg::PreferencesDlg(QWidget *parent, Settings& settings) :
|
|||||||
|
|
||||||
connect(ui->mChangePathButton, SIGNAL(clicked()), this, SLOT(onChangeDatabasePath()));
|
connect(ui->mChangePathButton, SIGNAL(clicked()), this, SLOT(onChangeDatabasePath()));
|
||||||
connect(ui->mPauseOnIdleCheckbox, SIGNAL(toggled(bool)), this, SLOT(onPauseOnIdle(bool)));
|
connect(ui->mPauseOnIdleCheckbox, SIGNAL(toggled(bool)), this, SLOT(onPauseOnIdle(bool)));
|
||||||
connect(ui->mAskQuestionOnResumeCheckbox, SIGNAL(toggled(bool)), this, SLOT(smartStartSettingChanged(bool)));
|
connect(ui->mChangeAppFontButton, SIGNAL(clicked()), this, SLOT(onChangeAppFont()));
|
||||||
|
|
||||||
// Autosave password
|
// Autosave password
|
||||||
ui->mAutosavePasswordCheckbox->setChecked(settings.data().value(KEY_AUTOSAVE_PASSWORD).toBool());
|
ui->mAutosavePasswordCheckbox->setChecked(settings.data().value(KEY_AUTOSAVE_PASSWORD).toBool());
|
||||||
@ -41,19 +41,15 @@ PreferencesDlg::PreferencesDlg(QWidget *parent, Settings& settings) :
|
|||||||
ui->mPathToDatabaseLabel->setText(settings.data().value(KEY_DB_FILENAME).toString());
|
ui->mPathToDatabaseLabel->setText(settings.data().value(KEY_DB_FILENAME).toString());
|
||||||
|
|
||||||
// Use stop on idle ?
|
// Use stop on idle ?
|
||||||
ui->mSmartStopTracking->setChecked(GET_BOOL(KEY_SMART_STOP));
|
ui->mPauseOnIdleCheckbox->setChecked(GET_BOOL(KEY_SMART_STOP));
|
||||||
ui->mSmartStopIntervalInMinutes->setText(settings.data().value(KEY_SMART_STOP_MINUTES).toString());
|
ui->mIdleTimeoutEdit->setText(settings.data().value(KEY_SMART_STOP_MINUTES).toString());
|
||||||
ui->mAskQuestionOnStopRadiobutton->setChecked(GET_BOOL(KEY_ASK_STOP));
|
ui->mAskQuestionOnResumeCheckbox->setChecked(GET_BOOL(KEY_ASK_STOP));
|
||||||
ui->mAutomaticallyOnStopRadiobutton->setChecked(!GET_BOOL(KEY_ASK_STOP));
|
|
||||||
|
|
||||||
// Use start after idle ?
|
|
||||||
ui->mSmartStartTracking->setChecked(GET_BOOL(KEY_SMART_START));
|
|
||||||
//ui->mAskQuestionOnStartRadiobutton->setChecked(GET_BOOL(KEY_ASK_START));
|
|
||||||
//ui->mAutomaticallyOnStartRadiobutton->setChecked(!GET_BOOL(KEY_ASK_START));
|
|
||||||
|
|
||||||
allowStartAfterIdleControls();
|
|
||||||
|
|
||||||
ui->mShowTrayIconCheckbox->setChecked(GET_BOOL(KEY_SHOW_TRAY_ICON));
|
ui->mShowTrayIconCheckbox->setChecked(GET_BOOL(KEY_SHOW_TRAY_ICON));
|
||||||
|
|
||||||
|
QFont f = qApp->font();
|
||||||
|
ui->mAppFontLabel->setText(QString("%1 %2pt").arg(f.family()).arg(f.pointSize()));
|
||||||
|
ui->mAppFontLabel->setFont(f);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -62,7 +58,7 @@ PreferencesDlg::~PreferencesDlg()
|
|||||||
delete ui;
|
delete ui;
|
||||||
}
|
}
|
||||||
|
|
||||||
void PreferencesDlg::selectDatabase()
|
void PreferencesDlg::onChangeDatabasePath()
|
||||||
{
|
{
|
||||||
QFileDialog dlg(this, tr("Select database to use"), helper::path::pathToDesktop());
|
QFileDialog dlg(this, tr("Select database to use"), helper::path::pathToDesktop());
|
||||||
dlg.setAcceptMode(QFileDialog::AcceptSave);
|
dlg.setAcceptMode(QFileDialog::AcceptSave);
|
||||||
@ -70,7 +66,29 @@ void PreferencesDlg::selectDatabase()
|
|||||||
if (dlg.exec() == QDialog::Accepted)
|
if (dlg.exec() == QDialog::Accepted)
|
||||||
{
|
{
|
||||||
QString filename = dlg.selectedFiles().front();
|
QString filename = dlg.selectedFiles().front();
|
||||||
ui->mDatabaseLocation->setText(filename);
|
ui->mPathToDatabaseLabel->setText(filename);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void PreferencesDlg::onPauseOnIdle(bool value)
|
||||||
|
{
|
||||||
|
if (value)
|
||||||
|
{
|
||||||
|
// It is possible to check idle time at all ?
|
||||||
|
if (!helper::activityTracker::ensureSmartTrackingIsPossible())
|
||||||
|
ui->mPauseOnIdleCheckbox->setChecked(false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void PreferencesDlg::onChangeAppFont()
|
||||||
|
{
|
||||||
|
QFontDialog dlg;
|
||||||
|
dlg.setCurrentFont(qApp->font());
|
||||||
|
if (dlg.exec() == QDialog::Accepted)
|
||||||
|
{
|
||||||
|
QFont f = dlg.currentFont();
|
||||||
|
ui->mAppFontLabel->setText(QString("%1 %2pt").arg(f.family()).arg(f.pointSize()));
|
||||||
|
ui->mAppFontLabel->setFont(f);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -82,60 +100,21 @@ void PreferencesDlg::accepted()
|
|||||||
|
|
||||||
mSettings.data()[KEY_SHOW_SECONDS] = ui->mShowSecondsCheckbox->isChecked();
|
mSettings.data()[KEY_SHOW_SECONDS] = ui->mShowSecondsCheckbox->isChecked();
|
||||||
mSettings.data()[KEY_ASK_BEFORE_DELETE] = ui->mAskBeforeDeleteCheckbox->isChecked();
|
mSettings.data()[KEY_ASK_BEFORE_DELETE] = ui->mAskBeforeDeleteCheckbox->isChecked();
|
||||||
mSettings.data()[KEY_DB_FILENAME] = ui->mDatabaseLocation->text();
|
mSettings.data()[KEY_DB_FILENAME] = ui->mPathToDatabaseLabel->text();
|
||||||
mSettings.data()[KEY_SMART_STOP] = ui->mSmartStopTracking->isChecked();
|
mSettings.data()[KEY_SMART_STOP] = ui->mPauseOnIdleCheckbox->isChecked();
|
||||||
mSettings.data()[KEY_SMART_STOP_MINUTES] = ui->mSmartStopIntervalInMinutes->text().toInt();
|
mSettings.data()[KEY_SMART_STOP_MINUTES] = ui->mIdleTimeoutEdit->text().toInt();
|
||||||
mSettings.data()[KEY_SMART_START] = ui->mSmartStartTracking->isChecked();
|
|
||||||
mSettings.data()[KEY_SHOW_TRAY_ICON] = ui->mShowTrayIconCheckbox->isChecked();
|
mSettings.data()[KEY_SHOW_TRAY_ICON] = ui->mShowTrayIconCheckbox->isChecked();
|
||||||
mSettings.data()[KEY_ASK_STOP] = ui->mAskQuestionOnStopRadiobutton->isChecked();
|
mSettings.data()[KEY_ASK_STOP] = ui->mAskQuestionOnResumeCheckbox->isChecked();
|
||||||
|
|
||||||
if (mSettings.data()[KEY_DARK_THEME].toBool() != ui->mDarkThemeCheckbox->isChecked()) {
|
if (mSettings.data()[KEY_DARK_THEME].toBool() != ui->mDarkThemeCheckbox->isChecked()) {
|
||||||
mSettings.data()[KEY_DARK_THEME] = ui->mDarkThemeCheckbox->isChecked();
|
mSettings.data()[KEY_DARK_THEME] = ui->mDarkThemeCheckbox->isChecked();
|
||||||
applyTheme();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void PreferencesDlg::smartStopSettingChanged(bool v)
|
|
||||||
{
|
|
||||||
if (v)
|
|
||||||
{
|
|
||||||
if (!helper::activityTracker::ensureSmartTrackingIsPossible())
|
|
||||||
ui->mSmartStopTracking->setChecked(false);
|
|
||||||
}
|
|
||||||
allowStartAfterIdleControls();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void PreferencesDlg::onPauseOnIdle(bool value)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
void PreferencesDlg::allowStartAfterIdleControls()
|
|
||||||
{
|
|
||||||
bool stopEnabled = ui->mSmartStopTracking->isChecked() && ui->mSmartStopIntervalInMinutes->text().toInt() > 0;
|
|
||||||
bool startEnabled = ui->mSmartStartTracking->isChecked();
|
|
||||||
bool automaticStopEnabled = ui->mAutomaticallyOnStopRadiobutton->isChecked();
|
|
||||||
//ui->mAskQuestionOnStartRadiobutton->setEnabled(stopEnabled && startEnabled);
|
|
||||||
//ui->mAutomaticallyOnStartRadiobutton->setEnabled(stopEnabled && startEnabled);
|
|
||||||
if (!stopEnabled || !automaticStopEnabled)
|
|
||||||
ui->mSmartStartTracking->setChecked(false);
|
|
||||||
ui->mSmartStartTracking->setEnabled(stopEnabled && automaticStopEnabled);
|
|
||||||
ui->mAskQuestionOnStopRadiobutton->setEnabled(stopEnabled);
|
|
||||||
ui->mAutomaticallyOnStopRadiobutton->setEnabled(stopEnabled);
|
|
||||||
}
|
|
||||||
|
|
||||||
void PreferencesDlg::onChangeAppFont()
|
|
||||||
{
|
|
||||||
QFontDialog dlg;
|
|
||||||
dlg.setCurrentFont(qApp->font());
|
|
||||||
if (dlg.exec() == QDialog::Accepted)
|
|
||||||
{
|
|
||||||
//
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void PreferencesDlg::applyTheme()
|
|
||||||
{
|
|
||||||
helper::theme::applyCurrent(mSettings);
|
helper::theme::applyCurrent(mSettings);
|
||||||
|
}
|
||||||
|
|
||||||
|
mSettings.data()[KEY_APP_FONT] = ui->mAppFontLabel->font().toString();
|
||||||
|
mSettings.save();
|
||||||
|
}
|
||||||
|
|
||||||
|
void PreferencesDlg::rejected()
|
||||||
|
{
|
||||||
}
|
}
|
||||||
|
|||||||
@ -27,7 +27,6 @@ private slots:
|
|||||||
void rejected();
|
void rejected();
|
||||||
|
|
||||||
void onPauseOnIdle(bool v);
|
void onPauseOnIdle(bool v);
|
||||||
void onAskQuestionWhenResume(bool v);
|
|
||||||
void onChangeAppFont();
|
void onChangeAppFont();
|
||||||
void onChangeDatabasePath();
|
void onChangeDatabasePath();
|
||||||
};
|
};
|
||||||
|
|||||||
@ -295,27 +295,5 @@
|
|||||||
</hint>
|
</hint>
|
||||||
</hints>
|
</hints>
|
||||||
</connection>
|
</connection>
|
||||||
<connection>
|
|
||||||
<sender>buttonGroup</sender>
|
|
||||||
<signal>buttonClicked(int)</signal>
|
|
||||||
<receiver>PreferencesDlg</receiver>
|
|
||||||
<slot>smartStopWayChanged()</slot>
|
|
||||||
<hints>
|
|
||||||
<hint type="sourcelabel">
|
|
||||||
<x>-1</x>
|
|
||||||
<y>-1</y>
|
|
||||||
</hint>
|
|
||||||
<hint type="destinationlabel">
|
|
||||||
<x>215</x>
|
|
||||||
<y>162</y>
|
|
||||||
</hint>
|
|
||||||
</hints>
|
|
||||||
</connection>
|
|
||||||
</connections>
|
</connections>
|
||||||
<slots>
|
|
||||||
<slot>smartStopWayChanged()</slot>
|
|
||||||
</slots>
|
|
||||||
<buttongroups>
|
|
||||||
<buttongroup name="buttonGroup"/>
|
|
||||||
</buttongroups>
|
|
||||||
</ui>
|
</ui>
|
||||||
|
|||||||
@ -31,6 +31,7 @@ void Settings::save()
|
|||||||
{
|
{
|
||||||
settings.setValue(e, data().value(e));
|
settings.setValue(e, data().value(e));
|
||||||
}
|
}
|
||||||
|
settings.sync();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Settings::load()
|
void Settings::load()
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user