Skip to content

Commit

Permalink
GUI: Add preview stubs
Browse files Browse the repository at this point in the history
  • Loading branch information
fdde authored and DrMcCoy committed Dec 29, 2017
1 parent 3dde008 commit db3205b
Show file tree
Hide file tree
Showing 12 changed files with 640 additions and 413 deletions.
92 changes: 67 additions & 25 deletions src/gui/mainwindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,17 +49,24 @@ MainWindow::MainWindow(QWidget *parent, const char *version, QSize size, QString
_ui->setupUi(this);

connect(this, &MainWindow::openDir, this, &MainWindow::setTreeViewModel);
connect(_ui->actionOpen_directory, &QAction::triggered, this, &MainWindow::on_actionOpen_directory_triggered);
connect(_ui->actionOpenDirectory, &QAction::triggered, this, &MainWindow::on_actionOpen_directory_triggered);
connect(_ui->actionClose, &QAction::triggered, this, &MainWindow::on_actionClose_triggered);
connect(_ui->actionQuit, &QAction::triggered, this, &MainWindow::on_actionQuit_triggered);
connect(_ui->pushButton_1, &QPushButton::clicked, this, &MainWindow::on_pushButton_1_clicked);
connect(_ui->pushButton_2, &QPushButton::clicked, this, &MainWindow::on_pushButton_2_clicked);
connect(_ui->pushButton_3, &QPushButton::clicked, this, &MainWindow::on_pushButton_3_clicked);
connect(_ui->pushButton_4, &QPushButton::clicked, this, &MainWindow::on_pushButton_4_clicked);
connect(_ui->bLoadKotorDir, &QPushButton::clicked, this, &MainWindow::on_pushButton_1_clicked);
connect(_ui->bCloseDir, &QPushButton::clicked, this, &MainWindow::on_pushButton_2_clicked);
connect(_ui->bUnused1, &QPushButton::clicked, this, &MainWindow::on_pushButton_3_clicked);
connect(_ui->bUnused2, &QPushButton::clicked, this, &MainWindow::on_pushButton_4_clicked);

if (size != QSize())
resize(size);

_panelPreviewEmpty = new PanelPreviewEmpty();
_panelPreviewImage = new PanelPreviewImage();
_panelPreviewSound = new PanelPreviewSound();
_panelPreviewText = new PanelPreviewText();

_ui->resLayout->addWidget(_panelPreviewEmpty);

connect(this, &MainWindow::openDir, this, &MainWindow::setTreeViewModel);

_statusLabel = new QLabel(this);
Expand All @@ -70,14 +77,8 @@ MainWindow::MainWindow(QWidget *parent, const char *version, QSize size, QString

_ui->treeView->setHeaderHidden(true);

_resLabels << _ui->resLabel1;
_resLabels << _ui->resLabel2;
_resLabels << _ui->resLabel3;
_resLabels << _ui->resLabel4;
_resLabels[0]->setText("Resource name:");
_resLabels[1]->setText("Size:");
_resLabels[2]->setText("File type:");
_resLabels[3]->setText("Resource type:");
// resource info panel
clearLabels();

if (!path.isEmpty())
emit openDir(path);
Expand Down Expand Up @@ -111,12 +112,11 @@ void MainWindow::on_actionOpen_directory_triggered() {
}

void MainWindow::on_actionClose_triggered() {
showPreviewPanel(_panelPreviewEmpty);

_ui->treeView->setModel(nullptr);

_resLabels[0]->setText("Resource name:");
_resLabels[1]->setText("Size:");
_resLabels[2]->setText("File type:");
_resLabels[3]->setText("Resource type:");
clearLabels();

_statusLabel->setText("None");

Expand Down Expand Up @@ -204,24 +204,66 @@ void MainWindow::setLabels() {
labelResType += getResTypeLabel(resType);
}

_resLabels[0]->setText(labelName);
_resLabels[1]->setText(labelSize);
_resLabels[2]->setText(labelFileType);
_resLabels[3]->setText(labelResType);
_ui->resLabelName->setText(labelName);
_ui->resLabelSize->setText(labelSize);
_ui->resLabelFileType->setText(labelFileType);
_ui->resLabelResType->setText(labelResType);
}


void MainWindow::clearLabels() {
_resLabels[0]->setText("Resource name:");
_resLabels[1]->setText("Size:");
_resLabels[2]->setText("File type:");
_resLabels[3]->setText("Resource type:");
_ui->resLabelName->setText("Resource name:");
_ui->resLabelSize->setText("Size:");
_ui->resLabelFileType->setText("File type:");
_ui->resLabelResType->setText("Resource type:");
}

void MainWindow::showPreviewPanel(QFrame *panel) {
if (_ui->resLayout->count()) {
QFrame *old = static_cast<QFrame*>(_ui->resLayout->itemAt(0)->widget());
if (old != panel) {
_ui->resLayout->removeWidget(old);
old->setParent(0);
_ui->resLayout->addWidget(panel);
}
}
}

void MainWindow::showPreviewPanel() {
switch (_currentSelection.getResourceType()) {
case Aurora::kResourceImage:
showPreviewPanel(_panelPreviewImage);
break;

case Aurora::kResourceSound:
showPreviewPanel(_panelPreviewSound);
break;

default:
{
switch (_currentSelection.getFileType()) {
case Aurora::FileType::kFileTypeICO:
showPreviewPanel(_panelPreviewImage);
break;

case Aurora::FileType::kFileTypeINI:
case Aurora::FileType::kFileTypeTXT:
showPreviewPanel(_panelPreviewText);
break;

default:
showPreviewPanel(_panelPreviewEmpty);
}
break;
}
}
}

void MainWindow::selection(const QItemSelection &selected) {
const QModelIndex index = selected.indexes().at(0);
_currentSelection = Selection(_treeModel->getNode(index)->getFileInfo());
setLabels();
showPreviewPanel();
}

} // End of namespace GUI
13 changes: 12 additions & 1 deletion src/gui/mainwindow.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,10 @@

#include "verdigris/wobjectdefs.h"

#include "src/gui/panelpreviewempty.h"
#include "src/gui/panelpreviewimage.h"
#include "src/gui/panelpreviewsound.h"
#include "src/gui/panelpreviewtext.h"
#include "src/gui/selection.h"

namespace Ui {
Expand Down Expand Up @@ -72,12 +76,19 @@ class MainWindow : public QMainWindow {
void setLabels();
void clearLabels();

void showPreviewPanel(QFrame *panel);
void showPreviewPanel();

private:
Ui::MainWindow *_ui;
ResourceTree *_treeModel;
QLabel *_statusLabel;
QList<QLabel*> _resLabels;
Selection _currentSelection;

PanelPreviewEmpty *_panelPreviewEmpty;
PanelPreviewImage *_panelPreviewImage;
PanelPreviewSound *_panelPreviewSound;
PanelPreviewText *_panelPreviewText;
};

} // End of namespace GUI
Expand Down
14 changes: 14 additions & 0 deletions src/gui/panelpreviewempty.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,24 @@
* Preview panel for resources we can't do anything with.
*/

#include "verdigris/wobjectimpl.h"

#include "src/gui/panelpreviewempty.h"

namespace GUI {

W_OBJECT_IMPL(PanelPreviewEmpty)

PanelPreviewEmpty::PanelPreviewEmpty(QObject *parent) {
_layout = new QHBoxLayout();
_layout->setObjectName("previewEmpty");
_label = new QLabel("Empty");
_layout->addWidget(_label);
setLayout(_layout);
}

PanelPreviewEmpty::~PanelPreviewEmpty() {
delete _layout;
}

} // End of namespace GUI
15 changes: 15 additions & 0 deletions src/gui/panelpreviewempty.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,26 @@
#ifndef PANELPREVIEWEMPTY_H
#define PANELPREVIEWEMPTY_H

#include <QFrame>
#include <QHBoxLayout>
#include <QLabel>
#include <QWidget>

#include "verdigris/wobjectdefs.h"

namespace GUI {

class PanelPreviewEmpty : public QFrame {
W_OBJECT(PanelPreviewEmpty)

private:
QHBoxLayout *_layout;
QLabel *_label;

public:
PanelPreviewEmpty(QObject *parent = 0);
~PanelPreviewEmpty();
};

} // End of namespace GUI

Expand Down
16 changes: 15 additions & 1 deletion src/gui/panelpreviewimage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,27 @@
*/

/** @file
* Preview panel for resources we can't do anything with.
* Preview panel for images resources.
*/

#include "verdigris/wobjectimpl.h"

#include "src/gui/panelpreviewimage.h"

namespace GUI {

W_OBJECT_IMPL(PanelPreviewImage)

PanelPreviewImage::PanelPreviewImage(QObject *parent) {
_layout = new QHBoxLayout();
_layout->setObjectName("previewImage");
_label = new QLabel("Image");
_layout->addWidget(_label);
setLayout(_layout);
}

PanelPreviewImage::~PanelPreviewImage() {
delete _layout;
}

} // End of namespace GUI
17 changes: 16 additions & 1 deletion src/gui/panelpreviewimage.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,26 @@
#ifndef PANELPREVIEWIMAGE_H
#define PANELPREVIEWIMAGE_H

#include <QFrame>
#include <QHBoxLayout>
#include <QLabel>
#include <QWidget>

#include "verdigris/wobjectdefs.h"

namespace GUI {


class PanelPreviewImage : public QFrame {
W_OBJECT(PanelPreviewImage)

private:
QHBoxLayout *_layout;
QLabel *_label;

public:
PanelPreviewImage(QObject *parent = 0);
~PanelPreviewImage();
};

} // End of namespace GUI

Expand Down
14 changes: 14 additions & 0 deletions src/gui/panelpreviewsound.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,24 @@
* Preview panel for sound resources.
*/

#include "verdigris/wobjectimpl.h"

#include "src/gui/panelpreviewsound.h"

namespace GUI {

W_OBJECT_IMPL(PanelPreviewSound)

PanelPreviewSound::PanelPreviewSound(QObject *parent) {
_layout = new QHBoxLayout();
_layout->setObjectName("previewSound");
_label = new QLabel("Sound");
_layout->addWidget(_label);
setLayout(_layout);
}

PanelPreviewSound::~PanelPreviewSound() {
delete _layout;
}

} // End of namespace GUI
17 changes: 16 additions & 1 deletion src/gui/panelpreviewsound.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,26 @@
#ifndef PANELPREVIEWSOUND_H
#define PANELPREVIEWSOUND_H

#include <QFrame>
#include <QHBoxLayout>
#include <QLabel>
#include <QWidget>

#include "verdigris/wobjectdefs.h"

namespace GUI {


class PanelPreviewSound : public QFrame {
W_OBJECT(PanelPreviewSound)

private:
QHBoxLayout *_layout;
QLabel *_label;

public:
PanelPreviewSound(QObject *parent = 0);
~PanelPreviewSound();
};

} // End of namespace GUI

Expand Down
45 changes: 45 additions & 0 deletions src/gui/panelpreviewtext.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
/* Phaethon - A FLOSS resource explorer for BioWare's Aurora engine games
*
* Phaethon is the legal property of its developers, whose names
* can be found in the AUTHORS file distributed with this source
* distribution.
*
* Phaethon is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 3
* of the License, or (at your option) any later version.
*
* Phaethon 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 General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Phaethon. If not, see <http://www.gnu.org/licenses/>.
*/

/** @file
* Preview panel for text files.
*/

#include "verdigris/wobjectimpl.h"

#include "src/gui/panelpreviewtext.h"

namespace GUI {

W_OBJECT_IMPL(PanelPreviewText)

PanelPreviewText::PanelPreviewText(QObject *parent) {
_layout = new QHBoxLayout();
_layout->setObjectName("previewText");
_label = new QLabel("Text");
_layout->addWidget(_label);
setLayout(_layout);
}

PanelPreviewText::~PanelPreviewText() {
delete _layout;
}

} // End of namespace GUI

0 comments on commit db3205b

Please sign in to comment.