Skip to content

Commit

Permalink
GUI: Resource info panel code
Browse files Browse the repository at this point in the history
  • Loading branch information
fdde authored and DrMcCoy committed Dec 29, 2017
1 parent 2fd0ed8 commit e1389d3
Show file tree
Hide file tree
Showing 6 changed files with 87 additions and 258 deletions.
22 changes: 7 additions & 15 deletions src/gui/panelpreviewimage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,13 @@ PanelPreviewImage::PanelPreviewImage(QWidget *UNUSED(parent)) {
_layoutVertical = new QVBoxLayout();
_layoutHorizontal = new QHBoxLayout();

_buttonZoomIn = new QPushButton(this);
_buttonZoomOut = new QPushButton(this);
_buttonZoomOriginal = new QPushButton(this);
_buttonFit = new QPushButton(this);
_buttonFitWidth = new QPushButton(this);
_buttonShrinkFit = new QPushButton(this);
_buttonShrinkFitWidth = new QPushButton(this);
_buttonZoomIn = new QPushButton(tr("Zoom in"), this);
_buttonZoomOut = new QPushButton(tr("Zoom out"), this);
_buttonZoomOriginal = new QPushButton(tr("Zoom 100%"), this);
_buttonFit = new QPushButton(tr("Fit"), this);
_buttonFitWidth = new QPushButton(tr("Fit width"), this);
_buttonShrinkFit = new QPushButton(tr("Shrink fit"), this);
_buttonShrinkFitWidth = new QPushButton(tr("Shrink fit width"), this);

_labelDimensions = new QLabel(this);
_labelBrightness = new QLabel(this);
Expand All @@ -39,14 +39,6 @@ PanelPreviewImage::PanelPreviewImage(QWidget *UNUSED(parent)) {

_checkNearest = new QCheckBox("Nearest", this);

_buttonZoomIn->setText(tr("Zoom in"));
_buttonZoomOut->setText(tr("Zoom out"));
_buttonZoomOriginal->setText(tr("Zoom 100%"));
_buttonFit->setText(tr("Fit"));
_buttonFitWidth->setText(tr("Fit width"));
_buttonShrinkFit->setText(tr("Shrink fit"));
_buttonShrinkFitWidth->setText(tr("Shrink fit width"));

_layoutVertical->addWidget(_labelZoomPercent);
_layoutVertical->addWidget(_buttonZoomIn);
_layoutVertical->addWidget(_buttonZoomOut);
Expand Down
10 changes: 3 additions & 7 deletions src/gui/panelpreviewsound.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,19 +22,15 @@ PanelPreviewSound::PanelPreviewSound(QWidget *UNUSED(parent)) {
_labelPercent = new QLabel(this);
_labelDuration = new QLabel(this);

_buttonPlay = new QPushButton(this);
_buttonPause = new QPushButton(this);
_buttonStop = new QPushButton(this);
_buttonPlay = new QPushButton(tr("Play"), this);
_buttonPause = new QPushButton(tr("Pause"), this);
_buttonStop = new QPushButton(tr("Stop"), this);

_sliderPosition = new QSlider(this);
_sliderVolume = new QSlider(this);

_sliderPosition->setOrientation(Qt::Horizontal);

_buttonPlay->setText(tr("Play"));
_buttonPause->setText(tr("Pause"));
_buttonStop->setText(tr("Stop"));

_layoutHorizontal->addWidget(_labelPosition);
_layoutHorizontal->addWidget(_labelPercent);
_layoutHorizontal->addWidget(_labelDuration);
Expand Down
105 changes: 58 additions & 47 deletions src/gui/panelresourceinfo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
#include "verdigris/wobjectimpl.h"

#include "src/common/filepath.h"
#include "src/common/system.h"
#include "src/common/writefile.h"
#include "src/gui/panelresourceinfo.h"
#include "src/gui/resourcetreeitem.h"
Expand All @@ -13,38 +14,48 @@ namespace GUI {

W_OBJECT_IMPL(PanelResourceInfo)

PanelResourceInfo::PanelResourceInfo(QWidget *parent)
: QFrame(parent)
, _btnExportRaw(new QPushButton("Save", this))
, _btnExportBMUMP3(new QPushButton("Export as MP3", this))
, _btnExportTGA(new QPushButton("Export as TGA", this))
, _btnExportWAV(new QPushButton("Export as WAV",this))
{
_ui.setupUi(this);

_ui.resLabelName->setText("Resource name:");
_ui.resLabelSize->setText("Size:");
_ui.resLabelFileType->setText("File type:");
_ui.resLabelResType->setText("Resource type:");

_ui.horizontalLayout->addWidget(_btnExportRaw);
_ui.horizontalLayout->addWidget(_btnExportBMUMP3);
_ui.horizontalLayout->addWidget(_btnExportTGA);
_ui.horizontalLayout->addWidget(_btnExportWAV);

_btnExportRaw->setVisible(false);
_btnExportBMUMP3->setVisible(false);
_btnExportTGA->setVisible(false);
_btnExportWAV->setVisible(false);

QObject::connect(_btnExportRaw, &QPushButton::clicked, this, &PanelResourceInfo::slotSave);
QObject::connect(_btnExportTGA, &QPushButton::clicked, this, &PanelResourceInfo::slotExportTGA);
QObject::connect(_btnExportBMUMP3, &QPushButton::clicked, this, &PanelResourceInfo::slotExportBMUMP3);
QObject::connect(_btnExportWAV, &QPushButton::clicked, this, &PanelResourceInfo::slotExportWAV);
}
PanelResourceInfo::PanelResourceInfo(QWidget *UNUSED(parent)) {
_layoutVertical = new QVBoxLayout(this);
_layoutVertical_2 = new QVBoxLayout();
_layoutHorizontal = new QHBoxLayout();

_buttonExportRaw = new QPushButton(tr("Save"), this);
_buttonExportBMUMP3 = new QPushButton(tr("Export as MP3"), this);
_buttonExportTGA = new QPushButton(tr("Export as TGA"), this);
_buttonExportWAV = new QPushButton(tr("Export as WAV"),this);

_labelName = new QLabel(tr("Resource name :"), this);
_labelSize = new QLabel(tr("Size"), this);
_labelFileType = new QLabel(tr("File type:"), this);
_labelResType = new QLabel(tr("Resource type:"), this);

_layoutVertical_2->addWidget(_labelName);
_layoutVertical_2->addWidget(_labelSize);
_layoutVertical_2->addWidget(_labelFileType);
_layoutVertical_2->addWidget(_labelResType);

_layoutHorizontal->addWidget(_buttonExportRaw);
_layoutHorizontal->addWidget(_buttonExportBMUMP3);
_layoutHorizontal->addWidget(_buttonExportTGA);
_layoutHorizontal->addWidget(_buttonExportWAV);
_layoutHorizontal->addItem(new QSpacerItem(0, 0, QSizePolicy::Expanding, QSizePolicy::Expanding));

_layoutHorizontal->setSizeConstraint(QLayout::SetMinimumSize);

_layoutVertical->addLayout(_layoutVertical_2);
_layoutVertical->addLayout(_layoutHorizontal);

_layoutVertical->setContentsMargins(5, 5, 5, 5); // left margin a bit

_buttonExportRaw->setVisible(false);
_buttonExportBMUMP3->setVisible(false);
_buttonExportTGA->setVisible(false);
_buttonExportWAV->setVisible(false);

Ui::PanelResourceInfo &PanelResourceInfo::getUi() {
return _ui;
QObject::connect(_buttonExportRaw, &QPushButton::clicked, this, &PanelResourceInfo::slotSave);
QObject::connect(_buttonExportTGA, &QPushButton::clicked, this, &PanelResourceInfo::slotExportTGA);
QObject::connect(_buttonExportBMUMP3, &QPushButton::clicked, this, &PanelResourceInfo::slotExportBMUMP3);
QObject::connect(_buttonExportWAV, &QPushButton::clicked, this, &PanelResourceInfo::slotExportWAV);
}

/** SLOTS **/
Expand Down Expand Up @@ -83,10 +94,10 @@ void PanelResourceInfo::showExportButtons(const GUI::ResourceTreeItem *item) {
}

void PanelResourceInfo::showExportButtons(bool enableRaw, bool showMP3, bool showWAV, bool showTGA) {
_btnExportRaw->setVisible(enableRaw);
_btnExportTGA->setVisible(showTGA);
_btnExportBMUMP3->setVisible(showMP3);
_btnExportWAV->setVisible(showWAV);
_buttonExportRaw->setVisible(enableRaw);
_buttonExportTGA->setVisible(showTGA);
_buttonExportBMUMP3->setVisible(showMP3);
_buttonExportWAV->setVisible(showWAV);
}

const QString getSizeLabel(size_t size) {
Expand Down Expand Up @@ -148,24 +159,24 @@ void PanelResourceInfo::setLabels(const ResourceTreeItem *item) {
labelResType += getResTypeLabel(resType);
}

_ui.resLabelName->setText(labelName);
_ui.resLabelSize->setText(labelSize);
_ui.resLabelFileType->setText(labelFileType);
_ui.resLabelResType->setText(labelResType);
_labelName->setText(labelName);
_labelSize->setText(labelSize);
_labelFileType->setText(labelFileType);
_labelResType->setText(labelResType);
}

void PanelResourceInfo::clearLabels() {
_ui.resLabelName->setText("Resource name:");
_ui.resLabelSize->setText("Size:");
_ui.resLabelFileType->setText("File type:");
_ui.resLabelResType->setText("Resource type:");
_labelName->setText("Resource name:");
_labelSize->setText("Size:");
_labelFileType->setText("File type:");
_labelResType->setText("Resource type:");
}

void PanelResourceInfo::setButtonsForClosedDir() {
_btnExportRaw->setVisible(false);
_btnExportBMUMP3->setVisible(false);
_btnExportWAV->setVisible(false);
_btnExportTGA->setVisible(false);
_buttonExportRaw->setVisible(false);
_buttonExportBMUMP3->setVisible(false);
_buttonExportWAV->setVisible(false);
_buttonExportTGA->setVisible(false);
}

} // End of namespace GUI
32 changes: 19 additions & 13 deletions src/gui/panelresourceinfo.h
Original file line number Diff line number Diff line change
@@ -1,24 +1,38 @@
#ifndef PANELRESOURCEINFO_H
#define PANELRESOURCEINFO_H

#include <QFrame>
#include <QLabel>
#include <QLayout>
#include <QWidget>

#include "verdigris/wobjectdefs.h"

#include "ui/ui_resourceinfo.h"

namespace GUI {

class ResourceTreeItem;

class PanelResourceInfo : public QFrame
{
class PanelResourceInfo : public QFrame {
W_OBJECT(PanelResourceInfo)

private:
QVBoxLayout *_layoutVertical;
QHBoxLayout *_layoutHorizontal;
QVBoxLayout *_layoutVertical_2;

QPushButton *_buttonExportRaw;
QPushButton *_buttonExportBMUMP3;
QPushButton *_buttonExportTGA;
QPushButton *_buttonExportWAV;

QLabel *_labelName;
QLabel *_labelSize;
QLabel *_labelFileType;
QLabel *_labelResType;

public:
PanelResourceInfo(QWidget *parent = 0);

Ui::PanelResourceInfo &getUi();
void showExportButtons(const GUI::ResourceTreeItem *item);
void showExportButtons(bool enableRaw, bool showMP3, bool showWAV, bool showTGA);
void setLabels(const GUI::ResourceTreeItem *item);
Expand Down Expand Up @@ -53,14 +67,6 @@ public /*slots*/:
void slotExportTGA();
void slotExportBMUMP3();
void slotExportWAV();

private:
Ui::PanelResourceInfo _ui;

QPushButton *_btnExportRaw;
QPushButton *_btnExportBMUMP3;
QPushButton *_btnExportTGA;
QPushButton *_btnExportWAV;
};

} // End of namespace GUI
Expand Down
1 change: 0 additions & 1 deletion src/gui/rules.mk
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ noinst_LTLIBRARIES += src/gui/libgui.la

QT_UI_FORMS_BUILT = \
ui/ui_mainwindow.h \
ui/ui_resourceinfo.h \
$(EMPTY)

BUILT_SOURCES += $(QT_UI_FORMS_BUILT)
Expand Down

0 comments on commit e1389d3

Please sign in to comment.