tycho: use a getIcon function for QIcons
parent
f74981d814
commit
77467ab69b
|
@ -35,6 +35,7 @@ add_library(
|
|||
cc/menu.cc
|
||||
cc/project.cc
|
||||
cc/tycho.h
|
||||
cc/utility.cc
|
||||
resources/resources.qrc
|
||||
ui/about.ui
|
||||
ui/license.ui
|
||||
|
|
|
@ -1,11 +1,6 @@
|
|||
#include "tycho.h"
|
||||
|
||||
extern "C" {
|
||||
void critical_msg(char const *title, char const *msg)
|
||||
{
|
||||
QMessageBox::critical(nullptr, QObject::tr(title), QObject::tr(msg));
|
||||
}
|
||||
|
||||
int main_cc(char *app_path)
|
||||
{
|
||||
dbgPrint("cc entry");
|
||||
|
|
|
@ -31,10 +31,7 @@ QVariant MapModel::data(const QModelIndex &index, int role) const
|
|||
{
|
||||
switch(role) {
|
||||
case Qt::DecorationRole: {
|
||||
auto name = propIcon(index.row());
|
||||
auto icon = name.front() == ':' ? QIcon(name)
|
||||
: QIcon::fromTheme(name);
|
||||
return QVariant::fromValue(icon);
|
||||
return QVariant::fromValue(::getIcon(propIcon(index.row())));
|
||||
}
|
||||
default:
|
||||
return IMapModel::data(index, role);
|
||||
|
|
|
@ -5,6 +5,8 @@ Menu::Menu(QWidget *parent) :
|
|||
{
|
||||
setupUi(this);
|
||||
|
||||
setWindowIcon(::getIcon("pfhor-hand"));
|
||||
|
||||
actionAbout->setShortcut(QKeySequence(QKeySequence::HelpContents));
|
||||
actionClose->setShortcut(QKeySequence(QKeySequence::Close));
|
||||
actionMapProps->setShortcut(QKeySequence(tr("Ctrl+P")));
|
||||
|
@ -58,10 +60,10 @@ void Menu::openAbout()
|
|||
auto text = ui.labelText->text();
|
||||
|
||||
text.replace("AUTHORS",
|
||||
tr(tychoAuthors()).replace(':', ", ").toHtmlEscaped());
|
||||
text.replace("HOMEPAGE", tr(tychoHomepage()));
|
||||
text.replace("REPOSITORY", tr(tychoRepository()));
|
||||
text.replace("VERSION", tr(tychoVersion()));
|
||||
tr(::tychoAuthors()).replace(':', ", ").toHtmlEscaped());
|
||||
text.replace("HOMEPAGE", tr(::tychoHomepage()));
|
||||
text.replace("REPOSITORY", tr(::tychoRepository()));
|
||||
text.replace("VERSION", tr(::tychoVersion()));
|
||||
|
||||
ui.labelText->setText(text);
|
||||
|
||||
|
|
|
@ -159,6 +159,8 @@ std::uint32_t fourCC(byte a, byte b, byte c, byte d)
|
|||
static_cast<std::uint32_t>(d);
|
||||
}
|
||||
|
||||
QIcon getIcon(QString const &name);
|
||||
|
||||
extern "C" {
|
||||
char const *tychoAuthors();
|
||||
char const *tychoHomepage();
|
||||
|
|
|
@ -0,0 +1,21 @@
|
|||
#include "tycho.h"
|
||||
|
||||
QIcon getIcon(QString const &name)
|
||||
{
|
||||
auto res = ":/tycho/icons/" + name + ".png";
|
||||
|
||||
if(QFile(res).exists()) {
|
||||
return QIcon(res);
|
||||
} else {
|
||||
return QIcon::fromTheme(name);
|
||||
}
|
||||
}
|
||||
|
||||
extern "C" {
|
||||
void critical_msg(char const *title, char const *msg)
|
||||
{
|
||||
QMessageBox::critical(nullptr, QObject::tr(title), QObject::tr(msg));
|
||||
}
|
||||
}
|
||||
|
||||
// EOF
|
|
@ -1,9 +1,9 @@
|
|||
<RCC>
|
||||
<qresource prefix="/tycho">
|
||||
<file alias="icons/lines.png">icons/lines.png</file>
|
||||
<file alias="icons/map.png">icons/map.png</file>
|
||||
<file alias="icons/points.png">icons/points.png</file>
|
||||
<file alias="icons/polygons.png">icons/polygons.png</file>
|
||||
<file alias="icons/tycho-lines.png">icons/lines.png</file>
|
||||
<file alias="icons/tycho-map.png">icons/map.png</file>
|
||||
<file alias="icons/tycho-points.png">icons/points.png</file>
|
||||
<file alias="icons/tycho-polygons.png">icons/polygons.png</file>
|
||||
<file alias="icons/pfhor-hand.png">icons/pfhor-hand.png</file>
|
||||
<file>images/tycho1.png</file>
|
||||
<file>images/tycho2.png</file>
|
||||
|
|
|
@ -52,7 +52,7 @@ impl IMapModelTrait for IMapModel
|
|||
{
|
||||
match self.get(index.into()).1.get_type() {
|
||||
EntryType::Image => "image-x-generic".to_string(),
|
||||
EntryType::Map => ":/tycho/icons/map.png".to_string(),
|
||||
EntryType::Map => "tycho-map".to_string(),
|
||||
EntryType::Other => "image-missing".to_string(),
|
||||
EntryType::Physics => "applications-system".to_string(),
|
||||
}
|
||||
|
|
|
@ -19,10 +19,6 @@
|
|||
<property name="windowTitle">
|
||||
<string>Tycho</string>
|
||||
</property>
|
||||
<property name="windowIcon">
|
||||
<iconset resource="../resources/resources.qrc">
|
||||
<normaloff>:/tycho/icons/pfhor-hand.png</normaloff>:/tycho/icons/pfhor-hand.png</iconset>
|
||||
</property>
|
||||
<widget class="QWidget" name="widget">
|
||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||
<property name="spacing">
|
||||
|
@ -153,9 +149,6 @@
|
|||
</action>
|
||||
</widget>
|
||||
<layoutdefault spacing="6" margin="11"/>
|
||||
<resources>
|
||||
<include location="../resources/resources.qrc"/>
|
||||
</resources>
|
||||
<connections>
|
||||
<connection>
|
||||
<sender>actionMapProps</sender>
|
||||
|
|
Loading…
Reference in New Issue