Commit b23e4854 authored by Jan Möbius's avatar Jan Möbius

Change icon for custom view modes

git-svn-id: http://www.openflipper.org/svnrepo/OpenFlipper/branches/Free@7335 383ad7c9-94d9-4d36-a494-682f7c89f535
parent 646008f1
......@@ -100,7 +100,20 @@ void viewModeChangeWidget::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 () + modes_[i]->icon));
QFile iconFile( OpenFlipper::Options::iconDirStr() + QDir::separator () + modes_[i]->icon );
if ( iconFile.exists() )
item->setIcon( QIcon(iconFile.fileName()) );
else {
iconFile.setFileName( OpenFlipper::Options::configDirStr() + QDir::separator() + "Icons" + QDir::separator() + modes_[i]->icon );
if ( iconFile.exists() )
item->setIcon( QIcon(iconFile.fileName()) );
else {
item->setIcon( QIcon(OpenFlipper::Options::iconDirStr() + QDir::separator () + "Unknown.png") );
std::cerr << "Unable to find icon file! " << iconFile.fileName().toStdString() << std::endl;
}
}
item->setText(modes_[i]->name);
......
......@@ -48,6 +48,7 @@
#include <OpenFlipper/common/GlobalOptions.hh>
#include <QInputDialog>
#include <QFileDialog>
#include <QMessageBox>
/// Constructor
......@@ -254,9 +255,22 @@ void viewModeWidget::slotSetIcon() {
std::cerr << "Unable to find Mode viewModeWidget::slotSetIcon()" << std::endl;
return;
}
// Get the filename from the user
QString fileName = QFileDialog::getOpenFileName ( this, tr("Select Image for view Mode ( best size : 150x150px )"), QString(), tr("Images (*.png *.xpm *.jpg)") );
QFile file(fileName);
QFileInfo fileInfo(file);
if ( ! file.exists() )
return;
file.copy(OpenFlipper::Options::configDirStr() + QDir::separator() + "Icons" + QDir::separator() + "viewMode_" + fileInfo.fileName() );
std::cerr << "Todo : implement change icon" << std::endl;
modes_[id]->icon = "viewMode_" + fileInfo.fileName();
show(modes_[id]->name);
}
// =======================================================================================================
......@@ -660,7 +674,20 @@ 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 () + modes_[i]->icon));
QFile iconFile( OpenFlipper::Options::iconDirStr() + QDir::separator () + modes_[i]->icon );
if ( iconFile.exists() )
item->setIcon( QIcon(iconFile.fileName()) );
else {
iconFile.setFileName( OpenFlipper::Options::configDirStr() + QDir::separator() + "Icons" + QDir::separator() + modes_[i]->icon );
if ( iconFile.exists() )
item->setIcon( QIcon(iconFile.fileName()) );
else {
item->setIcon( QIcon(OpenFlipper::Options::iconDirStr() + QDir::separator () + "Unknown.png") );
std::cerr << "Unable to find icon file! " << iconFile.fileName().toStdString() << std::endl;
}
}
item->setText(modes_[i]->name);
......
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