Commit 3fe213a5 authored by Jan Möbius's avatar Jan Möbius

Icons for view modes

git-svn-id: http://www.openflipper.org/svnrepo/OpenFlipper/branches/Free@7278 383ad7c9-94d9-4d36-a494-682f7c89f535
parent 1393890a
......@@ -102,6 +102,8 @@ class ViewModeInterface {
/** \brief Defines an Icon for a ViewMode
*
* With this function you can define an Icon associated with this view mode
* The Icon will be taken from the standard Icon path or in the OpenFlipper
* home directory.
*
* @param _mode name of the ViewMode
* @param _iconName Name of the Icon used for this view mode
......
......@@ -137,6 +137,7 @@ Core() :
// Add ViewMode All
ViewMode* vm = new ViewMode();
vm->name = "All";
vm->icon = "Unknown.png";
vm->custom = false;
vm->visibleToolboxes = QStringList();
......
......@@ -412,8 +412,11 @@ public:
/// Completly configure a view mode ( set toolbars, toolboxes ... )
void slotAddViewModeComplete(QString _mode , bool _custom, QStringList _toolboxes, QStringList _toolbars);
/// Sets the Icon for a given View Mode
/// Sets the Icon for a given View Mode (non-userdefined viewMode)
void slotSetViewModeIcon(QString _mode, QString _iconName);
/// Sets the Icon for a given View Mode (_custom == userdefined viewMode)
void slotSetViewModeIcon(QString _mode, bool _custom, QString _iconName);
/// Slot for Changing visible toolWidgets
void slotChangeView(QString _mode, QStringList _toolboxWidgets, QStringList _toolbars);
......
......@@ -103,9 +103,10 @@ void CoreWidget::slotAddViewModeToolboxes(QString _mode, bool _custom, QStringLi
ViewMode* vm = 0;
if ( id == -1 ) {
vm = new ViewMode();
vm->name = _mode;
vm = new ViewMode();
vm->name = _mode;
vm->custom = _custom;
vm->icon = "Unknown.png";
if (_custom) {
viewModes_.push_back(vm);
......@@ -145,9 +146,10 @@ void CoreWidget::slotAddViewModeToolbars(QString _mode, bool _custom, QStringLis
ViewMode* vm = 0;
if ( id == -1 ) {
vm = new ViewMode();
vm->name = _mode;
vm = new ViewMode();
vm->name = _mode;
vm->custom = _custom;
vm->icon = "Unknown.png";
if (_custom) {
viewModes_.push_back(vm);
......@@ -172,7 +174,48 @@ void CoreWidget::slotAddViewModeToolbars(QString _mode, bool _custom, QStringLis
/// Sets the Icon for a given View Mode
void CoreWidget::slotSetViewModeIcon(QString _mode, QString _iconName) {
std::cerr << "Todo: Implement slotSetViewModeIcon" << std::endl;
slotSetViewModeIcon(_mode,false,_iconName);
}
/// Sets the Icon for a given View Mode
void CoreWidget::slotSetViewModeIcon(QString _mode, bool _custom, QString _iconName) {
int id = -1;
// Check if it already exists
for ( int i = 0 ; i < viewModes_.size(); i++) {
if ( viewModes_[i]->name == _mode ) {
id = i;
break;
}
}
ViewMode* vm = 0;
if ( id == -1 ) {
vm = new ViewMode();
vm->name = _mode;
vm->custom = _custom;
vm->icon = _iconName;
if (_custom) {
viewModes_.push_back(vm);
} else {
//insert before custom viewModes
int i = viewModes_.size();
for (int k=0; k < viewModes_.size(); k++)
if (viewModes_[k]->custom == true){
i = k;
break;
}
viewModes_.insert(i,vm);
}
} else {
vm = viewModes_[id];
}
vm->icon = _iconName;
initViewModes();
}
/// Remove a viewMode
......
......@@ -6,8 +6,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>703</width>
<height>724</height>
<width>755</width>
<height>816</height>
</rect>
</property>
<property name="windowTitle">
......@@ -16,10 +16,28 @@
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="QGroupBox" name="groupBox_2">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>1</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>0</width>
<height>270</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>16777215</width>
<height>200</height>
<height>16777215</height>
</size>
</property>
<property name="baseSize">
<size>
<width>0</width>
<height>0</height>
</size>
</property>
<property name="title">
......@@ -34,6 +52,15 @@
<height>0</height>
</size>
</property>
<property name="alternatingRowColors">
<bool>false</bool>
</property>
<property name="iconSize">
<size>
<width>125</width>
<height>125</height>
</size>
</property>
<property name="flow">
<enum>QListView::LeftToRight</enum>
</property>
......@@ -78,6 +105,12 @@
</item>
<item>
<widget class="QTabWidget" name="tabWidget">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
<horstretch>0</horstretch>
<verstretch>2</verstretch>
</sizepolicy>
</property>
<property name="currentIndex">
<number>0</number>
</property>
......
......@@ -519,7 +519,8 @@ void viewModeWidget::show(QString _lastMode){
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->setIcon(QIcon(OpenFlipper::Options::iconDirStr() + QDir::separator () + modes_[i]->icon));
item->setText(modes_[i]->name);
if (modes_[i]->custom)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment