mirror of
https://gitee.com/vnotex/vnote.git
synced 2025-07-06 06:19:52 +08:00
support reset layout
This commit is contained in:
parent
4bcb60e903
commit
bc9dd643fc
@ -25,12 +25,19 @@ VSettingsDialog::VSettingsDialog(QWidget *p_parent)
|
|||||||
connect(m_resetVNoteBtn, &QPushButton::clicked,
|
connect(m_resetVNoteBtn, &QPushButton::clicked,
|
||||||
this, &VSettingsDialog::resetVNote);
|
this, &VSettingsDialog::resetVNote);
|
||||||
|
|
||||||
|
// Reset Layout.
|
||||||
|
m_resetLayoutBtn = new QPushButton(tr("Reset Layout"), this);
|
||||||
|
m_resetLayoutBtn->setToolTip(tr("Reset layout of VNote"));
|
||||||
|
connect(m_resetLayoutBtn, &QPushButton::clicked,
|
||||||
|
this, &VSettingsDialog::resetLayout);
|
||||||
|
|
||||||
m_btnBox = new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel);
|
m_btnBox = new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel);
|
||||||
connect(m_btnBox, &QDialogButtonBox::accepted, this, &VSettingsDialog::saveConfiguration);
|
connect(m_btnBox, &QDialogButtonBox::accepted, this, &VSettingsDialog::saveConfiguration);
|
||||||
connect(m_btnBox, &QDialogButtonBox::rejected, this, &QDialog::reject);
|
connect(m_btnBox, &QDialogButtonBox::rejected, this, &QDialog::reject);
|
||||||
m_btnBox->button(QDialogButtonBox::Ok)->setProperty("SpecialBtn", true);
|
m_btnBox->button(QDialogButtonBox::Ok)->setProperty("SpecialBtn", true);
|
||||||
|
|
||||||
m_btnBox->addButton(m_resetVNoteBtn, QDialogButtonBox::ResetRole);
|
m_btnBox->addButton(m_resetVNoteBtn, QDialogButtonBox::ResetRole);
|
||||||
|
m_btnBox->addButton(m_resetLayoutBtn, QDialogButtonBox::ResetRole);
|
||||||
|
|
||||||
QHBoxLayout *tabLayout = new QHBoxLayout();
|
QHBoxLayout *tabLayout = new QHBoxLayout();
|
||||||
tabLayout->addWidget(m_tabList);
|
tabLayout->addWidget(m_tabList);
|
||||||
@ -99,6 +106,35 @@ void VSettingsDialog::resetVNote()
|
|||||||
reject();
|
reject();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void VSettingsDialog::resetLayout()
|
||||||
|
{
|
||||||
|
int ret = VUtils::showMessage(QMessageBox::Warning,
|
||||||
|
tr("Warning"),
|
||||||
|
tr("Are you sure to reset the layout of VNote?"),
|
||||||
|
tr("The view and layout mode will be reset. "
|
||||||
|
"It is UNRECOVERABLE!"),
|
||||||
|
QMessageBox::Ok | QMessageBox::Cancel,
|
||||||
|
QMessageBox::Cancel,
|
||||||
|
this,
|
||||||
|
MessageBoxType::Danger);
|
||||||
|
|
||||||
|
if (ret == QMessageBox::Cancel) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
g_config->resetLayoutConfigurations();
|
||||||
|
|
||||||
|
VUtils::showMessage(QMessageBox::Information,
|
||||||
|
tr("Information"),
|
||||||
|
tr("Please restart VNote to make it work."),
|
||||||
|
tr("Any change to VNote before restart will be lost!"),
|
||||||
|
QMessageBox::Ok,
|
||||||
|
QMessageBox::Ok,
|
||||||
|
this);
|
||||||
|
|
||||||
|
reject();
|
||||||
|
}
|
||||||
|
|
||||||
void VSettingsDialog::addTab(QWidget *p_widget, const QString &p_label)
|
void VSettingsDialog::addTab(QWidget *p_widget, const QString &p_label)
|
||||||
{
|
{
|
||||||
int idx = m_tabs->addWidget(p_widget);
|
int idx = m_tabs->addWidget(p_widget);
|
||||||
|
@ -167,6 +167,8 @@ private slots:
|
|||||||
|
|
||||||
void resetVNote();
|
void resetVNote();
|
||||||
|
|
||||||
|
void resetLayout();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void loadConfiguration();
|
void loadConfiguration();
|
||||||
|
|
||||||
@ -178,6 +180,9 @@ private:
|
|||||||
|
|
||||||
// Reset all the configuration of VNote.
|
// Reset all the configuration of VNote.
|
||||||
QPushButton *m_resetVNoteBtn;
|
QPushButton *m_resetVNoteBtn;
|
||||||
|
|
||||||
|
// Reset the layout.
|
||||||
|
QPushButton *m_resetLayoutBtn;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // VSETTINGSDIALOG_H
|
#endif // VSETTINGSDIALOG_H
|
||||||
|
@ -1396,6 +1396,17 @@ void VConfigManager::resetConfigurations()
|
|||||||
m_hasReset = true;
|
m_hasReset = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void VConfigManager::resetLayoutConfigurations()
|
||||||
|
{
|
||||||
|
resetDefaultConfig("global", "tools_dock_checked");
|
||||||
|
resetDefaultConfig("global", "menu_bar_checked");
|
||||||
|
resetDefaultConfig("global", "enable_compact_mode");
|
||||||
|
|
||||||
|
clearGroupOfSettings(m_sessionSettings, "geometry");
|
||||||
|
|
||||||
|
m_hasReset = true;
|
||||||
|
}
|
||||||
|
|
||||||
void VConfigManager::clearGroupOfSettings(QSettings *p_settings, const QString &p_group)
|
void VConfigManager::clearGroupOfSettings(QSettings *p_settings, const QString &p_group)
|
||||||
{
|
{
|
||||||
p_settings->beginGroup(p_group);
|
p_settings->beginGroup(p_group);
|
||||||
|
@ -103,6 +103,9 @@ public:
|
|||||||
// Reset the configuratio files.
|
// Reset the configuratio files.
|
||||||
void resetConfigurations();
|
void resetConfigurations();
|
||||||
|
|
||||||
|
// Reset the layout.
|
||||||
|
void resetLayoutConfigurations();
|
||||||
|
|
||||||
QFont getMdEditFont() const;
|
QFont getMdEditFont() const;
|
||||||
|
|
||||||
QPalette getMdEditPalette() const;
|
QPalette getMdEditPalette() const;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user