Commit a5a390e7 authored by jhammen's avatar jhammen

CLI attempt to open project from path arg

parent 6b5c5707
......@@ -24,7 +24,7 @@ int main(int argc, char *argv[]) {
qRegisterMetaType<Position>("Position");
MainWindow w;
MainWindow w(0, argc > 1 ? argv[1] : nullptr);
w.showMaximized();
return a.exec();
......
......@@ -30,7 +30,7 @@
#include <QLabel>
#include <QTime>
MainWindow::MainWindow(QWidget *parent)
MainWindow::MainWindow(QWidget *parent, const char *folder)
: QMainWindow(parent), projectList(ProjectList::instance()),
audioEngine(AudioEngine::instance()), transportPosition(0), ui(new Ui::MainWindow),
timeWidget(this), bbtWidget(this) {
......@@ -68,6 +68,10 @@ MainWindow::MainWindow(QWidget *parent)
SLOT(handleLink(EditorLocation &)));
projectList.load();
if(folder) { // from CLI
QDir dir(folder);
projectList.select(dir.canonicalPath());
}
if (projectList.currentExists()) {
loadProject();
} else {
......
......@@ -37,7 +37,7 @@ class MainWindow;
class MainWindow : public QMainWindow {
Q_OBJECT
public:
explicit MainWindow(QWidget *parent = 0);
explicit MainWindow(QWidget *parent = 0, const char *project = nullptr);
~MainWindow();
void closeEvent(QCloseEvent *event);
private slots:
......
......@@ -137,6 +137,12 @@ bool ProjectList::open(int index) {
return false;
}
bool ProjectList::select(QString path)
{
int index = findProject(path);
return index == -1 ? false : open(index);
}
QString ProjectList::commonRoot(QString &path1, QString &path2) {
QStringList list1 = path1.split(QDir::separator());
QStringList list2 = path2.split(QDir::separator());
......
......@@ -76,5 +76,6 @@ class ProjectList {
void removeProject(int index);
bool isOpen(int index) { return index == openIndex; }
bool open(int index);
bool select(QString path);
};
#endif // PROJECTLIST_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