28 #include <KPluginLoader>
29 #include <KPluginFactory>
30 #include <KMessageBox>
31 #include <KApplication>
33 #include <KActionCollection>
34 #include <KStandardAction>
35 #include <KFileDialog>
36 #include <KRecentFilesAction>
39 #include <KEditToolBar>
40 #include <KShortcutsDialog>
41 #include <KXMLGUIFactory>
43 #include <QDragEnterEvent>
44 #include <QDragMoveEvent>
45 #include <QWeakPointer>
49 return ((data->
hasUrls()) && (data->
urls().count() == 1));
60 if (!initialGeometrySet()) {
70 if (m_recentFilesAction) {
71 m_recentFilesAction->saveEntries(KGlobal::config()->group(
"Recent Files"));
74 guiFactory()->removeClient(m_part);
88 if ((event->
source() == NULL) &&
90 event->acceptProposedAction();
104 if ((event->
source() == NULL) &&
106 event->acceptProposedAction();
123 if ((event->
source() == NULL) &&
125 event->acceptProposedAction();
132 KPluginFactory *factory = loader.factory();
134 m_part =
static_cast<KParts::ReadWritePart*
>(factory->create<KParts::ReadWritePart>(
this));
136 if (!factory || !m_part) {
137 KMessageBox::error(
this, i18n(
"Unable to find Ark's KPart component, please check your installation."));
138 kWarning() <<
"Error loading Ark KPart: " << loader.errorString();
143 setCentralWidget(m_part->widget());
146 connect(m_part, SIGNAL(busy()),
this, SLOT(updateActions()));
147 connect(m_part, SIGNAL(ready()),
this, SLOT(updateActions()));
148 connect(m_part, SIGNAL(quit()),
this, SLOT(quit()));
153 void MainWindow::setupActions()
155 m_newAction = KStandardAction::openNew(
this, SLOT(newArchive()), actionCollection());
156 m_openAction = KStandardAction::open(
this, SLOT(openArchive()), actionCollection());
157 KStandardAction::quit(
this, SLOT(quit()), actionCollection());
159 m_recentFilesAction = KStandardAction::openRecent(
this, SLOT(
openUrl(KUrl)), actionCollection());
160 m_recentFilesAction->setToolBarMode(KRecentFilesAction::MenuMode);
161 m_recentFilesAction->setToolButtonPopupMode(QToolButton::DelayedPopup);
162 m_recentFilesAction->setIconText(i18nc(
"action, to open an archive",
"Open"));
163 m_recentFilesAction->setStatusTip(i18n(
"Click to open an archive, click and hold to open a recently-opened archive"));
164 m_recentFilesAction->setToolTip(i18n(
"Open an archive"));
165 m_recentFilesAction->loadEntries(KGlobal::config()->group(
"Recent Files"));
166 connect(m_recentFilesAction, SIGNAL(triggered()),
167 this, SLOT(openArchive()));
169 createStandardStatusBarAction();
171 KStandardAction::configureToolbars(
this, SLOT(editToolbars()), actionCollection());
172 KStandardAction::keyBindings(
this, SLOT(editKeyBindings()), actionCollection());
175 void MainWindow::updateActions()
180 m_recentFilesAction->setEnabled(!iface->
isBusy());
183 void MainWindow::editKeyBindings()
185 KShortcutsDialog dlg(KShortcutsEditor::AllActions, KShortcutsEditor::LetterShortcutsAllowed,
this);
186 dlg.addCollection(actionCollection());
187 dlg.addCollection(m_part->actionCollection());
192 void MainWindow::editToolbars()
194 saveMainWindowSettings(KGlobal::config()->group(
QLatin1String(
"MainWindow")));
201 applyMainWindowSettings(KGlobal::config()->group(
QLatin1String(
"MainWindow")));
206 void MainWindow::openArchive()
210 const KUrl url = KFileDialog::getOpenUrl(KUrl(
"kfiledialog:///ArkOpenDir"),
218 if (!url.isEmpty()) {
219 m_part->setArguments(m_openArgs);
221 if (m_part->openUrl(url)) {
222 m_recentFilesAction->addUrl(url);
224 m_recentFilesAction->removeUrl(url);
234 m_openArgs.metaData().remove(
QLatin1String(
"showExtractDialog" ));
238 void MainWindow::quit()
243 void MainWindow::newArchive()
252 const KUrl saveFileUrl =
253 KFileDialog::getSaveUrl(KUrl(
"kfiledialog:///ArkNewDir"),
260 m_openArgs.metaData().remove(
QLatin1String(
"showExtractDialog" ));
261 m_openArgs.metaData().remove(
QLatin1String(
"createNewArchive" ));
void dragEnterEvent(class QDragEnterEvent *event)
const QMimeData * mimeData() const
QStringList supportedWriteMimeTypes()
QString join(const QString &separator) const
static bool isValidArchiveDrag(const QMimeData *data)
QStringList supportedMimeTypes()
MainWindow(QWidget *parent=0)
virtual bool isBusy() const =0
QList< QUrl > urls() const
void setShowExtractDialog(bool)
void dragMoveEvent(class QDragMoveEvent *event)
void openUrl(const KUrl &url)
void dropEvent(class QDropEvent *event)