mirror of
https://github.com/YACReader/yacreader
synced 2025-08-16 03:05:21 -04:00
YACReader
YACReaderLibrary
comic_vine
db
qml
server
Info.plist
YACReaderLibrary.icns
YACReaderLibrary.pro
add_label_dialog.cpp
add_label_dialog.h
add_library_dialog.cpp
add_library_dialog.h
bundle_creator.cpp
bundle_creator.h
classic_comics_view.cpp
classic_comics_view.h
comic_files_manager.cpp
comic_files_manager.h
comic_flow.cpp
comic_flow.h
comic_flow_widget.cpp
comic_flow_widget.h
comics_remover.cpp
comics_remover.h
comics_view.cpp
comics_view.h
comics_view_transition.cpp
comics_view_transition.h
create_library_dialog.cpp
create_library_dialog.h
current_comic_view_helper.cpp
current_comic_view_helper.h
db_helper.cpp
db_helper.h
empty_container_info.cpp
empty_container_info.h
empty_folder_widget.cpp
empty_folder_widget.h
empty_label_widget.cpp
empty_label_widget.h
empty_reading_list_widget.cpp
empty_reading_list_widget.h
empty_special_list.cpp
empty_special_list.h
export_comics_info_dialog.cpp
export_comics_info_dialog.h
export_library_dialog.cpp
export_library_dialog.h
files.qrc
grid_comics_view.cpp
grid_comics_view.h
icon.ico
icon.rc
icon2.ico
icon3.ico
images.qrc
images_osx.qrc
images_win.qrc
import_comics_info_dialog.cpp
import_comics_info_dialog.h
import_library_dialog.cpp
import_library_dialog.h
import_widget.cpp
import_widget.h
info_comics_view.cpp
info_comics_view.h
initial_comic_info_extractor.cpp
initial_comic_info_extractor.h
library_comic_opener.cpp
library_comic_opener.h
library_creator.cpp
library_creator.h
library_window.cpp
library_window.h
macostrayicon.svg
main.cpp
no_libraries_widget.cpp
no_libraries_widget.h
no_search_results_widget.cpp
no_search_results_widget.h
options_dialog.cpp
options_dialog.h
package_manager.cpp
package_manager.h
properties_dialog.cpp
properties_dialog.h
qml.qrc
qml_osx.qrc
qml_win.qrc
rename_library_dialog.cpp
rename_library_dialog.h
server_config_dialog.cpp
server_config_dialog.h
trayhandler.h
trayhandler.mm
trayicon_controller.cpp
trayicon_controller.h
xml_info_library_scanner.cpp
xml_info_library_scanner.h
xml_info_parser.cpp
xml_info_parser.h
yacreader_comic_info_helper.cpp
yacreader_comic_info_helper.h
yacreader_comics_selection_helper.cpp
yacreader_comics_selection_helper.h
yacreader_comics_views_manager.cpp
yacreader_comics_views_manager.h
yacreader_folders_view.cpp
yacreader_folders_view.h
yacreader_history_controller.cpp
yacreader_history_controller.h
yacreader_libraries.cpp
yacreader_libraries.h
yacreader_local_server.cpp
yacreader_local_server.h
yacreader_main_toolbar.cpp
yacreader_main_toolbar.h
yacreader_navigation_controller.cpp
yacreader_navigation_controller.h
yacreader_reading_lists_view.cpp
yacreader_reading_lists_view.h
yacreaderlibrary_de.ts
yacreaderlibrary_es.ts
yacreaderlibrary_fr.ts
yacreaderlibrary_it.ts
yacreaderlibrary_nl.ts
yacreaderlibrary_pt.ts
yacreaderlibrary_ru.ts
yacreaderlibrary_source.ts
yacreaderlibrary_tr.ts
yacreaderlibrary_zh_CN.ts
yacreaderlibrary_zh_HK.ts
yacreaderlibrary_zh_TW.ts
YACReaderLibraryServer
ci
common
compressed_archive
custom_widgets
dependencies
files
images
release
shortcuts_management
tests
third_party
.clang-format
.editorconfig
.gitattributes
.gitignore
CHANGELOG.md
COPYING.txt
INSTALL.md
README.md
YACReader.1
YACReader.desktop
YACReader.pro
YACReader.svg
YACReaderLibrary.1
YACReaderLibrary.desktop
YACReaderLibrary.svg
azure-pipelines-build-number.yml
azure-pipelines-windows-template-qt6.yml
azure-pipelines-windows-template.yml
azure-pipelines.yml
background.png
background@2x.png
cleanOSX.sh
com.yacreader.YACReader.appdata.xml
com.yacreader.YACReader.yml
compileOSX.sh
config.pri
dmg.json
icon.icns
mktarball.sh
signapps.sh
196 lines
5.6 KiB
C++
196 lines
5.6 KiB
C++
#include "create_library_dialog.h"
|
|
|
|
#include <QHBoxLayout>
|
|
#include <QVBoxLayout>
|
|
#include <QFileDialog>
|
|
#include <QSizePolicy>
|
|
#include <QMessageBox>
|
|
|
|
CreateLibraryDialog::CreateLibraryDialog(QWidget *parent)
|
|
: QDialog(parent)
|
|
{
|
|
setupUI();
|
|
}
|
|
|
|
void CreateLibraryDialog::setupUI()
|
|
{
|
|
textLabel = new QLabel(tr("Comics folder : "));
|
|
path = new QLineEdit;
|
|
textLabel->setBuddy(path);
|
|
connect(path, &QLineEdit::textChanged, this, &CreateLibraryDialog::pathSetted);
|
|
|
|
nameLabel = new QLabel(tr("Library Name : "));
|
|
nameEdit = new QLineEdit;
|
|
nameLabel->setBuddy(nameEdit);
|
|
connect(nameEdit, &QLineEdit::textChanged, this, &CreateLibraryDialog::nameSetted);
|
|
|
|
accept = new QPushButton(tr("Create"));
|
|
accept->setDisabled(true);
|
|
connect(accept, &QAbstractButton::clicked, this, &CreateLibraryDialog::create);
|
|
|
|
cancel = new QPushButton(tr("Cancel"));
|
|
connect(cancel, &QAbstractButton::clicked, this, &CreateLibraryDialog::cancelCreate);
|
|
connect(cancel, &QAbstractButton::clicked, this, &CreateLibraryDialog::close);
|
|
|
|
find = new QPushButton(QIcon(":/images/find_folder.png"), "");
|
|
connect(find, &QAbstractButton::clicked, this, &CreateLibraryDialog::findPath);
|
|
|
|
auto content = new QGridLayout;
|
|
|
|
// QHBoxLayout *nameLayout = new QHBoxLayout;
|
|
|
|
content->addWidget(nameLabel, 0, 0);
|
|
content->addWidget(nameEdit, 0, 1);
|
|
|
|
// QHBoxLayout *libraryLayout = new QHBoxLayout;
|
|
|
|
content->addWidget(textLabel, 1, 0);
|
|
content->addWidget(path, 1, 1);
|
|
content->addWidget(find, 1, 2);
|
|
content->setColumnMinimumWidth(2, 0); // TODO
|
|
|
|
auto bottomLayout = new QHBoxLayout;
|
|
bottomLayout->addWidget(message = new QLabel(tr("Create a library could take several minutes. You can stop the process and update the library later for completing the task.")));
|
|
message->setWordWrap(true);
|
|
// message->hide();
|
|
bottomLayout->addStretch();
|
|
bottomLayout->addWidget(accept);
|
|
bottomLayout->addWidget(cancel);
|
|
|
|
auto mainLayout = new QVBoxLayout;
|
|
mainLayout->addLayout(content);
|
|
|
|
mainLayout->addLayout(bottomLayout);
|
|
|
|
auto imgMainLayout = new QHBoxLayout;
|
|
QLabel *imgLabel = new QLabel(this);
|
|
QPixmap p(":/images/new.png");
|
|
imgLabel->setPixmap(p);
|
|
imgMainLayout->addWidget(imgLabel);
|
|
imgMainLayout->addLayout(mainLayout);
|
|
|
|
setLayout(imgMainLayout);
|
|
|
|
setModal(true);
|
|
setWindowTitle(tr("Create new library"));
|
|
}
|
|
|
|
void CreateLibraryDialog::open(const YACReaderLibraries &libs)
|
|
{
|
|
libraries = libs;
|
|
QDialog::open();
|
|
}
|
|
|
|
void CreateLibraryDialog::create()
|
|
{
|
|
|
|
QFileInfo f(path->text());
|
|
if (f.exists() && f.isDir() && f.isWritable()) {
|
|
if (!libraries.contains(nameEdit->text())) {
|
|
emit(createLibrary(QDir::cleanPath(path->text()), QDir::cleanPath(path->text()) + "/.yacreaderlibrary", nameEdit->text()));
|
|
close();
|
|
} else
|
|
emit(libraryExists(nameEdit->text()));
|
|
} else
|
|
QMessageBox::critical(NULL, tr("Path not found"), tr("The selected path does not exist or is not a valid path. Be sure that you have write access to this folder"));
|
|
}
|
|
|
|
void CreateLibraryDialog::nameSetted(const QString &text)
|
|
{
|
|
if (!text.isEmpty()) {
|
|
if (!path->text().isEmpty()) {
|
|
QFileInfo fi(path->text());
|
|
if (fi.isDir())
|
|
accept->setEnabled(true);
|
|
else
|
|
accept->setEnabled(false);
|
|
}
|
|
} else
|
|
accept->setEnabled(false);
|
|
}
|
|
|
|
void CreateLibraryDialog::pathSetted(const QString &text)
|
|
{
|
|
QFileInfo fi(text);
|
|
if (fi.isDir()) {
|
|
if (!nameEdit->text().isEmpty())
|
|
accept->setEnabled(true);
|
|
} else
|
|
accept->setEnabled(false);
|
|
}
|
|
|
|
void CreateLibraryDialog::findPath()
|
|
{
|
|
QString s = QFileDialog::getExistingDirectory(0, "Comics directory", ".");
|
|
if (!s.isEmpty()) {
|
|
path->setText(s);
|
|
if (!nameEdit->text().isEmpty())
|
|
accept->setEnabled(true);
|
|
} else
|
|
accept->setEnabled(false);
|
|
}
|
|
|
|
void CreateLibraryDialog::close()
|
|
{
|
|
path->clear();
|
|
nameEdit->clear();
|
|
accept->setEnabled(false);
|
|
QDialog::close();
|
|
}
|
|
|
|
void CreateLibraryDialog::setDataAndStart(QString name, QString path)
|
|
{
|
|
this->path->setText(path);
|
|
this->nameEdit->setText(name);
|
|
QDialog::open();
|
|
create();
|
|
}
|
|
//-----------------------------------------------------------------------------
|
|
// UpdateLibraryDialog
|
|
//-----------------------------------------------------------------------------
|
|
UpdateLibraryDialog::UpdateLibraryDialog(QWidget *parent)
|
|
: QDialog(parent)
|
|
{
|
|
auto mainLayout = new QVBoxLayout;
|
|
mainLayout->addWidget(message = new QLabel(tr("Updating....")));
|
|
mainLayout->addWidget(currentFileLabel = new QLabel("\n\n\n\n"));
|
|
currentFileLabel->setWordWrap(true);
|
|
|
|
auto bottom = new QHBoxLayout;
|
|
bottom->addStretch();
|
|
bottom->addWidget(cancel = new QPushButton(tr("Cancel")));
|
|
|
|
connect(cancel, &QAbstractButton::clicked, this, &UpdateLibraryDialog::cancelUpdate);
|
|
connect(cancel, &QAbstractButton::clicked, this, &UpdateLibraryDialog::close);
|
|
|
|
mainLayout->addStretch();
|
|
|
|
mainLayout->addLayout(bottom);
|
|
|
|
auto imgMainLayout = new QHBoxLayout;
|
|
QLabel *imgLabel = new QLabel(this);
|
|
QPixmap p(":/images/updateLibrary.png");
|
|
imgLabel->setPixmap(p);
|
|
imgMainLayout->addWidget(imgLabel);
|
|
imgMainLayout->addLayout(mainLayout);
|
|
|
|
setLayout(imgMainLayout);
|
|
|
|
setModal(true);
|
|
setWindowTitle(tr("Update library"));
|
|
}
|
|
|
|
void UpdateLibraryDialog::showCurrentFile(QString file)
|
|
{
|
|
currentFileLabel->setText(file);
|
|
currentFileLabel->update();
|
|
this->update();
|
|
}
|
|
|
|
void UpdateLibraryDialog::close()
|
|
{
|
|
currentFileLabel->setText("");
|
|
this->adjustSize();
|
|
QDialog::close();
|
|
}
|