Init custom DPI.
This commit is contained in:
@@ -239,3 +239,11 @@ void Controller::postNotification(const QString& roomId, const QString& eventId,
|
||||
notificationsManager.postNotification(roomId, eventId, roomName, senderName,
|
||||
text, icon, iconPath);
|
||||
}
|
||||
|
||||
int Controller::dpi() {
|
||||
return SettingsGroup("Interface").value("dpi", 100).toInt();
|
||||
}
|
||||
|
||||
void Controller::setDpi(int dpi) {
|
||||
SettingsGroup("Interface").setValue("dpi", dpi);
|
||||
}
|
||||
|
||||
@@ -32,6 +32,9 @@ class Controller : public QObject {
|
||||
|
||||
QVector<Connection*> connections() { return m_connections; }
|
||||
|
||||
Q_INVOKABLE int dpi();
|
||||
Q_INVOKABLE void setDpi(int dpi);
|
||||
|
||||
// All the non-Q_INVOKABLE functions.
|
||||
void addConnection(Connection* c);
|
||||
void dropConnection(Connection* c);
|
||||
|
||||
15
src/main.cpp
15
src/main.cpp
@@ -23,10 +23,21 @@
|
||||
using namespace QMatrixClient;
|
||||
|
||||
int main(int argc, char *argv[]) {
|
||||
#if defined(Q_OS_WIN)
|
||||
QCoreApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
|
||||
#if defined(Q_OS_LINUX) || defined(Q_OS_WIN) || defined(Q_OS_FREEBSD)
|
||||
if (qgetenv("QT_SCALE_FACTOR").size() == 0) {
|
||||
QSettings settings("ENCOM", "Spectral");
|
||||
float factor = settings.value("Interface/dpi", 100).toFloat() / 100;
|
||||
|
||||
qDebug() << "DPI:" << factor;
|
||||
|
||||
if (factor != -1)
|
||||
qputenv("QT_SCALE_FACTOR", QString::number(factor).toUtf8());
|
||||
}
|
||||
#endif
|
||||
|
||||
QCoreApplication::setAttribute(Qt::AA_UseHighDpiPixmaps);
|
||||
QCoreApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
|
||||
|
||||
QApplication app(argc, argv);
|
||||
|
||||
app.setOrganizationName("ENCOM");
|
||||
|
||||
Reference in New Issue
Block a user