cutter/src/common/Helpers.h

62 lines
1.7 KiB
C
Raw Normal View History

#ifndef QHELPERS_H
#define QHELPERS_H
2017-04-13 15:04:30 +00:00
#include <QString>
#include <QColor>
#include <QSizePolicy>
#include <functional>
2017-04-13 15:04:30 +00:00
class QIcon;
class QPlainTextEdit;
class QTextEdit;
class QString;
2017-04-13 15:04:30 +00:00
class QTreeWidget;
class QTreeWidgetItem;
class QAbstractItemView;
class QAbstractButton;
class QWidget;
2017-12-23 16:42:42 +00:00
class QTreeView;
class QAction;
class QMenu;
class QPaintDevice;
2018-03-21 20:32:32 +00:00
namespace qhelpers {
QString formatBytecount(const long bytecount);
void adjustColumns(QTreeView *tv, int columnCount, int padding);
void adjustColumns(QTreeWidget *tw, int padding);
bool selectFirstItem(QAbstractItemView *itemView);
2018-03-21 20:32:32 +00:00
QTreeWidgetItem *appendRow(QTreeWidget *tw, const QString &str, const QString &str2 = QString(),
const QString &str3 = QString(), const QString &str4 = QString(), const QString &str5 = QString());
2017-04-13 15:04:30 +00:00
2018-03-21 20:32:32 +00:00
void setVerticalScrollMode(QAbstractItemView *tw);
2018-03-21 20:32:32 +00:00
void setCheckedWithoutSignals(QAbstractButton *button, bool checked);
2018-03-21 20:32:32 +00:00
struct SizePolicyMinMax {
QSizePolicy sizePolicy;
int min;
int max;
2018-03-21 20:32:32 +00:00
void restoreWidth(QWidget *widget);
void restoreHeight(QWidget *widget);
};
2018-03-21 20:32:32 +00:00
SizePolicyMinMax forceWidth(QWidget *widget, int width);
SizePolicyMinMax forceHeight(QWidget *widget, int height);
2018-03-21 20:32:32 +00:00
int getMaxFullyDisplayedLines(QTextEdit *textEdit);
int getMaxFullyDisplayedLines(QPlainTextEdit *plainTextEdit);
2018-03-21 20:32:32 +00:00
QByteArray applyColorToSvg(const QByteArray &data, QColor color);
QByteArray applyColorToSvg(const QString &filename, QColor color);
void setThemeIcons(QList<QPair<void*, QString>> supportedIconsNames, std::function<void(void *, const QIcon &)> setter);
void prependQAction(QAction *action, QMenu *menu);
qreal devicePixelRatio(const QPaintDevice *p);
} // qhelpers
#endif // HELPERS_H