Skip to content

Commit 03421b0

Browse files
committed
v6
1 parent 3befec5 commit 03421b0

File tree

6 files changed

+56
-8
lines changed

6 files changed

+56
-8
lines changed

src/config/generalconf.cpp

Lines changed: 36 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ GeneralConf::GeneralConf(QWidget* parent)
5353
initUseJpgForClipboard();
5454
initCopyOnDoubleClick();
5555
initServerTPU();
56+
initCustomEnv();
5657
initWindowOffsets();
5758
initSaveAfterCopy();
5859
initCopyPathAfterSave();
@@ -369,9 +370,9 @@ void GeneralConf::initCheckForUpdates()
369370
void GeneralConf::initAllowMultipleGuiInstances()
370371
{
371372
m_allowMultipleGuiInstances = new QCheckBox(
372-
tr("Allow multiple flameshot GUI instances simultaneously"), this);
373+
tr("Allow multiple Flowshot GUI instances simultaneously"), this);
373374
m_allowMultipleGuiInstances->setToolTip(tr(
374-
"This allows you to take screenshots of Flameshot itself for example"));
375+
"This allows you to take screenshots of Flowshot itself for example"));
375376
m_scrollAreaLayout->addWidget(m_allowMultipleGuiInstances);
376377
connect(m_allowMultipleGuiInstances,
377378
&QCheckBox::clicked,
@@ -396,7 +397,7 @@ void GeneralConf::initAutostart()
396397
{
397398
m_autostart = new QCheckBox(tr("Launch in background at startup"), this);
398399
m_autostart->setToolTip(tr(
399-
"Launch Flameshot daemon (background process) when computer is booted"));
400+
"Launch Flowshot daemon (background process) when computer is booted"));
400401
m_scrollAreaLayout->addWidget(m_autostart);
401402

402403
connect(
@@ -612,6 +613,37 @@ void GeneralConf::initServerTPU()
612613
hboxLayoutKey->addWidget(labelAPIKey);
613614
}
614615

616+
void GeneralConf::initCustomEnv() {
617+
auto* box = new QGroupBox(tr("Force Qt Platform"));
618+
box->setFlat(true);
619+
m_scrollAreaLayout->addWidget(box);
620+
621+
auto* vboxLayout = new QVBoxLayout();
622+
box->setLayout(vboxLayout);
623+
624+
auto* platformLayout = new QHBoxLayout();
625+
m_selectPlatform = new QComboBox(this);
626+
m_selectPlatform->addItem(tr("System (default)"), "default");
627+
m_selectPlatform->addItem(tr("Wayland"), "wayland");
628+
m_selectPlatform->addItem(tr("X11 (XCB, Xwayland)"), "xcb");
629+
m_selectPlatform->setCurrentIndex(m_selectPlatform->findData(ConfigHandler().platform()));
630+
platformLayout->addWidget(m_selectPlatform);
631+
auto* platformWarning =
632+
new QLabel(tr("This setting requires a restart of "
633+
"Flowshot to take effect.\n\nYou may opt to force X11/XCB mode if you have issues with multiple displays or the upload notification window under Wayland.\n\nSetting it to \"default\" will use the default environment variable QT_QPA_PLATFORM."),
634+
this);
635+
platformWarning->setWordWrap(true);
636+
connect(m_selectPlatform,
637+
QOverload<int>::of(&QComboBox::currentIndexChanged),
638+
this,
639+
[this](int index) {
640+
QString platform = m_selectPlatform->itemData(index).toString();
641+
ConfigHandler().setPlatform(platform);
642+
});
643+
vboxLayout->addLayout(platformLayout);
644+
vboxLayout->addWidget(platformWarning);
645+
}
646+
615647
void GeneralConf::initWindowOffsets()
616648
{
617649
auto* box = new QGroupBox(tr("Upload Notification Settings"));
@@ -628,7 +660,7 @@ void GeneralConf::initWindowOffsets()
628660
auto* uploadWindowEnabledWarning =
629661
new QLabel(tr("WAYLAND USERS: This upload notification window does not "
630662
"currently function correctly under Wayland. Please "
631-
"disable if you experience problems and use Wayland."),
663+
"disable or force X11 (XCB) mode in Force Qt Platform."),
632664
this);
633665
uploadWindowEnabledWarning->setWordWrap(true);
634666

src/config/generalconf.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,6 @@ private slots:
6161
void setGeometryLocation(int index);
6262
void setSelGeoHideTime(int v);
6363
void setJpegQuality(int v);
64-
6564
private:
6665
const QString chooseFolder(const QString& currentPath = "");
6766

@@ -153,6 +152,7 @@ private slots:
153152
QSpinBox* m_xywhTimeout;
154153
QSpinBox* m_jpegQuality;
155154
QComboBox* m_selectDisplay;
155+
QComboBox* m_selectPlatform;
156156
void uploadWindowOffsetYEdited();
157157
void uploadWindowOffsetXEdited();
158158
void initWindowOffsets();
@@ -165,4 +165,5 @@ private slots:
165165
void uploadWindowDisplayEdited();
166166
void uploadWindowImageEnabledEdited(bool checked);
167167
void uploadWindowButtonsEnabledEdited(bool checked);
168+
void initCustomEnv();
168169
};

src/main.cpp

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,19 @@ int main(int argc, char* argv[])
137137
wayland_hacks();
138138
#endif
139139

140+
// We need to init QSettings but the Qt application is not yet created
141+
// so we need to do it manually
142+
QSettings settings = QSettings(QSettings::IniFormat,
143+
QSettings::UserScope,
144+
QStringLiteral("flameshot"),
145+
QStringLiteral("flameshot"));
146+
// get the "platform" key from the settings
147+
const QString platform = settings.value(QStringLiteral("platform"), QStringLiteral("default")).toString();
148+
if(platform != "default" && !platform.isEmpty()) {
149+
AbstractLogger::info() << "Setting QT_QPA_PLATFORM to " + platform;
150+
qputenv("QT_QPA_PLATFORM", platform.toUtf8());
151+
}
152+
140153
// required for the button serialization
141154
// TODO: change to QVector in v1.0
142155
qRegisterMetaTypeStreamOperators<QList<int>>("QList<int>");

src/utils/confighandler.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,8 @@ static QMap<class QString, QSharedPointer<ValueHandler>>
139139
OPTION("uploadWindowPreviewWidth" ,LowerBoundedInt(0, 125)),
140140
OPTION("showSelectionGeometry" , BoundedInt (0,5,4)),
141141
OPTION("showSelectionGeometryHideTime", LowerBoundedInt (0, 3000)),
142-
OPTION("jpegQuality", BoundedInt (0,100,75))
142+
OPTION("jpegQuality", BoundedInt (0,100,75)),
143+
OPTION("platform", String ( "default" )),
143144
};
144145

145146
static QMap<QString, QSharedPointer<KeySequence>> recognizedShortcuts = {

src/utils/confighandler.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,7 @@ class ConfigHandler : public QObject
153153
CONFIG_GETTER_SETTER(showSelectionGeometryHideTime,
154154
showSelectionGeometryHideTime,
155155
int)
156+
CONFIG_GETTER_SETTER(platform, setPlatform, QString)
156157

157158
// SPECIAL CASES
158159
bool startupLaunch();

src/utils/globalvalues.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@ int GlobalValues::buttonBaseSize()
1212

1313
QString GlobalValues::versionInfo()
1414
{
15-
return QStringLiteral("Flameshot " APP_VERSION " (" FLAMESHOT_GIT_HASH ")"
16-
"\n(Flowinity fork v5)"
15+
return QStringLiteral("Flowinity Flowshot " APP_VERSION " (" FLAMESHOT_GIT_HASH ")"
16+
"\n(Fork of Flameshot v6)"
1717
"\nCompiled with Qt " QT_VERSION_STR);
1818
}
1919

0 commit comments

Comments
 (0)