added create new project dialogue
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
assets/scss/*.css
|
||||
assets/images
|
||||
_index.html
|
||||
classes/__pycache__
|
||||
|
||||
@@ -9,16 +9,17 @@
|
||||
# @Last modified time: 21-04-2017
|
||||
# @License: GPL-V3
|
||||
|
||||
import sys, os
|
||||
import sys, os, shutil
|
||||
|
||||
from PyQt5 import QtCore
|
||||
from PyQt5.QtCore import QCoreApplication, QUrl, pyqtSlot, QSettings
|
||||
from PyQt5.QtGui import QKeySequence, QFont, QSyntaxHighlighter
|
||||
from PyQt5.QtWidgets import QMainWindow, QWidget, QApplication, QShortcut, QGridLayout, QLabel, QTabWidget, QHBoxLayout, QVBoxLayout, QSplitter, QSplitterHandle, QPlainTextEdit
|
||||
from PyQt5.QtWidgets import QMainWindow, QAction, QWidget, QApplication, QShortcut, QGridLayout, QLabel, QTabWidget, QHBoxLayout, QVBoxLayout, QSplitter, QSplitterHandle, QPlainTextEdit, QInputDialog, QLineEdit, QFileDialog
|
||||
# from PyQt5.QtNetwork import QNetworkProxyFactory, QNetworkRequest
|
||||
from PyQt5.QtWebKit import QWebSettings
|
||||
from PyQt5.QtWebKitWidgets import QWebPage, QWebView, QWebInspector
|
||||
|
||||
import json
|
||||
|
||||
from classes import server, compiler, view, content
|
||||
|
||||
@@ -32,10 +33,15 @@ class MainWindow(QMainWindow):
|
||||
def __init__(self, core):
|
||||
super(MainWindow, self).__init__()
|
||||
|
||||
# load core class
|
||||
self.core = core
|
||||
|
||||
# restore previous preferences
|
||||
self.restorePreferences()
|
||||
|
||||
self.setWindowTitle("Cascade")
|
||||
|
||||
self.initMenuBar()
|
||||
|
||||
# self.setWindowFlags(QtCore.Qt.WindowTitleHint)
|
||||
# QtCore.Qt.CustomizeWindowHint
|
||||
# | QtCore.Qt.Tool
|
||||
@@ -72,12 +78,69 @@ class MainWindow(QMainWindow):
|
||||
|
||||
self.setCentralWidget(self.tabwidget)
|
||||
|
||||
self.shortcut = QShortcut(QKeySequence("Ctrl+Q"), self)
|
||||
self.shortcut.activated.connect(self.on_quit)
|
||||
# self.shortcut = QShortcut(QKeySequence("Ctrl+Q"), self)
|
||||
# self.shortcut.activated.connect(self.quit)
|
||||
|
||||
|
||||
self.show()
|
||||
|
||||
def initMenuBar(self):
|
||||
# menu bar
|
||||
bar = self.menuBar()
|
||||
file = bar.addMenu("&File")
|
||||
|
||||
new = QAction("&New Project",self)
|
||||
new.setShortcut("Ctrl+n")
|
||||
file.addAction(new)
|
||||
|
||||
open = QAction("&Open",self)
|
||||
open.setShortcut("Ctrl+o")
|
||||
file.addAction(open)
|
||||
|
||||
quit = QAction("&Quit",self)
|
||||
quit.setShortcut("Ctrl+q")
|
||||
file.addAction(quit)
|
||||
|
||||
file.triggered[QAction].connect(self.processtrigger)
|
||||
|
||||
edit = bar.addMenu("Edit")
|
||||
edit.addAction("copy")
|
||||
edit.addAction("paste")
|
||||
|
||||
|
||||
def processtrigger(self, q):
|
||||
print(q.text()+" is triggered")
|
||||
if q.text() == "&New Project":
|
||||
self.newprojectdialogue()
|
||||
elif q.text() == "&Open":
|
||||
self.opendialogue()
|
||||
elif q.text() == "&Quit":
|
||||
self.quit()
|
||||
|
||||
def opendialogue(self):
|
||||
print("open")
|
||||
|
||||
def newprojectdialogue(self):
|
||||
projectname = QFileDialog.getSaveFileName(self, 'Dialog Title', '')
|
||||
# TODO: no file type
|
||||
if not os.path.isdir(projectname[0]):
|
||||
self.core.cwd = projectname[0]
|
||||
self.initnewproject()
|
||||
else:
|
||||
print("folder already exists")
|
||||
# TODO: check if is cascade folder
|
||||
|
||||
def initnewproject(self):
|
||||
shutil.copytree('templates/newproject', self.core.cwd)
|
||||
self.core.prefs = json.loads(open(os.path.join(self.core.cwd,'.config/prefs.json')).read())
|
||||
self.core.summary = json.loads(open(os.path.join(self.core.cwd,'.config/summary.json')).read())
|
||||
# TODO: init git repos
|
||||
|
||||
def quit(self):
|
||||
print("Quit")
|
||||
self.savePreferences()
|
||||
QCoreApplication.instance().quit()
|
||||
|
||||
def restorePreferences(self):
|
||||
try:
|
||||
self.resize(self.core.settings.value('mainwindow/size', QtCore.QSize(1024, 768)))
|
||||
@@ -89,14 +152,9 @@ class MainWindow(QMainWindow):
|
||||
self.core.settings.beginGroup("mainwindow")
|
||||
self.core.settings.setValue('size', self.size())
|
||||
self.core.settings.setValue('pos', self.pos())
|
||||
self.core.settings.setValue('cwd', self.core.cwd)
|
||||
self.core.settings.endGroup()
|
||||
|
||||
@pyqtSlot()
|
||||
def on_quit(self):
|
||||
print("Quit!")
|
||||
self.savePreferences()
|
||||
QCoreApplication.instance().quit()
|
||||
|
||||
|
||||
def main():
|
||||
app = QApplication(sys.argv)
|
||||
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -0,0 +1,4 @@
|
||||
{
|
||||
"prop1":1,
|
||||
"prop2":2
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
[
|
||||
{
|
||||
"title":"Default page",
|
||||
"file":"default.md",
|
||||
"index":0
|
||||
}
|
||||
]
|
||||
@@ -0,0 +1,5 @@
|
||||
jQuery(document).ready(function($) {
|
||||
|
||||
console.log("Hello Cascade");
|
||||
|
||||
});
|
||||
@@ -0,0 +1 @@
|
||||
// your styles here
|
||||
@@ -0,0 +1,5 @@
|
||||
# Default Page
|
||||
|
||||
Welcome message
|
||||
|
||||
insert her an image as example
|
||||
Reference in New Issue
Block a user