Changed: Started to add dialogs for server and publishing settings.

--HG--
branch : branch-mission-compiler-qt
hg/feature/gsoc2012-fabien
sfb 14 years ago
parent 884017a65d
commit ba23190a9d

@ -12,7 +12,7 @@ SET(OVQT_EXT_SYS_SRC ${CMAKE_CURRENT_SOURCE_DIR}/../../extension_system/iplugin.
SET(OVQT_PLUG_MISSION_COMPILER_HDR mission_compiler_plugin.h
mission_compiler_main_window.h)
SET(OVQT_PLUG_MISSION_COMPILER_UIS mission_compiler_main_window.ui)
SET(OVQT_PLUG_MISSION_COMPILER_UIS mission_compiler_main_window.ui server_entry_dialog.ui mission_compiler_settings_page.ui)
SET(OVQT_PLUG_MISSION_COMPILER_RCS mission_compiler.qrc)

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.2 KiB

@ -1,5 +1,11 @@
<RCC>
<qresource prefix="buttons">
<file>images/ic_nel_reset_all.png</file>
<file>images/ic_nel_add_item.png</file>
<file>images/ic_nel_delete_item.png</file>
<file>images/ic_nel_down_item.png</file>
<file>images/ic_nel_generic_settings.png</file>
<file>images/ic_nel_up_item.png</file>
<file>images/arrow-left-2.png</file>
<file>images/arrow-left-double-2.png</file>
<file>images/arrow-right-2.png</file>

@ -0,0 +1,212 @@
// Object Viewer Qt - MMORPG Framework <http://dev.ryzom.com/projects/nel/>
// Copyright (C) 2010 Winch Gate Property Limited
// Copyright (C) 2011 Dzmitry Kamiahin <dnk-88@tut.by>
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as
// published by the Free Software Foundation, either version 3 of the
// License, or (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Affero General Public License for more details.
//
// You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
// Project includes
#include "mission_compiler_settings_page.h"
#include "../core/core_constants.h"
#include "../core/icore.h"
// NeL includes
#include <nel/misc/path.h>
// Qt includes
#include <QtCore/QSettings>
#include <QtGui/QWidget>
#include <QtGui/QFileDialog>
namespace Plugin
{
QString lastDir = ".";
MissionCompilerSettingsPage::MissionCompilerSettingsPage(QObject *parent)
: IOptionsPage(parent),
m_page(0)
{
}
MissionCompilerSettingsPage::~MissionCompilerSettingsPage()
{
}
QString MissionCompilerSettingsPage::id() const
{
return QLatin1String("mission_compiler_settings");
}
QString MissionCompilerSettingsPage::trName() const
{
return tr("Mission Compiler Settings");
}
QString MissionCompilerSettingsPage::category() const
{
return QLatin1String("MissionCompilerSettings");
}
QString MissionCompilerSettingsPage::trCategory() const
{
return tr("MissionCompilerSettings");
}
QIcon MissionCompilerSettingsPage::categoryIcon() const
{
return QIcon();
}
QWidget *MissionCompilerSettingsPage::createPage(QWidget *parent)
{
m_page = new QWidget(parent);
m_ui.setupUi(m_page);
readSettings();
checkEnabledButton();
connect(m_ui.addToolButton, SIGNAL(clicked()), this, SLOT(addPath()));
connect(m_ui.removeToolButton, SIGNAL(clicked()), this, SLOT(delPath()));
connect(m_ui.upToolButton, SIGNAL(clicked()), this, SLOT(upPath()));
connect(m_ui.downToolButton, SIGNAL(clicked()), this, SLOT(downPath()));
connect(m_ui.resetToolButton, SIGNAL(clicked()), m_ui.serversTreeWidget, SLOT(clear()));
return m_page;
}
void MissionCompilerSettingsPage::apply()
{
writeSettings();
applySearchPaths();
}
void MissionCompilerSettingsPage::finish()
{
delete m_page;
m_page = 0;
}
void MissionCompilerSettingsPage::applySearchPaths()
{
QStringList paths, remapExt;
QSettings *settings = Core::ICore::instance()->settings();
settings->beginGroup(Core::Constants::DATA_PATH_SECTION);
if (m_recurse)
paths = settings->value(Core::Constants::RECURSIVE_SEARCH_PATHS).toStringList();
else
paths = settings->value(Core::Constants::SEARCH_PATHS).toStringList();
remapExt = settings->value(Core::Constants::REMAP_EXTENSIONS).toStringList();
settings->endGroup();
for (int i = 1; i < remapExt.size(); i += 2)
NLMISC::CPath::remapExtension(remapExt.at(i - 1).toStdString(), remapExt.at(i).toStdString(), true);
Q_FOREACH(QString path, paths)
{
NLMISC::CPath::addSearchPath(path.toStdString(), m_recurse, false);
}
}
void MissionCompilerSettingsPage::addPath()
{
QString newPath = QFileDialog::getExistingDirectory(m_page, "", lastDir);
if (!newPath.isEmpty())
{
QTreeWidgetItem *newItem = new QTreeWidgetItem;
newItem->setText(newPath);
newItem->setFlags(Qt::ItemIsEditable | Qt::ItemIsEnabled | Qt::ItemIsSelectable);
m_ui.serversTreeWidget->addItem(newItem);
lastDir = newPath;
}
checkEnabledButton();
}
void MissionCompilerSettingsPage::delPath()
{
QTreeWidgetItem *removeItem = m_ui.serversTreeWidget->takeItem(m_ui.serversTreeWidget->currentRow());
if (!removeItem)
delete removeItem;
checkEnabledButton();
}
void MissionCompilerSettingsPage::upPath()
{
int currentRow = m_ui.serversTreeWidget->currentRow();
if (!(currentRow == 0))
{
QListWidgetItem *item = m_ui.serversListWidget->takeItem(currentRow);
m_ui.serversListWidget->insertItem(--currentRow, item);
m_ui.serversListWidget->setCurrentRow(currentRow);
}
}
void MissionCompilerSettingsPage::downPath()
{
int currentRow = m_ui.serversListWidget->currentRow();
if (!(currentRow == m_ui.serversListWidget->count()-1))
{
QListWidgetItem *item = m_ui.serversListWidget->takeItem(currentRow);
m_ui.serversTreeWidget->insertItem(++currentRow, item);
m_ui.serversTreeWidget->setCurrentRow(currentRow);
}
}
void MissionCompilerSettingsPage::readSettings()
{
QStringList paths;
QSettings *settings = Core::ICore::instance()->settings();
settings->beginGroup(Core::Constants::DATA_PATH_SECTION);
if (m_recurse)
paths = settings->value(Core::Constants::RECURSIVE_SEARCH_PATHS).toStringList();
else
paths = settings->value(Core::Constants::SEARCH_PATHS).toStringList();
settings->endGroup();
Q_FOREACH(QString path, paths)
{
QListWidgetItem *newItem = new QListWidgetItem;
newItem->setText(path);
newItem->setFlags(Qt::ItemIsEditable | Qt::ItemIsEnabled | Qt::ItemIsSelectable);
m_ui.serversTreeWidget->addItem(newItem);
}
}
void MissionCompilerSettingsPage::writeSettings()
{
QStringList paths;
for (int i = 0; i < m_ui.serversTreeWidget->count(); ++i)
paths << m_ui.serversTreeWidget->item(i)->text();
QSettings *settings = Core::ICore::instance()->settings();
settings->beginGroup(Core::Constants::DATA_PATH_SECTION);
if (m_recurse)
settings->setValue(Core::Constants::RECURSIVE_SEARCH_PATHS, paths);
else
settings->setValue(Core::Constants::SEARCH_PATHS, paths);
settings->endGroup();
settings->sync();
}
void MissionCompilerSettingsPage::checkEnabledButton()
{
bool bEnabled = true;
if (m_ui.serversTreeWidget->count() == 0)
bEnabled = false;
m_ui.removeToolButton->setEnabled(bEnabled);
m_ui.upToolButton->setEnabled(bEnabled);
m_ui.downToolButton->setEnabled(bEnabled);
}
} /* namespace Plugin */

@ -0,0 +1,74 @@
// Object Viewer Qt - MMORPG Framework <http://dev.ryzom.com/projects/nel/>
// Copyright (C) 2010 Winch Gate Property Limited
// Copyright (C) 2011 Dzmitry Kamiahin <dnk-88@tut.by>
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as
// published by the Free Software Foundation, either version 3 of the
// License, or (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Affero General Public License for more details.
//
// You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
#ifndef MISSION_COMPILER_SETTINGS_PAGE_H
#define MISSION_COMPILER_SETTINGS_PAGE_H
#include <QtCore/QObject>
#include "../core/ioptions_page.h"
#include "ui_mission_compiler_settings_page.h"
class QWidget;
namespace Plugin
{
/**
@class MissionCompilerSettingsPage
*/
class MissionCompilerSettingsPage : public Core::IOptionsPage
{
Q_OBJECT
public:
MissionCompilerSettingsPage(QObject *parent = 0);
~MissionCompilerSettingsPage();
QString id() const;
QString trName() const;
QString category() const;
QString trCategory() const;
QIcon categoryIcon() const;
QWidget *createPage(QWidget *parent);
void apply();
void finish();
// Set of the search paths(not recursive) and the remap extensions (loading from settings file)
void applySearchPaths();
private Q_SLOTS:
void addPath();
void delPath();
void upPath();
void downPath();
private:
void readSettings();
void writeSettings();
void checkEnabledButton();
bool m_recurse;
QWidget *m_page;
Ui::MissionCompilerSettingsPage m_ui;
};
} // namespace Plugin
#endif // MISSION_COMPILER_SETTINGS_PAGE_H

@ -0,0 +1,265 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>MissionCompilerSettingsPage</class>
<widget class="QWidget" name="MissionCompilerSettingsPage">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>496</width>
<height>544</height>
</rect>
</property>
<property name="windowTitle">
<string>Form</string>
</property>
<layout class="QGridLayout" name="gridLayout">
<property name="margin">
<number>6</number>
</property>
<property name="spacing">
<number>3</number>
</property>
<item row="1" column="0" colspan="2">
<widget class="QGroupBox" name="publicationGroupBox">
<property name="title">
<string>Publication Servers</string>
</property>
<layout class="QGridLayout" name="gridLayout_2">
<item row="0" column="2">
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="QToolButton" name="removeToolButton">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="toolTip">
<string>Delete</string>
</property>
<property name="text">
<string/>
</property>
<property name="icon">
<iconset resource="mission_compiler.qrc">
<normaloff>:/buttons/images/ic_nel_delete_item.png</normaloff>:/buttons/images/ic_nel_delete_item.png</iconset>
</property>
<property name="iconSize">
<size>
<width>20</width>
<height>20</height>
</size>
</property>
<property name="autoRaise">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QToolButton" name="addToolButton">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="toolTip">
<string>Add</string>
</property>
<property name="text">
<string/>
</property>
<property name="icon">
<iconset resource="mission_compiler.qrc">
<normaloff>:/buttons/images/ic_nel_add_item.png</normaloff>:/buttons/images/ic_nel_add_item.png</iconset>
</property>
<property name="iconSize">
<size>
<width>20</width>
<height>20</height>
</size>
</property>
<property name="autoRaise">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QToolButton" name="upToolButton">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="toolTip">
<string>Up</string>
</property>
<property name="text">
<string/>
</property>
<property name="icon">
<iconset resource="mission_compiler.qrc">
<normaloff>:/buttons/images/ic_nel_up_item.png</normaloff>:/buttons/images/ic_nel_up_item.png</iconset>
</property>
<property name="iconSize">
<size>
<width>20</width>
<height>20</height>
</size>
</property>
<property name="autoRaise">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QToolButton" name="downToolButton">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="toolTip">
<string>Down</string>
</property>
<property name="text">
<string/>
</property>
<property name="icon">
<iconset resource="mission_compiler.qrc">
<normaloff>:/buttons/images/ic_nel_down_item.png</normaloff>:/buttons/images/ic_nel_down_item.png</iconset>
</property>
<property name="iconSize">
<size>
<width>20</width>
<height>20</height>
</size>
</property>
<property name="autoRaise">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QToolButton" name="resetToolButton">
<property name="toolTip">
<string>Reset</string>
</property>
<property name="text">
<string/>
</property>
<property name="icon">
<iconset resource="mission_compiler.qrc">
<normaloff>:/buttons/images/ic_nel_reset_all.png</normaloff>:/buttons/images/ic_nel_reset_all.png</iconset>
</property>
<property name="iconSize">
<size>
<width>20</width>
<height>20</height>
</size>
</property>
<property name="autoRaise">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
</layout>
</item>
<item row="1" column="1">
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item row="0" column="0" colspan="2">
<widget class="QTableWidget" name="serversTableWidget">
<property name="alternatingRowColors">
<bool>true</bool>
</property>
<attribute name="horizontalHeaderDefaultSectionSize">
<number>100</number>
</attribute>
<attribute name="horizontalHeaderStretchLastSection">
<bool>true</bool>
</attribute>
<column>
<property name="text">
<string>Server Name</string>
</property>
</column>
<column>
<property name="text">
<string>Server Text Path</string>
</property>
</column>
<column>
<property name="text">
<string>Server Primitive Path</string>
</property>
</column>
</widget>
</item>
</layout>
</widget>
</item>
<item row="0" column="0" colspan="2">
<widget class="QGroupBox" name="generalGroupBox">
<property name="title">
<string>General Settings</string>
</property>
<layout class="QGridLayout" name="gridLayout_3">
<item row="0" column="0">
<widget class="QLabel" name="localPathLabel">
<property name="text">
<string>Local Text Path</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QLineEdit" name="localPathEdit">
<property name="toolTip">
<string>Local path for compiled mission texts.</string>
</property>
</widget>
</item>
<item row="0" column="2">
<widget class="QToolButton" name="localPathButton">
<property name="text">
<string>...</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
</layout>
</widget>
<resources>
<include location="mission_compiler.qrc"/>
</resources>
<connections/>
</ui>

@ -0,0 +1,108 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>ServerEntryDialog</class>
<widget class="QDialog" name="ServerEntryDialog">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>400</width>
<height>300</height>
</rect>
</property>
<property name="windowTitle">
<string>Dialog</string>
</property>
<layout class="QGridLayout" name="gridLayout">
<item row="4" column="0">
<widget class="QDialogButtonBox" name="buttonBox">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="standardButtons">
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="serverNameLabel">
<property name="text">
<string>Server Name</string>
</property>
</widget>
</item>
<item row="2" column="0">
<widget class="QLabel" name="serverTextPathLabel">
<property name="text">
<string>Server Text Path</string>
</property>
</widget>
</item>
<item row="3" column="0">
<widget class="QLabel" name="serverPrimPathLabel">
<property name="text">
<string>Server Primitive Path</string>
</property>
</widget>
</item>
<item row="1" column="1" colspan="2">
<widget class="QLineEdit" name="serverNameEdit"/>
</item>
<item row="2" column="1">
<widget class="QLineEdit" name="serverTextPathEdit"/>
</item>
<item row="3" column="1">
<widget class="QLineEdit" name="serverPrimPathEdit"/>
</item>
<item row="2" column="2">
<widget class="QToolButton" name="serverTextPathButton">
<property name="text">
<string>...</string>
</property>
</widget>
</item>
<item row="3" column="2">
<widget class="QToolButton" name="serverPrimPathButton">
<property name="text">
<string>...</string>
</property>
</widget>
</item>
</layout>
</widget>
<resources/>
<connections>
<connection>
<sender>buttonBox</sender>
<signal>accepted()</signal>
<receiver>ServerEntryDialog</receiver>
<slot>accept()</slot>
<hints>
<hint type="sourcelabel">
<x>248</x>
<y>254</y>
</hint>
<hint type="destinationlabel">
<x>157</x>
<y>274</y>
</hint>
</hints>
</connection>
<connection>
<sender>buttonBox</sender>
<signal>rejected()</signal>
<receiver>ServerEntryDialog</receiver>
<slot>reject()</slot>
<hints>
<hint type="sourcelabel">
<x>316</x>
<y>260</y>
</hint>
<hint type="destinationlabel">
<x>286</x>
<y>274</y>
</hint>
</hints>
</connection>
</connections>
</ui>
Loading…
Cancel
Save