47 #include "viewModeChangeWidget.hh" 52 : QWidget(_parent,
Qt::Window |
Qt::CustomizeWindowHint),
57 connect(viewModeList, SIGNAL(clicked (QModelIndex)),
this, SLOT(
slotModeClicked(QModelIndex)) );
69 if ( viewModeList->selectedItems().count() > 0)
70 for (
int i=0; i < modes_.size(); i++)
71 if (modes_[i]->name == viewModeList->currentItem()->text()){
77 std::cerr <<
"Currently selected Mode not found?!" << std::endl;
81 emit
changeView(modes_[
id]->name,modes_[
id]->visibleToolboxes,modes_[
id]->visibleToolbars,modes_[
id]->visibleContextMenus);
85 void viewModeChangeWidget::slot_update(){
86 update(OpenFlipper::Options::currentViewMode());
89 void viewModeChangeWidget::showEvent(QShowEvent *event) {
91 QWidget::showEvent(event);
99 viewModeList->clear();
100 for (
int i=0; i < modes_.size(); i++){
101 QListWidgetItem *item =
new QListWidgetItem(viewModeList);
102 item->setTextAlignment(Qt::AlignHCenter);
103 item->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled);
105 QFile iconFile( OpenFlipper::Options::iconDirStr() + QDir::separator () + modes_[i]->icon );
107 if ( iconFile.exists() )
108 item->setIcon( QIcon(iconFile.fileName()) );
110 iconFile.setFileName( OpenFlipper::Options::configDirStr() + QDir::separator() +
"Icons" + QDir::separator() + modes_[i]->icon );
111 if ( iconFile.exists() )
112 item->setIcon( QIcon(iconFile.fileName()) );
114 item->setIcon( QIcon(OpenFlipper::Options::iconDirStr() + QDir::separator () +
"Unknown.png") );
115 std::cerr <<
"Unable to find icon file! " << iconFile.fileName().toStdString() << std::endl;
119 item->setText(modes_[i]->name);
121 if (modes_[i]->custom)
122 viewModeList->item(i)->setForeground( QBrush(QColor(0,0,150) ) );
124 viewModeList->item(i)->setForeground( QBrush(QColor(0,0,0) ) );
128 viewModeList->setCurrentRow(0);
130 for (
int i=0; i < viewModeList->count(); i++)
131 if (viewModeList->item(i)->text() == _lastMode)
132 viewModeList->setCurrentRow(i);
void update(QString _lastMode)
overloaded show function
void changeView(QString _mode, QStringList _toolboxWidgets, QStringList _toolbars, QStringList _contextmenus)
Changes the view mode to the currently configured one.
void slotModeClicked(QModelIndex _id)
Slot for changing View and closing widget.
viewModeChangeWidget(const QVector< ViewMode * > &_modes, QWidget *parent=0)
Constructor.