Rev 20185 | Details | Compare with Previous | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
4430 | cbradney | 1 | /* |
2 | For general Scribus (>=1.3.2) copyright and licensing information please refer |
||
3 | to the COPYING file provided with the program. Following this notice may exist |
||
4 | a copyright and/or license notice that predates the release of Scribus 1.3.2 |
||
5 | for which a new license (GPL+exception) is in place. |
||
6 | */ |
||
3 | paul | 7 | #include "newfile.h" |
3699 | cbradney | 8 | |
12594 | cbradney | 9 | #include <QFormLayout> |
9894 | fschmid | 10 | #include <QGridLayout> |
11 | #include <QHBoxLayout> |
||
12 | #include <QVBoxLayout> |
||
18154 | jghali | 13 | |
14 | #include <QDir> |
||
15 | #include <QCheckBox> |
||
16 | #include <QFileDialog> |
||
9894 | fschmid | 17 | #include <QFrame> |
18 | #include <QGroupBox> |
||
8501 | cbradney | 19 | #include <QLabel> |
18154 | jghali | 20 | #include <QListWidgetItem> |
21 | #include <QPixmap> |
||
22 | #include <QPoint> |
||
23 | #include <QPushButton> |
||
24 | #include <QSpacerItem> |
||
9894 | fschmid | 25 | #include <QSpinBox> |
19180 | craig | 26 | #include <QStandardPaths> |
27 | #include <QStringList> |
||
9894 | fschmid | 28 | #include <QTabWidget> |
29 | #include <QToolTip> |
||
3699 | cbradney | 30 | |
18154 | jghali | 31 | #include "scconfig.h" |
32 | |||
33 | #include "commonstrings.h" |
||
3699 | cbradney | 34 | #include "fileloader.h" |
18154 | jghali | 35 | #include "marginwidget.h" |
1542 | cbradney | 36 | #include "pagesize.h" |
5781 | cbradney | 37 | #include "scribuscore.h" |
2901 | fschmid | 38 | #include "pagelayout.h" |
4122 | cbradney | 39 | #include "pagestructs.h" |
18154 | jghali | 40 | #include "prefsfile.h" |
41 | #include "prefsmanager.h" |
||
42 | #include "sccombobox.h" |
||
19153 | craig | 43 | #include "filedialogeventcatcher.h" |
8602 | cbradney | 44 | #include "scrspinbox.h" |
18154 | jghali | 45 | #include "units.h" |
20185 | craig | 46 | #include "iconmanager.h" |
401 | Franz | 47 | |
9897 | fschmid | 48 | PageLayoutsWidget::PageLayoutsWidget(QWidget* parent) : QListWidget(parent) |
49 | { |
||
50 | setDragEnabled(false); |
||
51 | setViewMode(QListView::IconMode); |
||
52 | setFlow(QListView::LeftToRight); |
||
53 | setSortingEnabled(false); |
||
54 | setWrapping(false); |
||
55 | setWordWrap(true); |
||
56 | setAcceptDrops(false); |
||
57 | setDropIndicatorShown(false); |
||
58 | setDragDropMode(QAbstractItemView::NoDragDrop); |
||
59 | setResizeMode(QListView::Adjust); |
||
60 | setSelectionMode(QAbstractItemView::SingleSelection); |
||
61 | setFocusPolicy(Qt::NoFocus); |
||
62 | setIconSize(QSize(32, 32)); |
||
63 | clear(); |
||
64 | setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Expanding); |
||
65 | } |
||
3205 | craig | 66 | |
9897 | fschmid | 67 | void PageLayoutsWidget::arrangeIcons() |
68 | { |
||
69 | QListWidgetItem* ic; |
||
70 | int startY = 5; |
||
71 | int startX = 5; |
||
72 | setResizeMode(QListView::Fixed); |
||
73 | int maxSizeY = 0; |
||
74 | for (int cc = 0; cc < count(); ++cc) |
||
75 | { |
||
76 | ic = item(cc); |
||
77 | QRect ir = visualItemRect(ic); |
||
78 | setPositionForIndex(QPoint(startX, startY), indexFromItem(ic)); |
||
79 | startX += ir.width()+5; |
||
80 | maxSizeY = qMax(maxSizeY, ir.height()); |
||
81 | } |
||
82 | maxX = startX; |
||
83 | maxY = maxSizeY+10; |
||
84 | } |
||
85 | |||
19597 | jghali | 86 | QSize PageLayoutsWidget::minimumSizeHint() const |
9897 | fschmid | 87 | { |
88 | return QSize(maxX, maxY); |
||
89 | } |
||
90 | |||
15417 | craig | 91 | NewDoc::NewDoc( QWidget* parent, const QStringList& recentDocs, bool startUp, QString lang) : QDialog( parent ) |
3 | paul | 92 | { |
13487 | cbradney | 93 | setObjectName(QString::fromLocal8Bit("NewDocumentWindow")); |
9894 | fschmid | 94 | setModal(true); |
2834 | cbradney | 95 | prefsManager=PrefsManager::instance(); |
13236 | jghali | 96 | m_tabSelected = 0; |
97 | m_onStartup = startUp; |
||
13876 | cbradney | 98 | m_unitIndex = prefsManager->appPrefs.docSetupPrefs.docUnitIndex; |
13236 | jghali | 99 | m_unitRatio = unitGetRatioFromIndex(m_unitIndex); |
100 | m_unitSuffix = unitGetSuffixFromIndex(m_unitIndex); |
||
13876 | cbradney | 101 | m_orientation = prefsManager->appPrefs.docSetupPrefs.pageOrientation; |
9894 | fschmid | 102 | setWindowTitle( tr( "New Document" ) ); |
20185 | craig | 103 | setWindowIcon(IconManager::instance()->loadIcon("AppIcon.png")); |
9894 | fschmid | 104 | TabbedNewDocLayout = new QVBoxLayout( this ); |
105 | TabbedNewDocLayout->setMargin(10); |
||
106 | TabbedNewDocLayout->setSpacing(5); |
||
2830 | fschmid | 107 | if (startUp) |
10529 | fschmid | 108 | tabWidget = new QTabWidget( this ); |
2830 | fschmid | 109 | createNewDocPage(); |
110 | if (startUp) |
||
111 | { |
||
3803 | cbradney | 112 | tabWidget->addTab(newDocFrame, tr("&New Document")); |
13188 | fschmid | 113 | createNewFromTempPage(); |
15417 | craig | 114 | nftGui->setupSettings(lang); |
13188 | fschmid | 115 | tabWidget->addTab(newFromTempFrame, tr("New &from Template")); |
2842 | fschmid | 116 | createOpenDocPage(); |
3803 | cbradney | 117 | tabWidget->addTab(openDocFrame, tr("Open &Existing Document")); |
5781 | cbradney | 118 | recentDocList=recentDocs; |
5918 | cbradney | 119 | createRecentDocPage(); |
120 | tabWidget->addTab(recentDocFrame, tr("Open Recent &Document")); |
||
121 | TabbedNewDocLayout->addWidget(tabWidget); |
||
2830 | fschmid | 122 | } |
123 | else |
||
124 | TabbedNewDocLayout->addWidget(newDocFrame); |
||
125 | |||
9894 | fschmid | 126 | Layout1 = new QHBoxLayout; |
127 | Layout1->setSpacing( 5 ); |
||
2830 | fschmid | 128 | Layout1->setMargin( 0 ); |
2833 | fschmid | 129 | if (startUp) |
130 | { |
||
10529 | fschmid | 131 | startUpDialog = new QCheckBox( tr( "Do not show this dialog again" ), this ); |
13876 | cbradney | 132 | startUpDialog->setChecked(!prefsManager->appPrefs.uiPrefs.showStartupDialog); |
2833 | fschmid | 133 | Layout1->addWidget( startUpDialog ); |
134 | } |
||
9894 | fschmid | 135 | QSpacerItem* spacer = new QSpacerItem( 2, 2, QSizePolicy::Expanding, QSizePolicy::Minimum ); |
2830 | fschmid | 136 | Layout1->addItem( spacer ); |
10529 | fschmid | 137 | OKButton = new QPushButton( CommonStrings::tr_OK, this ); |
2830 | fschmid | 138 | OKButton->setDefault( true ); |
139 | Layout1->addWidget( OKButton ); |
||
10529 | fschmid | 140 | CancelB = new QPushButton( CommonStrings::tr_Cancel, this ); |
2830 | fschmid | 141 | CancelB->setAutoDefault( false ); |
142 | Layout1->addWidget( CancelB ); |
||
143 | TabbedNewDocLayout->addLayout( Layout1 ); |
||
144 | //tooltips |
||
10397 | cbradney | 145 | pageSizeComboBox->setToolTip( tr( "Document page size, either a standard size or a custom size" ) ); |
146 | pageOrientationComboBox->setToolTip( tr( "Orientation of the document's pages" ) ); |
||
147 | widthSpinBox->setToolTip( tr( "Width of the document's pages, editable if you have chosen a custom page size" ) ); |
||
148 | heightSpinBox->setToolTip( tr( "Height of the document's pages, editable if you have chosen a custom page size" ) ); |
||
149 | pageCountSpinBox->setToolTip( tr( "Initial number of pages of the document" ) ); |
||
150 | unitOfMeasureComboBox->setToolTip( tr( "Default unit of measurement for document editing" ) ); |
||
151 | autoTextFrame->setToolTip( tr( "Create text frames automatically when new pages are added" ) ); |
||
152 | numberOfCols->setToolTip( tr( "Number of columns to create in automatically created text frames" ) ); |
||
153 | Distance->setToolTip( tr( "Distance between automatically created columns" ) ); |
||
2830 | fschmid | 154 | |
155 | // signals and slots connections |
||
156 | connect( OKButton, SIGNAL( clicked() ), this, SLOT( ExitOK() ) ); |
||
157 | connect( CancelB, SIGNAL( clicked() ), this, SLOT( reject() ) ); |
||
13236 | jghali | 158 | connect(pageSizeComboBox, SIGNAL(activated(const QString &)), this, SLOT(setPageSize(const QString &))); |
159 | connect(pageOrientationComboBox, SIGNAL(activated(int)), this, SLOT(setOrientation(int))); |
||
5918 | cbradney | 160 | connect(unitOfMeasureComboBox, SIGNAL(activated(int)), this, SLOT(setUnit(int))); |
13236 | jghali | 161 | connect(Distance, SIGNAL(valueChanged(double)), this, SLOT(setDistance(double))); |
7023 | fschmid | 162 | connect(autoTextFrame, SIGNAL(clicked()), this, SLOT(handleAutoFrame())); |
9894 | fschmid | 163 | connect(layoutsView, SIGNAL(itemClicked(QListWidgetItem *)), this, SLOT(itemSelected(QListWidgetItem* ))); |
164 | connect(layoutsView, SIGNAL(itemDoubleClicked(QListWidgetItem *)), this, SLOT(itemSelected(QListWidgetItem* ))); |
||
165 | connect(layoutsView, SIGNAL(itemActivated(QListWidgetItem *)), this, SLOT(itemSelected(QListWidgetItem* ))); |
||
166 | connect(layoutsView, SIGNAL(itemPressed(QListWidgetItem *)), this, SLOT(itemSelected(QListWidgetItem* ))); |
||
2874 | subik | 167 | if (startUp) |
13188 | fschmid | 168 | { |
169 | connect(nftGui, SIGNAL(leaveOK()), this, SLOT(ExitOK())); |
||
9894 | fschmid | 170 | connect(recentDocListBox, SIGNAL(itemDoubleClicked(QListWidgetItem *)), this, SLOT(recentDocListBox_doubleClicked())); |
14452 | fschmid | 171 | connect(tabWidget, SIGNAL(currentChanged(int)), this, SLOT(adjustTitles(int))); |
13188 | fschmid | 172 | } |
2874 | subik | 173 | |
12594 | cbradney | 174 | // setMinimumSize(minimumSizeHint()); |
175 | // setMaximumSize(minimumSizeHint()); |
||
176 | // resize(minimumSizeHint()); |
||
2830 | fschmid | 177 | } |
178 | |||
179 | void NewDoc::createNewDocPage() |
||
180 | { |
||
9894 | fschmid | 181 | newDocFrame = new QFrame(this); |
7025 | fschmid | 182 | |
9894 | fschmid | 183 | pageSizeGroupBox = new QGroupBox(newDocFrame ); |
7552 | mrdocs | 184 | pageSizeGroupBox->setTitle( tr( "Document Layout" ) ); |
9894 | fschmid | 185 | pageSizeGroupBoxLayout = new QGridLayout( pageSizeGroupBox ); |
186 | pageSizeGroupBoxLayout->setMargin(10); |
||
187 | pageSizeGroupBoxLayout->setSpacing(5); |
||
5918 | cbradney | 188 | pageSizeGroupBoxLayout->setAlignment( Qt::AlignTop ); |
7025 | fschmid | 189 | |
9897 | fschmid | 190 | layoutsView = new PageLayoutsWidget( pageSizeGroupBox ); |
191 | layoutsView->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Maximum); |
||
8557 | subik | 192 | for (int pg = 0; pg < prefsManager->appPrefs.pageSets.count(); ++pg) |
7025 | fschmid | 193 | { |
9894 | fschmid | 194 | QListWidgetItem *ic; |
7025 | fschmid | 195 | QString psname=CommonStrings::translatePageSetString(prefsManager->appPrefs.pageSets[pg].Name); |
196 | if (pg == 0) |
||
197 | { |
||
20185 | craig | 198 | ic = new QListWidgetItem( IconManager::instance()->loadIcon("32/page-simple.png"), psname, layoutsView ); |
9894 | fschmid | 199 | ic->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled); |
7025 | fschmid | 200 | } |
201 | else if (pg == 1) |
||
202 | { |
||
20185 | craig | 203 | ic = new QListWidgetItem( IconManager::instance()->loadIcon("32/page-doublesided.png"), psname, layoutsView ); |
9894 | fschmid | 204 | ic->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled); |
7025 | fschmid | 205 | } |
19885 | craig | 206 | else if (pg == 2 && prefsManager->appPrefs.docSetupPrefs.pagePositioning == 2) |
7025 | fschmid | 207 | { |
20185 | craig | 208 | ic = new QListWidgetItem( IconManager::instance()->loadIcon("32/page-3fold.png"), psname, layoutsView ); |
9894 | fschmid | 209 | ic->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled); |
7025 | fschmid | 210 | } |
19885 | craig | 211 | else if (pg == 3 && prefsManager->appPrefs.docSetupPrefs.pagePositioning == 3) |
7025 | fschmid | 212 | { |
20185 | craig | 213 | ic = new QListWidgetItem( IconManager::instance()->loadIcon("32/page-4fold.png"), psname, layoutsView ); |
9894 | fschmid | 214 | ic->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled); |
7025 | fschmid | 215 | } |
216 | } |
||
9897 | fschmid | 217 | layoutsView->arrangeIcons(); |
9894 | fschmid | 218 | pageSizeGroupBoxLayout->addWidget( layoutsView, 0, 0, 5, 1 ); |
9897 | fschmid | 219 | layoutsView->arrangeIcons(); |
7230 | subik | 220 | |
221 | |||
10529 | fschmid | 222 | TextLabel1 = new QLabel( tr( "&Size:" ), pageSizeGroupBox ); |
7025 | fschmid | 223 | pageSizeGroupBoxLayout->addWidget( TextLabel1, 0, 1 ); |
13876 | cbradney | 224 | PageSize ps(prefsManager->appPrefs.docSetupPrefs.pageSize); |
10529 | fschmid | 225 | pageSizeComboBox = new QComboBox( pageSizeGroupBox ); |
15105 | cbradney | 226 | pageSizeComboBox->addItems(ps.activeSizeTRList()); |
10529 | fschmid | 227 | pageSizeComboBox->addItem( CommonStrings::trCustomPageSize ); |
4555 | cbradney | 228 | pageSizeComboBox->setEditable(false); |
229 | TextLabel1->setBuddy(pageSizeComboBox); |
||
7025 | fschmid | 230 | pageSizeGroupBoxLayout->addWidget(pageSizeComboBox, 0, 2 ); |
10529 | fschmid | 231 | TextLabel2 = new QLabel( tr( "Orie&ntation:" ), pageSizeGroupBox ); |
7025 | fschmid | 232 | pageSizeGroupBoxLayout->addWidget( TextLabel2, 1, 1 ); |
10529 | fschmid | 233 | pageOrientationComboBox = new QComboBox( pageSizeGroupBox ); |
234 | pageOrientationComboBox->addItem( tr( "Portrait" ) ); |
||
235 | pageOrientationComboBox->addItem( tr( "Landscape" ) ); |
||
4555 | cbradney | 236 | pageOrientationComboBox->setEditable(false); |
13876 | cbradney | 237 | pageOrientationComboBox->setCurrentIndex(prefsManager->appPrefs.docSetupPrefs.pageOrientation); |
4555 | cbradney | 238 | TextLabel2->setBuddy(pageOrientationComboBox); |
7025 | fschmid | 239 | pageSizeGroupBoxLayout->addWidget( pageOrientationComboBox, 1, 2 ); |
3 | paul | 240 | |
10529 | fschmid | 241 | TextLabel1_2 = new QLabel( tr( "&Width:" ), pageSizeGroupBox ); |
7025 | fschmid | 242 | pageSizeGroupBoxLayout->addWidget(TextLabel1_2, 2, 1 ); |
13236 | jghali | 243 | widthSpinBox = new ScrSpinBox( 1, 16777215, pageSizeGroupBox, m_unitIndex ); |
244 | widthSpinBox->setSuffix(m_unitSuffix); |
||
8602 | cbradney | 245 | TextLabel1_2->setBuddy(widthSpinBox); |
246 | pageSizeGroupBoxLayout->addWidget(widthSpinBox, 2, 2 ); |
||
10529 | fschmid | 247 | TextLabel2_2 = new QLabel( tr( "&Height:" ), pageSizeGroupBox ); |
7025 | fschmid | 248 | pageSizeGroupBoxLayout->addWidget(TextLabel2_2, 3, 1 ); |
13236 | jghali | 249 | heightSpinBox = new ScrSpinBox( 1, 16777215, pageSizeGroupBox, m_unitIndex ); |
250 | heightSpinBox->setSuffix(m_unitSuffix); |
||
8602 | cbradney | 251 | TextLabel2_2->setBuddy(heightSpinBox); |
252 | pageSizeGroupBoxLayout->addWidget(heightSpinBox, 3, 2 ); |
||
3 | paul | 253 | |
19835 | craig | 254 | unitOfMeasureLabel = new QLabel( tr( "&Default Unit:" ), pageSizeGroupBox ); |
255 | unitOfMeasureComboBox = new QComboBox( pageSizeGroupBox ); |
||
256 | unitOfMeasureComboBox->addItems(unitGetTextUnitList()); |
||
257 | unitOfMeasureComboBox->setCurrentIndex(m_unitIndex); |
||
258 | unitOfMeasureComboBox->setEditable(false); |
||
259 | unitOfMeasureLabel->setBuddy(unitOfMeasureComboBox); |
||
260 | pageSizeGroupBoxLayout->addWidget( unitOfMeasureLabel, 4, 1 ); |
||
261 | pageSizeGroupBoxLayout->addWidget( unitOfMeasureComboBox, 4, 2 ); |
||
262 | |||
13876 | cbradney | 263 | MarginStruct marg(prefsManager->appPrefs.docSetupPrefs.margins); |
13236 | jghali | 264 | marginGroup = new MarginWidget(newDocFrame, tr( "Margin Guides" ), &marg, m_unitIndex ); |
13876 | cbradney | 265 | marginGroup->setPageWidthHeight(prefsManager->appPrefs.docSetupPrefs.pageWidth, prefsManager->appPrefs.docSetupPrefs.pageHeight); |
266 | marginGroup->setFacingPages(!(prefsManager->appPrefs.docSetupPrefs.pagePositioning == singlePage)); |
||
267 | widthSpinBox->setValue(prefsManager->appPrefs.docSetupPrefs.pageWidth * m_unitRatio); |
||
268 | heightSpinBox->setValue(prefsManager->appPrefs.docSetupPrefs.pageHeight * m_unitRatio); |
||
15105 | cbradney | 269 | QStringList pageSizes=ps.activeSizeTRList(); |
10517 | cbradney | 270 | int sizeIndex=pageSizes.indexOf(ps.nameTR()); |
7023 | fschmid | 271 | if (sizeIndex!=-1) |
10529 | fschmid | 272 | pageSizeComboBox->setCurrentIndex(sizeIndex); |
7023 | fschmid | 273 | else |
10529 | fschmid | 274 | pageSizeComboBox->setCurrentIndex(pageSizeComboBox->count()-1); |
7023 | fschmid | 275 | marginGroup->setPageSize(pageSizeComboBox->currentText()); |
13876 | cbradney | 276 | marginGroup->setNewBleeds(prefsManager->appPrefs.docSetupPrefs.bleeds); |
277 | marginGroup->setMarginPreset(prefsManager->appPrefs.docSetupPrefs.marginPreset); |
||
7023 | fschmid | 278 | |
9894 | fschmid | 279 | optionsGroupBox = new QGroupBox( newDocFrame ); |
5918 | cbradney | 280 | optionsGroupBox->setTitle( tr( "Options" ) ); |
12594 | cbradney | 281 | optionsGroupBoxLayout = new QFormLayout( optionsGroupBox ); |
9894 | fschmid | 282 | optionsGroupBoxLayout->setSpacing( 5 ); |
283 | optionsGroupBoxLayout->setMargin( 10 ); |
||
5918 | cbradney | 284 | optionsGroupBoxLayout->setAlignment( Qt::AlignTop ); |
12664 | fschmid | 285 | optionsGroupBoxLayout->setFormAlignment(Qt::AlignLeft | Qt::AlignTop); |
286 | optionsGroupBoxLayout->setLabelAlignment(Qt::AlignLeft); |
||
10529 | fschmid | 287 | pageCountLabel = new QLabel( tr( "N&umber of Pages:" ), optionsGroupBox ); |
7230 | subik | 288 | |
10529 | fschmid | 289 | pageCountSpinBox = new QSpinBox( optionsGroupBox ); |
10493 | fschmid | 290 | pageCountSpinBox->setMaximum( 10000 ); |
291 | pageCountSpinBox->setMinimum( 1 ); |
||
5918 | cbradney | 292 | pageCountLabel->setBuddy(pageCountSpinBox); |
12594 | cbradney | 293 | optionsGroupBoxLayout->addRow( pageCountLabel, pageCountSpinBox); |
5918 | cbradney | 294 | |
19835 | craig | 295 | layoutLabel1 = new QLabel( optionsGroupBox ); |
296 | layoutLabel1->setText( tr( "First Page is:" ) ); |
||
297 | firstPage = new ScComboBox( optionsGroupBox ); |
||
298 | firstPage->clear(); |
||
299 | selectItem(prefsManager->appPrefs.docSetupPrefs.pagePositioning); |
||
300 | optionsGroupBoxLayout->addRow( layoutLabel1, firstPage ); |
||
301 | firstPage->setCurrentIndex(prefsManager->appPrefs.pageSets[prefsManager->appPrefs.docSetupPrefs.pagePositioning].FirstPage); |
||
302 | |||
303 | setDocLayout(prefsManager->appPrefs.docSetupPrefs.pagePositioning); |
||
304 | setSize(prefsManager->appPrefs.docSetupPrefs.pageSize); |
||
305 | setOrientation(prefsManager->appPrefs.docSetupPrefs.pageOrientation); |
||
306 | |||
10529 | fschmid | 307 | autoTextFrame = new QCheckBox( optionsGroupBox ); |
7023 | fschmid | 308 | autoTextFrame->setText( tr( "&Automatic Text Frames" ) ); |
12594 | cbradney | 309 | optionsGroupBoxLayout->addRow( autoTextFrame ); |
10529 | fschmid | 310 | TextLabel3 = new QLabel( tr( "Colu&mns:" ), optionsGroupBox ); |
311 | numberOfCols = new QSpinBox( optionsGroupBox ); |
||
7230 | subik | 312 | numberOfCols->setButtonSymbols( QSpinBox::UpDownArrows ); |
10529 | fschmid | 313 | numberOfCols->setMinimum( 1 ); |
7230 | subik | 314 | numberOfCols->setValue( 1 ); |
315 | TextLabel3->setBuddy(numberOfCols); |
||
12594 | cbradney | 316 | optionsGroupBoxLayout->addRow( TextLabel3, numberOfCols ); |
7230 | subik | 317 | |
10529 | fschmid | 318 | TextLabel4 = new QLabel( tr( "&Gap:" ), optionsGroupBox ); |
13236 | jghali | 319 | Distance = new ScrSpinBox( 0, 1000, optionsGroupBox, m_unitIndex ); |
320 | Distance->setValue(11 * m_unitRatio); |
||
321 | m_distance = 11; |
||
12594 | cbradney | 322 | optionsGroupBoxLayout->addRow( TextLabel4, Distance ); |
340 | Franz | 323 | TextLabel4->setBuddy(Distance); |
7230 | subik | 324 | |
19835 | craig | 325 | firstPage->setMinimumWidth(Distance->width()); |
326 | |||
7023 | fschmid | 327 | TextLabel3->setEnabled(false); |
328 | TextLabel4->setEnabled(false); |
||
329 | Distance->setEnabled(false); |
||
330 | numberOfCols->setEnabled(false); |
||
10529 | fschmid | 331 | startDocSetup = new QCheckBox( optionsGroupBox ); |
7140 | mrdocs | 332 | startDocSetup->setText( tr( "Show Document Settings After Creation" ) ); |
7023 | fschmid | 333 | startDocSetup->setChecked(false); |
12594 | cbradney | 334 | optionsGroupBoxLayout->addRow( startDocSetup ); |
9894 | fschmid | 335 | NewDocLayout = new QGridLayout( newDocFrame ); |
336 | NewDocLayout->setMargin(10); |
||
337 | NewDocLayout->setSpacing(5); |
||
7025 | fschmid | 338 | NewDocLayout->addWidget( marginGroup, 1, 0 ); |
339 | NewDocLayout->addWidget( optionsGroupBox, 1, 1 ); |
||
9894 | fschmid | 340 | NewDocLayout->addWidget( pageSizeGroupBox, 0, 0, 1, 2); |
2830 | fschmid | 341 | } |
3 | paul | 342 | |
13188 | fschmid | 343 | void NewDoc::createNewFromTempPage() |
344 | { |
||
345 | newFromTempFrame = new QFrame(this); |
||
346 | verticalLayout = new QVBoxLayout(newFromTempFrame); |
||
347 | nftGui = new nftwidget(newFromTempFrame); |
||
348 | verticalLayout->addWidget(nftGui); |
||
349 | } |
||
350 | |||
2830 | fschmid | 351 | void NewDoc::createOpenDocPage() |
352 | { |
||
2856 | cbradney | 353 | PrefsContext* docContext = prefsManager->prefsFile->getContext("docdirs", false); |
2830 | fschmid | 354 | QString docDir = "."; |
2871 | cbradney | 355 | QString prefsDocDir=prefsManager->documentDir(); |
2877 | cbradney | 356 | if (!prefsDocDir.isEmpty()) |
2871 | cbradney | 357 | docDir = docContext->get("docsopen", prefsDocDir); |
2830 | fschmid | 358 | else |
359 | docDir = docContext->get("docsopen", "."); |
||
3644 | craig | 360 | QString formats(FileLoader::getLoadFilterString()); |
14061 | fschmid | 361 | // formats.remove("PDF (*.pdf *.PDF);;"); |
9894 | fschmid | 362 | openDocFrame = new QFrame(this); |
363 | openDocLayout = new QVBoxLayout(openDocFrame); |
||
364 | openDocLayout->setMargin(5); |
||
365 | openDocLayout->setSpacing(5); |
||
13236 | jghali | 366 | m_selectedFile = ""; |
18154 | jghali | 367 | |
10034 | fschmid | 368 | fileDialog = new QFileDialog(openDocFrame, tr("Open"), docDir, formats); |
369 | fileDialog->setFileMode(QFileDialog::ExistingFile); |
||
370 | fileDialog->setAcceptMode(QFileDialog::AcceptOpen); |
||
16235 | fschmid | 371 | fileDialog->setOption(QFileDialog::DontUseNativeDialog); |
21338 | fschmid | 372 | fileDialog->setIconProvider(new ImIconProvider()); |
14061 | fschmid | 373 | fileDialog->setNameFilterDetailsVisible(false); |
10034 | fschmid | 374 | fileDialog->setReadOnly(true); |
2830 | fschmid | 375 | fileDialog->setSizeGripEnabled(false); |
376 | fileDialog->setModal(false); |
||
10529 | fschmid | 377 | QList<QPushButton *> b = fileDialog->findChildren<QPushButton *>(); |
378 | QListIterator<QPushButton *> i(b); |
||
379 | while (i.hasNext()) |
||
380 | i.next()->setVisible(false); |
||
9098 | fschmid | 381 | fileDialog->setWindowFlags(Qt::Widget); |
2830 | fschmid | 382 | openDocLayout->addWidget(fileDialog); |
18154 | jghali | 383 | |
19153 | craig | 384 | FileDialogEventCatcher* keyCatcher = new FileDialogEventCatcher(this); |
18154 | jghali | 385 | QList<QListView *> lv = fileDialog->findChildren<QListView *>(); |
386 | QListIterator<QListView *> lvi(lv); |
||
387 | while (lvi.hasNext()) |
||
388 | lvi.next()->installEventFilter(keyCatcher); |
||
389 | connect(keyCatcher, SIGNAL(escapePressed()), this, SLOT(reject())); |
||
19153 | craig | 390 | connect(keyCatcher, SIGNAL(dropLocation(QString)), this, SLOT(locationDropped(QString))); |
19180 | craig | 391 | connect(keyCatcher, SIGNAL(desktopPressed()), this, SLOT(gotoDesktopDirectory())); |
392 | connect(keyCatcher, SIGNAL(homePressed()), this, SLOT(gotoHomeDirectory())); |
||
393 | connect(keyCatcher, SIGNAL(parentPressed()), this, SLOT(gotoParentDirectory())); |
||
394 | connect(keyCatcher, SIGNAL(enterSelectedPressed()), this, SLOT(gotoSelectedDirectory())); |
||
10034 | fschmid | 395 | connect(fileDialog, SIGNAL(filesSelected(const QStringList &)), this, SLOT(openFile())); |
18933 | jghali | 396 | connect(fileDialog, SIGNAL(rejected()), this, SLOT(reject())); |
3 | paul | 397 | } |
398 | |||
10034 | fschmid | 399 | void NewDoc::openFile() |
2966 | fschmid | 400 | { |
401 | ExitOK(); |
||
402 | } |
||
403 | |||
2833 | fschmid | 404 | void NewDoc::createRecentDocPage() |
405 | { |
||
9894 | fschmid | 406 | recentDocFrame = new QFrame(this); |
407 | recentDocLayout = new QVBoxLayout(recentDocFrame); |
||
408 | recentDocLayout->setMargin(5); |
||
409 | recentDocLayout->setSpacing(5); |
||
410 | recentDocListBox = new QListWidget(recentDocFrame); |
||
5781 | cbradney | 411 | recentDocLayout->addWidget(recentDocListBox); |
13876 | cbradney | 412 | uint max = qMin(prefsManager->appPrefs.uiPrefs.recentDocCount, recentDocList.count()); |
2833 | fschmid | 413 | for (uint m = 0; m < max; ++m) |
16577 | craig | 414 | recentDocListBox->addItem( QDir::toNativeSeparators(recentDocList[m]) ); |
16494 | craig | 415 | if (max>0) |
416 | recentDocListBox->setCurrentRow(0); |
||
2833 | fschmid | 417 | } |
418 | |||
8687 | cbradney | 419 | void NewDoc::setWidth(double) |
36 | Franz | 420 | { |
13236 | jghali | 421 | m_pageWidth = widthSpinBox->value() / m_unitRatio; |
422 | marginGroup->setPageWidth(m_pageWidth); |
||
4555 | cbradney | 423 | QString psText=pageSizeComboBox->currentText(); |
6859 | cbradney | 424 | if (psText!=CommonStrings::trCustomPageSize && psText!=CommonStrings::customPageSize) |
10529 | fschmid | 425 | pageSizeComboBox->setCurrentIndex(pageSizeComboBox->count()-1); |
13308 | jghali | 426 | int newOrientation = (widthSpinBox->value() > heightSpinBox->value()) ? landscapePage : portraitPage; |
427 | if (newOrientation != m_orientation) |
||
428 | { |
||
429 | pageOrientationComboBox->blockSignals(true); |
||
430 | pageOrientationComboBox->setCurrentIndex(newOrientation); |
||
431 | pageOrientationComboBox->blockSignals(false); |
||
432 | m_orientation = newOrientation; |
||
433 | } |
||
36 | Franz | 434 | } |
435 | |||
8687 | cbradney | 436 | void NewDoc::setHeight(double) |
36 | Franz | 437 | { |
13236 | jghali | 438 | m_pageHeight = heightSpinBox->value() / m_unitRatio; |
439 | marginGroup->setPageHeight(m_pageHeight); |
||
4555 | cbradney | 440 | QString psText=pageSizeComboBox->currentText(); |
6859 | cbradney | 441 | if (psText!=CommonStrings::trCustomPageSize && psText!=CommonStrings::customPageSize) |
10529 | fschmid | 442 | pageSizeComboBox->setCurrentIndex(pageSizeComboBox->count()-1); |
13308 | jghali | 443 | int newOrientation = (widthSpinBox->value() > heightSpinBox->value()) ? landscapePage : portraitPage; |
444 | if (newOrientation != m_orientation) |
||
445 | { |
||
446 | pageOrientationComboBox->blockSignals(true); |
||
447 | pageOrientationComboBox->setCurrentIndex(newOrientation); |
||
448 | pageOrientationComboBox->blockSignals(false); |
||
449 | m_orientation = newOrientation; |
||
450 | } |
||
36 | Franz | 451 | } |
452 | |||
7025 | fschmid | 453 | void NewDoc::selectItem(uint nr) |
454 | { |
||
9894 | fschmid | 455 | disconnect(layoutsView, SIGNAL(itemClicked(QListWidgetItem *)), this, SLOT(itemSelected(QListWidgetItem* ))); |
456 | disconnect(layoutsView, SIGNAL(itemDoubleClicked(QListWidgetItem *)), this, SLOT(itemSelected(QListWidgetItem* ))); |
||
457 | disconnect(layoutsView, SIGNAL(itemActivated(QListWidgetItem *)), this, SLOT(itemSelected(QListWidgetItem* ))); |
||
458 | disconnect(layoutsView, SIGNAL(itemPressed(QListWidgetItem *)), this, SLOT(itemSelected(QListWidgetItem* ))); |
||
459 | if (nr > 0) |
||
7025 | fschmid | 460 | { |
9894 | fschmid | 461 | firstPage->setEnabled(true); |
462 | firstPage->clear(); |
||
463 | QStringList::Iterator pNames; |
||
464 | for(pNames = prefsManager->appPrefs.pageSets[nr].pageNames.begin(); pNames != prefsManager->appPrefs.pageSets[nr].pageNames.end(); ++pNames ) |
||
7025 | fschmid | 465 | { |
10529 | fschmid | 466 | firstPage->addItem(CommonStrings::translatePageSetLocString((*pNames))); |
7025 | fschmid | 467 | } |
468 | } |
||
9894 | fschmid | 469 | else |
470 | { |
||
471 | firstPage->clear(); |
||
10529 | fschmid | 472 | firstPage->addItem(" "); |
9894 | fschmid | 473 | firstPage->setEnabled(false); |
474 | } |
||
475 | layoutsView->setCurrentRow(nr); |
||
476 | layoutsView->item(nr)->setSelected(true); |
||
477 | connect(layoutsView, SIGNAL(itemClicked(QListWidgetItem *)), this, SLOT(itemSelected(QListWidgetItem* ))); |
||
478 | connect(layoutsView, SIGNAL(itemDoubleClicked(QListWidgetItem *)), this, SLOT(itemSelected(QListWidgetItem* ))); |
||
479 | connect(layoutsView, SIGNAL(itemActivated(QListWidgetItem *)), this, SLOT(itemSelected(QListWidgetItem* ))); |
||
480 | connect(layoutsView, SIGNAL(itemPressed(QListWidgetItem *)), this, SLOT(itemSelected(QListWidgetItem* ))); |
||
7025 | fschmid | 481 | } |
482 | |||
9894 | fschmid | 483 | void NewDoc::itemSelected(QListWidgetItem* ic) |
7025 | fschmid | 484 | { |
485 | if (ic == 0) |
||
486 | return; |
||
9894 | fschmid | 487 | selectItem(layoutsView->row(ic)); |
13236 | jghali | 488 | setDocLayout(layoutsView->row(ic)); |
7025 | fschmid | 489 | } |
490 | |||
7023 | fschmid | 491 | void NewDoc::handleAutoFrame() |
492 | { |
||
493 | if (autoTextFrame->isChecked()) |
||
494 | { |
||
495 | TextLabel3->setEnabled(true); |
||
496 | TextLabel4->setEnabled(true); |
||
497 | Distance->setEnabled(true); |
||
498 | numberOfCols->setEnabled(true); |
||
499 | } |
||
500 | else |
||
501 | { |
||
502 | TextLabel3->setEnabled(false); |
||
503 | TextLabel4->setEnabled(false); |
||
504 | Distance->setEnabled(false); |
||
505 | numberOfCols->setEnabled(false); |
||
506 | } |
||
507 | } |
||
508 | |||
13236 | jghali | 509 | void NewDoc::setDistance(double) |
3 | paul | 510 | { |
13236 | jghali | 511 | m_distance = Distance->value() / m_unitRatio; |
3 | paul | 512 | } |
513 | |||
806 | cbradney | 514 | void NewDoc::setUnit(int newUnitIndex) |
3 | paul | 515 | { |
8687 | cbradney | 516 | disconnect(widthSpinBox, SIGNAL(valueChanged(double)), this, SLOT(setWidth(double))); |
517 | disconnect(heightSpinBox, SIGNAL(valueChanged(double)), this, SLOT(setHeight(double))); |
||
8602 | cbradney | 518 | widthSpinBox->setNewUnit(newUnitIndex); |
519 | heightSpinBox->setNewUnit(newUnitIndex); |
||
520 | Distance->setNewUnit(newUnitIndex); |
||
13236 | jghali | 521 | m_unitRatio = unitGetRatioFromIndex(newUnitIndex); |
522 | m_unitIndex = newUnitIndex; |
||
17465 | fschmid | 523 | widthSpinBox->setValue(m_pageWidth * m_unitRatio); |
524 | heightSpinBox->setValue(m_pageHeight * m_unitRatio); |
||
401 | Franz | 525 | |
13236 | jghali | 526 | marginGroup->setNewUnit(m_unitIndex); |
527 | marginGroup->setPageHeight(m_pageHeight); |
||
528 | marginGroup->setPageWidth(m_pageWidth); |
||
8687 | cbradney | 529 | connect(widthSpinBox, SIGNAL(valueChanged(double)), this, SLOT(setWidth(double))); |
530 | connect(heightSpinBox, SIGNAL(valueChanged(double)), this, SLOT(setHeight(double))); |
||
3 | paul | 531 | } |
532 | |||
533 | void NewDoc::ExitOK() |
||
534 | { |
||
13236 | jghali | 535 | m_pageWidth = widthSpinBox->value() / m_unitRatio; |
536 | m_pageHeight = heightSpinBox->value() / m_unitRatio; |
||
537 | m_bleedBottom = marginGroup->bottomBleed(); |
||
538 | m_bleedTop = marginGroup->topBleed(); |
||
539 | m_bleedLeft = marginGroup->leftBleed(); |
||
540 | m_bleedRight = marginGroup->rightBleed(); |
||
541 | if (m_onStartup) |
||
10034 | fschmid | 542 | { |
13236 | jghali | 543 | m_tabSelected = tabWidget->currentIndex(); |
13380 | subik | 544 | if (m_tabSelected == NewDoc::NewFromTemplateTab) // new doc from template |
13236 | jghali | 545 | { |
13477 | jghali | 546 | if (nftGui->currentDocumentTemplate) |
547 | { |
||
548 | m_selectedFile = QDir::fromNativeSeparators(nftGui->currentDocumentTemplate->file); |
||
549 | m_selectedFile = QDir::cleanPath(m_selectedFile); |
||
550 | } |
||
13236 | jghali | 551 | } |
13380 | subik | 552 | else if (m_tabSelected == NewDoc::OpenExistingTab) // open existing doc |
13236 | jghali | 553 | { |
554 | QStringList files = fileDialog->selectedFiles(); |
||
555 | if (files.count() != 0) |
||
556 | m_selectedFile = QDir::fromNativeSeparators(files[0]); |
||
557 | } |
||
13380 | subik | 558 | else if (m_tabSelected == NewDoc::OpenRecentTab) // open recent doc |
13236 | jghali | 559 | { |
560 | if (recentDocListBox->currentItem() != NULL) |
||
561 | { |
||
562 | QString fileName(recentDocListBox->currentItem()->text()); |
||
563 | if (!fileName.isEmpty()) |
||
564 | m_selectedFile = QDir::fromNativeSeparators(fileName); |
||
565 | } |
||
566 | } |
||
10034 | fschmid | 567 | } |
2833 | fschmid | 568 | else |
13380 | subik | 569 | m_tabSelected = NewDoc::NewDocumentTab; |
2830 | fschmid | 570 | accept(); |
3 | paul | 571 | } |
572 | |||
13236 | jghali | 573 | void NewDoc::setOrientation(int ori) |
3 | paul | 574 | { |
8687 | cbradney | 575 | disconnect(widthSpinBox, SIGNAL(valueChanged(double)), this, SLOT(setWidth(double))); |
576 | disconnect(heightSpinBox, SIGNAL(valueChanged(double)), this, SLOT(setHeight(double))); |
||
13236 | jghali | 577 | if (ori != m_orientation) |
167 | Franz | 578 | { |
19533 | jghali | 579 | double w = widthSpinBox->value(), h = heightSpinBox->value(); |
580 | double pw = m_pageWidth, ph = m_pageHeight; |
||
13307 | jghali | 581 | widthSpinBox->setValue((ori == portraitPage) ? qMin(w, h) : qMax(w, h)); |
582 | heightSpinBox->setValue((ori == portraitPage) ? qMax(w, h) : qMin(w, h)); |
||
19533 | jghali | 583 | m_pageWidth = (ori == portraitPage) ? qMin(pw, ph) : qMax(pw, ph); |
584 | m_pageHeight = (ori == portraitPage) ? qMax(pw, ph) : qMin(pw, ph); |
||
167 | Franz | 585 | } |
401 | Franz | 586 | // #869 pv - defined constants added + code repeat (check w/h) |
13236 | jghali | 587 | (ori == portraitPage) ? m_orientation = portraitPage : m_orientation = landscapePage; |
6859 | cbradney | 588 | if (pageSizeComboBox->currentText() == CommonStrings::trCustomPageSize) |
2798 | fschmid | 589 | { |
8602 | cbradney | 590 | if (widthSpinBox->value() > heightSpinBox->value()) |
10529 | fschmid | 591 | pageOrientationComboBox->setCurrentIndex(landscapePage); |
2798 | fschmid | 592 | else |
10529 | fschmid | 593 | pageOrientationComboBox->setCurrentIndex(portraitPage); |
2798 | fschmid | 594 | } |
401 | Franz | 595 | // end of #869 |
13236 | jghali | 596 | marginGroup->setPageHeight(m_pageHeight); |
597 | marginGroup->setPageWidth(m_pageWidth); |
||
8687 | cbradney | 598 | connect(widthSpinBox, SIGNAL(valueChanged(double)), this, SLOT(setWidth(double))); |
599 | connect(heightSpinBox, SIGNAL(valueChanged(double)), this, SLOT(setHeight(double))); |
||
3 | paul | 600 | } |
601 | |||
13236 | jghali | 602 | void NewDoc::setPageSize(const QString &size) |
3 | paul | 603 | { |
6859 | cbradney | 604 | if (size == CommonStrings::trCustomPageSize) |
1542 | cbradney | 605 | setSize(size); |
3 | paul | 606 | else |
332 | Franz | 607 | { |
1542 | cbradney | 608 | setSize(size); |
13236 | jghali | 609 | setOrientation(pageOrientationComboBox->currentIndex()); |
332 | Franz | 610 | } |
5786 | cbradney | 611 | marginGroup->setPageSize(size); |
3 | paul | 612 | } |
613 | |||
1542 | cbradney | 614 | void NewDoc::setSize(QString gr) |
3 | paul | 615 | { |
13236 | jghali | 616 | m_pageWidth = widthSpinBox->value() / m_unitRatio; |
617 | m_pageHeight = heightSpinBox->value() / m_unitRatio; |
||
2874 | subik | 618 | |
8687 | cbradney | 619 | disconnect(widthSpinBox, SIGNAL(valueChanged(double)), this, SLOT(setWidth(double))); |
620 | disconnect(heightSpinBox, SIGNAL(valueChanged(double)), this, SLOT(setHeight(double))); |
||
6859 | cbradney | 621 | if (gr==CommonStrings::trCustomPageSize || gr==CommonStrings::customPageSize) |
167 | Franz | 622 | { |
8701 | fschmid | 623 | widthSpinBox->setEnabled(true); |
624 | heightSpinBox->setEnabled(true); |
||
167 | Franz | 625 | } |
173 | Franz | 626 | else |
627 | { |
||
1542 | cbradney | 628 | PageSize *ps2=new PageSize(gr); |
10529 | fschmid | 629 | if (pageOrientationComboBox->currentIndex() == portraitPage) |
401 | Franz | 630 | { |
13236 | jghali | 631 | m_pageWidth = ps2->width(); |
632 | m_pageHeight = ps2->height(); |
||
401 | Franz | 633 | } else { |
13236 | jghali | 634 | m_pageWidth = ps2->height(); |
635 | m_pageHeight = ps2->width(); |
||
401 | Franz | 636 | } |
3449 | cbradney | 637 | delete ps2; |
173 | Franz | 638 | } |
13236 | jghali | 639 | widthSpinBox->setValue(m_pageWidth * m_unitRatio); |
640 | heightSpinBox->setValue(m_pageHeight * m_unitRatio); |
||
641 | marginGroup->setPageHeight(m_pageHeight); |
||
642 | marginGroup->setPageWidth(m_pageWidth); |
||
8687 | cbradney | 643 | connect(widthSpinBox, SIGNAL(valueChanged(double)), this, SLOT(setWidth(double))); |
644 | connect(heightSpinBox, SIGNAL(valueChanged(double)), this, SLOT(setHeight(double))); |
||
3 | paul | 645 | } |
646 | |||
13236 | jghali | 647 | void NewDoc::setDocLayout(int layout) |
3 | paul | 648 | { |
14839 | cbradney | 649 | marginGroup->setFacingPages(layout != singlePage); |
13236 | jghali | 650 | m_choosenLayout = layout; |
651 | firstPage->setCurrentIndex(prefsManager->appPrefs.pageSets[m_choosenLayout].FirstPage); |
||
3 | paul | 652 | } |
1542 | cbradney | 653 | |
9894 | fschmid | 654 | void NewDoc::recentDocListBox_doubleClicked() |
2874 | subik | 655 | { |
4026 | craig | 656 | /* Yep. There is nothing to solve. ScribusMainWindow handles all |
2874 | subik | 657 | openings etc. It's Franz's programming style ;) */ |
658 | ExitOK(); |
||
659 | } |
||
14452 | fschmid | 660 | |
661 | void NewDoc::adjustTitles(int tab) |
||
662 | { |
||
663 | if (tab == 0) |
||
664 | setWindowTitle( tr( "New Document" ) ); |
||
665 | else if (tab == 1) |
||
666 | setWindowTitle( tr("New from Template")); |
||
667 | else if (tab == 2) |
||
668 | setWindowTitle( tr("Open Existing Document")); |
||
669 | else if (tab == 3) |
||
670 | setWindowTitle( tr("Open Recent Document")); |
||
671 | else |
||
672 | setWindowTitle( tr( "New Document" ) ); |
||
673 | } |
||
19153 | craig | 674 | |
19168 | craig | 675 | void NewDoc::locationDropped(QString fileUrl) |
19153 | craig | 676 | { |
19168 | craig | 677 | QFileInfo fi(fileUrl); |
678 | if (fi.isDir()) |
||
679 | fileDialog->setDirectory(fi.absoluteFilePath()); |
||
680 | else |
||
681 | { |
||
682 | fileDialog->setDirectory(fi.absolutePath()); |
||
683 | fileDialog->selectFile(fi.fileName()); |
||
684 | } |
||
19153 | craig | 685 | } |
686 | |||
19180 | craig | 687 | void NewDoc::gotoParentDirectory() |
688 | { |
||
689 | QDir d(fileDialog->directory()); |
||
690 | d.cdUp(); |
||
691 | fileDialog->setDirectory(d); |
||
692 | } |
||
693 | |||
694 | |||
695 | void NewDoc::gotoSelectedDirectory() |
||
696 | { |
||
697 | QStringList s(fileDialog->selectedFiles()); |
||
698 | if (s.count()>0) |
||
699 | { |
||
700 | QFileInfo fi(s.first()); |
||
701 | qDebug()<<s.first()<<fi.absoluteFilePath(); |
||
702 | if (fi.isDir()) |
||
703 | fileDialog->setDirectory(fi.absoluteFilePath()); |
||
704 | } |
||
705 | } |
||
706 | |||
707 | void NewDoc::gotoDesktopDirectory() |
||
708 | { |
||
709 | QString dp=QStandardPaths::writableLocation(QStandardPaths::DesktopLocation); |
||
710 | QFileInfo fi(dp); |
||
711 | if (fi.exists()) |
||
712 | fileDialog->setDirectory(dp); |
||
713 | } |
||
714 | |||
715 | |||
716 | void NewDoc::gotoHomeDirectory() |
||
717 | { |
||
718 | QString dp=QStandardPaths::writableLocation(QStandardPaths::HomeLocation); |
||
719 | QFileInfo fi(dp); |
||
720 | if (fi.exists()) |
||
721 | fileDialog->setDirectory(dp); |
||
722 | } |