important fix, texture manager
This commit is contained in:
103
src/widgets/textures_editor.cpp
Normal file
103
src/widgets/textures_editor.cpp
Normal file
@@ -0,0 +1,103 @@
|
||||
/*
|
||||
QGL TexturesEditor
|
||||
Ivan Pelipenko peri4ko@yandex.ru
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Lesser General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "textures_editor.h"
|
||||
|
||||
#include "glmaterial.h"
|
||||
#include "gltexture_manager.h"
|
||||
#include "qglview.h"
|
||||
#include "ui_textures_editor.h"
|
||||
|
||||
#include <QInputDialog>
|
||||
#include <QMessageBox>
|
||||
#include <qad_types.h>
|
||||
|
||||
|
||||
TexturesEditor::TexturesEditor(QWidget * parent): QWidget(parent) {
|
||||
ui = new Ui::TexturesEditor();
|
||||
ui->setupUi(this);
|
||||
ui->labelMissed->hide();
|
||||
view = 0;
|
||||
}
|
||||
|
||||
|
||||
void TexturesEditor::assignQGLView(QGLView * v) {
|
||||
view = v;
|
||||
connect(view->textureManager(), &TextureManager::loadingDone, this, [this]() { showWarning(); });
|
||||
connect(view->textureManager(), &TextureManager::filesUsed, this, [this](int count) { ui->labelUsedFiles->setNum(count); });
|
||||
showPathes();
|
||||
}
|
||||
|
||||
|
||||
void TexturesEditor::changeEvent(QEvent * e) {
|
||||
QWidget::changeEvent(e);
|
||||
switch (e->type()) {
|
||||
case QEvent::LanguageChange: ui->retranslateUi(this); break;
|
||||
default: break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void TexturesEditor::showPathes() {
|
||||
ui->listWidget->clear();
|
||||
ui->listWidget->addItems(TextureManager::searchPathes());
|
||||
}
|
||||
|
||||
|
||||
void TexturesEditor::showWarning() {
|
||||
QString mf = QStringList(view->textureManager()->missedFiles().values()).join("\n");
|
||||
ui->labelMissed->setText(tr("Missed files:") + "\n" + mf);
|
||||
ui->labelMissed->setHidden(mf.isEmpty());
|
||||
}
|
||||
|
||||
|
||||
void TexturesEditor::setPathes() {
|
||||
QStringList pl;
|
||||
for (int i = 0; i < ui->listWidget->count(); ++i)
|
||||
pl << ui->listWidget->item(i)->text();
|
||||
TextureManager::setSearchPathes(pl);
|
||||
if (view) view->reloadTextures();
|
||||
}
|
||||
|
||||
|
||||
void TexturesEditor::on_buttonPathesAdd_clicked() {
|
||||
QString p = QFileDialog::getExistingDirectory(nullptr, tr("Select search path"), prev_path);
|
||||
if (p.isEmpty()) return;
|
||||
prev_path = p;
|
||||
if (TextureManager::searchPathes().contains(p)) return;
|
||||
ui->listWidget->addItem(p);
|
||||
setPathes();
|
||||
}
|
||||
|
||||
|
||||
void TexturesEditor::on_buttonPathesDelete_clicked() {
|
||||
qDeleteAll(ui->listWidget->selectedItems());
|
||||
setPathes();
|
||||
}
|
||||
|
||||
|
||||
void TexturesEditor::on_buttonPathesClear_clicked() {
|
||||
ui->listWidget->clear();
|
||||
setPathes();
|
||||
}
|
||||
|
||||
|
||||
void TexturesEditor::on_buttonReload_clicked() {
|
||||
if (!view) return;
|
||||
view->reloadTextures();
|
||||
}
|
||||
60
src/widgets/textures_editor.h
Normal file
60
src/widgets/textures_editor.h
Normal file
@@ -0,0 +1,60 @@
|
||||
/*
|
||||
QGL TexturesEditor
|
||||
Ivan Pelipenko peri4ko@yandex.ru
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Lesser General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef textures_editor_H
|
||||
#define textures_editor_H
|
||||
|
||||
#include "gltypes.h"
|
||||
|
||||
#include <QFileDialog>
|
||||
|
||||
namespace Ui {
|
||||
class TexturesEditor;
|
||||
}
|
||||
|
||||
class TexturesEditor: public QWidget {
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit TexturesEditor(QWidget * parent = 0);
|
||||
|
||||
void assignQGLView(QGLView * v);
|
||||
|
||||
protected:
|
||||
void changeEvent(QEvent * e);
|
||||
void setPathes();
|
||||
|
||||
Ui::TexturesEditor * ui;
|
||||
QGLView * view;
|
||||
QString prev_path;
|
||||
|
||||
public slots:
|
||||
void showPathes();
|
||||
|
||||
private slots:
|
||||
void showWarning();
|
||||
void on_buttonPathesAdd_clicked();
|
||||
void on_buttonPathesDelete_clicked();
|
||||
void on_buttonPathesClear_clicked();
|
||||
void on_buttonReload_clicked();
|
||||
|
||||
signals:
|
||||
void changed();
|
||||
};
|
||||
|
||||
#endif
|
||||
172
src/widgets/textures_editor.ui
Normal file
172
src/widgets/textures_editor.ui
Normal file
@@ -0,0 +1,172 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>TexturesEditor</class>
|
||||
<widget class="QWidget" name="TexturesEditor">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>435</width>
|
||||
<height>347</height>
|
||||
</rect>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_2">
|
||||
<property name="leftMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="topMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="rightMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="bottomMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<item>
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_2">
|
||||
<item>
|
||||
<widget class="QLabel" name="label">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Preferred">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Search pathes:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QToolButton" name="buttonPathesAdd">
|
||||
<property name="toolTip">
|
||||
<string>Add</string>
|
||||
</property>
|
||||
<property name="icon">
|
||||
<iconset resource="../../../qad/libs/piqt_utils/qad_piqt_widgets.qrc">
|
||||
<normaloff>:/icons/list-add.png</normaloff>:/icons/list-add.png</iconset>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QToolButton" name="buttonPathesDelete">
|
||||
<property name="toolTip">
|
||||
<string>Delete</string>
|
||||
</property>
|
||||
<property name="icon">
|
||||
<iconset resource="../../../qad/libs/blockview/qad_blockview.qrc">
|
||||
<normaloff>:/icons/edit-delete.png</normaloff>:/icons/edit-delete.png</iconset>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="horizontalSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeType">
|
||||
<enum>QSizePolicy::Preferred</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>20</width>
|
||||
<height>10</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QToolButton" name="buttonPathesClear">
|
||||
<property name="toolTip">
|
||||
<string>Clear</string>
|
||||
</property>
|
||||
<property name="icon">
|
||||
<iconset resource="../../../qad/libs/application/qad_application.qrc">
|
||||
<normaloff>:/icons/edit-clear.png</normaloff>:/icons/edit-clear.png</iconset>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QListWidget" name="listWidget">
|
||||
<property name="editTriggers">
|
||||
<set>QAbstractItemView::NoEditTriggers</set>
|
||||
</property>
|
||||
<property name="dragDropMode">
|
||||
<enum>QAbstractItemView::InternalMove</enum>
|
||||
</property>
|
||||
<property name="defaultDropAction">
|
||||
<enum>Qt::MoveAction</enum>
|
||||
</property>
|
||||
<property name="verticalScrollMode">
|
||||
<enum>QAbstractItemView::ScrollPerPixel</enum>
|
||||
</property>
|
||||
<property name="horizontalScrollMode">
|
||||
<enum>QAbstractItemView::ScrollPerPixel</enum>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||
<item>
|
||||
<widget class="QLabel" name="label_2">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Fixed" vsizetype="Preferred">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Used files:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="labelUsedFiles">
|
||||
<property name="text">
|
||||
<string>0</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QToolButton" name="buttonReload">
|
||||
<property name="toolTip">
|
||||
<string>Reload</string>
|
||||
</property>
|
||||
<property name="icon">
|
||||
<iconset resource="../core/qglengine_core.qrc">
|
||||
<normaloff>:/icons/view-refresh.png</normaloff>:/icons/view-refresh.png</iconset>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="labelMissed">
|
||||
<property name="text">
|
||||
<string>Missed files:</string>
|
||||
</property>
|
||||
<property name="wordWrap">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<resources>
|
||||
<include location="../../../qad/libs/application/qad_application.qrc"/>
|
||||
<include location="../../../qad/libs/blockview/qad_blockview.qrc"/>
|
||||
<include location="../../../qad/libs/piqt_utils/qad_piqt_widgets.qrc"/>
|
||||
<include location="../core/qglengine_core.qrc"/>
|
||||
</resources>
|
||||
<connections/>
|
||||
<slots>
|
||||
<slot>materialChanged()</slot>
|
||||
</slots>
|
||||
</ui>
|
||||
Reference in New Issue
Block a user