Skip to content

Commit

Permalink
GUI: Rename panel.h -> config.h
Browse files Browse the repository at this point in the history
And properly use the variable defined in it.
  • Loading branch information
fdde authored and DrMcCoy committed Dec 27, 2017
1 parent b299784 commit 6a41bc8
Show file tree
Hide file tree
Showing 5 changed files with 55 additions and 16 deletions.
11 changes: 5 additions & 6 deletions src/gui/panel.h → src/gui/config.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,10 @@
* Config file for Phaethon.
*/

#ifndef PANEL_H
#define PANEL_H
#include "config.h"

namespace Panel {
bool kPreviewMoreTypes = true;
}
namespace GUI {

#endif // PANEL_H
bool kPreviewMoreTypes = false;

} // End of namespace GUI
32 changes: 32 additions & 0 deletions src/gui/config.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
/* 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
* Config file for Phaethon.
*/

#ifndef GUI_CONFIG_H
#define GUI_CONFIG_H

namespace GUI {
extern bool kPreviewMoreTypes;
}

#endif // GUI_CONFIG_H
21 changes: 14 additions & 7 deletions src/gui/mainwindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
#include "src/common/strutil.h"
#include "src/common/system.h"
#include "src/common/writefile.h"
#include "src/gui/config.h"
#include "src/gui/mainwindow.h"
#include "src/gui/panelpreviewempty.h"
#include "src/gui/panelpreviewimage.h"
Expand Down Expand Up @@ -75,7 +76,8 @@ MainWindow::MainWindow(QWidget *parent, const char *title, const QSize &size, co
_panelPreviewEmpty = new PanelPreviewEmpty();
_panelPreviewImage = new PanelPreviewImage();
_panelPreviewSound = new PanelPreviewSound();
_panelPreviewText = new PanelPreviewText();
if (kPreviewMoreTypes)
_panelPreviewText = new PanelPreviewText();
_panelResourceInfo = new PanelResourceInfo();

_treeView = new QTreeView(_splitterLeftRight);
Expand Down Expand Up @@ -209,7 +211,8 @@ MainWindow::MainWindow(QWidget *parent, const char *title, const QSize &size, co
QObject::connect(_panelResourceInfo, &PanelResourceInfo::exportBMUMP3Clicked, this, &MainWindow::exportBMUMP3);
QObject::connect(_panelResourceInfo, &PanelResourceInfo::exportWAVClicked, this, &MainWindow::exportWAV);
QObject::connect(_actionAbout, &QAction::triggered, this, &MainWindow::slotAbout);
QObject::connect(_panelPreviewText, &PanelPreviewText::log, this, &MainWindow::slotLog);
if (kPreviewMoreTypes)
QObject::connect(_panelPreviewText, &PanelPreviewText::log, this, &MainWindow::slotLog);

_actionAbout->setShortcut(QKeySequence(tr("F1")));

Expand All @@ -232,8 +235,9 @@ MainWindow::~MainWindow() {
if (_panelPreviewEmpty)
delete _panelPreviewEmpty;

if (_panelPreviewText)
delete _panelPreviewText;
if (kPreviewMoreTypes)
if (_panelPreviewText)
delete _panelPreviewText;

if (_panelPreviewSound)
delete _panelPreviewSound;
Expand Down Expand Up @@ -339,12 +343,14 @@ void MainWindow::showPreviewPanel() {
{
switch (_currentItem->getFileType()) {
case Aurora::FileType::kFileTypeICO:
showPreviewPanel(_panelPreviewImage);
if (kPreviewMoreTypes)
showPreviewPanel(_panelPreviewImage);
break;

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

default:
Expand All @@ -362,7 +368,8 @@ void MainWindow::resourceSelect(const QItemSelection &selected, const QItemSelec
showPreviewPanel();

_panelPreviewImage->setItem(_currentItem);
_panelPreviewText->setItem(_currentItem);
if (kPreviewMoreTypes)
_panelPreviewText->setItem(_currentItem);
_panelPreviewSound->setItem(_currentItem);
}

Expand Down
4 changes: 2 additions & 2 deletions src/gui/panelpreviewimage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@

#include "verdigris/wobjectimpl.h"

#include "src/gui/panel.h"
#include "src/gui/config.h"
#include "src/gui/panelpreviewimage.h"
#include "src/gui/resourcetreeitem.h"

Expand Down Expand Up @@ -125,7 +125,7 @@ void PanelPreviewImage::setItem(const ResourceTreeItem *item) {
}

void PanelPreviewImage::loadImage() {
if (Panel::kPreviewMoreTypes) {
if (kPreviewMoreTypes) {
if (_currentItem->getFileType() == Aurora::FileType::kFileTypeICO) {
QImageReader reader(_currentItem->getPath());
reader.setAutoTransform(true);
Expand Down
3 changes: 2 additions & 1 deletion src/gui/rules.mk
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ src_gui_libgui_la_SOURCES += \
src/gui/panelpreviewimage.h \
src/gui/panelpreviewtext.h \
src/gui/statusbar.h \
src/gui/panel.h \
src/gui/config.h \
$(EMPTY)

src_gui_libgui_la_SOURCES += \
Expand All @@ -46,4 +46,5 @@ src_gui_libgui_la_SOURCES += \
src/gui/panelpreviewimage.cpp \
src/gui/panelpreviewtext.cpp \
src/gui/statusbar.cpp \
src/gui/config.cpp
$(EMPTY)

0 comments on commit 6a41bc8

Please sign in to comment.