Skip to content

Commit 2866cd4

Browse files
committed
Port to StandardPaths
1 parent 2942316 commit 2866cd4

File tree

4 files changed

+27
-27
lines changed

4 files changed

+27
-27
lines changed

gui/adddictdialog.cpp

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
#include <QFileDialog>
1616
#include <QLineEdit>
1717
#include <QPushButton>
18-
#include <fcitx-utils/standardpath.h>
18+
#include <fcitx-utils/standardpaths.h>
1919
#include <fcitxqti18nhelper.h>
2020

2121
#define FCITX_CONFIG_DIR "$FCITX_CONFIG_DIR"
@@ -95,17 +95,17 @@ void AddDictDialog::browseClicked() {
9595
path = QFileDialog::getOpenFileName(this, _("Select Dictionary File"),
9696
info.path());
9797
} else {
98-
auto fcitxBasePath = stringutils::joinPath(
99-
StandardPath::global().userDirectory(StandardPath::Type::PkgData),
100-
"cskk");
98+
auto fcitxBasePath =
99+
StandardPaths::global().userDirectory(StandardPathsType::PkgData) /
100+
"cskk";
101101
fs::makePath(fcitxBasePath);
102102
QString fcitxConfigBasePath =
103103
QDir::cleanPath(QString::fromStdString(fcitxBasePath));
104104

105105
if (path.isEmpty()) {
106-
auto baseDataPath = stringutils::joinPath(
107-
StandardPath::global().userDirectory(StandardPath::Type::Data),
108-
"fcitx5-cskk");
106+
auto baseDataPath =
107+
StandardPaths::global().userDirectory(StandardPathsType::Data) /
108+
"fcitx5-cskk";
109109
fs::makePath(baseDataPath);
110110
QString basePath = QDir::cleanPath(QString::fromStdString(baseDataPath));
111111
path = basePath;

gui/dictmodel.cpp

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
#include <QStringList>
1313
#include <QTemporaryFile>
1414
#include <QtGlobal>
15-
#include <fcitx-utils/standardpath.h>
15+
#include <fcitx-utils/standardpaths.h>
1616
#include <fcntl.h>
1717
#include <iostream>
1818

@@ -23,16 +23,16 @@ const std::string config_path = "cskk/dictionary_list";
2323
SkkDictModel::SkkDictModel(QObject *parent) : QAbstractListModel(parent) {}
2424

2525
void SkkDictModel::defaults() {
26-
auto path = StandardPath::fcitxPath("pkgdatadir", config_path.c_str());
27-
QFile f(path.data());
26+
auto path = StandardPaths::fcitxPath("pkgdatadir", config_path.c_str());
27+
QFile f(path);
2828
if (f.open(QIODevice::ReadOnly)) {
2929
load(f);
3030
}
3131
}
3232

3333
void SkkDictModel::load() {
34-
auto file = StandardPath::global().open(StandardPath::Type::PkgData,
35-
config_path, O_RDONLY);
34+
auto file =
35+
StandardPaths::global().open(StandardPathsType::PkgData, config_path);
3636
if (file.fd() < 0) {
3737
return;
3838
}
@@ -61,8 +61,8 @@ void SkkDictModel::load(QFile &file) {
6161
}
6262

6363
bool SkkDictModel::save() {
64-
return StandardPath::global().safeSave(
65-
StandardPath::Type::PkgData, config_path, [this](int fd) {
64+
return StandardPaths::global().safeSave(
65+
StandardPathsType::PkgData, config_path, [this](int fd) {
6666
QFile tempFile;
6767
if (!tempFile.open(fd, QIODevice::WriteOnly)) {
6868
return false;

gui/dictwidget.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
#include "dictmodel.h"
1111
#include <QItemSelectionModel>
1212
#include <fcitx-utils/fs.h>
13-
#include <fcitx-utils/standardpath.h>
13+
#include <fcitx-utils/standardpaths.h>
1414
#include <fcitx-utils/stringutils.h>
1515
#include <fcitxqti18nhelper.h>
1616

@@ -21,9 +21,9 @@ SkkDictWidget::SkkDictWidget(QWidget *parent)
2121
m_ui(std::make_unique<Ui::SkkDictWidget>()) {
2222
m_ui->setupUi(this);
2323
m_dictModel = new SkkDictModel(this);
24-
auto fcitxBasePath = stringutils::joinPath(
25-
StandardPath::global().userDirectory(StandardPath::Type::PkgData),
26-
"cskk");
24+
auto fcitxBasePath =
25+
StandardPaths::global().userDirectory(StandardPathsType::PkgData) /
26+
"cskk";
2727
fs::makePath(fcitxBasePath);
2828

2929
m_dictModel->load();

src/cskk.cpp

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
#include <fcitx-utils/key.h>
2727
#include <fcitx-utils/keysym.h>
2828
#include <fcitx-utils/log.h>
29-
#include <fcitx-utils/standardpath.h>
29+
#include <fcitx-utils/standardpaths.h>
3030
#include <fcitx-utils/stringutils.h>
3131
#include <fcitx-utils/textformatflags.h>
3232
#include <fcitx/addoninstance.h>
@@ -131,8 +131,8 @@ typedef enum _FcitxSkkDictType { FSDT_Invalid, FSDT_File } FcitxSkkDictType;
131131
void FcitxCskkEngine::loadDictionary() {
132132
freeDictionaries();
133133

134-
auto dict_config_file = StandardPath::global().open(
135-
StandardPath::Type::PkgData, "cskk/dictionary_list", O_RDONLY);
134+
auto dict_config_file = StandardPaths::global().open(
135+
StandardPathsType::PkgData, "cskk/dictionary_list");
136136

137137
if (!dict_config_file.isValid()) {
138138
return;
@@ -217,9 +217,9 @@ void FcitxCskkEngine::loadDictionary() {
217217
constexpr auto var_len = sizeof(configDir) - 1;
218218
std::string realpath = path;
219219
if (stringutils::startsWith(path, configDir)) {
220-
realpath = stringutils::joinPath(
221-
StandardPath::global().userDirectory(StandardPath::Type::PkgData),
222-
path.substr(var_len));
220+
realpath =
221+
StandardPaths::global().userDirectory(StandardPathsType::PkgData) /
222+
path.substr(var_len);
223223
}
224224
auto *userdict =
225225
skk_user_dict_new(realpath.c_str(), encoding.c_str(), complete);
@@ -404,7 +404,8 @@ void FcitxCskkContext::updateUI() {
404404

405405
// Preedit
406406
uint32_t stateStackLen;
407-
auto *preeditDetail = skk_context_get_preedit_detail(context_, &stateStackLen);
407+
auto *preeditDetail =
408+
skk_context_get_preedit_detail(context_, &stateStackLen);
408409
auto [mainPreedit, supplementPreedit] =
409410
FcitxCskkContext::formatPreedit(preeditDetail, stateStackLen);
410411
skk_free_preedit_detail(preeditDetail, stateStackLen);
@@ -427,8 +428,7 @@ void FcitxCskkContext::updateUI() {
427428
std::make_unique<FcitxCskkCandidateList>(engine_, ic_));
428429
} else {
429430
// Sync UI with actual data
430-
currentCandidateList->setCursorPosition(
431-
currentCursorPosition);
431+
currentCandidateList->setCursorPosition(currentCursorPosition);
432432
}
433433

434434
} else {

0 commit comments

Comments
 (0)