Subversion Repositories Scribus

Compare Revisions

Ignore whitespace Rev 24697 → Rev 24698

/trunk/Scribus/scribus/ui/customfdialog.cpp
25,6 → 25,7
#include <QApplication>
#include <QCheckBox>
#include <QComboBox>
#include <QDesktopWidget>
#include <QDir>
#include <QFileInfo>
#include <QFrame>
35,6 → 36,7
#include <QPainter>
#include <QPixmap>
#include <QPushButton>
#include <QScreen>
#include <QTextCodec>
#include <QVBoxLayout>
 
46,6 → 48,8
#include "fileloader.h"
#include "iconmanager.h"
#include "loadsaveplugin.h"
#include "prefscontext.h"
#include "prefsfile.h"
#include "prefsmanager.h"
#include "scfilewidget.h"
#include "scimage.h"
57,9 → 61,6
#include "util_color.h"
#include "util_formats.h"
 
 
 
 
extern QString DocDir;
 
ImIconProvider::ImIconProvider()
284,6 → 285,8
CustomFDialog::CustomFDialog(QWidget *parent, const QString& wDir, const QString& caption, const QString& filter, int flags)
: QDialog(parent), m_optionFlags(flags)
{
m_fileDialogPrefs = PrefsManager::instance().prefsFile->getContext("customfdialog", false);
 
setModal(true);
setWindowTitle(caption);
setWindowIcon(IconManager::instance().loadIcon("AppIcon.png"));
491,6 → 494,48
{
}
 
void CustomFDialog::closeEvent(QCloseEvent *closeEvent)
{
storeSize();
QDialog::closeEvent(closeEvent);
}
 
void CustomFDialog::hideEvent(QHideEvent* hideEvent)
{
storeSize();
QDialog::hideEvent(hideEvent);
}
 
void CustomFDialog::showEvent(QShowEvent *showEvent)
{
QScreen* dialogScreen = this->screen();
if (m_fileDialogPrefs && dialogScreen && !showEvent->spontaneous())
{
if (m_fileDialogPrefs->contains("width"))
{
QRect scr = dialogScreen->availableGeometry();
int fdWidth = qMax(0, qMin(m_fileDialogPrefs->getInt("width"), scr.width()));
int fdHeight = qMax(0, qMin(m_fileDialogPrefs->getInt("height"), scr.height()));
if (fdWidth > 0 && fdHeight > 0)
{
int newWidth = qMax(0, qMin(this->width() + fdWidth - fileDialog->width(), scr.width()));
int newHeight = qMax(0, qMin(this->height() + fdHeight - fileDialog->height(), scr.height()));
if (newWidth > 0 && newHeight > 0)
resize(newWidth, newHeight);
}
}
}
QDialog::showEvent(showEvent);
}
 
void CustomFDialog::storeSize()
{
if (!m_fileDialogPrefs)
return;
m_fileDialogPrefs->set("width", fileDialog->width());
m_fileDialogPrefs->set("height", fileDialog->height());
}
 
void CustomFDialog::fileClicked(const QString &path)
{
if (m_optionFlags & fdDisableOk)
/trunk/Scribus/scribus/ui/customfdialog.h
27,14 → 27,17
#include <QDialog>
#include <QFileIconProvider>
#include <QLabel>
 
class QPushButton;
class QComboBox;
class QCheckBox;
class QIcon;
class QHBoxLayout;
class QVBoxLayout;
class QFrame;
 
class PrefsContext;
class ScFileWidget;
class QIcon;
 
#include "scribusapi.h"
 
171,13 → 174,24
QPushButton* okButton { nullptr };
QPushButton* cancelButton { nullptr };
 
PrefsContext* m_fileDialogPrefs { nullptr };
 
//! \brief Property with default extension
QString m_ext;
//! \brief Property with default compress extension
QString m_extZip;
//! \brief Option flags given by user in ctore
int m_optionFlags;
bool m_previewIsShown;
int m_optionFlags { 0 };
bool m_previewIsShown { false };
 
/** @brief Restore the geometry of the window when showing it. */
void showEvent(QShowEvent *showEvent) override;
/** @brief Captures the close event and changes it to hide */
void closeEvent(QCloseEvent *closeEvent) override;
/** @brief Stores the geometry of the window when hiding. */
void hideEvent(QHideEvent* hideEvent) override;
 
void storeSize();
};
 
#endif
/trunk/Scribus/scribus/ui/gtfiledialog.cpp
5,8 → 5,10
for which a new license (GPL+exception) is in place.
*/
#include <QPushButton>
#include <QScreen>
#include <QToolTip>
#include <QTextCodec>
 
#include "gtfiledialog.h"
 
#include "prefsmanager.h"
15,6 → 17,8
 
gtFileDialog::gtFileDialog(const QString& filters, const QStringList& importers, const QString& wdir)
{
m_fileDialogPrefs = PrefsManager::instance().prefsFile->getContext("gtFileDialog", false);
 
setupUi(this);
 
fileWidget->setDirectory(wdir);
53,6 → 57,40
connect(buttonBox, SIGNAL(rejected()), this, SLOT(reject()));
}
 
void gtFileDialog::closeEvent(QCloseEvent *closeEvent)
{
storeSize();
QDialog::closeEvent(closeEvent);
}
 
void gtFileDialog::hideEvent(QHideEvent* hideEvent)
{
storeSize();
QDialog::hideEvent(hideEvent);
}
 
void gtFileDialog::showEvent(QShowEvent *showEvent)
{
QScreen* dialogScreen = this->screen();
if (m_fileDialogPrefs && dialogScreen && !showEvent->spontaneous())
{
if (m_fileDialogPrefs->contains("width"))
{
QRect scr = dialogScreen->availableGeometry();
int fdWidth = qMax(0, qMin(m_fileDialogPrefs->getInt("width"), scr.width()));
int fdHeight = qMax(0, qMin(m_fileDialogPrefs->getInt("height"), scr.height()));
if (fdWidth > 0 && fdHeight > 0)
{
int newWidth = qMax(0, qMin(this->width() + fdWidth - fileWidget->width(), scr.width()));
int newHeight = qMax(0, qMin(this->height() + fdHeight - fileWidget->height(), scr.height()));
if (newWidth > 0 && newHeight > 0)
resize(newWidth, newHeight);
}
}
}
QDialog::showEvent(showEvent);
}
 
QString gtFileDialog::selectedFile()
{
return fileWidget->selectedFile();
129,6 → 167,10
context->set("prefix", prefixStylesCheckBox->isChecked());
}
 
gtFileDialog::~gtFileDialog()
void gtFileDialog::storeSize()
{
if (!m_fileDialogPrefs)
return;
m_fileDialogPrefs->set("width", fileWidget->width());
m_fileDialogPrefs->set("height", fileWidget->height());
}
/trunk/Scribus/scribus/ui/gtfiledialog.h
11,6 → 11,7
#include "ui_gtfiledialog.h"
#include "scribusapi.h"
 
class PrefsContext;
 
/*! \brief Enhanced file dialog for get-text plugins
This class is separated from gtdialogs.h file due the huge
23,7 → 24,7
Q_OBJECT
public:
gtFileDialog(const QString& filters, const QStringList& importers, const QString& wdir);
~gtFileDialog();
~gtFileDialog() {};
 
QString selectedFile();
 
33,6 → 34,17
void okClicked();
 
protected:
PrefsContext* m_fileDialogPrefs { nullptr };
 
/** @brief Restore the geometry of the window when showing it. */
void showEvent(QShowEvent *showEvent) override;
/** @brief Captures the close event and changes it to hide */
void closeEvent(QCloseEvent *closeEvent) override;
/** @brief Stores the geometry of the window when hiding. */
void hideEvent(QHideEvent* hideEvent) override;
 
void storeSize();
 
void loadSettings();
void saveSettings();
};