1 /***************************************************************************
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
10 * Copyright (C) 2010 Robert Bieber
12 * This program is free software; you can redistribute it and/or
13 * modify it under the terms of the GNU General Public License
14 * as published by the Free Software Foundation; either version 2
15 * of the License, or (at your option) any later version.
17 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
18 * KIND, either express or implied.
20 ****************************************************************************/
22 #include "editorwindow.h"
23 #include "ui_editorwindow.h"
25 #include <QDesktopWidget>
26 #include <QFileSystemModel>
28 EditorWindow::EditorWindow(QWidget
*parent
) :
30 ui(new Ui::EditorWindow
)
38 void EditorWindow::loadSettings()
40 /* When there are settings to load, they'll be loaded here */
41 /* For now, we'll just set the window to take up most of the screen */
42 QDesktopWidget
* desktop
= QApplication::desktop();
44 QRect availableSpace
= desktop
->availableGeometry(desktop
->primaryScreen());
45 QRect
buffer(availableSpace
.left() + availableSpace
.width() / 10,
46 availableSpace
.top() + availableSpace
.height() / 10,
47 availableSpace
.width() * 8 / 10,
48 availableSpace
.height() * 8 / 10);
49 this->setGeometry(buffer
);
53 void EditorWindow::setupUI()
55 /* Displaying some files to test the file tree view */
56 QFileSystemModel
* model
= new QFileSystemModel
;
57 model
->setRootPath(QDir::currentPath());
58 ui
->fileTree
->setModel(model
);
60 /* Connecting the buttons */
61 QObject::connect(ui
->fromTree
, SIGNAL(pressed()),
62 this, SLOT(updateCode()));
66 void EditorWindow::setupMenus()
68 /* Connecting panel show actions */
69 QObject::connect(ui
->actionFile_Panel
, SIGNAL(triggered()),
70 this, SLOT(showPanel()));
71 QObject::connect(ui
->actionDisplay_Panel
, SIGNAL(triggered()),
72 this, SLOT(showPanel()));
73 QObject::connect(ui
->actionPreview_Panel
, SIGNAL(triggered()),
74 this, SLOT(showPanel()));
76 /* Connecting the document opening/closing actions */
77 QObject::connect(ui
->actionNew_Document
, SIGNAL(triggered()),
78 this, SLOT(newTab()));
82 void EditorWindow::newTab()
84 SkinDocument
* doc
= new SkinDocument
;
85 ui
->editorTabs
->addTab(doc
, doc
->getTitle());
88 void EditorWindow::showPanel()
90 if(sender() == ui
->actionFile_Panel
)
91 ui
->fileDock
->setVisible(true);
92 if(sender() == ui
->actionPreview_Panel
)
93 ui
->skinPreviewDock
->setVisible(true);
94 if(sender() == ui
->actionDisplay_Panel
)
95 ui
->parseTreeDock
->setVisible(true);
98 void EditorWindow::closeEvent(QCloseEvent
* event
)
103 EditorWindow::~EditorWindow()