Skip to content

Commit

Permalink
Remove unused functions or marked as maybe_unused
Browse files Browse the repository at this point in the history
  • Loading branch information
rolandlo committed Apr 11, 2023
1 parent 724540d commit 53fcf67
Show file tree
Hide file tree
Showing 23 changed files with 52 additions and 176 deletions.
32 changes: 2 additions & 30 deletions src/core/control/Control.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1282,30 +1282,6 @@ void Control::customizeToolbars() {
this->dragDropHandler->configure();
}

void Control::endDragDropToolbar() {
if (!this->dragDropHandler) {
return;
}

this->dragDropHandler->clearToolbarsFromDragAndDrop();
}

void Control::startDragDropToolbar() {
if (!this->dragDropHandler) {
return;
}

this->dragDropHandler->prepareToolbarsForDragAndDrop();
}

auto Control::isInDragAndDropToolbar() -> bool {
if (!this->dragDropHandler) {
return false;
}

return this->dragDropHandler->isInDragAndDrop();
}

void Control::setShapeTool(ActionType type, bool enabled) {

if (this->toolHandler->getDrawingType() == DRAWING_TYPE_SPLINE && (type != ACTION_TOOL_DRAW_SPLINE || !enabled)) {
Expand Down Expand Up @@ -3142,13 +3118,9 @@ void Control::setClipboardHandlerSelection(EditSelection* selection) {
}
}

void Control::addChangedDocumentListener(DocumentListener* dl) {
this->changedDocumentListeners.push_back(dl);
}
void Control::addChangedDocumentListener(DocumentListener* dl) { this->changedDocumentListeners.push_back(dl); }

void Control::removeChangedDocumentListener(DocumentListener* dl) {
this->changedDocumentListeners.remove(dl);
}
void Control::removeChangedDocumentListener(DocumentListener* dl) { this->changedDocumentListeners.remove(dl); }

void Control::setCopyCutEnabled(bool enabled) { this->clipboardHandler->setCopyCutEnabled(enabled); }

Expand Down
4 changes: 0 additions & 4 deletions src/core/control/Control.h
Original file line number Diff line number Diff line change
Expand Up @@ -184,10 +184,6 @@ class Control:
void changePageBackgroundColor();
void updateBackgroundSizeButton();

void endDragDropToolbar();
void startDragDropToolbar();
bool isInDragAndDropToolbar();

/**
* Loads the view mode (hide/show menu-,tool-&sidebar)
*/
Expand Down
46 changes: 3 additions & 43 deletions src/core/control/FullscreenHandler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,52 +17,14 @@ FullscreenHandler::~FullscreenHandler() = default;

auto FullscreenHandler::isFullscreen() const -> bool { return this->fullscreen; }

void FullscreenHandler::hideWidget(MainWindow* win, const std::string& widgetName) {
if ("sidebarContents" == widgetName && settings->isSidebarVisible()) {
this->sidebarHidden = true;
win->setSidebarVisible(false);

return;
}

if ("mainMenubar" == widgetName) {
// If the menu is hidden, shortcuts are not working anymore
// therefore the menu is not hidden, it's displayed, but invisible
// this costs 1px at the bottom, even if the preferred size is 0px,
// 1px is used by GTK

GtkWidget* mainMenubar = win->get("mainMenubar");
GtkWidget* mainBox = win->get("mainBox");

if (mainMenubar == nullptr || !gtk_widget_is_visible(mainMenubar)) {
// Menu not visible (global menu or something like this)
return;
}

// Remove menu from parent
gtk_container_remove(GTK_CONTAINER(gtk_widget_get_parent(mainMenubar)), mainMenubar);

GtkWidget* fix = gtk_invisible_new();

gtk_widget_set_size_request(fix, 0, 0);
gtk_fixed_put(GTK_FIXED(fix), mainMenubar, 0, 0);

gtk_widget_show(fix);

gtk_box_pack_end(GTK_BOX(mainBox), fix, false, false, 0);

menubarHidden = true;

return;
}
}

void FullscreenHandler::enableFullscreen(MainWindow* win) { gtk_window_fullscreen(GTK_WINDOW(win->getWindow())); }

void FullscreenHandler::disableFullscreen(MainWindow* win) {
gtk_window_unfullscreen(GTK_WINDOW(win->getWindow()));

for (GtkWidget* w: hiddenFullscreenWidgets) { gtk_widget_show(w); }
for (GtkWidget* w: hiddenFullscreenWidgets) {
gtk_widget_show(w);
}
hiddenFullscreenWidgets.clear();

if (this->sidebarHidden) {
Expand Down Expand Up @@ -165,5 +127,3 @@ auto gtk_invisible_get_type() -> GType {

return gtk_invisible_menu_type;
}

auto gtk_invisible_new() -> GtkWidget* { return GTK_WIDGET(g_object_new(gtk_invisible_get_type(), nullptr)); }
1 change: 0 additions & 1 deletion src/core/control/FullscreenHandler.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ class FullscreenHandler {

private:
void enableFullscreen(MainWindow* win);
void hideWidget(MainWindow* win, const std::string& widgetName);
void disableFullscreen(MainWindow* win);

private:
Expand Down
2 changes: 0 additions & 2 deletions src/core/control/PdfCache.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,6 @@ void PdfCache::updateSettings(Settings* settings) {
}
}

void PdfCache::clearCache() { this->data.clear(); }

auto PdfCache::lookup(size_t pdfPageNo) const -> const PdfCacheEntry* {
for (auto& e: this->data) {
if (static_cast<size_t>(e->popplerPage->getPageId()) == pdfPageNo) {
Expand Down
5 changes: 0 additions & 5 deletions src/core/control/PdfCache.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,13 +45,8 @@ class PdfCache {
* @param pageWidth/pageHeight Xournal++ page dimensions
*/
void render(cairo_t* cr, size_t pdfPageNo, double zoom, double pageWidth, double pageHeight);
/**
* @brief Empty the cache
*/
void clearCache();

public:

/**
* @brief Set the maximum tolerable zoom difference, as a percentage.
*
Expand Down
68 changes: 34 additions & 34 deletions src/core/control/settings/Settings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@
#include "gui/toolbarMenubar/model/ColorPalette.h" // for Palette
#include "model/FormatDefinitions.h" // for FormatUnits, XOJ_...
#include "util/Color.h"
#include "util/PathUtil.h" // for getConfigFile
#include "util/Util.h" // for PRECISION_FORMAT_...
#include "util/i18n.h" // for _
#include "util/PathUtil.h" // for getConfigFile
#include "util/Util.h" // for PRECISION_FORMAT_...
#include "util/i18n.h" // for _

#include "ButtonConfig.h" // for ButtonConfig
#include "config-dev.h" // for PALETTE_FILE
Expand Down Expand Up @@ -144,30 +144,31 @@ void Settings::loadDefault() {
this->defaultPdfExportName = _("%{name}_annotated");

// Eraser
this->buttonConfig[BUTTON_ERASER] =
std::make_unique<ButtonConfig>(TOOL_ERASER, Colors::black, TOOL_SIZE_NONE, DRAWING_TYPE_DEFAULT, ERASER_TYPE_NONE);
this->buttonConfig[BUTTON_ERASER] = std::make_unique<ButtonConfig>(TOOL_ERASER, Colors::black, TOOL_SIZE_NONE,
DRAWING_TYPE_DEFAULT, ERASER_TYPE_NONE);
// Middle button
this->buttonConfig[BUTTON_MOUSE_MIDDLE] =
std::make_unique<ButtonConfig>(TOOL_HAND, Colors::black, TOOL_SIZE_NONE, DRAWING_TYPE_DEFAULT, ERASER_TYPE_NONE);
this->buttonConfig[BUTTON_MOUSE_MIDDLE] = std::make_unique<ButtonConfig>(TOOL_HAND, Colors::black, TOOL_SIZE_NONE,
DRAWING_TYPE_DEFAULT, ERASER_TYPE_NONE);
// Right button
this->buttonConfig[BUTTON_MOUSE_RIGHT] =
std::make_unique<ButtonConfig>(TOOL_NONE, Colors::black, TOOL_SIZE_NONE, DRAWING_TYPE_DEFAULT, ERASER_TYPE_NONE);
this->buttonConfig[BUTTON_MOUSE_RIGHT] = std::make_unique<ButtonConfig>(TOOL_NONE, Colors::black, TOOL_SIZE_NONE,
DRAWING_TYPE_DEFAULT, ERASER_TYPE_NONE);
// Touch
this->buttonConfig[BUTTON_TOUCH] =
std::make_unique<ButtonConfig>(TOOL_NONE, Colors::black, TOOL_SIZE_NONE, DRAWING_TYPE_DEFAULT, ERASER_TYPE_NONE);
this->buttonConfig[BUTTON_TOUCH] = std::make_unique<ButtonConfig>(TOOL_NONE, Colors::black, TOOL_SIZE_NONE,
DRAWING_TYPE_DEFAULT, ERASER_TYPE_NONE);
// Default config
this->buttonConfig[BUTTON_DEFAULT] =
std::make_unique<ButtonConfig>(TOOL_PEN, Colors::black, TOOL_SIZE_FINE, DRAWING_TYPE_DEFAULT, ERASER_TYPE_NONE);
this->buttonConfig[BUTTON_DEFAULT] = std::make_unique<ButtonConfig>(TOOL_PEN, Colors::black, TOOL_SIZE_FINE,
DRAWING_TYPE_DEFAULT, ERASER_TYPE_NONE);
// Pen button 1
this->buttonConfig[BUTTON_STYLUS_ONE] =
std::make_unique<ButtonConfig>(TOOL_NONE, Colors::black, TOOL_SIZE_NONE, DRAWING_TYPE_DEFAULT, ERASER_TYPE_NONE);
this->buttonConfig[BUTTON_STYLUS_ONE] = std::make_unique<ButtonConfig>(TOOL_NONE, Colors::black, TOOL_SIZE_NONE,
DRAWING_TYPE_DEFAULT, ERASER_TYPE_NONE);
// Pen button 2
this->buttonConfig[BUTTON_STYLUS_TWO] =
std::make_unique<ButtonConfig>(TOOL_NONE, Colors::black, TOOL_SIZE_NONE, DRAWING_TYPE_DEFAULT, ERASER_TYPE_NONE);
this->buttonConfig[BUTTON_STYLUS_TWO] = std::make_unique<ButtonConfig>(TOOL_NONE, Colors::black, TOOL_SIZE_NONE,
DRAWING_TYPE_DEFAULT, ERASER_TYPE_NONE);

// default view modes
this->activeViewMode = PresetViewModeIds::VIEW_MODE_DEFAULT;
this->viewModes = std::vector<ViewMode>{VIEW_MODE_STRUCT_DEFAULT, VIEW_MODE_STRUCT_FULLSCREEN, VIEW_MODE_STRUCT_PRESENTATION};
this->viewModes =
std::vector<ViewMode>{VIEW_MODE_STRUCT_DEFAULT, VIEW_MODE_STRUCT_FULLSCREEN, VIEW_MODE_STRUCT_PRESENTATION};

this->touchZoomStartThreshold = 0.0;

Expand Down Expand Up @@ -240,9 +241,7 @@ auto Settings::loadViewMode(ViewModeId mode) -> bool {
return true;
}

auto Settings::getViewModes() const -> const std::vector<ViewMode>& {
return this->viewModes;
}
auto Settings::getViewModes() const -> const std::vector<ViewMode>& { return this->viewModes; }

/**
* tempg_ascii_strtod
Expand Down Expand Up @@ -472,11 +471,14 @@ void Settings::parseItem(xmlDocPtr doc, xmlNodePtr cur) {
} else if (xmlStrcmp(name, reinterpret_cast<const xmlChar*>("autosaveTimeout")) == 0) {
this->autosaveTimeout = g_ascii_strtoll(reinterpret_cast<const char*>(value), nullptr, 10);
} else if (xmlStrcmp(name, reinterpret_cast<const xmlChar*>("defaultViewModeAttributes")) == 0) {
this->viewModes.at(PresetViewModeIds::VIEW_MODE_DEFAULT) = settingsStringToViewMode(reinterpret_cast<const char*>(value));
this->viewModes.at(PresetViewModeIds::VIEW_MODE_DEFAULT) =
settingsStringToViewMode(reinterpret_cast<const char*>(value));
} else if (xmlStrcmp(name, reinterpret_cast<const xmlChar*>("fullscreenViewModeAttributes")) == 0) {
this->viewModes.at(PresetViewModeIds::VIEW_MODE_FULLSCREEN) = settingsStringToViewMode(reinterpret_cast<const char*>(value));
this->viewModes.at(PresetViewModeIds::VIEW_MODE_FULLSCREEN) =
settingsStringToViewMode(reinterpret_cast<const char*>(value));
} else if (xmlStrcmp(name, reinterpret_cast<const xmlChar*>("presentationViewModeAttributes")) == 0) {
this->viewModes.at(PresetViewModeIds::VIEW_MODE_PRESENTATION) = settingsStringToViewMode(reinterpret_cast<const char*>(value));
this->viewModes.at(PresetViewModeIds::VIEW_MODE_PRESENTATION) =
settingsStringToViewMode(reinterpret_cast<const char*>(value));
} else if (xmlStrcmp(name, reinterpret_cast<const xmlChar*>("touchZoomStartThreshold")) == 0) {
this->touchZoomStartThreshold = g_ascii_strtod(reinterpret_cast<const char*>(value), nullptr);
} else if (xmlStrcmp(name, reinterpret_cast<const xmlChar*>("pageRerenderThreshold")) == 0) {
Expand Down Expand Up @@ -936,7 +938,8 @@ void Settings::save() {

auto defaultViewModeAttributes = viewModeToSettingsString(viewModes.at(PresetViewModeIds::VIEW_MODE_DEFAULT));
auto fullscreenViewModeAttributes = viewModeToSettingsString(viewModes.at(PresetViewModeIds::VIEW_MODE_FULLSCREEN));
auto presentationViewModeAttributes = viewModeToSettingsString(viewModes.at(PresetViewModeIds::VIEW_MODE_PRESENTATION));
auto presentationViewModeAttributes =
viewModeToSettingsString(viewModes.at(PresetViewModeIds::VIEW_MODE_PRESENTATION));
SAVE_STRING_PROP(defaultViewModeAttributes);
ATTACH_COMMENT("Which GUI elements are shown in default view mode, separated by a colon (,)");
SAVE_STRING_PROP(fullscreenViewModeAttributes);
Expand All @@ -948,7 +951,8 @@ void Settings::save() {
ATTACH_COMMENT("The cursor icon used with a stylus, allowed values are \"none\", \"dot\", \"big\", \"arrow\"");

xmlNode = saveProperty("eraserVisibility", eraserVisibilityToString(this->eraserVisibility), root);
ATTACH_COMMENT("The eraser cursor visibility used with a stylus, allowed values are \"never\", \"always\", \"hover\", \"touch\"");
ATTACH_COMMENT("The eraser cursor visibility used with a stylus, allowed values are \"never\", \"always\", "
"\"hover\", \"touch\"");

xmlNode = saveProperty("iconTheme", iconThemeToString(this->iconTheme), root);
ATTACH_COMMENT("The icon theme, allowed values are \"iconsColor\", \"iconsLucide\"");
Expand Down Expand Up @@ -1614,7 +1618,9 @@ void Settings::setPresentationMode(bool presentationMode) {
save();
}

auto Settings::isPresentationMode() const -> bool { return this->activeViewMode == PresetViewModeIds::VIEW_MODE_PRESENTATION; }
auto Settings::isPresentationMode() const -> bool {
return this->activeViewMode == PresetViewModeIds::VIEW_MODE_PRESENTATION;
}

void Settings::setPressureSensitivity(gboolean presureSensitivity) {
if (this->pressureSensitivity == presureSensitivity) {
Expand Down Expand Up @@ -1810,10 +1816,6 @@ auto Settings::areStockIconsUsed() const -> bool { return this->useStockIcons; }

auto Settings::isFullscreen() const -> bool { return this->fullscreenActive; }

void Settings::setIsFullscreen(bool isFullscreen) {
this->fullscreenActive = isFullscreen;
}

auto Settings::isSidebarVisible() const -> bool { return this->showSidebar; }

void Settings::setSidebarVisible(bool visible) {
Expand Down Expand Up @@ -1883,9 +1885,7 @@ auto Settings::getButtonConfig(unsigned int id) -> ButtonConfig* {
return this->buttonConfig[id].get();
}

void Settings::setViewMode(ViewModeId mode, ViewMode viewMode) {
viewModes.at(mode) = viewMode;
}
void Settings::setViewMode(ViewModeId mode, ViewMode viewMode) { viewModes.at(mode) = viewMode; }

auto Settings::getTouchZoomStartThreshold() const -> double { return this->touchZoomStartThreshold; }
void Settings::setTouchZoomStartThreshold(double threshold) {
Expand Down
5 changes: 2 additions & 3 deletions src/core/control/settings/Settings.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,13 @@

#pragma once

#include <array> // for array
#include <cstddef> // for size_t
#include <map> // for map
#include <memory> // for make_shared, shared_ptr
#include <string> // for string, basic_string
#include <utility> // for pair
#include <vector> // for vector
#include <array> // for array

#include <gdk/gdk.h> // for GdkInputSource, GdkD...
#include <glib.h> // for gchar, gboolean, gint
Expand All @@ -30,8 +30,8 @@

#include "LatexSettings.h" // for LatexSettings
#include "SettingsEnums.h" // for InputDeviceTypeOption
#include "filesystem.h" // for path
#include "ViewModes.h" // for ViewModes
#include "filesystem.h" // for path

struct Palette;

Expand Down Expand Up @@ -211,7 +211,6 @@ class Settings {
bool isMainWndMaximized() const;

bool isFullscreen() const;
void setIsFullscreen(bool isFullscreen);

bool isSidebarVisible() const;
void setSidebarVisible(bool visible);
Expand Down
2 changes: 1 addition & 1 deletion src/core/gui/LegacyRedrawable.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ class [[deprecated]] LegacyRedrawable {
* for refreshing the view buffer (if you have changed the document) call rerender.
*/
virtual void repaintArea(double x1, double y1, double x2, double y2) const = 0;
void repaintRect(double x, double y, double width, double height) const;
[[maybe_unused]] void repaintRect(double x, double y, double width, double height) const;
[[maybe_unused]] void repaintElement(Element* e) const;

/**
Expand Down
4 changes: 1 addition & 3 deletions src/core/gui/MainWindow.h
Original file line number Diff line number Diff line change
Expand Up @@ -112,9 +112,7 @@ class MainWindow: public GladeGui, public LayerCtrlListener {

Layout* getLayout() const;

bool isGestureActive() const;

Menubar* getMenubar() const;
[[maybe_unused]] Menubar* getMenubar() const;

/**
* Disable kinetic scrolling if there is a touchscreen device that was manually mapped to another enabled input
Expand Down
7 changes: 3 additions & 4 deletions src/core/gui/PageView.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -304,8 +304,9 @@ auto XojPageView::onButtonPressEvent(const PositionInputData& pos) -> bool {
auto* zoomControl = this->getXournal()->getControl()->getZoomControl();
this->verticalSpace = std::make_unique<VerticalToolHandler>(this->page, this->settings, y, pos.isControlDown());
this->overlayViews.emplace_back(this->verticalSpace->createView(this, zoomControl, this->settings));
} else if (h->getToolType() == TOOL_SELECT_RECT || h->getToolType() == TOOL_SELECT_REGION || h->getToolType() == TOOL_SELECT_MULTILAYER_RECT ||
h->getToolType() == TOOL_SELECT_MULTILAYER_REGION || h->getToolType() == TOOL_PLAY_OBJECT || h->getToolType() == TOOL_SELECT_OBJECT ||
} else if (h->getToolType() == TOOL_SELECT_RECT || h->getToolType() == TOOL_SELECT_REGION ||
h->getToolType() == TOOL_SELECT_MULTILAYER_RECT || h->getToolType() == TOOL_SELECT_MULTILAYER_REGION ||
h->getToolType() == TOOL_PLAY_OBJECT || h->getToolType() == TOOL_SELECT_OBJECT ||
h->getToolType() == TOOL_SELECT_PDF_TEXT_LINEAR || h->getToolType() == TOOL_SELECT_PDF_TEXT_RECT) {
if (h->getToolType() == TOOL_SELECT_RECT) {
if (!selection) {
Expand Down Expand Up @@ -778,8 +779,6 @@ void XojPageView::deleteOverlayView(xoj::view::OverlayView* v, const Range& rg)
}
}

int XojPageView::getDPIScaling() const { return xournal->getDpiScaleFactor(); }

double XojPageView::getZoom() const { return xournal->getZoom(); }

ZoomControl* XojPageView::getZoomControl() const { return this->getXournal()->getControl()->getZoomControl(); }
Expand Down
3 changes: 1 addition & 2 deletions src/core/gui/PageView.h
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ class XojPdfPage;
namespace xoj::view {
class OverlayView;
class ToolView;
}
} // namespace xoj::view

class XojPageView: public LegacyRedrawable, public PageListener, public xoj::view::Repaintable {
public:
Expand Down Expand Up @@ -78,7 +78,6 @@ class XojPageView: public LegacyRedrawable, public PageListener, public xoj::vie
*/
void deleteOverlayView(xoj::view::OverlayView* v, const Range& rg) override;

int getDPIScaling() const override;
double getZoom() const override;
ZoomControl* getZoomControl() const override;
Range getVisiblePart() const override;
Expand Down
2 changes: 1 addition & 1 deletion src/core/gui/dialog/SettingsDialog.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ class SettingsDialog: public GladeGui {
* Set active regions
*/
void enableWithCheckbox(const std::string& checkbox, const std::string& widget);
void disableWithCheckbox(const std::string& checkbox, const std::string& widget);
[[maybe_unused]] void disableWithCheckbox(const std::string& checkbox, const std::string& widget);

/*
* Listeners for changes to settings.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,5 +55,3 @@ void ToolbarDragDropHandler::configure() {

this->customizeDialog->show(GTK_WINDOW(win->getWindow()));
}

auto ToolbarDragDropHandler::isInDragAndDrop() -> bool { return !this->toolbars.empty(); }

0 comments on commit 53fcf67

Please sign in to comment.