2010-06-01 21:25:02 +00:00
|
|
|
/***************************************************************************
|
|
|
|
* __________ __ ___.
|
|
|
|
* Open \______ \ ____ ____ | | _\_ |__ _______ ___
|
|
|
|
* Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
|
|
|
|
* Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
|
|
|
|
* Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
|
|
|
|
* \/ \/ \/ \/ \/
|
|
|
|
* $Id$
|
|
|
|
*
|
|
|
|
* Copyright (C) 2010 Robert Bieber
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU General Public License
|
|
|
|
* as published by the Free Software Foundation; either version 2
|
|
|
|
* of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
|
|
|
|
* KIND, either express or implied.
|
|
|
|
*
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
#include "editorwindow.h"
|
2010-06-09 21:37:15 +00:00
|
|
|
#include "projectmodel.h"
|
2010-06-01 21:25:02 +00:00
|
|
|
#include "ui_editorwindow.h"
|
2010-07-07 09:33:47 +00:00
|
|
|
#include "rbfontcache.h"
|
|
|
|
#include "rbtextcache.h"
|
2010-07-15 21:39:09 +00:00
|
|
|
#include "newprojectdialog.h"
|
2010-07-23 21:15:15 +00:00
|
|
|
#include "projectexporter.h"
|
2010-06-01 21:25:02 +00:00
|
|
|
|
2010-06-03 20:05:55 +00:00
|
|
|
#include <QDesktopWidget>
|
|
|
|
#include <QFileSystemModel>
|
2010-06-05 07:14:03 +00:00
|
|
|
#include <QSettings>
|
2010-06-06 03:35:40 +00:00
|
|
|
#include <QFileDialog>
|
2010-07-15 21:39:09 +00:00
|
|
|
#include <QMessageBox>
|
2010-06-17 00:40:07 +00:00
|
|
|
#include <QGraphicsScene>
|
2010-07-15 21:39:09 +00:00
|
|
|
#include <QDir>
|
|
|
|
#include <QFile>
|
2010-06-01 21:25:02 +00:00
|
|
|
|
2010-07-25 21:16:37 +00:00
|
|
|
const int EditorWindow::numRecent = 5;
|
|
|
|
|
2010-06-01 21:25:02 +00:00
|
|
|
EditorWindow::EditorWindow(QWidget *parent) :
|
2010-06-25 05:49:16 +00:00
|
|
|
QMainWindow(parent), ui(new Ui::EditorWindow), parseTreeSelection(0)
|
2010-06-01 21:25:02 +00:00
|
|
|
{
|
|
|
|
ui->setupUi(this);
|
2010-06-07 03:25:40 +00:00
|
|
|
prefs = new PreferencesDialog(this);
|
2010-06-09 07:51:22 +00:00
|
|
|
project = 0;
|
2010-06-03 18:42:36 +00:00
|
|
|
setupUI();
|
2010-06-25 05:49:16 +00:00
|
|
|
loadSettings();
|
2010-06-03 18:42:36 +00:00
|
|
|
setupMenus();
|
|
|
|
}
|
2010-06-01 21:25:02 +00:00
|
|
|
|
2010-06-25 05:49:16 +00:00
|
|
|
|
|
|
|
EditorWindow::~EditorWindow()
|
|
|
|
{
|
|
|
|
delete ui;
|
|
|
|
delete prefs;
|
|
|
|
if(project)
|
|
|
|
delete project;
|
|
|
|
delete deviceConfig;
|
|
|
|
delete deviceDock;
|
2010-07-25 21:16:37 +00:00
|
|
|
delete timer;
|
|
|
|
delete timerDock;
|
2010-07-07 09:33:47 +00:00
|
|
|
|
|
|
|
RBFontCache::clearCache();
|
|
|
|
RBTextCache::clearCache();
|
2010-06-25 05:49:16 +00:00
|
|
|
}
|
|
|
|
|
2010-06-15 06:54:58 +00:00
|
|
|
void EditorWindow::loadTabFromSkinFile(QString fileName)
|
2010-06-09 21:37:15 +00:00
|
|
|
{
|
2010-07-25 21:16:37 +00:00
|
|
|
docToTop(fileName);
|
|
|
|
|
2010-06-10 07:06:38 +00:00
|
|
|
/* Checking to see if the file is already open */
|
|
|
|
for(int i = 0; i < ui->editorTabs->count(); i++)
|
|
|
|
{
|
2010-06-15 06:54:58 +00:00
|
|
|
TabContent* current = dynamic_cast<TabContent*>
|
2010-06-10 07:06:38 +00:00
|
|
|
(ui->editorTabs->widget(i));
|
2010-06-15 06:54:58 +00:00
|
|
|
if(current->file() == fileName)
|
2010-06-10 07:06:38 +00:00
|
|
|
{
|
|
|
|
ui->editorTabs->setCurrentIndex(i);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Adding a new document*/
|
2010-06-26 05:18:21 +00:00
|
|
|
SkinDocument* doc = new SkinDocument(parseStatus, fileName, project,
|
|
|
|
deviceConfig);
|
2010-06-09 21:37:15 +00:00
|
|
|
addTab(doc);
|
2010-06-14 06:47:05 +00:00
|
|
|
ui->editorTabs->setCurrentWidget(doc);
|
2010-06-09 21:37:15 +00:00
|
|
|
|
|
|
|
}
|
|
|
|
|
2010-06-15 06:54:58 +00:00
|
|
|
void EditorWindow::loadConfigTab(ConfigDocument* doc)
|
|
|
|
{
|
|
|
|
for(int i = 0; i < ui->editorTabs->count(); i++)
|
|
|
|
{
|
|
|
|
TabContent* current = dynamic_cast<TabContent*>
|
|
|
|
(ui->editorTabs->widget(i));
|
|
|
|
if(current->file() == doc->file())
|
|
|
|
{
|
|
|
|
ui->editorTabs->setCurrentIndex(i);
|
|
|
|
doc->deleteLater();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
addTab(doc);
|
|
|
|
ui->editorTabs->setCurrentWidget(doc);
|
|
|
|
|
|
|
|
QObject::connect(doc, SIGNAL(titleChanged(QString)),
|
|
|
|
this, SLOT(tabTitleChanged(QString)));
|
|
|
|
}
|
|
|
|
|
2010-07-29 07:38:01 +00:00
|
|
|
void EditorWindow::loadSettings()
|
2010-06-03 18:42:36 +00:00
|
|
|
{
|
2010-06-03 20:05:55 +00:00
|
|
|
|
2010-06-05 07:14:03 +00:00
|
|
|
QSettings settings;
|
|
|
|
|
|
|
|
/* Main Window location */
|
2010-06-07 03:25:40 +00:00
|
|
|
settings.beginGroup("EditorWindow");
|
2010-06-05 07:14:03 +00:00
|
|
|
QSize size = settings.value("size").toSize();
|
|
|
|
QPoint pos = settings.value("position").toPoint();
|
|
|
|
QByteArray state = settings.value("state").toByteArray();
|
2010-07-25 21:16:37 +00:00
|
|
|
|
|
|
|
/* Recent docs/projects */
|
|
|
|
recentDocs = settings.value("recentDocs", QStringList()).toStringList();
|
|
|
|
recentProjects = settings.value("recentProjects",
|
|
|
|
QStringList()).toStringList();
|
|
|
|
|
2010-06-05 07:14:03 +00:00
|
|
|
settings.endGroup();
|
|
|
|
|
|
|
|
if(!(size.isNull() || pos.isNull() || state.isNull()))
|
|
|
|
{
|
|
|
|
resize(size);
|
|
|
|
move(pos);
|
|
|
|
restoreState(state);
|
|
|
|
}
|
|
|
|
|
2010-06-03 18:42:36 +00:00
|
|
|
}
|
|
|
|
|
2010-06-05 07:14:03 +00:00
|
|
|
void EditorWindow::saveSettings()
|
|
|
|
{
|
|
|
|
|
|
|
|
QSettings settings;
|
|
|
|
|
|
|
|
/* Saving window and panel positions */
|
2010-06-07 03:25:40 +00:00
|
|
|
settings.beginGroup("EditorWindow");
|
2010-06-05 07:14:03 +00:00
|
|
|
settings.setValue("position", pos());
|
|
|
|
settings.setValue("size", size());
|
|
|
|
settings.setValue("state", saveState());
|
2010-07-25 21:16:37 +00:00
|
|
|
|
|
|
|
/* Saving recent docs/projects */
|
|
|
|
settings.setValue("recentDocs", recentDocs);
|
|
|
|
settings.setValue("recentProjects", recentProjects);
|
|
|
|
|
2010-06-05 07:14:03 +00:00
|
|
|
settings.endGroup();
|
|
|
|
}
|
|
|
|
|
2010-06-03 18:42:36 +00:00
|
|
|
void EditorWindow::setupUI()
|
|
|
|
{
|
2010-06-05 07:38:29 +00:00
|
|
|
/* Connecting the tab bar signals */
|
|
|
|
QObject::connect(ui->editorTabs, SIGNAL(currentChanged(int)),
|
|
|
|
this, SLOT(shiftTab(int)));
|
|
|
|
QObject::connect(ui->editorTabs, SIGNAL(tabCloseRequested(int)),
|
|
|
|
this, SLOT(closeTab(int)));
|
|
|
|
|
2010-06-06 02:11:04 +00:00
|
|
|
/* Connecting the code gen button */
|
|
|
|
QObject::connect(ui->fromTree, SIGNAL(pressed()),
|
|
|
|
this, SLOT(updateCurrent()));
|
|
|
|
|
2010-06-07 03:25:40 +00:00
|
|
|
/* Connecting the preferences dialog */
|
|
|
|
QObject::connect(ui->actionPreferences, SIGNAL(triggered()),
|
|
|
|
prefs, SLOT(exec()));
|
|
|
|
|
2010-06-07 20:29:46 +00:00
|
|
|
/* Setting up the parse status label */
|
|
|
|
parseStatus = new QLabel(this);
|
2010-06-07 21:59:16 +00:00
|
|
|
ui->statusbar->addPermanentWidget(parseStatus);
|
2010-06-07 20:29:46 +00:00
|
|
|
|
2010-06-17 00:40:07 +00:00
|
|
|
/* Setting the selection for parse tree highlighting initially NULL */
|
2010-06-16 19:24:53 +00:00
|
|
|
parseTreeSelection = 0;
|
2010-06-17 00:40:07 +00:00
|
|
|
|
|
|
|
/* Adding the skin viewer */
|
|
|
|
viewer = new SkinViewer(this);
|
|
|
|
ui->skinPreviewLayout->addWidget(viewer);
|
|
|
|
|
2010-06-24 07:59:41 +00:00
|
|
|
/* Positioning the device settings dialog */
|
2010-06-25 05:49:16 +00:00
|
|
|
deviceDock = new QDockWidget(tr("Device Configuration"), this);
|
|
|
|
deviceConfig = new DeviceState(deviceDock);
|
2010-06-24 07:59:41 +00:00
|
|
|
|
2010-06-25 05:49:16 +00:00
|
|
|
deviceDock->setObjectName("deviceDock");
|
|
|
|
deviceDock->setWidget(deviceConfig);
|
|
|
|
deviceDock->setFloating(true);
|
2010-07-08 21:53:27 +00:00
|
|
|
deviceDock->move(QPoint(x() + width() / 2, y() + height() / 2));
|
2010-06-25 05:49:16 +00:00
|
|
|
deviceDock->hide();
|
2010-07-03 06:53:06 +00:00
|
|
|
|
2010-07-08 21:53:27 +00:00
|
|
|
/* Positioning the timer panel */
|
|
|
|
timerDock = new QDockWidget(tr("Timer"), this);
|
|
|
|
timer = new SkinTimer(deviceConfig, timerDock);
|
|
|
|
|
|
|
|
timerDock->setObjectName("timerDock");
|
|
|
|
timerDock->setWidget(timer);
|
|
|
|
timerDock->setFloating(true);
|
|
|
|
timerDock->move(QPoint(x() + width() / 2, y() + height() / 2));
|
|
|
|
timerDock->hide();
|
|
|
|
|
2010-07-03 06:53:06 +00:00
|
|
|
shiftTab(-1);
|
2010-06-03 18:42:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void EditorWindow::setupMenus()
|
|
|
|
{
|
2010-08-04 17:56:00 +00:00
|
|
|
/* Adding actions to the toolbar */
|
|
|
|
ui->toolBar->addAction(ui->actionNew_Document);
|
|
|
|
ui->toolBar->addAction(ui->actionOpen_Document);
|
|
|
|
ui->toolBar->addAction(ui->actionSave_Document);
|
|
|
|
ui->toolBar->addAction(ui->actionSave_Document_As);
|
|
|
|
|
|
|
|
ui->toolBar->addSeparator();
|
|
|
|
ui->toolBar->addAction(ui->actionUndo);
|
|
|
|
ui->toolBar->addAction(ui->actionRedo);
|
|
|
|
|
|
|
|
ui->toolBar->addSeparator();
|
|
|
|
ui->toolBar->addAction(ui->actionCut);
|
|
|
|
ui->toolBar->addAction(ui->actionCopy);
|
|
|
|
ui->toolBar->addAction(ui->actionPaste);
|
|
|
|
|
|
|
|
ui->toolBar->addSeparator();
|
|
|
|
ui->toolBar->addAction(ui->actionFind_Replace);
|
|
|
|
|
2010-06-04 06:59:25 +00:00
|
|
|
/* Connecting panel show actions */
|
|
|
|
QObject::connect(ui->actionFile_Panel, SIGNAL(triggered()),
|
|
|
|
this, SLOT(showPanel()));
|
|
|
|
QObject::connect(ui->actionDisplay_Panel, SIGNAL(triggered()),
|
|
|
|
this, SLOT(showPanel()));
|
|
|
|
QObject::connect(ui->actionPreview_Panel, SIGNAL(triggered()),
|
|
|
|
this, SLOT(showPanel()));
|
2010-06-23 20:46:43 +00:00
|
|
|
QObject::connect(ui->actionDevice_Configuration, SIGNAL(triggered()),
|
2010-06-25 05:49:16 +00:00
|
|
|
deviceDock, SLOT(show()));
|
2010-07-08 21:53:27 +00:00
|
|
|
QObject::connect(ui->actionTimer, SIGNAL(triggered()),
|
|
|
|
timerDock, SLOT(show()));
|
2010-06-01 21:25:02 +00:00
|
|
|
|
2010-06-05 19:47:49 +00:00
|
|
|
/* Connecting the document management actions */
|
2010-06-04 07:57:19 +00:00
|
|
|
QObject::connect(ui->actionNew_Document, SIGNAL(triggered()),
|
|
|
|
this, SLOT(newTab()));
|
2010-07-15 21:39:09 +00:00
|
|
|
QObject::connect(ui->actionNew_Project, SIGNAL(triggered()),
|
|
|
|
this, SLOT(newProject()));
|
2010-06-05 19:47:49 +00:00
|
|
|
|
|
|
|
QObject::connect(ui->actionClose_Document, SIGNAL(triggered()),
|
|
|
|
this, SLOT(closeCurrent()));
|
2010-07-14 05:06:42 +00:00
|
|
|
QObject::connect(ui->actionClose_Project, SIGNAL(triggered()),
|
|
|
|
this, SLOT(closeProject()));
|
2010-06-05 19:47:49 +00:00
|
|
|
|
|
|
|
QObject::connect(ui->actionSave_Document, SIGNAL(triggered()),
|
|
|
|
this, SLOT(saveCurrent()));
|
|
|
|
QObject::connect(ui->actionSave_Document_As, SIGNAL(triggered()),
|
|
|
|
this, SLOT(saveCurrentAs()));
|
2010-07-23 21:15:15 +00:00
|
|
|
QObject::connect(ui->actionExport_Project, SIGNAL(triggered()),
|
|
|
|
this, SLOT(exportProject()));
|
2010-06-05 19:47:49 +00:00
|
|
|
|
2010-06-07 01:08:25 +00:00
|
|
|
QObject::connect(ui->actionOpen_Document, SIGNAL(triggered()),
|
|
|
|
this, SLOT(openFile()));
|
|
|
|
|
2010-06-09 07:51:22 +00:00
|
|
|
QObject::connect(ui->actionOpen_Project, SIGNAL(triggered()),
|
|
|
|
this, SLOT(openProject()));
|
2010-06-26 07:59:23 +00:00
|
|
|
|
|
|
|
/* Connecting the edit menu */
|
|
|
|
QObject::connect(ui->actionUndo, SIGNAL(triggered()),
|
|
|
|
this, SLOT(undo()));
|
|
|
|
QObject::connect(ui->actionRedo, SIGNAL(triggered()),
|
|
|
|
this, SLOT(redo()));
|
|
|
|
QObject::connect(ui->actionCut, SIGNAL(triggered()),
|
|
|
|
this, SLOT(cut()));
|
|
|
|
QObject::connect(ui->actionCopy, SIGNAL(triggered()),
|
|
|
|
this, SLOT(copy()));
|
|
|
|
QObject::connect(ui->actionPaste, SIGNAL(triggered()),
|
|
|
|
this, SLOT(paste()));
|
|
|
|
QObject::connect(ui->actionFind_Replace, SIGNAL(triggered()),
|
|
|
|
this, SLOT(findReplace()));
|
2010-07-25 21:16:37 +00:00
|
|
|
|
|
|
|
/* Adding the recent docs/projects menus */
|
|
|
|
for(int i = 0; i < numRecent; i++)
|
|
|
|
{
|
|
|
|
recentDocsMenu.append(new QAction(tr("Recent Doc"),
|
|
|
|
ui->menuRecent_Files));
|
|
|
|
recentDocsMenu.last()
|
|
|
|
->setShortcut(QKeySequence(tr("CTRL+")
|
|
|
|
+ QString::number(i + 1)));
|
|
|
|
QObject::connect(recentDocsMenu.last(), SIGNAL(triggered()),
|
|
|
|
this, SLOT(openRecentFile()));
|
|
|
|
ui->menuRecent_Files->addAction(recentDocsMenu.last());
|
|
|
|
|
|
|
|
|
|
|
|
recentProjectsMenu.append(new QAction(tr("Recent Project"),
|
|
|
|
ui->menuRecent_Projects));
|
|
|
|
recentProjectsMenu.last()
|
|
|
|
->setShortcut(QKeySequence(tr("CTRL+SHIFT+") +
|
|
|
|
QString::number(i + 1)));
|
|
|
|
QObject::connect(recentProjectsMenu.last(), SIGNAL(triggered()),
|
|
|
|
this, SLOT(openRecentProject()));
|
|
|
|
ui->menuRecent_Projects->addAction(recentProjectsMenu.last());
|
|
|
|
}
|
|
|
|
refreshRecentMenus();
|
2010-06-01 21:25:02 +00:00
|
|
|
}
|
|
|
|
|
2010-06-15 06:54:58 +00:00
|
|
|
void EditorWindow::addTab(TabContent *doc)
|
2010-06-03 20:05:55 +00:00
|
|
|
{
|
2010-06-15 06:54:58 +00:00
|
|
|
ui->editorTabs->addTab(doc, doc->title());
|
2010-06-05 08:22:30 +00:00
|
|
|
|
|
|
|
/* Connecting to title change events */
|
|
|
|
QObject::connect(doc, SIGNAL(titleChanged(QString)),
|
|
|
|
this, SLOT(tabTitleChanged(QString)));
|
2010-06-15 06:54:58 +00:00
|
|
|
QObject::connect(doc, SIGNAL(lineChanged(int)),
|
|
|
|
this, SLOT(lineChanged(int)));
|
2010-06-07 03:25:40 +00:00
|
|
|
|
|
|
|
/* Connecting to settings change events */
|
2010-08-15 01:50:27 +00:00
|
|
|
doc->connectPrefs(prefs);
|
2010-06-07 03:25:40 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void EditorWindow::newTab()
|
|
|
|
{
|
2010-06-26 05:18:21 +00:00
|
|
|
SkinDocument* doc = new SkinDocument(parseStatus, project, deviceConfig);
|
2010-06-07 03:25:40 +00:00
|
|
|
addTab(doc);
|
2010-06-14 06:47:05 +00:00
|
|
|
ui->editorTabs->setCurrentWidget(doc);
|
2010-06-03 20:05:55 +00:00
|
|
|
}
|
|
|
|
|
2010-07-15 21:39:09 +00:00
|
|
|
void EditorWindow::newProject()
|
|
|
|
{
|
|
|
|
NewProjectDialog dialog(this);
|
|
|
|
if(dialog.exec() == QDialog::Rejected)
|
|
|
|
return;
|
|
|
|
|
|
|
|
/* Assembling the new project if the dialog was accepted */
|
|
|
|
NewProjectDialog::NewProjectInfo info = dialog.results();
|
|
|
|
|
|
|
|
QDir path(info.path);
|
|
|
|
if(!path.exists())
|
|
|
|
{
|
|
|
|
QMessageBox::warning(this, tr("Error Creating Project"), tr("Error:"
|
|
|
|
" Project directory does not exist"));
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if(path.exists(info.name))
|
|
|
|
{
|
|
|
|
QMessageBox::warning(this, tr("Error Creating Project"), tr("Error:"
|
|
|
|
" Project directory already exists"));
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if(!path.mkdir(info.name))
|
|
|
|
{
|
|
|
|
QMessageBox::warning(this, tr("Error Creating Project"), tr("Error:"
|
|
|
|
" Project directory not writeable"));
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
path.cd(info.name);
|
|
|
|
|
|
|
|
/* Making standard directories */
|
|
|
|
path.mkdir("fonts");
|
|
|
|
path.mkdir("icons");
|
|
|
|
path.mkdir("backdrops");
|
|
|
|
|
|
|
|
/* Adding the desired wps documents */
|
|
|
|
path.mkdir("wps");
|
|
|
|
path.cd("wps");
|
|
|
|
|
|
|
|
if(info.sbs)
|
|
|
|
createFile(path.filePath(info.name + ".sbs"), tr("# SBS Document\n"));
|
|
|
|
if(info.wps)
|
|
|
|
createFile(path.filePath(info.name + ".wps"), tr("# WPS Document\n"));
|
|
|
|
if(info.fms)
|
|
|
|
createFile(path.filePath(info.name + ".fms"), tr("# FMS Document\n"));
|
|
|
|
if(info.rsbs)
|
|
|
|
createFile(path.filePath(info.name + ".rsbs"), tr("# RSBS Document\n"));
|
|
|
|
if(info.rwps)
|
|
|
|
createFile(path.filePath(info.name + ".rwps"), tr("# RWPS Document\n"));
|
|
|
|
if(info.rfms)
|
|
|
|
createFile(path.filePath(info.name + ".rfms"), tr("# RFMS Document\n"));
|
|
|
|
|
|
|
|
path.mkdir(info.name);
|
|
|
|
|
|
|
|
path.cdUp();
|
|
|
|
|
|
|
|
/* Adding the config file */
|
|
|
|
path.mkdir("themes");
|
|
|
|
path.cd("themes");
|
|
|
|
|
|
|
|
/* Generating the config file */
|
|
|
|
QString config = tr("# Config file for ") + info.name + "\n";
|
2010-07-17 00:35:54 +00:00
|
|
|
config.append("#target: " + info.target + "\n\n");
|
2010-07-15 21:39:09 +00:00
|
|
|
QString wpsBase = "/.rockbox/wps/";
|
|
|
|
if(info.sbs)
|
|
|
|
config.append("sbs: " + wpsBase + info.name + ".sbs\n");
|
|
|
|
if(info.wps)
|
|
|
|
config.append("wps: " + wpsBase + info.name + ".wps\n");
|
|
|
|
if(info.fms)
|
|
|
|
config.append("fms: " + wpsBase + info.name + ".fms\n");
|
|
|
|
if(info.rsbs)
|
|
|
|
config.append("rsbs: " + wpsBase + info.name + ".rsbs\n");
|
|
|
|
if(info.rwps)
|
|
|
|
config.append("rwps: " + wpsBase + info.name + ".rwps\n");
|
|
|
|
if(info.rfms)
|
|
|
|
config.append("rfms: " + wpsBase + info.name + ".rfms\n");
|
|
|
|
|
|
|
|
|
|
|
|
createFile(path.filePath(info.name + ".cfg"),
|
|
|
|
config);
|
|
|
|
|
|
|
|
/* Opening the new project */
|
|
|
|
loadProjectFile(path.filePath(info.name + ".cfg"));
|
|
|
|
}
|
|
|
|
|
2010-06-05 07:38:29 +00:00
|
|
|
void EditorWindow::shiftTab(int index)
|
|
|
|
{
|
2010-06-15 06:54:58 +00:00
|
|
|
TabContent* widget = dynamic_cast<TabContent*>
|
|
|
|
(ui->editorTabs->currentWidget());
|
2010-06-15 20:55:56 +00:00
|
|
|
if(index < 0)
|
2010-06-05 19:47:49 +00:00
|
|
|
{
|
2010-06-05 07:38:29 +00:00
|
|
|
ui->parseTree->setModel(0);
|
2010-06-05 19:47:49 +00:00
|
|
|
ui->actionSave_Document->setEnabled(false);
|
|
|
|
ui->actionSave_Document_As->setEnabled(false);
|
|
|
|
ui->actionClose_Document->setEnabled(false);
|
2010-06-06 02:11:04 +00:00
|
|
|
ui->fromTree->setEnabled(false);
|
2010-06-26 07:59:23 +00:00
|
|
|
ui->actionUndo->setEnabled(false);
|
|
|
|
ui->actionRedo->setEnabled(false);
|
|
|
|
ui->actionCut->setEnabled(false);
|
|
|
|
ui->actionCopy->setEnabled(false);
|
|
|
|
ui->actionPaste->setEnabled(false);
|
|
|
|
ui->actionFind_Replace->setEnabled(false);
|
2010-08-05 00:43:33 +00:00
|
|
|
viewer->connectSkin(0);
|
2010-06-05 19:47:49 +00:00
|
|
|
}
|
2010-06-15 20:55:56 +00:00
|
|
|
else if(widget->type() == TabContent::Config)
|
|
|
|
{
|
|
|
|
ui->actionSave_Document->setEnabled(true);
|
|
|
|
ui->actionSave_Document_As->setEnabled(true);
|
|
|
|
ui->actionClose_Document->setEnabled(true);
|
2010-06-26 07:59:23 +00:00
|
|
|
ui->actionUndo->setEnabled(false);
|
|
|
|
ui->actionRedo->setEnabled(false);
|
|
|
|
ui->actionCut->setEnabled(false);
|
|
|
|
ui->actionCopy->setEnabled(false);
|
|
|
|
ui->actionPaste->setEnabled(false);
|
|
|
|
ui->actionFind_Replace->setEnabled(false);
|
2010-08-05 00:43:33 +00:00
|
|
|
viewer->connectSkin(0);
|
2010-06-15 20:55:56 +00:00
|
|
|
}
|
2010-06-17 06:59:46 +00:00
|
|
|
else if(widget->type() == TabContent::Skin)
|
2010-06-05 19:47:49 +00:00
|
|
|
{
|
2010-06-07 20:29:46 +00:00
|
|
|
/* Syncing the tree view and the status bar */
|
2010-06-15 06:54:58 +00:00
|
|
|
SkinDocument* doc = dynamic_cast<SkinDocument*>(widget);
|
2010-06-07 21:09:13 +00:00
|
|
|
ui->parseTree->setModel(doc->getModel());
|
|
|
|
parseStatus->setText(doc->getStatus());
|
2010-06-07 20:29:46 +00:00
|
|
|
|
2010-06-05 19:47:49 +00:00
|
|
|
ui->actionSave_Document->setEnabled(true);
|
|
|
|
ui->actionSave_Document_As->setEnabled(true);
|
|
|
|
ui->actionClose_Document->setEnabled(true);
|
2010-06-06 02:11:04 +00:00
|
|
|
ui->fromTree->setEnabled(true);
|
2010-06-15 06:54:58 +00:00
|
|
|
|
2010-06-26 07:59:23 +00:00
|
|
|
ui->actionUndo->setEnabled(true);
|
|
|
|
ui->actionRedo->setEnabled(true);
|
|
|
|
ui->actionCut->setEnabled(true);
|
|
|
|
ui->actionCopy->setEnabled(true);
|
|
|
|
ui->actionPaste->setEnabled(true);
|
|
|
|
ui->actionFind_Replace->setEnabled(true);
|
|
|
|
|
2010-06-15 06:54:58 +00:00
|
|
|
sizeColumns();
|
|
|
|
|
2010-06-17 06:59:46 +00:00
|
|
|
/* Syncing the preview */
|
2010-08-05 00:43:33 +00:00
|
|
|
viewer->connectSkin(doc);
|
|
|
|
|
2010-06-17 06:59:46 +00:00
|
|
|
|
2010-06-05 19:47:49 +00:00
|
|
|
}
|
2010-06-26 07:59:23 +00:00
|
|
|
|
|
|
|
/* Hiding all the find/replace dialogs */
|
|
|
|
for(int i = 0; i < ui->editorTabs->count(); i++)
|
|
|
|
if(dynamic_cast<TabContent*>(ui->editorTabs->widget(i))->type() ==
|
|
|
|
TabContent::Skin)
|
|
|
|
dynamic_cast<SkinDocument*>(ui->editorTabs->widget(i))->hideFind();
|
|
|
|
|
2010-06-05 07:38:29 +00:00
|
|
|
}
|
|
|
|
|
2010-06-05 19:47:49 +00:00
|
|
|
bool EditorWindow::closeTab(int index)
|
2010-06-05 07:38:29 +00:00
|
|
|
{
|
2010-06-15 06:54:58 +00:00
|
|
|
TabContent* widget = dynamic_cast<TabContent*>
|
2010-06-05 07:38:29 +00:00
|
|
|
(ui->editorTabs->widget(index));
|
|
|
|
if(widget->requestClose())
|
|
|
|
{
|
|
|
|
ui->editorTabs->removeTab(index);
|
|
|
|
widget->deleteLater();
|
2010-06-05 19:47:49 +00:00
|
|
|
return true;
|
2010-06-05 07:38:29 +00:00
|
|
|
}
|
2010-06-05 19:47:49 +00:00
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
void EditorWindow::closeCurrent()
|
|
|
|
{
|
|
|
|
closeTab(ui->editorTabs->currentIndex());
|
2010-06-05 07:38:29 +00:00
|
|
|
}
|
|
|
|
|
2010-07-14 05:06:42 +00:00
|
|
|
void EditorWindow::closeProject()
|
|
|
|
{
|
|
|
|
if(project)
|
|
|
|
{
|
|
|
|
project->deleteLater();
|
|
|
|
project = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
for(int i = 0; i < ui->editorTabs->count(); i++)
|
|
|
|
{
|
|
|
|
TabContent* doc = dynamic_cast<TabContent*>
|
|
|
|
(ui->editorTabs->widget(i));
|
|
|
|
if(doc->type() == TabContent::Skin)
|
|
|
|
{
|
|
|
|
dynamic_cast<SkinDocument*>(doc)->setProject(project);
|
|
|
|
if(i == ui->editorTabs->currentIndex())
|
|
|
|
{
|
2010-08-05 00:43:33 +00:00
|
|
|
viewer->connectSkin(dynamic_cast<SkinDocument*>(doc));
|
2010-07-14 05:06:42 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
ui->actionClose_Project->setEnabled(false);
|
2010-07-23 21:15:15 +00:00
|
|
|
ui->actionExport_Project->setEnabled(false);
|
2010-07-14 05:06:42 +00:00
|
|
|
}
|
|
|
|
|
2010-06-05 19:47:49 +00:00
|
|
|
void EditorWindow::saveCurrent()
|
|
|
|
{
|
|
|
|
if(ui->editorTabs->currentIndex() >= 0)
|
2010-06-15 06:54:58 +00:00
|
|
|
dynamic_cast<TabContent*>(ui->editorTabs->currentWidget())->save();
|
2010-06-05 19:47:49 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void EditorWindow::saveCurrentAs()
|
|
|
|
{
|
|
|
|
if(ui->editorTabs->currentIndex() >= 0)
|
2010-06-15 06:54:58 +00:00
|
|
|
dynamic_cast<TabContent*>(ui->editorTabs->currentWidget())->saveAs();
|
2010-06-05 19:47:49 +00:00
|
|
|
}
|
|
|
|
|
2010-07-23 21:15:15 +00:00
|
|
|
void EditorWindow::exportProject()
|
|
|
|
{
|
|
|
|
QDir dir = project->getSetting("themebase", "");
|
|
|
|
dir.cdUp();
|
|
|
|
QString file = project->getSetting("configfile", "").split("/").
|
|
|
|
last().split(".").first() + ".zip";
|
|
|
|
file = dir.filePath(file);
|
|
|
|
|
|
|
|
file = QFileDialog::getSaveFileName(this, tr("Export Project"),
|
|
|
|
file, "Zip Files (*.zip *.ZIP);;"
|
|
|
|
"All Files (*)");
|
|
|
|
|
|
|
|
if(file != "")
|
|
|
|
{
|
|
|
|
ProjectExporter* exporter = new ProjectExporter(file, project, this);
|
|
|
|
exporter->show();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-06-06 03:35:40 +00:00
|
|
|
void EditorWindow::openFile()
|
|
|
|
{
|
|
|
|
QStringList fileNames;
|
|
|
|
QSettings settings;
|
|
|
|
|
|
|
|
settings.beginGroup("SkinDocument");
|
|
|
|
QString directory = settings.value("defaultDirectory", "").toString();
|
|
|
|
fileNames = QFileDialog::getOpenFileNames(this, tr("Open Files"), directory,
|
|
|
|
SkinDocument::fileFilter());
|
2010-06-07 01:08:25 +00:00
|
|
|
|
|
|
|
for(int i = 0; i < fileNames.count(); i++)
|
|
|
|
{
|
|
|
|
if(!QFile::exists(fileNames[i]))
|
|
|
|
continue;
|
|
|
|
|
|
|
|
QString current = fileNames[i];
|
|
|
|
|
2010-06-15 06:54:58 +00:00
|
|
|
loadTabFromSkinFile(current);
|
2010-06-07 01:08:25 +00:00
|
|
|
|
|
|
|
/* And setting the new default directory */
|
|
|
|
current.chop(current.length() - current.lastIndexOf('/') - 1);
|
|
|
|
settings.setValue("defaultDirectory", current);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
settings.endGroup();
|
2010-06-06 03:35:40 +00:00
|
|
|
}
|
|
|
|
|
2010-06-09 07:51:22 +00:00
|
|
|
void EditorWindow::openProject()
|
|
|
|
{
|
|
|
|
QString fileName;
|
|
|
|
QSettings settings;
|
|
|
|
|
|
|
|
settings.beginGroup("ProjectModel");
|
|
|
|
QString directory = settings.value("defaultDirectory", "").toString();
|
|
|
|
fileName = QFileDialog::getOpenFileName(this, tr("Open Project"), directory,
|
|
|
|
ProjectModel::fileFilter());
|
|
|
|
|
|
|
|
settings.endGroup();
|
2010-07-15 21:39:09 +00:00
|
|
|
loadProjectFile(fileName);
|
2010-06-09 07:51:22 +00:00
|
|
|
|
|
|
|
}
|
2010-06-05 19:47:49 +00:00
|
|
|
|
2010-07-25 21:16:37 +00:00
|
|
|
void EditorWindow::openRecentFile()
|
|
|
|
{
|
|
|
|
loadTabFromSkinFile(dynamic_cast<QAction*>(QObject::sender())->text());
|
|
|
|
}
|
|
|
|
|
|
|
|
void EditorWindow::openRecentProject()
|
|
|
|
{
|
|
|
|
loadProjectFile(dynamic_cast<QAction*>(QObject::sender())->text());
|
|
|
|
}
|
|
|
|
|
2010-06-15 20:55:56 +00:00
|
|
|
void EditorWindow::configFileChanged(QString configFile)
|
|
|
|
{
|
|
|
|
|
|
|
|
if(QFile::exists(configFile))
|
|
|
|
{
|
|
|
|
|
|
|
|
if(project)
|
|
|
|
delete project;
|
|
|
|
|
|
|
|
project = new ProjectModel(configFile, this);
|
|
|
|
ui->projectTree->setModel(project);
|
|
|
|
|
|
|
|
QObject::connect(ui->projectTree, SIGNAL(activated(QModelIndex)),
|
|
|
|
project, SLOT(activated(QModelIndex)));
|
|
|
|
|
2010-06-17 06:59:46 +00:00
|
|
|
for(int i = 0; i < ui->editorTabs->count(); i++)
|
|
|
|
{
|
|
|
|
TabContent* doc = dynamic_cast<TabContent*>
|
|
|
|
(ui->editorTabs->widget(i));
|
|
|
|
if(doc->type() == TabContent::Skin)
|
|
|
|
{
|
|
|
|
dynamic_cast<SkinDocument*>(doc)->setProject(project);
|
|
|
|
if(i == ui->editorTabs->currentIndex())
|
|
|
|
{
|
2010-08-05 00:43:33 +00:00
|
|
|
viewer->connectSkin(dynamic_cast<SkinDocument*>(doc));
|
2010-06-17 06:59:46 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2010-06-15 20:55:56 +00:00
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2010-06-05 08:22:30 +00:00
|
|
|
void EditorWindow::tabTitleChanged(QString title)
|
|
|
|
{
|
2010-06-15 06:54:58 +00:00
|
|
|
TabContent* sender = dynamic_cast<TabContent*>(QObject::sender());
|
2010-06-05 08:22:30 +00:00
|
|
|
ui->editorTabs->setTabText(ui->editorTabs->indexOf(sender), title);
|
|
|
|
}
|
|
|
|
|
2010-06-04 06:59:25 +00:00
|
|
|
void EditorWindow::showPanel()
|
|
|
|
{
|
|
|
|
if(sender() == ui->actionFile_Panel)
|
2010-06-08 21:30:28 +00:00
|
|
|
ui->projectDock->setVisible(true);
|
2010-06-04 06:59:25 +00:00
|
|
|
if(sender() == ui->actionPreview_Panel)
|
|
|
|
ui->skinPreviewDock->setVisible(true);
|
|
|
|
if(sender() == ui->actionDisplay_Panel)
|
|
|
|
ui->parseTreeDock->setVisible(true);
|
|
|
|
}
|
|
|
|
|
|
|
|
void EditorWindow::closeEvent(QCloseEvent* event)
|
2010-06-01 21:25:02 +00:00
|
|
|
{
|
2010-06-05 19:47:49 +00:00
|
|
|
|
2010-06-05 07:14:03 +00:00
|
|
|
saveSettings();
|
2010-06-05 19:47:49 +00:00
|
|
|
|
|
|
|
/* Closing all the tabs */
|
|
|
|
for(int i = 0; i < ui->editorTabs->count(); i++)
|
|
|
|
{
|
2010-06-15 20:55:56 +00:00
|
|
|
if(!dynamic_cast<TabContent*>
|
2010-06-05 19:47:49 +00:00
|
|
|
(ui->editorTabs->widget(i))->requestClose())
|
|
|
|
{
|
|
|
|
event->ignore();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-06-04 06:59:25 +00:00
|
|
|
event->accept();
|
2010-06-01 21:25:02 +00:00
|
|
|
}
|
|
|
|
|
2010-06-06 02:11:04 +00:00
|
|
|
void EditorWindow::updateCurrent()
|
|
|
|
{
|
|
|
|
if(ui->editorTabs->currentIndex() < 0)
|
|
|
|
return;
|
|
|
|
|
|
|
|
dynamic_cast<SkinDocument*>
|
|
|
|
(ui->editorTabs->currentWidget())->genCode();
|
|
|
|
}
|
|
|
|
|
2010-06-15 06:54:58 +00:00
|
|
|
void EditorWindow::lineChanged(int line)
|
|
|
|
{
|
2010-07-07 20:56:16 +00:00
|
|
|
QSettings settings;
|
|
|
|
settings.beginGroup("EditorWindow");
|
|
|
|
|
|
|
|
if(settings.value("autoExpandTree", false).toBool())
|
|
|
|
{
|
2010-06-29 06:14:36 +00:00
|
|
|
ui->parseTree->collapseAll();
|
|
|
|
ParseTreeModel* model = dynamic_cast<ParseTreeModel*>
|
|
|
|
(ui->parseTree->model());
|
|
|
|
parseTreeSelection = new QItemSelectionModel(model);
|
2010-07-07 20:56:16 +00:00
|
|
|
expandLine(model, QModelIndex(), line,
|
|
|
|
settings.value("autoHighlightTree", false).toBool());
|
2010-06-29 06:14:36 +00:00
|
|
|
sizeColumns();
|
|
|
|
ui->parseTree->setSelectionModel(parseTreeSelection);
|
2010-07-07 20:56:16 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
settings.endGroup();
|
2010-06-15 06:54:58 +00:00
|
|
|
}
|
|
|
|
|
2010-06-26 07:59:23 +00:00
|
|
|
void EditorWindow::undo()
|
|
|
|
{
|
|
|
|
TabContent* doc = dynamic_cast<TabContent*>
|
|
|
|
(ui->editorTabs->currentWidget());
|
|
|
|
if(doc->type() == TabContent::Skin)
|
|
|
|
dynamic_cast<SkinDocument*>(doc)->getEditor()->undo();
|
|
|
|
}
|
|
|
|
|
|
|
|
void EditorWindow::redo()
|
|
|
|
{
|
|
|
|
TabContent* doc = dynamic_cast<TabContent*>
|
|
|
|
(ui->editorTabs->currentWidget());
|
|
|
|
if(doc->type() == TabContent::Skin)
|
|
|
|
dynamic_cast<SkinDocument*>(doc)->getEditor()->redo();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
void EditorWindow::cut()
|
|
|
|
{
|
|
|
|
TabContent* doc = dynamic_cast<TabContent*>
|
|
|
|
(ui->editorTabs->currentWidget());
|
|
|
|
if(doc->type() == TabContent::Skin)
|
|
|
|
dynamic_cast<SkinDocument*>(doc)->getEditor()->cut();
|
|
|
|
}
|
|
|
|
|
|
|
|
void EditorWindow::copy()
|
|
|
|
{
|
|
|
|
TabContent* doc = dynamic_cast<TabContent*>
|
|
|
|
(ui->editorTabs->currentWidget());
|
|
|
|
if(doc->type() == TabContent::Skin)
|
|
|
|
dynamic_cast<SkinDocument*>(doc)->getEditor()->copy();
|
|
|
|
}
|
|
|
|
|
|
|
|
void EditorWindow::paste()
|
|
|
|
{
|
|
|
|
TabContent* doc = dynamic_cast<TabContent*>
|
|
|
|
(ui->editorTabs->currentWidget());
|
|
|
|
if(doc->type() == TabContent::Skin)
|
|
|
|
dynamic_cast<SkinDocument*>(doc)->getEditor()->paste();
|
|
|
|
}
|
|
|
|
|
|
|
|
void EditorWindow::findReplace()
|
|
|
|
{
|
|
|
|
TabContent* doc = dynamic_cast<TabContent*>
|
|
|
|
(ui->editorTabs->currentWidget());
|
|
|
|
if(doc->type() == TabContent::Skin)
|
|
|
|
dynamic_cast<SkinDocument*>(doc)->showFind();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2010-06-15 06:54:58 +00:00
|
|
|
void EditorWindow::expandLine(ParseTreeModel* model, QModelIndex parent,
|
2010-07-07 20:56:16 +00:00
|
|
|
int line, bool highlight)
|
2010-06-15 06:54:58 +00:00
|
|
|
{
|
|
|
|
for(int i = 0; i < model->rowCount(parent); i++)
|
|
|
|
{
|
2010-06-16 19:24:53 +00:00
|
|
|
QModelIndex dataType = model->index(i, ParseTreeModel::typeColumn,
|
|
|
|
parent);
|
|
|
|
QModelIndex dataVal = model->index(i, ParseTreeModel::valueColumn,
|
|
|
|
parent);
|
2010-06-15 06:54:58 +00:00
|
|
|
QModelIndex data = model->index(i, ParseTreeModel::lineColumn, parent);
|
|
|
|
QModelIndex recurse = model->index(i, 0, parent);
|
|
|
|
|
2010-07-07 20:56:16 +00:00
|
|
|
expandLine(model, recurse, line, highlight);
|
2010-06-15 06:54:58 +00:00
|
|
|
|
|
|
|
if(model->data(data, Qt::DisplayRole) == line)
|
|
|
|
{
|
|
|
|
ui->parseTree->expand(parent);
|
|
|
|
ui->parseTree->expand(data);
|
|
|
|
ui->parseTree->scrollTo(parent, QAbstractItemView::PositionAtTop);
|
2010-06-16 19:24:53 +00:00
|
|
|
|
2010-07-07 20:56:16 +00:00
|
|
|
if(highlight)
|
|
|
|
{
|
|
|
|
parseTreeSelection->select(data,
|
|
|
|
QItemSelectionModel::Select);
|
|
|
|
parseTreeSelection->select(dataType,
|
|
|
|
QItemSelectionModel::Select);
|
|
|
|
parseTreeSelection->select(dataVal,
|
|
|
|
QItemSelectionModel::Select);
|
|
|
|
}
|
2010-06-15 06:54:58 +00:00
|
|
|
}
|
|
|
|
}
|
2010-07-07 20:56:16 +00:00
|
|
|
|
2010-06-15 06:54:58 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void EditorWindow::sizeColumns()
|
|
|
|
{
|
|
|
|
/* Setting the column widths */
|
|
|
|
ui->parseTree->resizeColumnToContents(ParseTreeModel::lineColumn);
|
|
|
|
ui->parseTree->resizeColumnToContents(ParseTreeModel::typeColumn);
|
|
|
|
ui->parseTree->resizeColumnToContents(ParseTreeModel::valueColumn);
|
|
|
|
}
|
2010-07-15 21:39:09 +00:00
|
|
|
|
|
|
|
void EditorWindow::loadProjectFile(QString fileName)
|
|
|
|
{
|
|
|
|
QSettings settings;
|
|
|
|
settings.beginGroup("ProjectModel");
|
|
|
|
|
|
|
|
if(QFile::exists(fileName))
|
|
|
|
{
|
2010-07-25 21:16:37 +00:00
|
|
|
projectToTop(fileName);
|
|
|
|
|
2010-07-15 21:39:09 +00:00
|
|
|
if(project)
|
|
|
|
project->deleteLater();
|
|
|
|
|
|
|
|
ui->actionClose_Project->setEnabled(true);
|
2010-07-23 21:15:15 +00:00
|
|
|
ui->actionExport_Project->setEnabled(true);
|
2010-07-15 21:39:09 +00:00
|
|
|
|
|
|
|
project = new ProjectModel(fileName, this);
|
|
|
|
ui->projectTree->setModel(project);
|
|
|
|
|
2010-07-18 00:39:40 +00:00
|
|
|
/* Setting target info if necessary */
|
|
|
|
TargetData targets;
|
|
|
|
QString target = project->getSetting("#target", "");
|
|
|
|
if(target != "" && targets.index(target) >= 0)
|
|
|
|
{
|
|
|
|
int index = targets.index(target);
|
|
|
|
|
|
|
|
QRect screen = targets.screenSize(index);
|
|
|
|
deviceConfig->setData("screenwidth", screen.width());
|
|
|
|
deviceConfig->setData("screenheight", screen.height());
|
|
|
|
|
|
|
|
if(targets.remoteDepth(index) != TargetData::None)
|
|
|
|
{
|
|
|
|
QRect remote = targets.remoteSize(index);
|
|
|
|
deviceConfig->setData("remotewidth", remote.width());
|
|
|
|
deviceConfig->setData("remoteheight", remote.height());
|
|
|
|
}
|
|
|
|
|
|
|
|
deviceConfig->setData("tp", targets.fm(index));
|
|
|
|
deviceConfig->setData("Rp", targets.canRecord(index));
|
|
|
|
}
|
|
|
|
|
2010-07-15 21:39:09 +00:00
|
|
|
if(project->getSetting("#screenwidth") != "")
|
|
|
|
deviceConfig->setData("screenwidth",
|
|
|
|
project->getSetting("#screenwidth"));
|
|
|
|
if(project->getSetting("#screenheight") != "")
|
|
|
|
deviceConfig->setData("screenheight",
|
|
|
|
project->getSetting("#screenheight"));
|
|
|
|
|
|
|
|
QObject::connect(ui->projectTree, SIGNAL(activated(QModelIndex)),
|
|
|
|
project, SLOT(activated(QModelIndex)));
|
|
|
|
|
|
|
|
fileName.chop(fileName.length() - fileName.lastIndexOf('/') - 1);
|
|
|
|
settings.setValue("defaultDirectory", fileName);
|
|
|
|
|
|
|
|
for(int i = 0; i < ui->editorTabs->count(); i++)
|
|
|
|
{
|
|
|
|
TabContent* doc = dynamic_cast<TabContent*>
|
|
|
|
(ui->editorTabs->widget(i));
|
|
|
|
if(doc->type() == TabContent::Skin)
|
|
|
|
{
|
|
|
|
dynamic_cast<SkinDocument*>(doc)->setProject(project);
|
|
|
|
if(i == ui->editorTabs->currentIndex())
|
|
|
|
{
|
2010-08-05 00:43:33 +00:00
|
|
|
viewer->connectSkin(dynamic_cast<SkinDocument*>(doc));
|
2010-07-15 21:39:09 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
settings.endGroup();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
void EditorWindow::createFile(QString filename, QString contents)
|
|
|
|
{
|
|
|
|
QFile fout(filename);
|
|
|
|
fout.open(QFile::WriteOnly);
|
|
|
|
|
2020-09-03 16:33:12 +00:00
|
|
|
fout.write(contents.toLatin1());
|
2010-07-15 21:39:09 +00:00
|
|
|
|
|
|
|
fout.close();
|
|
|
|
}
|
2010-07-25 21:16:37 +00:00
|
|
|
|
|
|
|
void EditorWindow::docToTop(QString file)
|
|
|
|
{
|
|
|
|
if(!QFile::exists(file))
|
|
|
|
return;
|
|
|
|
|
|
|
|
int index = recentDocs.indexOf(file);
|
|
|
|
if(index == -1)
|
|
|
|
{
|
|
|
|
/* Bumping off the last file */
|
|
|
|
if(recentDocs.count() >= numRecent)
|
|
|
|
recentDocs.removeLast();
|
|
|
|
recentDocs.prepend(file);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
/* Shuffling file to the top of the list */
|
|
|
|
recentDocs.removeAt(index);
|
|
|
|
recentDocs.prepend(file);
|
|
|
|
}
|
|
|
|
|
|
|
|
refreshRecentMenus();
|
|
|
|
}
|
|
|
|
|
|
|
|
void EditorWindow::projectToTop(QString file)
|
|
|
|
{
|
|
|
|
if(!QFile::exists(file))
|
|
|
|
return;
|
|
|
|
|
|
|
|
int index = recentProjects.indexOf(file);
|
|
|
|
if(index == -1)
|
|
|
|
{
|
|
|
|
/* Bumping off the last project */
|
|
|
|
if(recentProjects.count() >= numRecent)
|
|
|
|
recentProjects.removeLast();
|
|
|
|
recentProjects.prepend(file);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
/* Shuffling file to the top of the list */
|
|
|
|
recentProjects.removeAt(index);
|
|
|
|
recentProjects.prepend(file);
|
|
|
|
}
|
|
|
|
|
|
|
|
refreshRecentMenus();
|
|
|
|
}
|
|
|
|
|
|
|
|
void EditorWindow::refreshRecentMenus()
|
|
|
|
{
|
2010-07-29 07:38:01 +00:00
|
|
|
/* Clearing any deleted documents */
|
|
|
|
for(int i = 0; i < recentDocs.count(); i++)
|
|
|
|
if(!QFile::exists(recentDocs[i]))
|
|
|
|
recentDocs.removeAt(i--);
|
|
|
|
|
|
|
|
/* Clearing any deleted projects */
|
|
|
|
for(int i = 0; i < recentProjects.count(); i++)
|
|
|
|
if(!QFile::exists(recentProjects[i]))
|
|
|
|
recentProjects.removeAt(i--);
|
|
|
|
|
2010-07-25 21:16:37 +00:00
|
|
|
/* First hiding all the menu items */
|
|
|
|
for(int i = 0; i < recentDocsMenu.count(); i++)
|
|
|
|
recentDocsMenu[i]->setVisible(false);
|
|
|
|
for(int i = 0; i < recentProjectsMenu.count(); i++)
|
|
|
|
recentProjectsMenu[i]->setVisible(false);
|
|
|
|
|
|
|
|
/* Then setting the text of and showing any available */
|
|
|
|
for(int i = 0; i < recentDocs.count(); i++)
|
|
|
|
{
|
|
|
|
recentDocsMenu[i]->setText(recentDocs[i]);
|
|
|
|
recentDocsMenu[i]->setVisible(true);
|
|
|
|
}
|
|
|
|
|
|
|
|
for(int i = 0; i < recentProjects.count(); i++)
|
|
|
|
{
|
|
|
|
recentProjectsMenu[i]->setText(recentProjects[i]);
|
|
|
|
recentProjectsMenu[i]->setVisible(true);
|
|
|
|
}
|
|
|
|
}
|