Fixing review comments

This commit is contained in:
Pandagrapher 2023-10-13 11:12:37 +02:00
parent 0c2d7c1382
commit 488a157476
11 changed files with 41 additions and 66 deletions

View File

@ -178,9 +178,7 @@ bool DynamicProfileRules::loadRules()
const Glib::ustring fileName = Glib::build_filename (Options::rtdir, "dynamicprofile.cfg");
try {
if (Glib::file_test(fileName, Glib::FILE_TEST_EXISTS)) {
kf.load_from_file (fileName);
} else {
if (!(Glib::file_test(fileName, Glib::FILE_TEST_EXISTS) && kf.load_from_file (fileName))) {
return false;
}
} catch (Glib::Error &e) {

View File

@ -25,9 +25,9 @@
bool BatchQueueButtonSet::iconsLoaded = false;
std::shared_ptr<RTSurface> BatchQueueButtonSet::cancelIcon = std::shared_ptr<RTSurface>(nullptr);
std::shared_ptr<RTSurface> BatchQueueButtonSet::headIcon = std::shared_ptr<RTSurface>(nullptr);
std::shared_ptr<RTSurface> BatchQueueButtonSet::tailIcon = std::shared_ptr<RTSurface>(nullptr);
std::shared_ptr<RTSurface> BatchQueueButtonSet::cancelIcon;
std::shared_ptr<RTSurface> BatchQueueButtonSet::headIcon;
std::shared_ptr<RTSurface> BatchQueueButtonSet::tailIcon;
Glib::ustring BatchQueueButtonSet::moveHeadToolTip;
Glib::ustring BatchQueueButtonSet::moveEndToolTip;

View File

@ -228,13 +228,13 @@ void BatchQueuePanel::updateTab (int qsize, int forceOrientation)
}
} else {
if (!qsize ) {
grid->attach_next_to(*Gtk::manage (new RTImage ("gears")), Gtk::POS_RIGHT, 1, 1);
grid->attach_next_to(*Gtk::manage (new RTImage ("gears", Gtk::ICON_SIZE_LARGE_TOOLBAR)), Gtk::POS_RIGHT, 1, 1);
grid->attach_next_to(*Gtk::manage (new Gtk::Label (M("MAIN_FRAME_QUEUE") )), Gtk::POS_RIGHT, 1, 1);
} else if (qStartStop->get_active()) {
grid->attach_next_to(*Gtk::manage (new RTImage ("gears-play")), Gtk::POS_RIGHT, 1, 1);
grid->attach_next_to(*Gtk::manage (new RTImage ("gears-play", Gtk::ICON_SIZE_LARGE_TOOLBAR)), Gtk::POS_RIGHT, 1, 1);
grid->attach_next_to(*Gtk::manage (new Gtk::Label (M("MAIN_FRAME_QUEUE") + " [" + Glib::ustring::format( qsize ) + "]" )), Gtk::POS_RIGHT, 1, 1);
} else {
grid->attach_next_to(*Gtk::manage (new RTImage ("gears-pause")), Gtk::POS_RIGHT, 1, 1);
grid->attach_next_to(*Gtk::manage (new RTImage ("gears-pause", Gtk::ICON_SIZE_LARGE_TOOLBAR)), Gtk::POS_RIGHT, 1, 1);
grid->attach_next_to(*Gtk::manage (new Gtk::Label (M("MAIN_FRAME_QUEUE") + " [" + Glib::ustring::format( qsize ) + "]" )), Gtk::POS_RIGHT, 1, 1);
}

View File

@ -43,12 +43,10 @@ void CursorManager::init (Glib::RefPtr<Gdk::Window> mainWindow)
// - By default, cursor hotspot is located at middle of surface.
// Use (offX, offY) between -1 and 0.99 to move cursor hotspot
auto cursor_surf = RTSurface(name, Gtk::ICON_SIZE_MENU);
double offXb = std::min(std::max(-1., offX), 0.99); // offX should belong to (-1; 0.99)
double offYb = std::min(std::max(-1., offY), 0.99); // offY should belong to (-1; 0.99)
auto cursor = Gdk::Cursor::create(this->display,
cursor_surf.get(),
cursor_surf.getWidth() / 2 * (1. + offXb),
cursor_surf.getHeight() / 2 * (1. + offYb));
std::min(std::max(cursor_surf.getWidth() / 2 * (1. + offX), 0.), static_cast<double>(cursor_surf.getWidth())),
std::min(std::max(cursor_surf.getHeight() / 2 * (1. + offY), 0.), static_cast<double>(cursor_surf.getHeight())));
if (!cursor) {
cursor = Gdk::Cursor::create(this->display, fb_cursor);
@ -58,7 +56,7 @@ void CursorManager::init (Glib::RefPtr<Gdk::Window> mainWindow)
};
cAdd = createCursor("crosshair-hicontrast", Gdk::PLUS);
cAddPicker = createCursor("color-picker-add-hicontrast", Gdk::PLUS, -0.333, 0.75);
cAddPicker = createCursor("color-picker-add-hicontrast", Gdk::PLUS, -0.666, 0.75);
cCropDraw = createCursor("crop-point-hicontrast", Gdk::DIAMOND_CROSS);
cCrosshair = createCursor("crosshair-hicontrast", Gdk::CROSSHAIR);
cEmpty = createCursor("empty", Gdk::BLANK_CURSOR);
@ -74,7 +72,7 @@ void CursorManager::init (Glib::RefPtr<Gdk::Window> mainWindow)
cMoveXY = createCursor("node-move-xy-hicontrast", Gdk::FLEUR);
cMoveY = createCursor("node-move-y-hicontrast", Gdk::SB_V_DOUBLE_ARROW);
cRotate = createCursor("rotate-aroundnode-hicontrast", Gdk::EXCHANGE);
cWB = createCursor("color-picker-hicontrast", Gdk::TARGET, -0.333, 0.75);
cWB = createCursor("color-picker-hicontrast", Gdk::TARGET, -0.666, 0.75);
cWait = createCursor("gears", Gdk::CLOCK);
window = mainWindow;

View File

@ -63,7 +63,7 @@ protected:
ExifFilterSettings curefs;
FilterPanelListener* listener;
std::shared_ptr<RTSurface> ornamentSurface;
std::unique_ptr<RTSurface> ornamentSurface;
public:
FilterPanel ();

View File

@ -64,7 +64,7 @@ LensProfilePanel::LensProfilePanel() :
lensfunCameras(Gtk::manage((new MyComboBox()))),
lensfunLensesLbl(Gtk::manage((new Gtk::Label(M("EXIFFILTER_LENS"))))),
lensfunLenses(Gtk::manage((new MyComboBox()))),
warning(Gtk::manage(new RTImage("warning"))),
warning(Gtk::manage(new RTImage("warning", Gtk::ICON_SIZE_LARGE_TOOLBAR))),
ckbUseDist(Gtk::manage((new Gtk::CheckButton(M("TP_LENSPROFILE_USE_GEOMETRIC"))))),
ckbUseVign(Gtk::manage((new Gtk::CheckButton(M("TP_LENSPROFILE_USE_VIGNETTING"))))),
ckbUseCA(Gtk::manage((new Gtk::CheckButton(M("TP_LENSPROFILE_USE_CA")))))

View File

@ -82,20 +82,7 @@ RTImage::RTImage (const Glib::RefPtr<const Gio::Icon>& gIcon, const Gtk::IconSiz
void RTImage::set_from_icon_name(const Glib::ustring& iconName)
{
this->icon_name = iconName;
// Set surface from icon cache
surface = RTImageCache::getCachedSurface(this->icon_name, this->size);
// Add it to the RTImage if surface exists
if (surface) {
set(surface->get());
}
// Unset Gio::Icon if firstly exists
if (this->g_icon) {
g_icon = Glib::RefPtr<const Gio::Icon>();
}
set_from_icon_name(iconName, this->size);
}
void RTImage::set_from_icon_name(const Glib::ustring& iconName, const Gtk::IconSize iconSize)
@ -119,17 +106,7 @@ void RTImage::set_from_icon_name(const Glib::ustring& iconName, const Gtk::IconS
void RTImage::set_from_gicon(const Glib::RefPtr<const Gio::Icon>& gIcon)
{
this->g_icon = gIcon;
// Set image from Gio::Icon
set(this->g_icon, this->size);
// Unset surface if previously chosen
this->icon_name = "";
if (surface) {
surface = std::shared_ptr<RTSurface>();
}
set_from_gicon(gIcon, this->size);
}
void RTImage::set_from_gicon(const Glib::RefPtr<const Gio::Icon>& gIcon, const Gtk::IconSize iconSize)

View File

@ -32,7 +32,7 @@ extern Glib::ustring argv0;
double RTScalable::dpi = 96.;
int RTScalable::scale = 1;
void RTScalable::updateDPInScale(const Gtk::Window* window, double &newDPI, int &newScale)
void RTScalable::getDPInScale(const Gtk::Window* window, double &newDPI, int &newScale)
{
if (window) {
const auto screen = window->get_screen();
@ -169,6 +169,7 @@ Cairo::RefPtr<Cairo::ImageSurface> RTScalable::loadSurfaceFromSVG(const Glib::us
if (error) {
std::cerr << "Failed to load SVG file \"" << fname << "\": " << std::endl
<< Glib::ustring(error->message) << std::endl;
free(error);
return surf;
}
@ -215,6 +216,7 @@ Cairo::RefPtr<Cairo::ImageSurface> RTScalable::loadSurfaceFromSVG(const Glib::us
if (!success && error) {
std::cerr << "Failed to load SVG file \"" << fname << "\": " << std::endl
<< Glib::ustring(error->message) << std::endl;
free(error);
return surf;
}
@ -234,12 +236,12 @@ Cairo::RefPtr<Cairo::ImageSurface> RTScalable::loadSurfaceFromSVG(const Glib::us
void RTScalable::init(const Gtk::Window* window)
{
// Retrieve DPI and Scale paremeters from OS
updateDPInScale(window, dpi, scale);
getDPInScale(window, dpi, scale);
}
void RTScalable::setDPInScale (const Gtk::Window* window)
{
updateDPInScale(window, dpi, scale);
getDPInScale(window, dpi, scale);
}
void RTScalable::setDPInScale (const double newDPI, const int newScale)

View File

@ -54,7 +54,7 @@ class RTScalable
private:
static double dpi;
static int scale;
static void updateDPInScale(const Gtk::Window* window, double &newDPI, int &newScale);
static void getDPInScale(const Gtk::Window* window, double &newDPI, int &newScale);
protected:
static Cairo::RefPtr<Cairo::ImageSurface> loadSurfaceFromIcon(const Glib::ustring &icon_name, const Gtk::IconSize iconSize = Gtk::ICON_SIZE_SMALL_TOOLBAR);

View File

@ -32,7 +32,7 @@ RTSurface::RTSurface() :
scaleBack = RTScalable::getScale();
// Initialize other private parameters
type = RTSurface::InvalidType;
type = RTSurfaceType::InvalidType;
name = "";
icon_size = Gtk::ICON_SIZE_INVALID;
}
@ -45,7 +45,7 @@ RTSurface::RTSurface(const Glib::ustring &icon_name, const Gtk::IconSize iconSiz
if (surface) {
// Save private parameters
type = RTSurface::IconType;
type = RTSurfaceType::IconType;
name = icon_name;
icon_size = iconSize;
}
@ -67,7 +67,7 @@ RTSurface::RTSurface(const Glib::ustring &fname) :
if (surface) {
// Save private parameter
type = RTSurface::PNGType;
type = RTSurfaceType::PNGType;
name = fname;
}
}
@ -79,7 +79,7 @@ RTSurface::RTSurface(const Glib::ustring &fname) :
if (surface) {
// Save private parameter
type = RTSurface::SVGType;
type = RTSurfaceType::SVGType;
name = fname;
}
}
@ -92,7 +92,7 @@ int RTSurface::getWidth()
if (hasSurface()) {
switch (type) {
case RTSurface::IconType:
case RTSurfaceType::IconType:
// Get width from Gtk::IconSize
if (!Gtk::IconSize::lookup(icon_size, w, h)) { // Size in invalid
w = h = -1; // Invalid case
@ -100,15 +100,15 @@ int RTSurface::getWidth()
return w;
case RTSurface::PNGType:
case RTSurfaceType::PNGType:
// Directly return surface width
return surface->get_width();
case RTSurface::SVGType:
case RTSurfaceType::SVGType:
// Returned size shall consider the scaling
return (surface->get_width() / RTScalable::getScale());
case RTSurface::InvalidType:
case RTSurfaceType::InvalidType:
default:
// Invalid case
return -1;
@ -125,7 +125,7 @@ int RTSurface::getHeight()
if (hasSurface()) {
switch (type) {
case RTSurface::IconType:
case RTSurfaceType::IconType:
// Get width from Gtk::IconSize
if (!Gtk::IconSize::lookup(icon_size, w, h)) { // Size in invalid
w = h = -1; // Invalid case
@ -133,15 +133,15 @@ int RTSurface::getHeight()
return h;
case RTSurface::PNGType:
case RTSurfaceType::PNGType:
// Directly return surface width
return surface->get_height();
case RTSurface::SVGType:
case RTSurfaceType::SVGType:
// Returned size shall consider the scaling
return (surface->get_height() / RTScalable::getScale());
case RTSurface::InvalidType:
case RTSurfaceType::InvalidType:
default:
// Invalid case
return -1;
@ -175,13 +175,13 @@ void RTSurface::updateSurface()
{
// Update surface based on the scale
switch (type) {
case RTSurface::IconType :
case RTSurfaceType::IconType :
surface = RTScalable::loadSurfaceFromIcon(name, icon_size);
break;
case RTSurface::PNGType :
case RTSurfaceType::PNGType :
surface = RTScalable::loadSurfaceFromPNG(name);
break;
case RTSurface::SVGType :
case RTSurfaceType::SVGType :
surface = RTScalable::loadSurfaceFromSVG(name);
break;
default :

View File

@ -27,11 +27,11 @@
class RTSurface final : public RTScalable
{
public:
enum RTSurfaceType {
InvalidType = 1,
IconType = 2,
PNGType = 3,
SVGType = 4
enum class RTSurfaceType {
InvalidType,
IconType,
PNGType,
SVGType
};
private: