Commit 82fa72ef authored by Jan Möbius's avatar Jan Möbius

ViewMode Interface Skeleton for toolbars .. still a lot todo

git-svn-id: http://www.openflipper.org/svnrepo/OpenFlipper/branches/Free@7235 383ad7c9-94d9-4d36-a494-682f7c89f535
parent 7bdfaed6
......@@ -1239,9 +1239,13 @@ void Core::setDescriptions(){
QString(tr("Toolbox Entry name,Widget")).split(","),
QString(tr("Name of the new widget in the toolbox,Pointer to the new widget")).split(","));
emit setSlotDescription("addViewMode(QString,QString)", tr("Add a new viewmode"),
emit setSlotDescription("addViewModeToolboxes(QString,QString)", tr("Set toolboxes for a viewmode"),
QString(tr("Name,Toolbox List")).split(","),
QString(tr("Name of the new Viewmode, ; seperated list of toolboxes visible in this viewmode")).split(","));
QString(tr("Name of the Viewmode, ; seperated list of toolboxes visible in this viewmode")).split(","));
emit setSlotDescription("addViewModeToolbars(QString,QString)", tr("Set toolbars for a viewmode"),
QString(tr("Name,Toolbar List")).split(","),
QString(tr("Name of the Viewmode, ; seperated list of toolbars visible in this viewmode")).split(","));
emit setSlotDescription("objectList(QString,QStringList)", tr("Returns object list"),
QString(tr("Selection type,Object types")).split(","),
......
......@@ -402,12 +402,19 @@ public slots:
//===========================================================================
public slots:
/** \brief Scripting function to add a nev viewMode
/** \brief Scripting function to set toolboxes in a view mode
@param _modeName Name of the new View Mode
@param _modeName Name of the View Mode
@param _toolboxList ; seperated list of toolboxes in the view mode
*/
void addViewMode(QString _modeName, QString _toolboxList);
void addViewModeToolboxes(QString _modeName, QString _toolboxList);
/** \brief Scripting function to set toolbars in a view mode
@param _modeName Name of the View Mode
@param _toolboxList ; seperated list of toolbars in the view mode
*/
void addViewModeToolbars(QString _modeName, QString _toolbarList);
/** @} */
......
......@@ -77,6 +77,8 @@ void Core::readApplicationOptions(INIFile& _ini) {
// Parse standard options
if ( _ini.section_exists("Options") ) {
// TODO: Load View Mode Toolbars and Context Menu Items
// load ViewModes
int viewModeCount;
if (_ini.get_entry(viewModeCount,"Options","ViewModeCount") )
......@@ -483,6 +485,7 @@ void Core::writeApplicationOptions(INIFile& _ini) {
_ini.add_entry( "Options" , key , type );
}
// TODO: Save View Mode Toolbars and Context Menu Items
// save ViewModes
QVector< QString > entries;
if ( OpenFlipper::Options::gui() )
......
......@@ -130,7 +130,7 @@ void Core::setViewMode(QString _viewMode){
//-----------------------------------------------------------------------------
void Core::addViewMode(QString _modeName, QString _toolboxList) {
void Core::addViewModeToolboxes(QString _modeName, QString _toolboxList) {
QStringList list = _toolboxList.split(";");
coreWidget_->slotAddViewModeToolboxes(_modeName,list);
......@@ -138,6 +138,14 @@ void Core::addViewMode(QString _modeName, QString _toolboxList) {
//-----------------------------------------------------------------------------
void Core::addViewModeToolbars(QString _modeName, QString _toolbarList) {
QStringList list = _toolbarList.split(";");
coreWidget_->slotAddViewModeToolbars(_modeName,list);
}
//-----------------------------------------------------------------------------
void Core::addToolbox(QString _name ,QWidget* _widget) {
int id = -1;
......
<ui version="4.0" >
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>viewMode</class>
<widget class="QDialog" name="viewMode" >
<property name="geometry" >
<widget class="QDialog" name="viewMode">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>782</width>
<height>743</height>
<width>777</width>
<height>600</height>
</rect>
</property>
<property name="windowTitle" >
<property name="windowTitle">
<string>Change View Mode</string>
</property>
<layout class="QGridLayout" >
<item row="0" column="0" >
<widget class="QGroupBox" name="groupBox" >
<property name="title" >
<string> View Modes </string>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="QGroupBox" name="groupBox_2">
<property name="maximumSize">
<size>
<width>16777215</width>
<height>200</height>
</size>
</property>
<layout class="QGridLayout" >
<item row="0" column="0" >
<widget class="QListWidget" name="modeList" >
<property name="selectionMode" >
<enum>QAbstractItemView::SingleSelection</enum>
<property name="title">
<string>View Modes</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout_2">
<item>
<widget class="QListWidget" name="viewModeList">
<property name="baseSize">
<size>
<width>0</width>
<height>0</height>
</size>
</property>
<property name="flow">
<enum>QListView::LeftToRight</enum>
</property>
<property name="spacing">
<number>15</number>
</property>
<property name="viewMode">
<enum>QListView::IconMode</enum>
</property>
<property name="wordWrap">
<bool>false</bool>
</property>
</widget>
</item>
<item row="1" column="0" >
<widget class="QPushButton" name="removeButton" >
<property name="text" >
<item>
<widget class="QPushButton" name="removeButton">
<property name="text">
<string>Remove Mode</string>
</property>
</widget>
......@@ -36,130 +58,153 @@
</layout>
</widget>
</item>
<item row="0" column="1" >
<widget class="QGroupBox" name="toolGroup" >
<property name="title" >
<string>Tool Widgets</string>
<item>
<widget class="QTabWidget" name="tabWidget">
<property name="currentIndex">
<number>0</number>
</property>
<layout class="QHBoxLayout" >
<item>
<layout class="QGridLayout" >
<item row="0" column="0" >
<widget class="QListWidget" name="toolList" >
<property name="showDropIndicator" stdset="0" >
<bool>false</bool>
</property>
<property name="dragDropOverwriteMode" >
<bool>false</bool>
</property>
<property name="dragDropMode" >
<enum>QAbstractItemView::NoDragDrop</enum>
</property>
<property name="selectionMode" >
<enum>QAbstractItemView::ExtendedSelection</enum>
</property>
<property name="movement" >
<enum>QListView::Static</enum>
</property>
<property name="sortingEnabled" >
<bool>false</bool>
</property>
</widget>
</item>
<item row="0" column="1" >
<layout class="QVBoxLayout" >
<item>
<spacer>
<property name="orientation" >
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" >
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QToolButton" name="upButton" >
<property name="text" >
<string/>
</property>
</widget>
</item>
<item>
<widget class="QToolButton" name="removeWidgetButton" >
<property name="text" >
<string/>
</property>
</widget>
</item>
<item>
<widget class="QToolButton" name="downButton" >
<property name="text" >
<string/>
</property>
</widget>
</item>
<item>
<spacer>
<property name="orientation" >
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" >
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
</layout>
</item>
<item row="1" column="0" >
<widget class="QPushButton" name="saveButton" >
<property name="text" >
<string>Save Configuration</string>
</property>
</widget>
</item>
</layout>
</item>
</layout>
<widget class="QWidget" name="tab">
<attribute name="title">
<string>Toolboxes</string>
</attribute>
<layout class="QGridLayout" name="gridLayout">
<item row="1" column="0" colspan="2">
<layout class="QHBoxLayout" name="_10">
<item>
<widget class="QPushButton" name="cancelButton">
<property name="text">
<string>&amp;Cancel</string>
</property>
</widget>
</item>
<item>
<spacer>
<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>
<widget class="QPushButton" name="okButton">
<property name="text">
<string>&amp;Ok</string>
</property>
</widget>
</item>
</layout>
</item>
<item row="0" column="0">
<layout class="QGridLayout" name="_7">
<item row="0" column="0">
<widget class="QListWidget" name="toolboxList">
<property name="showDropIndicator" stdset="0">
<bool>false</bool>
</property>
<property name="dragDropOverwriteMode">
<bool>false</bool>
</property>
<property name="dragDropMode">
<enum>QAbstractItemView::NoDragDrop</enum>
</property>
<property name="selectionMode">
<enum>QAbstractItemView::ExtendedSelection</enum>
</property>
<property name="movement">
<enum>QListView::Static</enum>
</property>
<property name="sortingEnabled">
<bool>false</bool>
</property>
</widget>
</item>
<item row="0" column="1">
<layout class="QVBoxLayout" name="_8">
<item>
<spacer>
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QToolButton" name="upButton">
<property name="text">
<string/>
</property>
</widget>
</item>
<item>
<widget class="QToolButton" name="removeWidgetButton">
<property name="text">
<string/>
</property>
</widget>
</item>
<item>
<widget class="QToolButton" name="downButton">
<property name="text">
<string/>
</property>
</widget>
</item>
<item>
<spacer>
<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="0">
<widget class="QPushButton" name="saveButton">
<property name="text">
<string>Save Configuration</string>
</property>
</widget>
</item>
</layout>
</item>
<item row="0" column="1">
<widget class="QGroupBox" name="groupBox">
<property name="minimumSize">
<size>
<width>300</width>
<height>0</height>
</size>
</property>
<property name="title">
<string>Widget</string>
</property>
</widget>
</item>
</layout>
</widget>
<widget class="QWidget" name="tab_2">
<attribute name="title">
<string>Toolbars</string>
</attribute>
</widget>
</widget>
</item>
<item row="1" column="0" colspan="2" >
<layout class="QHBoxLayout" >
<item>
<widget class="QPushButton" name="cancelButton" >
<property name="text" >
<string>&amp;Cancel</string>
</property>
</widget>
</item>
<item>
<spacer>
<property name="orientation" >
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" >
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QPushButton" name="okButton" >
<property name="text" >
<string>&amp;Ok</string>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</widget>
<resources/>
......
......@@ -59,22 +59,22 @@ viewModeWidget::viewModeWidget(const QVector< ViewMode* >& _modes, QWidget *_par
connect(modeList ,SIGNAL(customContextMenuRequested ( const QPoint & ) ),
connect(viewModeList ,SIGNAL(customContextMenuRequested ( const QPoint & ) ),
this,SLOT(slotModeContextMenu ( const QPoint & ) ));
connect(toolList ,SIGNAL(customContextMenuRequested ( const QPoint & ) ),
connect(toolboxList ,SIGNAL(customContextMenuRequested ( const QPoint & ) ),
this,SLOT(slotToolContextMenu ( const QPoint & ) ));
modeList->setContextMenuPolicy(Qt::CustomContextMenu);
toolList->setContextMenuPolicy(Qt::CustomContextMenu);
viewModeList->setContextMenuPolicy(Qt::CustomContextMenu);
toolboxList->setContextMenuPolicy(Qt::CustomContextMenu);
connect(modeList, SIGNAL(itemSelectionChanged()), this, SLOT(slotSetToolWidgets()));
connect(viewModeList, SIGNAL(itemSelectionChanged()), this, SLOT(slotSetToolWidgets()));
connect(cancelButton, SIGNAL(clicked()), this, SLOT(close()));
connect(okButton, SIGNAL(clicked()), this, SLOT(slotChangeView()));
connect(saveButton, SIGNAL(clicked()), this, SLOT(slotSaveMode()));
connect(removeButton, SIGNAL(clicked()), this, SLOT(slotRemoveMode()));
connect(modeList, SIGNAL(currentTextChanged (QString)), this, SLOT(slotModeChanged(QString)) );
connect(modeList, SIGNAL(clicked (QModelIndex)), this, SLOT(slotModeClicked(QModelIndex)) );
connect(viewModeList, SIGNAL(currentTextChanged (QString)), this, SLOT(slotModeChanged(QString)) );
connect(viewModeList, SIGNAL(clicked (QModelIndex)), this, SLOT(slotModeClicked(QModelIndex)) );
connect(upButton, SIGNAL(clicked()), this, SLOT(slotMoveUp()) );
connect(downButton, SIGNAL(clicked()), this, SLOT(slotMoveDown()) );
connect(removeWidgetButton, SIGNAL(clicked()), this, SLOT(slotRemoveWidget()) );
......@@ -87,14 +87,14 @@ viewModeWidget::viewModeWidget(const QVector< ViewMode* >& _modes, QWidget *_par
/// Move Widget up in the list
void viewModeWidget::slotMoveUp(){
if (toolList->selectedItems().count() == 1){
if (toolList->currentRow() == 0) return;
if (toolboxList->selectedItems().count() == 1){
if (toolboxList->currentRow() == 0) return;
//extract a list of all items
QString item = toolList->currentItem()->text();
int oldRow = toolList->currentRow();
QString item = toolboxList->currentItem()->text();
int oldRow = toolboxList->currentRow();
QStringList widgets;
for (int i=0; i < toolList->count(); i++)
widgets << toolList->item(i)->text();
for (int i=0; i < toolboxList->count(); i++)
widgets << toolboxList->item(i)->text();
//reorder items
QString last = widgets[0];
......@@ -105,24 +105,24 @@ void viewModeWidget::slotMoveUp(){
}
last = widgets[i];
}
// set new list as elements for the toolList
toolList->clear();
toolList->addItems(widgets);
// set new list as elements for the toolboxList
toolboxList->clear();
toolboxList->addItems(widgets);
//highlight active item
toolList->setCurrentRow(oldRow-1);
toolboxList->setCurrentRow(oldRow-1);
}
}
/// Move widget do in the list
void viewModeWidget::slotMoveDown(){
if (toolList->selectedItems().count() == 1){
if (toolList->currentRow() == toolList->count()-1) return;
if (toolboxList->selectedItems().count() == 1){
if (toolboxList->currentRow() == toolboxList->count()-1) return;
//extract a list of all items
QString item = toolList->currentItem()->text();
int oldRow = toolList->currentRow();
QString item = toolboxList->currentItem()->text();
int oldRow = toolboxList->currentRow();
QStringList widgets;
for (int i=0; i < toolList->count(); i++)
widgets << toolList->item(i)->text();
for (int i=0; i < toolboxList->count(); i++)
widgets << toolboxList->item(i)->text();
//reorder items
QString last = widgets[widgets.size()-1];
......@@ -133,17 +133,17 @@ void viewModeWidget::slotMoveDown(){
}
last = widgets[i];
}
// set new list as elements for the toolList
toolList->clear();
toolList->addItems(widgets);
// set new list as elements for the toolboxList
toolboxList->clear();
toolboxList->addItems(widgets);
//highlight active item
toolList->setCurrentRow(oldRow+1);
toolboxList->setCurrentRow(oldRow+1);
}
}
/// remove Widget form the list
void viewModeWidget::slotRemoveWidget(){
qDeleteAll(toolList->selectedItems());
qDeleteAll(toolboxList->selectedItems());
}
/// Slot for updating removeButton when new mode is selected
......@@ -154,9 +154,9 @@ void viewModeWidget::slotModeClicked(QModelIndex /*_id*/){
/// Slot for updating removeButton when new mode is selected
void viewModeWidget::slotModeChanged(QString /*_mode*/){
//check if mode is custom e.g. that it can be removed
if (modeList->selectedItems().count() > 0){
if (viewModeList->selectedItems().count() > 0){
for (int i=0; i < modes_.size(); i++)
if (modes_[i]->name == modeList->currentItem()->text()){
if (modes_[i]->name == viewModeList->currentItem()->text()){
removeButton->setEnabled(modes_[i]->custom);
break;
}
......@@ -166,7 +166,7 @@ void viewModeWidget::slotModeChanged(QString /*_mode*/){
/// opens custom context menu in Mode-List
void viewModeWidget::slotModeContextMenu ( const QPoint & _pos ){
if (modeList->itemAt(_pos)){
if (viewModeList->itemAt(_pos)){
QMenu menu(0);
......@@ -174,23 +174,23 @@ void viewModeWidget::slotModeContextMenu ( const QPoint & _pos ){
//check if mode is custom e.g. that it can be removed
for (int i=0; i < modes_.size(); i++)
if (modes_[i]->name == modeList->currentItem()->text()){
if (modes_[i]->name == viewModeList->currentItem()->text()){
menu.actions()[0]->setEnabled(modes_[i]->custom);
break;
}
menu.exec(modeList->mapToGlobal( _pos) );
menu.exec(viewModeList->mapToGlobal( _pos) );
}
}
/// opens custom context menu in tool-List
void viewModeWidget::slotToolContextMenu ( const QPoint & _pos ){
if (toolList->itemAt(_pos)){
if (toolboxList->itemAt(_pos)){
QMenu menu(0);
if (toolList->selectedItems().count() == 1){
if (toolboxList->selectedItems().count() == 1){
menu.addAction(tr("Move up"), this, SLOT ( slotMoveUp() ));
menu.addAction(tr("Move down"), this, SLOT ( slotMoveDown() ));
menu.addSeparator();
......@@ -198,45 +198,45 @@ void viewModeWidget::slotToolContextMenu ( const QPoint & _pos ){
menu.addAction(tr("Remove Widget"), this, SLOT ( slotRemoveWidget() ));
menu.exec(toolList->mapToGlobal( _pos) );
menu.exec(toolboxList->mapToGlobal( _pos) );
}
}
/// Slot for removing custom modes
void viewModeWidget::slotRemoveMode(){
emit removeMode( modeList->currentItem()->text() );
QListWidgetItem* item = modeList->takeItem( modeList->currentRow() );
emit removeMode( viewModeList->currentItem()->text() );
QListWidgetItem* item = viewModeList->takeItem( viewModeList->currentRow() );
delete item;
}
/// Slot for updating ToolWidget-List depending on the selected Mode
void viewModeWidget::slotSetToolWidgets(){
toolList->clear();
toolboxList->clear();
//iterate over all selected modes
for (int m=0; m < modeList->selectedItems().size(); m++)
for (int m=0; m < viewModeList->selectedItems().size(); m++)
// find mode in modeVector modes_
for (int i=0; i < modes_.size(); i++)
if ( modes_[i]->name == (modeList->selectedItems()[m])->text() )
toolList->addItems(modes_[i]->visibleToolboxes); //add corresponding widgets
if ( modes_[i]->name == (viewModeList->selectedItems()[m])->text() )
toolboxList->addItems(modes_[i]->visibleToolboxes); //add corresponding widgets
}
/// Slot for changing View and closing widget
void viewModeWidget::slotChangeView(){
//get widgets
QStringList widgets;
for (int i=0; i < toolList->count(); i++)
widgets << toolList->item(i)->text();
for (int i=0; i < toolboxList->count(); i++)
widgets << toolboxList->item(i)->text();
//get mode
QString mode = "";
if (modeList->selectedItems().size() > 0)
mode = modeList->selectedItems()[0]->text();
if (viewModeList->selectedItems().size() > 0)
mode = viewModeList->selectedItems()[0]->text();
emit changeView(mode,widgets);
close();
}
/// Slot for saving current List of Widgets as custom mode
void viewModeWidget::slotSaveMode(){
if (toolList->count() == 0) return;
if (toolboxList->count() == 0) return;
//ask for a name for the new viewmode
bool ok;
QString name = QInputDialog::getText(this, tr("Change View Mode"),
......@@ -256,8 +256,8 @@ void viewModeWidget::slotSaveMode(){
}
QStringList widgets;
for (int i=0; i < toolList->count(); i++)
widgets << toolList->item(i)->text();
for (int i=0; i < toolboxList->count(); i++)
widgets << toolboxList->item(i)->text();
emit saveMode(name, true, widgets);
show(name);
}
......@@ -266,22 +266,27 @@ void viewModeWidget::slotSaveMode(){
void viewModeWidget::show(QString _lastMode){
QDialog::show();
//fill modeList
modeList->clear();
//fill viewModeList
viewModeList->clear();
for (int i=0; i < modes_.size(); i++){
modeList->addItem(modes_[i]->name);
QListWidgetItem *item = new QListWidgetItem(viewModeList);
item->setTextAlignment(Qt::AlignHCenter);
item->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled);
item->setIcon(QIcon(OpenFlipper::Options::iconDirStr() + QDir::separator () + "Unknown.png"));
item->setText(modes_[i]->name);
if (modes_[i]->custom)
modeList->item(i)->setForeground( QBrush(QColor(0,0,150) ) );
viewModeList->item(i)->setForeground( QBrush(QColor(0,0,150) ) );
else
modeList->item(i)->setForeground( QBrush(QColor(0,0,0) ) );
viewModeList->item(i)->setForeground( QBrush(QColor(0,0,0) ) );
}