mirror of
https://github.com/naoufalzerai/pdf_tools.git
synced 2025-11-09 07:45:54 +00:00
fix linux
This commit is contained in:
parent
7af41bcf45
commit
dbae375ebd
@ -1,4 +1,8 @@
|
||||
# This is a generated file; do not edit or check into version control.
|
||||
bitsdojo_window=/home/naoufal/.pub-cache/hosted/pub.dev/bitsdojo_window-0.1.5/
|
||||
bitsdojo_window_linux=/home/naoufal/.pub-cache/hosted/pub.dev/bitsdojo_window_linux-0.1.3/
|
||||
bitsdojo_window_macos=/home/naoufal/.pub-cache/hosted/pub.dev/bitsdojo_window_macos-0.1.3/
|
||||
bitsdojo_window_windows=/home/naoufal/.pub-cache/hosted/pub.dev/bitsdojo_window_windows-0.1.5/
|
||||
device_info_plus=/home/naoufal/.pub-cache/hosted/pub.dev/device_info_plus-4.1.3/
|
||||
device_info_plus_linux=/home/naoufal/.pub-cache/hosted/pub.dev/device_info_plus_linux-3.0.0/
|
||||
device_info_plus_macos=/home/naoufal/.pub-cache/hosted/pub.dev/device_info_plus_macos-3.0.0/
|
||||
@ -13,5 +17,3 @@ path_provider_linux=/home/naoufal/.pub-cache/hosted/pub.dev/path_provider_linux-
|
||||
path_provider_windows=/home/naoufal/.pub-cache/hosted/pub.dev/path_provider_windows-2.1.3/
|
||||
pdfx=/home/naoufal/.pub-cache/hosted/pub.dev/pdfx-2.3.0/
|
||||
printing=/home/naoufal/.pub-cache/hosted/pub.dev/printing-5.10.1/
|
||||
screen_retriever=/home/naoufal/.pub-cache/hosted/pub.dev/screen_retriever-0.1.6/
|
||||
window_manager=/home/naoufal/.pub-cache/hosted/pub.dev/window_manager-0.3.0/
|
||||
|
||||
File diff suppressed because one or more lines are too long
14
.kdev4/pdf_tools.kdev4
Normal file
14
.kdev4/pdf_tools.kdev4
Normal file
@ -0,0 +1,14 @@
|
||||
[Buildset]
|
||||
BuildItems=@Variant(\x00\x00\x00\t\x00\x00\x00\x00\x01\x00\x00\x00\x0b\x00\x00\x00\x00\x01\x00\x00\x00\x12\x00p\x00d\x00f\x00_\x00t\x00o\x00o\x00l\x00s)
|
||||
|
||||
[Launch]
|
||||
Launch Configurations=Launch Configuration 0
|
||||
|
||||
[Launch][Launch Configuration 0]
|
||||
Configured Launch Modes=execute
|
||||
Configured Launchers=scriptAppLauncher
|
||||
Name=New Script Application Launcher
|
||||
Type=Script Application
|
||||
|
||||
[Project]
|
||||
VersionControlSupport=kdevgit
|
||||
269
lib/main.dart
269
lib/main.dart
@ -1,19 +1,25 @@
|
||||
import 'dart:io';
|
||||
import 'dart:ui' as ui;
|
||||
|
||||
import 'package:bitsdojo_window/bitsdojo_window.dart';
|
||||
import 'package:file_picker/file_picker.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
import 'package:pdf/pdf.dart';
|
||||
import 'package:printing/printing.dart';
|
||||
import 'package:pdf/widgets.dart' as pw;
|
||||
import 'package:window_manager/window_manager.dart';
|
||||
import 'package:printing/printing.dart';
|
||||
|
||||
Future<void> main() async {
|
||||
WidgetsFlutterBinding.ensureInitialized();
|
||||
// Must add this line.
|
||||
await windowManager.ensureInitialized();
|
||||
|
||||
if (Platform.isWindows || Platform.isLinux || Platform.isMacOS) {
|
||||
await windowManager.setSize(const Size(450, 300));
|
||||
doWhenWindowReady(() {
|
||||
const initialSize = Size(600, 300);
|
||||
appWindow.minSize = initialSize;
|
||||
appWindow.maxSize = initialSize;
|
||||
appWindow.size = initialSize;
|
||||
appWindow.alignment = Alignment.center;
|
||||
appWindow.show();
|
||||
});
|
||||
}
|
||||
runApp(const MyApp());
|
||||
}
|
||||
@ -28,15 +34,126 @@ class MyApp extends StatefulWidget {
|
||||
|
||||
class _MyAppState extends State<MyApp> {
|
||||
String _openFilePath = "";
|
||||
bool loading = false;
|
||||
String? _encryption = "";
|
||||
double _dpi = 200;
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
// test();
|
||||
return MaterialApp(
|
||||
home: Scaffold(
|
||||
//appBar: AppBar(title: const Text("PDF Tools")),
|
||||
body: Row(
|
||||
children: [
|
||||
RightSide(
|
||||
body: Padding(
|
||||
padding: const EdgeInsets.all(8.0),
|
||||
child: Column(children: [
|
||||
Row(
|
||||
children: [
|
||||
Expanded(
|
||||
child: ElevatedButton(
|
||||
onPressed: (loading) ? null : () => openFile(),
|
||||
child: Flex(
|
||||
direction: Axis.vertical,
|
||||
children: const [
|
||||
Icon(Icons.folder),
|
||||
Text("Open pdf")
|
||||
],
|
||||
)),
|
||||
),
|
||||
const SizedBox(
|
||||
width: 10,
|
||||
),
|
||||
Expanded(
|
||||
child: ElevatedButton(
|
||||
onPressed: (_openFilePath.isEmpty || loading)
|
||||
? null
|
||||
: () => saveFile(),
|
||||
child: Flex(
|
||||
direction: Axis.vertical,
|
||||
children: const [
|
||||
Icon(Icons.save),
|
||||
Text("save"),
|
||||
],
|
||||
)),
|
||||
),
|
||||
],
|
||||
),
|
||||
Padding(
|
||||
padding: const EdgeInsets.only(top: 10, bottom: 10),
|
||||
child: Row(
|
||||
children: [
|
||||
Expanded(
|
||||
child: Container(
|
||||
decoration: BoxDecoration(
|
||||
borderRadius:
|
||||
const BorderRadius.all(Radius.circular(5)),
|
||||
border: Border.all(
|
||||
color: Colors.grey,
|
||||
width: 1,
|
||||
)),
|
||||
padding: const EdgeInsets.only(top: 10, bottom: 10),
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.only(left: 5, right: 5),
|
||||
child: Text(_openFilePath),
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
|
||||
mainAxisSize: MainAxisSize.max,
|
||||
children: [
|
||||
const Text("Quality :"),
|
||||
Expanded(
|
||||
child: Slider(
|
||||
min: 100,
|
||||
max: 500,
|
||||
divisions: 20,
|
||||
label: _dpi.toString(),
|
||||
value: _dpi,
|
||||
onChanged: (_openFilePath.isEmpty || loading)
|
||||
? null
|
||||
: (value) {
|
||||
setState(() {
|
||||
_dpi = value;
|
||||
});
|
||||
},
|
||||
),
|
||||
),
|
||||
Text(_dpi.toString()),
|
||||
],
|
||||
),
|
||||
const SizedBox(height: 10),
|
||||
TextField(
|
||||
enabled: (_openFilePath.isNotEmpty),
|
||||
decoration: const InputDecoration(
|
||||
labelText: 'Encrypt (Optional)',
|
||||
border: OutlineInputBorder(),
|
||||
),
|
||||
controller: TextEditingController(text: _encryption),
|
||||
onSubmitted: (value) {
|
||||
setState(() {
|
||||
_encryption = value;
|
||||
});
|
||||
},
|
||||
),
|
||||
const SizedBox(height: 10),
|
||||
]),
|
||||
))
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Future convert(String savePath) async {
|
||||
final pdf = pw.Document();
|
||||
final file = File(savePath);
|
||||
|
||||
final openddPdf = await rootBundle.load(_openFilePath);
|
||||
var doc = openddPdf.buffer.asUint8List();
|
||||
|
||||
final doc = await File(_openFilePath).readAsBytes();
|
||||
// var tempDir = Directory.systemTemp.createTempSync();
|
||||
// int index = 1;
|
||||
|
||||
@ -60,111 +177,79 @@ class _MyAppState extends State<MyApp> {
|
||||
}
|
||||
|
||||
void openFile() async {
|
||||
setState(() {
|
||||
loading = true;
|
||||
});
|
||||
FilePickerResult? result = await FilePicker.platform
|
||||
.pickFiles(allowMultiple: false, lockParentWindow: true);
|
||||
if (result != null) {
|
||||
setState(() {
|
||||
_openFilePath = result.files.first.path!;
|
||||
});
|
||||
} else {
|
||||
// User canceled the picker
|
||||
}
|
||||
setState(() {
|
||||
loading = false;
|
||||
});
|
||||
}
|
||||
|
||||
Future saveFile() async {
|
||||
setState(() {
|
||||
loading = true;
|
||||
});
|
||||
var savePath = await FilePicker.platform
|
||||
.saveFile(allowedExtensions: ['pdf'], lockParentWindow: true);
|
||||
if (savePath != null) {
|
||||
return await convert(savePath);
|
||||
} else {
|
||||
// User canceled the picker
|
||||
await convert(savePath);
|
||||
}
|
||||
setState(() {
|
||||
loading = false;
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
final backgroundStartColor = Colors.grey.shade50;
|
||||
final backgroundEndColor = Colors.grey.shade300;
|
||||
|
||||
// ignore: must_be_immutable
|
||||
class RightSide extends StatelessWidget {
|
||||
RightSide({Key? key, required this.body}) : super(key: key);
|
||||
Widget body;
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
// test();
|
||||
return MaterialApp(
|
||||
home: Scaffold(
|
||||
appBar: AppBar(title: const Text("PDF Tools")),
|
||||
body: SizedBox(
|
||||
width: double.infinity,
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.all(8.0),
|
||||
child: Column(
|
||||
return Expanded(
|
||||
child: Container(
|
||||
decoration: BoxDecoration(
|
||||
gradient: LinearGradient(
|
||||
begin: Alignment.topCenter,
|
||||
end: Alignment.bottomCenter,
|
||||
colors: [backgroundStartColor, backgroundEndColor],
|
||||
stops: const [0.0, 1.0]),
|
||||
),
|
||||
child: Column(children: [
|
||||
WindowTitleBarBox(
|
||||
child: Row(
|
||||
children: [
|
||||
Text(_openFilePath),
|
||||
Column(children: [
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
|
||||
mainAxisSize: MainAxisSize.max,
|
||||
children: [
|
||||
const Text("Quality :"),
|
||||
Expanded(
|
||||
child: Slider(
|
||||
min: 100,
|
||||
max: 500,
|
||||
divisions: 20,
|
||||
label: _dpi.toString(),
|
||||
value: _dpi,
|
||||
onChanged: (value) {
|
||||
setState(() {
|
||||
_dpi = value;
|
||||
});
|
||||
},
|
||||
),
|
||||
),
|
||||
Text(_dpi.toString()),
|
||||
],
|
||||
),
|
||||
const SizedBox(height: 10),
|
||||
TextField(
|
||||
decoration: const InputDecoration(
|
||||
labelText: 'Encrypt (Optional)',
|
||||
border: OutlineInputBorder(),
|
||||
),
|
||||
controller: TextEditingController(text: _encryption),
|
||||
onSubmitted: (value) {
|
||||
setState(() {
|
||||
_encryption = value;
|
||||
});
|
||||
},
|
||||
),
|
||||
const SizedBox(height: 10),
|
||||
Row(
|
||||
children: [
|
||||
ElevatedButton(
|
||||
onPressed: () => openFile(),
|
||||
child: Flex(
|
||||
direction: Axis.vertical,
|
||||
children: const [
|
||||
Icon(Icons.folder),
|
||||
Text("Open pdf")
|
||||
],
|
||||
)),
|
||||
ElevatedButton(
|
||||
onPressed: () async {
|
||||
await saveFile();
|
||||
showDialog(
|
||||
context: context,
|
||||
builder: (context) => Text("ok"),
|
||||
);
|
||||
},
|
||||
child: Flex(
|
||||
direction: Axis.vertical,
|
||||
children: const [
|
||||
Icon(Icons.save),
|
||||
Text("save"),
|
||||
],
|
||||
)),
|
||||
],
|
||||
),
|
||||
])
|
||||
Expanded(child: MoveWindow()),
|
||||
const WindowButtons(),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
body
|
||||
]),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class WindowButtons extends StatelessWidget {
|
||||
const WindowButtons({Key? key}) : super(key: key);
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Row(
|
||||
children: [
|
||||
MinimizeWindowButton(),
|
||||
CloseWindowButton(),
|
||||
],
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@ -6,18 +6,14 @@
|
||||
|
||||
#include "generated_plugin_registrant.h"
|
||||
|
||||
#include <bitsdojo_window_linux/bitsdojo_window_plugin.h>
|
||||
#include <printing/printing_plugin.h>
|
||||
#include <screen_retriever/screen_retriever_plugin.h>
|
||||
#include <window_manager/window_manager_plugin.h>
|
||||
|
||||
void fl_register_plugins(FlPluginRegistry* registry) {
|
||||
g_autoptr(FlPluginRegistrar) bitsdojo_window_linux_registrar =
|
||||
fl_plugin_registry_get_registrar_for_plugin(registry, "BitsdojoWindowPlugin");
|
||||
bitsdojo_window_plugin_register_with_registrar(bitsdojo_window_linux_registrar);
|
||||
g_autoptr(FlPluginRegistrar) printing_registrar =
|
||||
fl_plugin_registry_get_registrar_for_plugin(registry, "PrintingPlugin");
|
||||
printing_plugin_register_with_registrar(printing_registrar);
|
||||
g_autoptr(FlPluginRegistrar) screen_retriever_registrar =
|
||||
fl_plugin_registry_get_registrar_for_plugin(registry, "ScreenRetrieverPlugin");
|
||||
screen_retriever_plugin_register_with_registrar(screen_retriever_registrar);
|
||||
g_autoptr(FlPluginRegistrar) window_manager_registrar =
|
||||
fl_plugin_registry_get_registrar_for_plugin(registry, "WindowManagerPlugin");
|
||||
window_manager_plugin_register_with_registrar(window_manager_registrar);
|
||||
}
|
||||
|
||||
@ -3,9 +3,8 @@
|
||||
#
|
||||
|
||||
list(APPEND FLUTTER_PLUGIN_LIST
|
||||
bitsdojo_window_linux
|
||||
printing
|
||||
screen_retriever
|
||||
window_manager
|
||||
)
|
||||
|
||||
list(APPEND FLUTTER_FFI_PLUGIN_LIST
|
||||
|
||||
@ -1,3 +1,4 @@
|
||||
#include <bitsdojo_window_linux/bitsdojo_window_plugin.h>
|
||||
#include "my_application.h"
|
||||
|
||||
#include <flutter_linux/flutter_linux.h>
|
||||
@ -47,7 +48,9 @@ static void my_application_activate(GApplication* application) {
|
||||
gtk_window_set_title(window, "pdf_tools");
|
||||
}
|
||||
|
||||
gtk_window_set_default_size(window, 1280, 720);
|
||||
auto bdw = bitsdojo_window_from(window); // <--- add this line
|
||||
bdw->setCustomFrame(true); // <-- add this line
|
||||
//gtk_window_set_default_size(window, 1280, 720); // <-- comment this line
|
||||
gtk_widget_show(GTK_WIDGET(window));
|
||||
|
||||
g_autoptr(FlDartProject) project = fl_dart_project_new();
|
||||
|
||||
@ -5,18 +5,16 @@
|
||||
import FlutterMacOS
|
||||
import Foundation
|
||||
|
||||
import bitsdojo_window_macos
|
||||
import device_info_plus_macos
|
||||
import path_provider_foundation
|
||||
import pdfx
|
||||
import printing
|
||||
import screen_retriever
|
||||
import window_manager
|
||||
|
||||
func RegisterGeneratedPlugins(registry: FlutterPluginRegistry) {
|
||||
BitsdojoWindowPlugin.register(with: registry.registrar(forPlugin: "BitsdojoWindowPlugin"))
|
||||
DeviceInfoPlusMacosPlugin.register(with: registry.registrar(forPlugin: "DeviceInfoPlusMacosPlugin"))
|
||||
PathProviderPlugin.register(with: registry.registrar(forPlugin: "PathProviderPlugin"))
|
||||
PdfxPlugin.register(with: registry.registrar(forPlugin: "PdfxPlugin"))
|
||||
PrintingPlugin.register(with: registry.registrar(forPlugin: "PrintingPlugin"))
|
||||
ScreenRetrieverPlugin.register(with: registry.registrar(forPlugin: "ScreenRetrieverPlugin"))
|
||||
WindowManagerPlugin.register(with: registry.registrar(forPlugin: "WindowManagerPlugin"))
|
||||
}
|
||||
|
||||
4
pdf_tools.kdev4
Normal file
4
pdf_tools.kdev4
Normal file
@ -0,0 +1,4 @@
|
||||
[Project]
|
||||
CreatedFrom=
|
||||
Manager=KDevGenericManager
|
||||
Name=pdf_tools
|
||||
11
pdf_tools.sublime-project
Normal file
11
pdf_tools.sublime-project
Normal file
@ -0,0 +1,11 @@
|
||||
{
|
||||
"folders":
|
||||
[
|
||||
{
|
||||
"path": ".",
|
||||
}
|
||||
],
|
||||
"debugger_configurations":
|
||||
[
|
||||
],
|
||||
}
|
||||
596
pdf_tools.sublime-workspace
Normal file
596
pdf_tools.sublime-workspace
Normal file
File diff suppressed because one or more lines are too long
@ -41,9 +41,9 @@ dependencies:
|
||||
path_provider: ^2.0.12
|
||||
pdfx: ^2.3.0
|
||||
printing: ^5.10.1
|
||||
window_manager: ^0.3.0
|
||||
flutter_localizations:
|
||||
sdk: flutter
|
||||
bitsdojo_window: ^0.1.5
|
||||
|
||||
dev_dependencies:
|
||||
flutter_test:
|
||||
|
||||
@ -6,18 +6,15 @@
|
||||
|
||||
#include "generated_plugin_registrant.h"
|
||||
|
||||
#include <bitsdojo_window_windows/bitsdojo_window_plugin.h>
|
||||
#include <pdfx/pdfx_plugin.h>
|
||||
#include <printing/printing_plugin.h>
|
||||
#include <screen_retriever/screen_retriever_plugin.h>
|
||||
#include <window_manager/window_manager_plugin.h>
|
||||
|
||||
void RegisterPlugins(flutter::PluginRegistry* registry) {
|
||||
BitsdojoWindowPluginRegisterWithRegistrar(
|
||||
registry->GetRegistrarForPlugin("BitsdojoWindowPlugin"));
|
||||
PdfxPluginRegisterWithRegistrar(
|
||||
registry->GetRegistrarForPlugin("PdfxPlugin"));
|
||||
PrintingPluginRegisterWithRegistrar(
|
||||
registry->GetRegistrarForPlugin("PrintingPlugin"));
|
||||
ScreenRetrieverPluginRegisterWithRegistrar(
|
||||
registry->GetRegistrarForPlugin("ScreenRetrieverPlugin"));
|
||||
WindowManagerPluginRegisterWithRegistrar(
|
||||
registry->GetRegistrarForPlugin("WindowManagerPlugin"));
|
||||
}
|
||||
|
||||
@ -3,10 +3,9 @@
|
||||
#
|
||||
|
||||
list(APPEND FLUTTER_PLUGIN_LIST
|
||||
bitsdojo_window_windows
|
||||
pdfx
|
||||
printing
|
||||
screen_retriever
|
||||
window_manager
|
||||
)
|
||||
|
||||
list(APPEND FLUTTER_FFI_PLUGIN_LIST
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user