use "real" resources

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@21007 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
André Pönitz 2007-10-17 18:28:45 +00:00
parent 4e9609f183
commit 33e397dff8
7 changed files with 61 additions and 112 deletions

View File

@ -13,19 +13,12 @@
#include "BulletsModule.h" #include "BulletsModule.h"
#include "qt_helpers.h" #include "qt_helpers.h"
#include "support/filetools.h"
#include <QPixmap> #include <QPixmap>
#include <QPainter> #include <QPainter>
#include <boost/assert.hpp>
namespace lyx { namespace lyx {
using support::libFileSearch;
using std::string;
BulletsModule::BulletsModule(QWidget * , char const * , Qt::WFlags) BulletsModule::BulletsModule(QWidget * , char const * , Qt::WFlags)
{ {
setupUi(this); setupUi(this);
@ -67,7 +60,7 @@ void BulletsModule::setupPanel(QListWidget * lw, QString const & panelname,
bulletpaneCO->addItem(panelname); bulletpaneCO->addItem(panelname);
// get pixmap with bullets // get pixmap with bullets
QPixmap pixmap = QPixmap(toqstr(libFileSearch("images", fname, "png").absFilename())); QPixmap pixmap(":/images/" + toqstr(fname) + ".png");
int const w = pixmap.width() / 6; int const w = pixmap.width() / 6;
int const h = pixmap.height() / 6; int const h = pixmap.height() / 6;

View File

@ -12,8 +12,6 @@
#include <config.h> #include <config.h>
// Qt defines a macro 'signals' that clashes with a boost namespace.
// All is well if the namespace is visible first.
#include "GuiView.h" #include "GuiView.h"
#include "GuiCommandBuffer.h" #include "GuiCommandBuffer.h"
@ -30,7 +28,6 @@
#include "support/lyxalgo.h" #include "support/lyxalgo.h"
#include "support/lstrings.h" #include "support/lstrings.h"
#include "support/filetools.h"
#include <QHBoxLayout> #include <QHBoxLayout>
#include <QKeyEvent> #include <QKeyEvent>
@ -52,7 +49,6 @@ namespace lyx {
namespace frontend { namespace frontend {
using support::prefixIs; using support::prefixIs;
using support::libFileSearch;
namespace { namespace {
@ -98,8 +94,8 @@ GuiCommandBuffer::GuiCommandBuffer(GuiViewBase * view)
transform(lyxaction.func_begin(), lyxaction.func_end(), transform(lyxaction.func_begin(), lyxaction.func_end(),
back_inserter(commands_), firster()); back_inserter(commands_), firster());
QPixmap qpup(toqstr(libFileSearch("images", "up", "png").absFilename())); QPixmap qpup(":/images/up.png");
QPixmap qpdown(toqstr(libFileSearch("images", "down", "png").absFilename())); QPixmap qpdown(":/images/down.png");
QVBoxLayout * top = new QVBoxLayout(this); QVBoxLayout * top = new QVBoxLayout(this);
QHBoxLayout * layout = new QHBoxLayout(0); QHBoxLayout * layout = new QHBoxLayout(0);

View File

@ -24,9 +24,6 @@
#include "frontends/LyXView.h" #include "frontends/LyXView.h"
#include "support/FileFilterList.h" #include "support/FileFilterList.h"
#include "support/convert.h"
#include "support/FileName.h"
#include "support/filetools.h"
using std::string; using std::string;
@ -35,8 +32,6 @@ namespace lyx {
namespace frontend { namespace frontend {
using support::FileFilterList; using support::FileFilterList;
using support::FileName;
using support::libFileSearch;
EmbeddedFilesWidget::EmbeddedFilesWidget EmbeddedFilesWidget::EmbeddedFilesWidget
(GuiEmbeddedFiles & controller) (GuiEmbeddedFiles & controller)
@ -44,17 +39,13 @@ EmbeddedFilesWidget::EmbeddedFilesWidget
{ {
setupUi(this); setupUi(this);
setWindowTitle("LyX: " + qt_("Embedded Files")); setWindowTitle("LyX: " + qt_("Embedded Files"));
// Temporary icons.
FileName icon_path = libFileSearch("images", "tabular-feature_set-all-lines.png"); // FIXME: Temporary icons.
selectPB->setIcon(QIcon(toqstr(icon_path.absFilename()))); selectPB->setIcon(QIcon(":/images/tabular-feature_set-all-lines.png"));
icon_path = libFileSearch("images", "tabular-feature_unset-all-lines.png"); unselectPB->setIcon(QIcon(":/images/tabular-feature_unset-all-lines.png"));
unselectPB->setIcon(QIcon(toqstr(icon_path.absFilename()))); addPB->setIcon(QIcon(":/images/file-open.png"));
icon_path = libFileSearch("images", "file-open.png"); extractPB->setIcon(QIcon(":/images/depth-decrement.png"));
addPB->setIcon(QIcon(toqstr(icon_path.absFilename()))); updatePB->setIcon(QIcon(":/images/depth-increment.png"));
icon_path = libFileSearch("images", "depth-decrement.png");
extractPB->setIcon(QIcon(toqstr(icon_path.absFilename())));
icon_path = libFileSearch("images", "depth-increment.png");
updatePB->setIcon(QIcon(toqstr(icon_path.absFilename())));
updateView(); updateView();
} }
@ -248,7 +239,8 @@ void EmbeddedFilesWidget::on_enableCB_toggled(bool enable)
GuiEmbeddedFiles::GuiEmbeddedFiles(GuiViewBase & parent, Qt::DockWidgetArea area, Qt::WindowFlags flags) GuiEmbeddedFiles::GuiEmbeddedFiles(GuiViewBase & parent,
Qt::DockWidgetArea area, Qt::WindowFlags flags)
: DockView(parent, "embedded", area, flags) : DockView(parent, "embedded", area, flags)
{ {
widget_ = new EmbeddedFilesWidget(*this); widget_ = new EmbeddedFilesWidget(*this);

View File

@ -33,7 +33,6 @@
#include "qt_helpers.h" #include "qt_helpers.h"
#include "InsertTableWidget.h" #include "InsertTableWidget.h"
#include "support/filetools.h"
#include "support/lstrings.h" #include "support/lstrings.h"
#include "support/lyxalgo.h" // sorted #include "support/lyxalgo.h" // sorted
@ -43,20 +42,28 @@
#include <QAction> #include <QAction>
#include <QPixmap> #include <QPixmap>
static void initializeResources()
{
extern void qInitResources();
static bool initialized = false;
if (!initialized) {
qInitResources();
initialized = true;
}
}
namespace lyx { namespace lyx {
namespace frontend {
using std::string; using std::string;
using std::endl; using std::endl;
using support::FileName;
using support::libFileSearch;
using support::subst; using support::subst;
using support::compare; using support::compare;
namespace frontend {
namespace { namespace {
struct PngMap { struct PngMap {
@ -152,8 +159,7 @@ string const find_png(string const & name)
LYXERR(Debug::GUI) << "find_png(" << name << ")\n" LYXERR(Debug::GUI) << "find_png(" << name << ")\n"
<< "Looking for math PNG called \"" << "Looking for math PNG called \""
<< png_name << '"' << std::endl; << png_name << '"' << std::endl;
return png_name;
return libFileSearch("images/math/", png_name, "png").absFilename();
} }
} // namespace anon } // namespace anon
@ -162,44 +168,41 @@ string const find_png(string const & name)
/// return a icon for the given action /// return a icon for the given action
static QIcon getIcon(FuncRequest const & f, bool unknown) static QIcon getIcon(FuncRequest const & f, bool unknown)
{ {
string fullname; initializeResources();
QPixmap pm;
string name1;
string name2;
switch (f.action) { switch (f.action) {
case LFUN_MATH_INSERT: case LFUN_MATH_INSERT:
if (!f.argument().empty()) if (!f.argument().empty())
fullname = find_png(to_utf8(f.argument()).substr(1)); name1 = "math/" + find_png(to_utf8(f.argument()).substr(1));
break; break;
case LFUN_MATH_DELIM: case LFUN_MATH_DELIM:
case LFUN_MATH_BIGDELIM: case LFUN_MATH_BIGDELIM:
fullname = find_png(to_utf8(f.argument())); name1 = find_png(to_utf8(f.argument()));
break; break;
default: default:
string const name = lyxaction.getActionName(f.action); name2 = lyxaction.getActionName(f.action);
string png_name = name; name1 = name2;
if (!f.argument().empty()) if (!f.argument().empty())
png_name = subst(name + ' ' + to_utf8(f.argument()), ' ', '_'); name1 = subst(name2 + ' ' + to_utf8(f.argument()), ' ', '_');
fullname = libFileSearch("images", png_name, "png").absFilename();
if (fullname.empty()) {
// try without the argument
fullname = libFileSearch("images", name, "png").absFilename();
}
} }
if (!fullname.empty()) { if (pm.load(":/images/" + toqstr(name1) + ".png"))
LYXERR(Debug::GUI) << "Full icon name is `" return pm;
<< fullname << '\'' << endl;
return QIcon(toqstr(fullname)); if (pm.load(":/images/" + toqstr(name2) + ".png"))
} return pm;
LYXERR(Debug::GUI) << "Cannot find icon for command \"" LYXERR(Debug::GUI) << "Cannot find icon for command \""
<< lyxaction.getActionName(f.action) << lyxaction.getActionName(f.action)
<< '(' << to_utf8(f.argument()) << ")\"" << endl; << '(' << to_utf8(f.argument()) << ")\"" << endl;
if (unknown) if (unknown)
return QIcon(toqstr(libFileSearch("images", "unknown", "png").absFilename())); pm.load(":/images/unknown.png");
return QIcon();
return pm;
} }
@ -261,8 +264,7 @@ void GuiLayoutBox::updateContents()
TextClass::const_iterator const end = tc.end(); TextClass::const_iterator const end = tc.end();
for (; it != end; ++it) { for (; it != end; ++it) {
// ignore obsolete entries // ignore obsolete entries
if ((*it)->obsoleted_by().empty()) addItem(toqstr(translateIfPossible((*it)->name())));
addItem(toqstr(translateIfPossible((*it)->name())));
} }
// needed to recalculate size hint // needed to recalculate size hint
@ -290,8 +292,7 @@ void GuiLayoutBox::selected(const QString & str)
return; return;
} }
} }
lyxerr << "ERROR (layoutSelected): layout not found!" lyxerr << "ERROR (layoutSelected): layout not found!" << endl;
<< endl;
} }
@ -396,8 +397,7 @@ void GuiToolbar::add(ToolbarItem const & item)
tb->setToolTip(qt_(to_ascii(item.label_))); tb->setToolTip(qt_(to_ascii(item.label_)));
tb->setStatusTip(qt_(to_ascii(item.label_))); tb->setStatusTip(qt_(to_ascii(item.label_)));
tb->setText(qt_(to_ascii(item.label_))); tb->setText(qt_(to_ascii(item.label_)));
FileName icon_path = libFileSearch("images/math", item.name_, "png"); tb->setIcon(QPixmap(":images/math/" + toqstr(item.name_) + ".png"));
tb->setIcon(QIcon(toqstr(icon_path.absFilename())));
connect(this, SIGNAL(iconSizeChanged(QSize)), connect(this, SIGNAL(iconSizeChanged(QSize)),
tb, SLOT(setIconSize(QSize))); tb, SLOT(setIconSize(QSize)));
@ -476,7 +476,6 @@ void GuiToolbar::updateContents()
} }
} // namespace frontend } // namespace frontend
} // namespace lyx } // namespace lyx

View File

@ -50,8 +50,6 @@
#include "ToolbarBackend.h" #include "ToolbarBackend.h"
#include "version.h" #include "version.h"
#include <boost/current_function.hpp>
#include <QAction> #include <QAction>
#include <QApplication> #include <QApplication>
#include <QCloseEvent> #include <QCloseEvent>
@ -74,8 +72,6 @@ using std::vector;
namespace lyx { namespace lyx {
using support::FileName;
using support::libFileSearch;
using support::makeDisplayPath; using support::makeDisplayPath;
extern bool quitting; extern bool quitting;
@ -192,11 +188,7 @@ struct GuiViewBase::GuiViewPrivate
LYXERR(Debug::GUI) << "show banner: " << lyxrc.show_banner << endl; LYXERR(Debug::GUI) << "show banner: " << lyxrc.show_banner << endl;
/// The text to be written on top of the pixmap /// The text to be written on top of the pixmap
QString const text = lyx_version ? QString(lyx_version) : qt_("unknown version"); QString const text = lyx_version ? QString(lyx_version) : qt_("unknown version");
FileName const file = support::libFileSearch("images", "banner", "png"); bg_widget_ = new BackgroundWidget(":/images/banner.png", text);
if (file.empty())
return;
bg_widget_ = new BackgroundWidget(toqstr(file.absFilename()), text);
} }
void setBackground() void setBackground()
@ -229,9 +221,7 @@ GuiViewBase::GuiViewBase(int id)
#ifndef Q_WS_MACX #ifndef Q_WS_MACX
// assign an icon to main form. We do not do it under Qt/Mac, // assign an icon to main form. We do not do it under Qt/Mac,
// since the icon is provided in the application bundle. // since the icon is provided in the application bundle.
FileName const iconname = libFileSearch("images", "lyx", "png"); setWindowIcon(QPixmap(":/images/lyx.png"));
if (!iconname.empty())
setWindowIcon(QPixmap(toqstr(iconname.absFilename())));
#endif #endif
d.tab_widget_ = new TabWorkArea; d.tab_widget_ = new TabWorkArea;

View File

@ -30,8 +30,6 @@
#include "LyXRC.h" #include "LyXRC.h"
#include "version.h" #include "version.h"
#include "support/filetools.h" // LibFileSearch
#include "graphics/GraphicsImage.h" #include "graphics/GraphicsImage.h"
#include "graphics/GraphicsLoader.h" #include "graphics/GraphicsLoader.h"
@ -46,7 +44,6 @@
#include <QTimer> #include <QTimer>
#include <boost/bind.hpp> #include <boost/bind.hpp>
#include <boost/current_function.hpp>
#ifdef Q_WS_X11 #ifdef Q_WS_X11
#include <QX11Info> #include <QX11Info>
@ -288,8 +285,7 @@ void GuiWorkArea::mousePressEvent(QMouseEvent * e)
{ {
if (dc_event_.active && dc_event_ == *e) { if (dc_event_.active && dc_event_ == *e) {
dc_event_.active = false; dc_event_.active = false;
FuncRequest cmd(LFUN_MOUSE_TRIPLE, FuncRequest cmd(LFUN_MOUSE_TRIPLE, e->x(), e->y(),
e->x(), e->y(),
q_button_state(e->button())); q_button_state(e->button()));
dispatch(cmd); dispatch(cmd);
return; return;
@ -693,9 +689,13 @@ QVariant GuiWorkArea::inputMethodQuery(Qt::InputMethodQuery query) const
} }
} }
//////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////
// TabWorkArea implementation. //
// TabWorkArea
//
//////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////
TabWorkArea::TabWorkArea(QWidget * parent): QTabWidget(parent) TabWorkArea::TabWorkArea(QWidget * parent): QTabWidget(parent)
{ {
QPalette pal = palette(); QPalette pal = palette();
@ -705,13 +705,8 @@ TabWorkArea::TabWorkArea(QWidget * parent): QTabWidget(parent)
QToolButton * closeTabButton = new QToolButton(this); QToolButton * closeTabButton = new QToolButton(this);
closeTabButton->setPalette(pal); closeTabButton->setPalette(pal);
FileName const file = support::libFileSearch("images", "closetab", "png"); closeTabButton->setIcon(QIcon(":/images/closetab.png"));
if (!file.empty()) { closeTabButton->setText("Close");
QPixmap pm(toqstr(file.absFilename()));
closeTabButton->setIcon(QIcon(pm));
} else {
closeTabButton->setText("Close");
}
closeTabButton->setAutoRaise(true); closeTabButton->setAutoRaise(true);
closeTabButton->setCursor(Qt::ArrowCursor); closeTabButton->setCursor(Qt::ArrowCursor);
closeTabButton->setToolTip(tr("Close tab")); closeTabButton->setToolTip(tr("Close tab"));

View File

@ -15,8 +15,6 @@
#include "GuiToc.h" #include "GuiToc.h"
#include "qt_helpers.h" #include "qt_helpers.h"
#include "support/filetools.h"
#include "support/lstrings.h"
#include "debug.h" #include "debug.h"
@ -25,21 +23,12 @@
#include <QTreeWidgetItem> #include <QTreeWidgetItem>
#include <vector> #include <vector>
#include <string>
#include <stack>
using std::endl; using std::endl;
using std::pair;
using std::stack;
using std::vector; using std::vector;
using std::string;
namespace lyx { namespace lyx {
using support::FileName;
using support::libFileSearch;
namespace frontend { namespace frontend {
TocWidget::TocWidget(GuiToc & form, QWidget * parent) TocWidget::TocWidget(GuiToc & form, QWidget * parent)
@ -50,16 +39,11 @@ TocWidget::TocWidget(GuiToc & form, QWidget * parent)
connect(&form_, SIGNAL(modelReset()), SLOT(updateGui())); connect(&form_, SIGNAL(modelReset()), SLOT(updateGui()));
FileName icon_path = libFileSearch("images", "promote.png"); moveOutTB->setIcon(QIcon(":/images/promote.png"));
moveOutTB->setIcon(QIcon(toqstr(icon_path.absFilename()))); moveInTB->setIcon(QIcon(":/images/demote.png"));
icon_path = libFileSearch("images", "demote.png"); moveUpTB->setIcon(QIcon(":/images/up.png"));
moveInTB->setIcon(QIcon(toqstr(icon_path.absFilename()))); moveDownTB->setIcon(QIcon(":/images/down.png"));
icon_path = libFileSearch("images", "up.png"); updateTB->setIcon(QIcon(":/images/reload.png"));
moveUpTB->setIcon(QIcon(toqstr(icon_path.absFilename())));
icon_path = libFileSearch("images", "down.png");
moveDownTB->setIcon(QIcon(toqstr(icon_path.absFilename())));
icon_path = libFileSearch("images", "reload.png");
updateTB->setIcon(QIcon(toqstr(icon_path.absFilename())));
// avoid flickering // avoid flickering
tocTV->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOn); tocTV->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOn);