53 #include "viewModeChangeWidget.hh"
58 : QWidget(_parent,
Qt::Window |
Qt::CustomizeWindowHint),
63 connect(viewModeList, SIGNAL(clicked (QModelIndex)),
this, SLOT(
slotModeClicked(QModelIndex)) );
75 if ( viewModeList->selectedItems().count() > 0)
76 for (
int i=0; i < modes_.size(); i++)
77 if (modes_[i]->name == viewModeList->currentItem()->text()){
83 std::cerr <<
"Currently selected Mode not found?!" << std::endl;
87 emit
changeView(modes_[
id]->name,modes_[
id]->visibleToolboxes,modes_[
id]->visibleToolbars,modes_[
id]->visibleContextMenus);
91 void viewModeChangeWidget::slot_update(){
92 update(OpenFlipper::Options::currentViewMode());
95 void viewModeChangeWidget::showEvent(QShowEvent *event) {
97 QWidget::showEvent(event);
105 viewModeList->clear();
106 for (
int i=0; i < modes_.size(); i++){
107 QListWidgetItem *item =
new QListWidgetItem(viewModeList);
108 item->setTextAlignment(Qt::AlignHCenter);
109 item->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled);
111 QFile iconFile( OpenFlipper::Options::iconDirStr() + QDir::separator () + modes_[i]->icon );
113 if ( iconFile.exists() )
114 item->setIcon( QIcon(iconFile.fileName()) );
116 iconFile.setFileName( OpenFlipper::Options::configDirStr() + QDir::separator() +
"Icons" + QDir::separator() + modes_[i]->icon );
117 if ( iconFile.exists() )
118 item->setIcon( QIcon(iconFile.fileName()) );
120 item->setIcon( QIcon(OpenFlipper::Options::iconDirStr() + QDir::separator () +
"Unknown.png") );
121 std::cerr <<
"Unable to find icon file! " << iconFile.fileName().toStdString() << std::endl;
125 item->setText(modes_[i]->name);
127 if (modes_[i]->custom)
128 viewModeList->item(i)->setForeground( QBrush(QColor(0,0,150) ) );
130 viewModeList->item(i)->setForeground( QBrush(QColor(0,0,0) ) );
134 viewModeList->setCurrentRow(0);
136 for (
int i=0; i < viewModeList->count(); i++)
137 if (viewModeList->item(i)->text() == _lastMode)
138 viewModeList->setCurrentRow(i);
void update(QString _lastMode)
overloaded show function
viewModeChangeWidget(const QVector< ViewMode * > &_modes, QWidget *parent=0)
Constructor.
void slotModeClicked(QModelIndex _id)
Slot for changing View and closing widget.
void changeView(QString _mode, QStringList _toolboxWidgets, QStringList _toolbars, QStringList _contextmenus)
Changes the view mode to the currently configured one.