Printers window peristence
implemented using same pattern as Screen preferences made corrections from review Fixes #4262 Change-Id: I658baebcdc6ef7809d871b61db75d0b4099937ed Reviewed-on: https://review.haiku-os.org/c/haiku/+/3870 Reviewed-by: Adrien Destugues <pulkomandy@gmail.com>
This commit is contained in:
parent
375a70e9fd
commit
572e0095c2
@ -8,6 +8,7 @@ Preference Printers :
|
|||||||
PrintersWindow.cpp
|
PrintersWindow.cpp
|
||||||
PrinterListView.cpp
|
PrinterListView.cpp
|
||||||
JobListView.cpp
|
JobListView.cpp
|
||||||
|
ScreenSettings.cpp
|
||||||
SpoolFolder.cpp
|
SpoolFolder.cpp
|
||||||
TestPageView.cpp
|
TestPageView.cpp
|
||||||
TransportMenu.cpp
|
TransportMenu.cpp
|
||||||
|
@ -14,6 +14,7 @@
|
|||||||
#include "pr_server.h"
|
#include "pr_server.h"
|
||||||
#include "Messages.h"
|
#include "Messages.h"
|
||||||
#include "PrintersWindow.h"
|
#include "PrintersWindow.h"
|
||||||
|
#include "ScreenSettings.h"
|
||||||
|
|
||||||
|
|
||||||
int
|
int
|
||||||
@ -34,7 +35,7 @@ PrintersApp::PrintersApp()
|
|||||||
void
|
void
|
||||||
PrintersApp::ReadyToRun()
|
PrintersApp::ReadyToRun()
|
||||||
{
|
{
|
||||||
PrintersWindow* win = new PrintersWindow(BRect(78, 71, 561, 409));
|
PrintersWindow* win = new PrintersWindow(new ScreenSettings());
|
||||||
win->Show();
|
win->Show();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -12,6 +12,8 @@
|
|||||||
#include <Application.h>
|
#include <Application.h>
|
||||||
#include <Catalog.h>
|
#include <Catalog.h>
|
||||||
|
|
||||||
|
#include "ScreenSettings.h"
|
||||||
|
|
||||||
|
|
||||||
#define PRINTERS_SIGNATURE "application/x-vnd.Be-PRNT"
|
#define PRINTERS_SIGNATURE "application/x-vnd.Be-PRNT"
|
||||||
|
|
||||||
|
@ -32,6 +32,7 @@
|
|||||||
#include "Messages.h"
|
#include "Messages.h"
|
||||||
#include "PrinterListView.h"
|
#include "PrinterListView.h"
|
||||||
#include "TestPageView.h"
|
#include "TestPageView.h"
|
||||||
|
#include "ScreenSettings.h"
|
||||||
#include "SpoolFolder.h"
|
#include "SpoolFolder.h"
|
||||||
|
|
||||||
|
|
||||||
@ -52,7 +53,8 @@ private:
|
|||||||
|
|
||||||
|
|
||||||
TestPageWindow::TestPageWindow(BPrintJob* job, PrinterItem* printer)
|
TestPageWindow::TestPageWindow(BPrintJob* job, PrinterItem* printer)
|
||||||
: BWindow(job->PaperRect().OffsetByCopy(-20000, -20000), B_TRANSLATE("Test page"),
|
: BWindow(job->PaperRect().OffsetByCopy(-20000, -20000),
|
||||||
|
B_TRANSLATE("Test page"),
|
||||||
B_TITLED_WINDOW, 0), fJob(job)
|
B_TITLED_WINDOW, 0), fJob(job)
|
||||||
{
|
{
|
||||||
fTestPage = new TestPageView(job->PrintableRect(), printer);
|
fTestPage = new TestPageView(job->PrintableRect(), printer);
|
||||||
@ -93,10 +95,11 @@ TestPageWindow::MessageReceived(BMessage* message)
|
|||||||
// #pragma mark PrintersWindow main class
|
// #pragma mark PrintersWindow main class
|
||||||
|
|
||||||
|
|
||||||
PrintersWindow::PrintersWindow(BRect frame)
|
PrintersWindow::PrintersWindow(ScreenSettings* settings)
|
||||||
:
|
:
|
||||||
BWindow(BRect(78, 71, 761, 509), B_TRANSLATE_SYSTEM_NAME("Printers"),
|
BWindow(settings->WindowFrame(), B_TRANSLATE_SYSTEM_NAME("Printers"),
|
||||||
B_TITLED_WINDOW, B_AUTO_UPDATE_SIZE_LIMITS),
|
B_TITLED_WINDOW, B_AUTO_UPDATE_SIZE_LIMITS),
|
||||||
|
fSettings(settings),
|
||||||
fSelectedPrinter(NULL),
|
fSelectedPrinter(NULL),
|
||||||
fAddingPrinter(false)
|
fAddingPrinter(false)
|
||||||
{
|
{
|
||||||
@ -104,9 +107,17 @@ PrintersWindow::PrintersWindow(BRect frame)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
PrintersWindow::~PrintersWindow()
|
||||||
|
{
|
||||||
|
delete fSettings;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
bool
|
bool
|
||||||
PrintersWindow::QuitRequested()
|
PrintersWindow::QuitRequested()
|
||||||
{
|
{
|
||||||
|
fSettings->SetWindowFrame(Frame());
|
||||||
|
|
||||||
bool result = Inherited::QuitRequested();
|
bool result = Inherited::QuitRequested();
|
||||||
if (result)
|
if (result)
|
||||||
be_app->PostMessage(B_QUIT_REQUESTED);
|
be_app->PostMessage(B_QUIT_REQUESTED);
|
||||||
|
@ -19,11 +19,13 @@ class JobListView;
|
|||||||
class Job;
|
class Job;
|
||||||
class SpoolFolder;
|
class SpoolFolder;
|
||||||
class PrinterItem;
|
class PrinterItem;
|
||||||
|
class ScreenSettings;
|
||||||
|
|
||||||
|
|
||||||
class PrintersWindow : public BWindow {
|
class PrintersWindow : public BWindow {
|
||||||
public:
|
public:
|
||||||
PrintersWindow(BRect frame);
|
PrintersWindow(ScreenSettings *settings);
|
||||||
|
virtual ~PrintersWindow();
|
||||||
|
|
||||||
void MessageReceived(BMessage* msg);
|
void MessageReceived(BMessage* msg);
|
||||||
bool QuitRequested();
|
bool QuitRequested();
|
||||||
@ -35,6 +37,7 @@ public:
|
|||||||
void UpdateJob(SpoolFolder* folder, Job* job);
|
void UpdateJob(SpoolFolder* folder, Job* job);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
ScreenSettings* fSettings;
|
||||||
void _BuildGUI();
|
void _BuildGUI();
|
||||||
bool _IsSelected(PrinterItem* printer);
|
bool _IsSelected(PrinterItem* printer);
|
||||||
void _UpdatePrinterButtons();
|
void _UpdatePrinterButtons();
|
||||||
|
60
src/preferences/printers/ScreenSettings.cpp
Normal file
60
src/preferences/printers/ScreenSettings.cpp
Normal file
@ -0,0 +1,60 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2001-2015, Haiku.
|
||||||
|
* Distributed under the terms of the MIT License.
|
||||||
|
*
|
||||||
|
* Authors:
|
||||||
|
* Rafael Romo
|
||||||
|
* Stefano Ceccherini (burton666@libero.it)
|
||||||
|
* Axel Dörfler, axeld@pinc-software.de
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
#include "ScreenSettings.h"
|
||||||
|
|
||||||
|
#include <File.h>
|
||||||
|
#include <FindDirectory.h>
|
||||||
|
#include <Path.h>
|
||||||
|
|
||||||
|
|
||||||
|
static const char* kSettingsFileName = "Screen_data";
|
||||||
|
|
||||||
|
|
||||||
|
ScreenSettings::ScreenSettings()
|
||||||
|
{
|
||||||
|
fWindowFrame.Set(0, 0, 450, 250);
|
||||||
|
BPoint offset;
|
||||||
|
|
||||||
|
BPath path;
|
||||||
|
if (find_directory(B_USER_SETTINGS_DIRECTORY, &path) == B_OK) {
|
||||||
|
path.Append(kSettingsFileName);
|
||||||
|
|
||||||
|
BFile file(path.Path(), B_READ_ONLY);
|
||||||
|
if (file.InitCheck() == B_OK)
|
||||||
|
file.Read(&offset, sizeof(BPoint));
|
||||||
|
}
|
||||||
|
|
||||||
|
fWindowFrame.OffsetBy(offset);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
ScreenSettings::~ScreenSettings()
|
||||||
|
{
|
||||||
|
BPath path;
|
||||||
|
if (find_directory(B_USER_SETTINGS_DIRECTORY, &path) < B_OK)
|
||||||
|
return;
|
||||||
|
|
||||||
|
path.Append(kSettingsFileName);
|
||||||
|
|
||||||
|
BPoint offset = fWindowFrame.LeftTop();
|
||||||
|
|
||||||
|
BFile file(path.Path(), B_WRITE_ONLY | B_CREATE_FILE);
|
||||||
|
if (file.InitCheck() == B_OK)
|
||||||
|
file.Write(&offset, sizeof(BPoint));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
ScreenSettings::SetWindowFrame(BRect frame)
|
||||||
|
{
|
||||||
|
fWindowFrame = frame;
|
||||||
|
}
|
29
src/preferences/printers/ScreenSettings.h
Normal file
29
src/preferences/printers/ScreenSettings.h
Normal file
@ -0,0 +1,29 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2001-2006, Haiku.
|
||||||
|
* Distributed under the terms of the MIT License.
|
||||||
|
*
|
||||||
|
* Authors:
|
||||||
|
* Rafael Romo
|
||||||
|
* Stefano Ceccherini (burton666@libero.it)
|
||||||
|
* Axel Dörfler, axeld@pinc-software.de
|
||||||
|
*/
|
||||||
|
#ifndef SCREEN_SETTINGS_H
|
||||||
|
#define SCREEN_SETTINGS_H
|
||||||
|
|
||||||
|
|
||||||
|
#include <Rect.h>
|
||||||
|
|
||||||
|
|
||||||
|
class ScreenSettings {
|
||||||
|
public:
|
||||||
|
ScreenSettings();
|
||||||
|
virtual ~ScreenSettings();
|
||||||
|
|
||||||
|
BRect WindowFrame() const { return fWindowFrame; };
|
||||||
|
void SetWindowFrame(BRect);
|
||||||
|
|
||||||
|
private:
|
||||||
|
BRect fWindowFrame;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // SCREEN_SETTINGS_H
|
Loading…
Reference in New Issue
Block a user