mirror of
https://github.com/sqlitebrowser/sqlitebrowser.git
synced 2026-05-24 22:48:23 -05:00
Move recent files items to new submenu and add clear recent file function (#2347)
* Add a new submenu ('File > Recent Files') and move recent file actions inside.
* Add a new menu item to the menu of recent files ('Clear List') and delete divider(QAction *recentSeparatorAct) because that is no longer used.
* Added general function to clear Settings value (including cache)
This commit is contained in:
+13
-4
@@ -231,8 +231,11 @@ void MainWindow::init()
|
||||
connect(recentFileActs[i], &QAction::triggered, this, &MainWindow::openRecentFile);
|
||||
}
|
||||
for(int i = 0; i < MaxRecentFiles; ++i)
|
||||
ui->fileMenu->insertAction(ui->fileExitAction, recentFileActs[i]);
|
||||
recentSeparatorAct = ui->fileMenu->insertSeparator(ui->fileExitAction);
|
||||
ui->fileRecentFiles->insertAction(ui->fileExitAction, recentFileActs[i]);
|
||||
|
||||
QAction *clearRecentFilesAction = ui->fileRecentFiles->addAction(tr("Clear List"));
|
||||
ui->fileRecentFiles->insertAction(ui->fileExitAction, clearRecentFilesAction);
|
||||
connect(clearRecentFilesAction, &QAction::triggered, this, &MainWindow::clearRecentFiles);
|
||||
|
||||
// Create popup menus
|
||||
popupTableMenu = new QMenu(this);
|
||||
@@ -1624,8 +1627,6 @@ void MainWindow::updateRecentFileActions()
|
||||
}
|
||||
for (int j = numRecentFiles; j < MaxRecentFiles; ++j)
|
||||
recentFileActs[j]->setVisible(false);
|
||||
|
||||
recentSeparatorAct->setVisible(numRecentFiles > 0);
|
||||
}
|
||||
|
||||
void MainWindow::setCurrentFile(const QString &fileName)
|
||||
@@ -3434,3 +3435,11 @@ void MainWindow::moveDocksTo(Qt::DockWidgetArea area)
|
||||
tabifyDockWidget(ui->dockLog, ui->dockSchema);
|
||||
tabifyDockWidget(ui->dockLog, ui->dockRemote);
|
||||
}
|
||||
|
||||
void MainWindow::clearRecentFiles()
|
||||
{
|
||||
Settings::clearValue("General", "recentFileList");
|
||||
|
||||
for(int i=0; i < MaxRecentFiles; ++i)
|
||||
recentFileActs[i]->setVisible(false);
|
||||
}
|
||||
|
||||
+1
-1
@@ -82,7 +82,6 @@ private:
|
||||
|
||||
static const int MaxRecentFiles = 5;
|
||||
QAction *recentFileActs[MaxRecentFiles];
|
||||
QAction *recentSeparatorAct;
|
||||
|
||||
EditDialog* editDock;
|
||||
PlotDock* plotDock;
|
||||
@@ -101,6 +100,7 @@ private:
|
||||
void clearCompleterModelsFields();
|
||||
|
||||
void updateRecentFileActions();
|
||||
void clearRecentFiles();
|
||||
void setCurrentFile(const QString& fileName);
|
||||
void addToRecentFilesMenu(const QString& filename, bool read_only = false);
|
||||
void activateFields(bool enable = true);
|
||||
|
||||
+9
-3
@@ -174,8 +174,8 @@ You can drag SQL statements from an object row and drop them into other applicat
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>641</width>
|
||||
<height>544</height>
|
||||
<width>639</width>
|
||||
<height>574</height>
|
||||
</rect>
|
||||
</property>
|
||||
<layout class="QFormLayout" name="formLayout">
|
||||
@@ -744,7 +744,7 @@ You can drag SQL statements from an object row and drop them into other applicat
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>1037</width>
|
||||
<height>23</height>
|
||||
<height>22</height>
|
||||
</rect>
|
||||
</property>
|
||||
<widget class="QMenu" name="fileMenu">
|
||||
@@ -766,11 +766,17 @@ You can drag SQL statements from an object row and drop them into other applicat
|
||||
<addaction name="fileExportCSVAction"/>
|
||||
<addaction name="fileExportJsonAction"/>
|
||||
</widget>
|
||||
<widget class="QMenu" name="fileRecentFiles">
|
||||
<property name="title">
|
||||
<string>Recent Files</string>
|
||||
</property>
|
||||
</widget>
|
||||
<addaction name="fileNewAction"/>
|
||||
<addaction name="fileNewInMemoryDatabaseAction"/>
|
||||
<addaction name="fileOpenAction"/>
|
||||
<addaction name="fileOpenReadOnlyAction"/>
|
||||
<addaction name="fileAttachAction"/>
|
||||
<addaction name="fileRecentFiles"/>
|
||||
<addaction name="fileCloseAction"/>
|
||||
<addaction name="separator"/>
|
||||
<addaction name="fileSaveAction"/>
|
||||
|
||||
@@ -489,6 +489,15 @@ QColor Settings::getDefaultColorValue(const std::string& group, const std::strin
|
||||
return QColor();
|
||||
}
|
||||
|
||||
void Settings::clearValue(const std::string& group, const std::string& name)
|
||||
{
|
||||
QSettings settings(QApplication::organizationName(), QApplication::organizationName());
|
||||
settings.beginGroup(QString::fromStdString(group));
|
||||
settings.remove(QString::fromStdString(name));
|
||||
settings.endGroup();
|
||||
m_hCache.clear();
|
||||
}
|
||||
|
||||
void Settings::restoreDefaults ()
|
||||
{
|
||||
QSettings settings(QApplication::organizationName(), QApplication::organizationName());
|
||||
|
||||
@@ -16,6 +16,7 @@ public:
|
||||
};
|
||||
static QVariant getValue(const std::string& group, const std::string& name);
|
||||
static void setValue(const std::string& group, const std::string& name, const QVariant& value, bool dont_save_to_disk = false);
|
||||
static void clearValue(const std::string& group, const std::string& name);
|
||||
static void restoreDefaults();
|
||||
|
||||
static void rememberDefaultFontSize(int size) { m_defaultFontSize = size; }
|
||||
|
||||
Reference in New Issue
Block a user