mirror of
https://bitbucket.org/smil3y/katie.git
synced 2025-02-25 03:12:56 +00:00
replace resolveCups() function with its body
Signed-off-by: Ivailo Monev <xakepa10@gmail.com>
This commit is contained in:
parent
e363dd6fee
commit
91a74c0b49
1 changed files with 9 additions and 16 deletions
|
@ -31,16 +31,6 @@ QT_BEGIN_NAMESPACE
|
||||||
static bool cupsLoaded = false;
|
static bool cupsLoaded = false;
|
||||||
static int qt_cups_num_printers = 0;
|
static int qt_cups_num_printers = 0;
|
||||||
|
|
||||||
static inline void resolveCups()
|
|
||||||
{
|
|
||||||
cups_dest_t *printers;
|
|
||||||
int num_printers = cupsGetDests(&printers);
|
|
||||||
if (num_printers)
|
|
||||||
cupsFreeDests(num_printers, printers);
|
|
||||||
qt_cups_num_printers = num_printers;
|
|
||||||
cupsLoaded = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
// ================ CUPS Support class ========================
|
// ================ CUPS Support class ========================
|
||||||
|
|
||||||
QCUPSSupport::QCUPSSupport()
|
QCUPSSupport::QCUPSSupport()
|
||||||
|
@ -51,9 +41,6 @@ QCUPSSupport::QCUPSSupport()
|
||||||
currPrinterIndex(0),
|
currPrinterIndex(0),
|
||||||
currPPD(0)
|
currPPD(0)
|
||||||
{
|
{
|
||||||
if (!cupsLoaded)
|
|
||||||
resolveCups();
|
|
||||||
|
|
||||||
// getting all available printers
|
// getting all available printers
|
||||||
if (!isAvailable())
|
if (!isAvailable())
|
||||||
return;
|
return;
|
||||||
|
@ -61,7 +48,7 @@ QCUPSSupport::QCUPSSupport()
|
||||||
// Update the available printer count
|
// Update the available printer count
|
||||||
qt_cups_num_printers = prnCount = cupsGetDests(&printers);
|
qt_cups_num_printers = prnCount = cupsGetDests(&printers);
|
||||||
|
|
||||||
for (int i = 0; i < prnCount; ++i) {
|
for (int i = 0; i < prnCount; ++i) {
|
||||||
if (printers[i].is_default) {
|
if (printers[i].is_default) {
|
||||||
currPrinterIndex = i;
|
currPrinterIndex = i;
|
||||||
setCurrentPrinter(i);
|
setCurrentPrinter(i);
|
||||||
|
@ -140,8 +127,14 @@ int QCUPSSupport::currentPrinterIndex() const
|
||||||
|
|
||||||
bool QCUPSSupport::isAvailable()
|
bool QCUPSSupport::isAvailable()
|
||||||
{
|
{
|
||||||
if(!cupsLoaded)
|
if (!cupsLoaded) {
|
||||||
resolveCups();
|
cups_dest_t *printers = nullptr;
|
||||||
|
int num_printers = cupsGetDests(&printers);
|
||||||
|
if (num_printers)
|
||||||
|
cupsFreeDests(num_printers, printers);
|
||||||
|
qt_cups_num_printers = num_printers;
|
||||||
|
cupsLoaded = true;
|
||||||
|
}
|
||||||
|
|
||||||
return (qt_cups_num_printers > 0);
|
return (qt_cups_num_printers > 0);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue