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 { ...@@ -102,6 +102,8 @@ class ViewModeInterface {
/** \brief Defines an Icon for a ViewMode /** \brief Defines an Icon for a ViewMode
* *
* With this function you can define an Icon associated with this view mode * 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 _mode name of the ViewMode
* @param _iconName Name of the Icon used for this view mode * @param _iconName Name of the Icon used for this view mode
......
...@@ -137,6 +137,7 @@ Core() : ...@@ -137,6 +137,7 @@ Core() :
// Add ViewMode All // Add ViewMode All
ViewMode* vm = new ViewMode(); ViewMode* vm = new ViewMode();
vm->name = "All"; vm->name = "All";
vm->icon = "Unknown.png";
vm->custom = false; vm->custom = false;
vm->visibleToolboxes = QStringList(); vm->visibleToolboxes = QStringList();
......
...@@ -412,8 +412,11 @@ public: ...@@ -412,8 +412,11 @@ public:
/// Completly configure a view mode ( set toolbars, toolboxes ... ) /// Completly configure a view mode ( set toolbars, toolboxes ... )
void slotAddViewModeComplete(QString _mode , bool _custom, QStringList _toolboxes, QStringList _toolbars); 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); 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 /// Slot for Changing visible toolWidgets
void slotChangeView(QString _mode, QStringList _toolboxWidgets, QStringList _toolbars); void slotChangeView(QString _mode, QStringList _toolboxWidgets, QStringList _toolbars);
......
...@@ -103,9 +103,10 @@ void CoreWidget::slotAddViewModeToolboxes(QString _mode, bool _custom, QStringLi ...@@ -103,9 +103,10 @@ void CoreWidget::slotAddViewModeToolboxes(QString _mode, bool _custom, QStringLi
ViewMode* vm = 0; ViewMode* vm = 0;
if ( id == -1 ) { if ( id == -1 ) {
vm = new ViewMode(); vm = new ViewMode();
vm->name = _mode; vm->name = _mode;
vm->custom = _custom; vm->custom = _custom;
vm->icon = "Unknown.png";
if (_custom) { if (_custom) {
viewModes_.push_back(vm); viewModes_.push_back(vm);
...@@ -145,9 +146,10 @@ void CoreWidget::slotAddViewModeToolbars(QString _mode, bool _custom, QStringLis ...@@ -145,9 +146,10 @@ void CoreWidget::slotAddViewModeToolbars(QString _mode, bool _custom, QStringLis
ViewMode* vm = 0; ViewMode* vm = 0;
if ( id == -1 ) { if ( id == -1 ) {
vm = new ViewMode(); vm = new ViewMode();
vm->name = _mode; vm->name = _mode;
vm->custom = _custom; vm->custom = _custom;
vm->icon = "Unknown.png";
if (_custom) { if (_custom) {
viewModes_.push_back(vm); viewModes_.push_back(vm);
...@@ -172,7 +174,48 @@ void CoreWidget::slotAddViewModeToolbars(QString _mode, bool _custom, QStringLis ...@@ -172,7 +174,48 @@ void CoreWidget::slotAddViewModeToolbars(QString _mode, bool _custom, QStringLis
/// Sets the Icon for a given View Mode /// Sets the Icon for a given View Mode
void CoreWidget::slotSetViewModeIcon(QString _mode, QString _iconName) { 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 /// Remove a viewMode
......
...@@ -6,8 +6,8 @@ ...@@ -6,8 +6,8 @@
<rect> <rect>
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>703</width> <width>755</width>
<height>724</height> <height>816</height>
</rect> </rect>
</property> </property>
<property name="windowTitle"> <property name="windowTitle">
...@@ -16,10 +16,28 @@ ...@@ -16,10 +16,28 @@
<layout class="QVBoxLayout" name="verticalLayout"> <layout class="QVBoxLayout" name="verticalLayout">
<item> <item>
<widget class="QGroupBox" name="groupBox_2"> <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"> <property name="maximumSize">
<size> <size>
<width>16777215</width> <width>16777215</width>
<height>200</height> <height>16777215</height>
</size>
</property>
<property name="baseSize">
<size>
<width>0</width>
<height>0</height>
</size> </size>
</property> </property>
<property name="title"> <property name="title">
...@@ -34,6 +52,15 @@ ...@@ -34,6 +52,15 @@
<height>0</height> <height>0</height>
</size> </size>
</property> </property>
<property name="alternatingRowColors">
<bool>false</bool>
</property>
<property name="iconSize">
<size>
<width>125</width>
<height>125</height>
</size>
</property>
<property name="flow"> <property name="flow">
<enum>QListView::LeftToRight</enum> <enum>QListView::LeftToRight</enum>
</property> </property>
...@@ -78,6 +105,12 @@ ...@@ -78,6 +105,12 @@
</item> </item>
<item> <item>
<widget class="QTabWidget" name="tabWidget"> <widget class="QTabWidget" name="tabWidget">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
<horstretch>0</horstretch>
<verstretch>2</verstretch>
</sizepolicy>
</property>
<property name="currentIndex"> <property name="currentIndex">
<number>0</number> <number>0</number>
</property> </property>
......
...@@ -519,7 +519,8 @@ void viewModeWidget::show(QString _lastMode){ ...@@ -519,7 +519,8 @@ void viewModeWidget::show(QString _lastMode){
QListWidgetItem *item = new QListWidgetItem(viewModeList); QListWidgetItem *item = new QListWidgetItem(viewModeList);
item->setTextAlignment(Qt::AlignHCenter); item->setTextAlignment(Qt::AlignHCenter);
item->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled); 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); item->setText(modes_[i]->name);
if (modes_[i]->custom) 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