Commit b8c6d94f authored by Filipe Saraiva's avatar Filipe Saraiva
Browse files

Add a filter to present worksheets and notebooks together

parent 5a1e6ce4
...@@ -214,14 +214,9 @@ void CantorShell::fileOpen() ...@@ -214,14 +214,9 @@ void CantorShell::fileOpen()
// this slot is called whenever the File->Open menu is selected, // this slot is called whenever the File->Open menu is selected,
// the Open shortcut is pressed (usually CTRL+O) or the Open toolbar // the Open shortcut is pressed (usually CTRL+O) or the Open toolbar
// button is clicked // button is clicked
static const QString& worksheetFilter = i18n("Cantor Worksheet (*.cws)"); static const QString& filter = i18n("All supported files (*.cws *ipynb);;Cantor Worksheet (*.cws);;Jupyter Notebook (*.ipynb)");
static const QString& notebookFilter = i18n("Jupyter Notebook (*.ipynb)");
QString filter; QUrl url = QFileDialog::getOpenFileUrl(this, i18n("Open file"), QUrl(), filter);
if (m_previousFilter == notebookFilter)
filter = notebookFilter + QLatin1String(";;") + worksheetFilter;
else
filter = worksheetFilter + QLatin1String(";;") + notebookFilter;
QUrl url = QFileDialog::getOpenFileUrl(this, i18n("Open file"), QUrl(), filter, &m_previousFilter);
if (url.isEmpty() == false) if (url.isEmpty() == false)
{ {
......
...@@ -117,8 +117,6 @@ private: ...@@ -117,8 +117,6 @@ private:
QList<QAction*> m_newBackendActions; QList<QAction*> m_newBackendActions;
QDockWidget* m_helpDocker; QDockWidget* m_helpDocker;
KRecentFilesAction* m_recentProjectsAction; KRecentFilesAction* m_recentProjectsAction;
// For better UX: set previous used filter in "Open" action as default filter
QString m_previousFilter;
}; };
#endif // CANTOR_H #endif // CANTOR_H
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment