LeechCraft 0.6.70-16373-g319c272718
Modular cross-platform feature rich live environment.
Loading...
Searching...
No Matches
util.cpp
Go to the documentation of this file.
1/**********************************************************************
2 * LeechCraft - modular cross-platform feature rich internet client.
3 * Copyright (C) 2006-2014 Georg Rudoy
4 *
5 * Distributed under the Boost Software License, Version 1.0.
6 * (See accompanying file LICENSE or copy at https://www.boost.org/LICENSE_1_0.txt)
7 **********************************************************************/
8
9#include "util.h"
10#include <QCoreApplication>
11#include <QDialogButtonBox>
12#include <QDialog>
13#include <QVBoxLayout>
14#include <QSettings>
15#include <xmlsettingsdialog/xmlsettingsdialog.h>
16
17namespace LC::Util
18{
19 XmlSettingsDialog* OpenXSD (const QString& title, const QString& filename, Util::BaseSettingsManager *bsm)
20 {
21 auto lay = new QVBoxLayout;
22
23 auto xsd = new XmlSettingsDialog;
24 xsd->RegisterObject (bsm, filename);
25 lay->addWidget (xsd->GetWidget ());
26
27 auto bbox = new QDialogButtonBox { QDialogButtonBox::Ok | QDialogButtonBox::Cancel };
28 lay->addWidget (bbox);
29
30 auto dia = new QDialog;
31 dia->setLayout (lay);
32
33 QObject::connect (bbox,
34 &QDialogButtonBox::accepted,
35 xsd,
36 &XmlSettingsDialog::accept);
37 QObject::connect (bbox,
38 &QDialogButtonBox::rejected,
39 xsd,
40 &XmlSettingsDialog::reject);
41 QObject::connect (bbox,
42 &QDialogButtonBox::accepted,
43 dia,
44 &QDialog::accept);
45 QObject::connect (bbox,
46 &QDialogButtonBox::rejected,
47 dia,
48 &QDialog::reject);
49
50 dia->setAttribute (Qt::WA_DeleteOnClose);
51 dia->setWindowTitle (title);
52 dia->show ();
53
54 return xsd;
55 }
56
57 UTIL_XSD_API std::shared_ptr<QSettings> MakeGroupSettings (const QString& suffix, const QString& groupName)
58 {
59 std::shared_ptr<QSettings> settings
60 {
61 new QSettings
62 {
63 QCoreApplication::organizationName (),
64 QCoreApplication::applicationName () + '_' + suffix
65 },
66 [] (QSettings *settings)
67 {
68 settings->endGroup ();
69 delete settings;
70 }
71 };
72 settings->beginGroup (groupName);
73 return settings;
74 }
75}
XmlSettingsDialog * OpenXSD(const QString &title, const QString &filename, Util::BaseSettingsManager *bsm)
Opens XML settings dialog for the given XML filename.
Definition util.cpp:19
UTIL_XSD_API std::shared_ptr< QSettings > MakeGroupSettings(const QString &suffix, const QString &groupName)
Definition util.cpp:57
#define UTIL_XSD_API
Definition xsdconfig.h:16