mirror of
https://invent.kde.org/graphics/okular
synced 2024-07-04 16:48:48 +00:00
Port from removed KConfigGroup keys api
This commit is contained in:
parent
5fe172991e
commit
70acf82817
|
@ -153,7 +153,7 @@ void MainShellTest::initTestCase()
|
|||
#endif
|
||||
// Tell the presentationWidget and queryClose to not be annoying
|
||||
KSharedConfigPtr c = KSharedConfig::openConfig(QStringLiteral("mainshelltest.kmessagebox"));
|
||||
KConfigGroup cg = c->group("General");
|
||||
KConfigGroup cg = c->group(QStringLiteral("General"));
|
||||
cg.writeEntry("presentationInfo", 4);
|
||||
cg.writeEntry("ShowTabWarning", 4);
|
||||
}
|
||||
|
|
|
@ -67,6 +67,10 @@ public:
|
|||
KSharedConfig::Ptr config;
|
||||
Q_DISABLE_COPY(FilePrinterPreviewPrivate)
|
||||
};
|
||||
static const QString ConfigGroupKey()
|
||||
{
|
||||
return QStringLiteral("Print Preview");
|
||||
}
|
||||
|
||||
void FilePrinterPreviewPrivate::getPart()
|
||||
{
|
||||
|
@ -122,12 +126,12 @@ FilePrinterPreview::FilePrinterPreview(const QString &filename, QWidget *parent)
|
|||
|
||||
connect(d->buttonBox, &QDialogButtonBox::rejected, this, &QDialog::reject);
|
||||
|
||||
KWindowConfig::restoreWindowSize(windowHandle(), d->config->group("Print Preview"));
|
||||
KWindowConfig::restoreWindowSize(windowHandle(), d->config->group(ConfigGroupKey()));
|
||||
}
|
||||
|
||||
FilePrinterPreview::~FilePrinterPreview()
|
||||
{
|
||||
KConfigGroup group(d->config->group("Print Preview"));
|
||||
KConfigGroup group(d->config->group(ConfigGroupKey()));
|
||||
KWindowConfig::saveWindowSize(windowHandle(), group);
|
||||
|
||||
delete d;
|
||||
|
|
|
@ -608,7 +608,7 @@ void Part::setupConfigSkeleton(const QVariantList &args)
|
|||
|
||||
// Configuration update: SlidesTransitionsEnabled -> SlidesTransition = NoTransitions.
|
||||
// See https://invent.kde.org/graphics/okular/-/merge_requests/357
|
||||
KConfigGroup slidesConfigGroup = config.data()->group("Dlg Presentation");
|
||||
KConfigGroup slidesConfigGroup = config.data()->group(QStringLiteral("Dlg Presentation"));
|
||||
if (slidesConfigGroup.readEntry<bool>("SlidesTransitionsEnabled", true) == false) {
|
||||
slidesConfigGroup.writeEntry("SlidesTransition", "NoTransitions");
|
||||
}
|
||||
|
|
|
@ -35,11 +35,26 @@
|
|||
#include <KSharedConfig>
|
||||
namespace
|
||||
{
|
||||
static constexpr char ConfigGroup[] = "Signature";
|
||||
static constexpr char ConfigBackgroundKey[] = "RecentBackgrounds";
|
||||
static constexpr char ConfigLastReason[] = "Reason";
|
||||
static constexpr char ConfigLastLocation[] = "Location";
|
||||
static constexpr char ConfigLastKeyNick[] = "KeyNick";
|
||||
static inline QString ConfigGroup()
|
||||
{
|
||||
return QStringLiteral("Signature");
|
||||
}
|
||||
static inline QString ConfigBackgroundKey()
|
||||
{
|
||||
return QStringLiteral("RecentBackgrounds");
|
||||
}
|
||||
static inline QString ConfigLastReason()
|
||||
{
|
||||
return QStringLiteral("Reason");
|
||||
}
|
||||
static inline QString ConfigLastLocation()
|
||||
{
|
||||
return QStringLiteral("Location");
|
||||
}
|
||||
static inline QString ConfigLastKeyNick()
|
||||
{
|
||||
return QStringLiteral("KeyNick");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
@ -107,7 +122,7 @@ class RecentImagesModel : public QAbstractListModel
|
|||
public:
|
||||
RecentImagesModel()
|
||||
{
|
||||
const auto recentList = KSharedConfig::openConfig()->group(QLatin1String(ConfigGroup)).readEntry<QStringList>(QLatin1String(ConfigBackgroundKey), QStringList());
|
||||
const auto recentList = KSharedConfig::openConfig()->group(ConfigGroup()).readEntry<QStringList>(ConfigBackgroundKey(), QStringList());
|
||||
for (const auto &element : recentList) {
|
||||
if (QFile::exists(element)) { // maybe the image has been removed from disk since last invocation
|
||||
m_storedElements.push_back(element);
|
||||
|
@ -206,7 +221,7 @@ public:
|
|||
while (elementsToStore.size() > 3) {
|
||||
elementsToStore.pop_back();
|
||||
}
|
||||
KSharedConfig::openConfig()->group(QString::fromUtf8(ConfigGroup)).writeEntry(ConfigBackgroundKey, elementsToStore);
|
||||
KSharedConfig::openConfig()->group(ConfigGroup()).writeEntry(ConfigBackgroundKey(), elementsToStore);
|
||||
}
|
||||
|
||||
private:
|
||||
|
@ -236,7 +251,7 @@ std::optional<SigningInformation> getCertificateAndPasswordForSigning(PageView *
|
|||
bool showIcons = false;
|
||||
int selectIndex = 0;
|
||||
auto config = KSharedConfig::openConfig();
|
||||
const QString lastNick = config->group(ConfigGroup).readEntry<QString>(ConfigLastKeyNick, QString());
|
||||
const QString lastNick = config->group(ConfigGroup()).readEntry<QString>(ConfigLastKeyNick(), QString());
|
||||
for (const auto &cert : std::as_const(certs)) {
|
||||
auto item = std::make_unique<QStandardItem>();
|
||||
QString commonName = cert.subjectInfo(Okular::CertificateInfo::CommonName, Okular::CertificateInfo::EmptyString::Empty);
|
||||
|
@ -367,8 +382,8 @@ std::optional<SigningInformation> getCertificateAndPasswordForSigning(PageView *
|
|||
}
|
||||
});
|
||||
}
|
||||
dialog.ui->reasonInput->setText(config->group(ConfigGroup).readEntry(ConfigLastReason, QString()));
|
||||
dialog.ui->locationInput->setText(config->group(ConfigGroup).readEntry(ConfigLastLocation, QString()));
|
||||
dialog.ui->reasonInput->setText(config->group(ConfigGroup()).readEntry(ConfigLastReason(), QString()));
|
||||
dialog.ui->locationInput->setText(config->group(ConfigGroup()).readEntry(ConfigLastLocation(), QString()));
|
||||
auto result = dialog.exec();
|
||||
|
||||
if (result == QDialog::Rejected) {
|
||||
|
@ -411,9 +426,9 @@ std::optional<SigningInformation> getCertificateAndPasswordForSigning(PageView *
|
|||
}
|
||||
|
||||
if (passok) {
|
||||
config->group(ConfigGroup).writeEntry(ConfigLastKeyNick, cert.nickName());
|
||||
config->group(ConfigGroup).writeEntry(ConfigLastReason, dialog.ui->reasonInput->text());
|
||||
config->group(ConfigGroup).writeEntry(ConfigLastLocation, dialog.ui->locationInput->text());
|
||||
config->group(ConfigGroup()).writeEntry(ConfigLastKeyNick(), cert.nickName());
|
||||
config->group(ConfigGroup()).writeEntry(ConfigLastReason(), dialog.ui->reasonInput->text());
|
||||
config->group(ConfigGroup()).writeEntry(ConfigLastLocation(), dialog.ui->locationInput->text());
|
||||
return SigningInformation {std::make_unique<Okular::CertificateInfo>(std::move(cert)), password, documentPassword, dialog.ui->reasonInput->text(), dialog.ui->locationInput->text(), backGroundImage};
|
||||
}
|
||||
return std::nullopt;
|
||||
|
|
|
@ -74,6 +74,19 @@ static const char *const SESSION_TAB_KEY = "ActiveTab";
|
|||
static constexpr char SIDEBAR_LOCKED_KEY[] = "LockSidebar";
|
||||
static constexpr char SIDEBAR_VISIBLE_KEY[] = "ShowSidebar";
|
||||
|
||||
static inline QString DesktopEntryGroupKey()
|
||||
{
|
||||
return QStringLiteral("Desktop Entry");
|
||||
}
|
||||
static inline QString RecentFilesGroupKey()
|
||||
{
|
||||
return QStringLiteral("Recent Files");
|
||||
}
|
||||
static inline QString GeneralGroupKey()
|
||||
{
|
||||
return QStringLiteral("General");
|
||||
}
|
||||
|
||||
class ResizableStackedWidget : public QStackedWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
|
@ -485,10 +498,10 @@ void Shell::closeUrl()
|
|||
|
||||
void Shell::readSettings()
|
||||
{
|
||||
m_recent->loadEntries(KSharedConfig::openConfig()->group("Recent Files"));
|
||||
m_recent->loadEntries(KSharedConfig::openConfig()->group(RecentFilesGroupKey()));
|
||||
m_recent->setEnabled(true); // force enabling
|
||||
|
||||
const KConfigGroup group = KSharedConfig::openConfig()->group("Desktop Entry");
|
||||
const KConfigGroup group = KSharedConfig::openConfig()->group(DesktopEntryGroupKey());
|
||||
bool fullScreen = group.readEntry("FullScreen", false);
|
||||
setFullScreen(fullScreen);
|
||||
|
||||
|
@ -497,7 +510,7 @@ void Shell::readSettings()
|
|||
m_toolBarWasShown = group.readEntry(shouldShowToolBarComingFromFullScreen, true);
|
||||
}
|
||||
|
||||
const KConfigGroup sidebarGroup = KSharedConfig::openConfig()->group("General");
|
||||
const KConfigGroup sidebarGroup = KSharedConfig::openConfig()->group(GeneralGroupKey());
|
||||
m_sidebar->setVisible(sidebarGroup.readEntry(SIDEBAR_VISIBLE_KEY, true));
|
||||
m_sidebar->setLocked(sidebarGroup.readEntry(SIDEBAR_LOCKED_KEY, true));
|
||||
|
||||
|
@ -509,13 +522,13 @@ void Shell::writeSettings()
|
|||
{
|
||||
saveRecents();
|
||||
|
||||
KConfigGroup sidebarGroup = KSharedConfig::openConfig()->group("General");
|
||||
KConfigGroup sidebarGroup = KSharedConfig::openConfig()->group(GeneralGroupKey());
|
||||
sidebarGroup.writeEntry(SIDEBAR_LOCKED_KEY, m_sidebar->isLocked());
|
||||
// NOTE : Consider whether the m_showSidebarAction is checked, because
|
||||
// the sidebar can be forcibly hidden if the welcome screen is displayed
|
||||
sidebarGroup.writeEntry(SIDEBAR_VISIBLE_KEY, m_sidebar->isVisibleTo(this) || m_showSidebarAction->isChecked());
|
||||
|
||||
KConfigGroup group = KSharedConfig::openConfig()->group("Desktop Entry");
|
||||
KConfigGroup group = KSharedConfig::openConfig()->group(DesktopEntryGroupKey());
|
||||
group.writeEntry("FullScreen", m_fullScreenAction->isChecked());
|
||||
if (m_fullScreenAction->isChecked()) {
|
||||
group.writeEntry(shouldShowMenuBarComingFromFullScreen, m_menuBarWasShown);
|
||||
|
@ -526,7 +539,7 @@ void Shell::writeSettings()
|
|||
|
||||
void Shell::saveRecents()
|
||||
{
|
||||
m_recent->saveEntries(KSharedConfig::openConfig()->group("Recent Files"));
|
||||
m_recent->saveEntries(KSharedConfig::openConfig()->group(RecentFilesGroupKey()));
|
||||
}
|
||||
|
||||
void Shell::setupActions()
|
||||
|
|
|
@ -160,7 +160,7 @@ void WelcomeScreen::showEvent(QShowEvent *e)
|
|||
|
||||
void WelcomeScreen::loadRecents()
|
||||
{
|
||||
m_recentsModel->loadEntries(KSharedConfig::openConfig()->group("Recent Files"));
|
||||
m_recentsModel->loadEntries(KSharedConfig::openConfig()->group(QStringLiteral("Recent Files")));
|
||||
}
|
||||
|
||||
int WelcomeScreen::recentsCount()
|
||||
|
|
Loading…
Reference in New Issue
Block a user