summaryrefslogtreecommitdiff
path: root/muse2/muse/widgets
diff options
context:
space:
mode:
Diffstat (limited to 'muse2/muse/widgets')
-rw-r--r--muse2/muse/widgets/CMakeLists.txt3
-rw-r--r--muse2/muse/widgets/copy_on_write.cpp39
-rw-r--r--muse2/muse/widgets/copy_on_write.h42
-rw-r--r--muse2/muse/widgets/copy_on_write_base.ui102
-rw-r--r--muse2/muse/widgets/utils.cpp33
-rw-r--r--muse2/muse/widgets/utils.h4
6 files changed, 222 insertions, 1 deletions
diff --git a/muse2/muse/widgets/CMakeLists.txt b/muse2/muse/widgets/CMakeLists.txt
index 88706339..0e9d369d 100644
--- a/muse2/muse/widgets/CMakeLists.txt
+++ b/muse2/muse/widgets/CMakeLists.txt
@@ -40,6 +40,7 @@ QT4_WRAP_CPP (widget_mocs
comboQuant.h
combobox.h
comment.h
+ copy_on_write.h
ctrlcombo.h
custom_widget_actions.h
dentry.h
@@ -114,6 +115,7 @@ file (GLOB widgets_ui_files
cliplisteditorbase.ui
commentbase.ui
configmidifilebase.ui
+ copy_on_write_base.ui
didyouknow.ui
editnotedialogbase.ui
editsysexdialogbase.ui
@@ -153,6 +155,7 @@ file (GLOB widgets_source_files
comboQuant.cpp
combobox.cpp
comment.cpp
+ copy_on_write.cpp
ctrlcombo.cpp
custom_widget_actions.cpp
dentry.cpp
diff --git a/muse2/muse/widgets/copy_on_write.cpp b/muse2/muse/widgets/copy_on_write.cpp
new file mode 100644
index 00000000..53e79a91
--- /dev/null
+++ b/muse2/muse/widgets/copy_on_write.cpp
@@ -0,0 +1,39 @@
+//=========================================================
+// MusE
+// Linux Music Editor
+// copy_on_write.cpp
+// (C) Copyright 2012 Tim E. Real (terminator356 on users dot sourceforge dot net)
+//
+// This program is free software; you can redistribute it and/or
+// modify it under the terms of the GNU General Public License
+// as published by the Free Software Foundation; version 2 of
+// the License, or (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program; if not, write to the Free Software
+// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+//
+//=========================================================
+
+#include "copy_on_write.h"
+
+namespace MusEGui {
+
+CopyOnWriteDialog::CopyOnWriteDialog(QWidget* parent): QDialog(parent)
+{
+ setupUi(this);
+
+}
+
+void CopyOnWriteDialog::addProjDirFile(const QString& s)
+{
+ projDirList->addItem(s);
+}
+
+
+} // namespace MusEGui \ No newline at end of file
diff --git a/muse2/muse/widgets/copy_on_write.h b/muse2/muse/widgets/copy_on_write.h
new file mode 100644
index 00000000..f06274eb
--- /dev/null
+++ b/muse2/muse/widgets/copy_on_write.h
@@ -0,0 +1,42 @@
+//=========================================================
+// MusE
+// Linux Music Editor
+// copy_on_write.h
+// (C) Copyright 2012 Tim E. Real (terminator356 on users dot sourceforge dot net)
+//
+// This program is free software; you can redistribute it and/or
+// modify it under the terms of the GNU General Public License
+// as published by the Free Software Foundation; version 2 of
+// the License, or (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program; if not, write to the Free Software
+// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+//
+//=========================================================
+
+#ifndef __COPY_ON_WRITE_H__
+#define __COPY_ON_WRITE_H__
+
+#include "ui_copy_on_write_base.h"
+
+namespace MusEGui {
+
+class CopyOnWriteDialog : public QDialog, public Ui::CopyOnWriteDialogBase
+{
+ Q_OBJECT
+
+public:
+ CopyOnWriteDialog(QWidget* parent = 0);
+ void addProjDirFile(const QString&);
+};
+
+} // namespace MusEGui
+
+
+#endif
diff --git a/muse2/muse/widgets/copy_on_write_base.ui b/muse2/muse/widgets/copy_on_write_base.ui
new file mode 100644
index 00000000..d59b6325
--- /dev/null
+++ b/muse2/muse/widgets/copy_on_write_base.ui
@@ -0,0 +1,102 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<ui version="4.0">
+ <class>CopyOnWriteDialogBase</class>
+ <widget class="QDialog" name="CopyOnWriteDialogBase">
+ <property name="geometry">
+ <rect>
+ <x>0</x>
+ <y>0</y>
+ <width>431</width>
+ <height>344</height>
+ </rect>
+ </property>
+ <property name="windowTitle">
+ <string>Copy Wave Files</string>
+ </property>
+ <layout class="QVBoxLayout" name="verticalLayout_2">
+ <item>
+ <widget class="QFrame" name="frame">
+ <property name="frameShape">
+ <enum>QFrame::StyledPanel</enum>
+ </property>
+ <property name="frameShadow">
+ <enum>QFrame::Raised</enum>
+ </property>
+ <layout class="QVBoxLayout" name="verticalLayout">
+ <item>
+ <widget class="QLabel" name="label_3">
+ <property name="text">
+ <string>Some wave files will be copied to the Project Directory,
+either because they are not writable or because more
+than one independent Wave Event shares them.
+Multiple copies will be made in some cases.
+
+If no Project has been created yet, you will be asked to,
+giving another chance to cancel.</string>
+ </property>
+ <property name="wordWrap">
+ <bool>true</bool>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </widget>
+ </item>
+ <item>
+ <widget class="QLabel" name="label_2">
+ <property name="text">
+ <string>These files will be copied to the Project Directory:</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QListWidget" name="projDirList"/>
+ </item>
+ <item>
+ <widget class="QDialogButtonBox" name="buttonBox">
+ <property name="orientation">
+ <enum>Qt::Horizontal</enum>
+ </property>
+ <property name="standardButtons">
+ <set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </widget>
+ <resources/>
+ <connections>
+ <connection>
+ <sender>buttonBox</sender>
+ <signal>accepted()</signal>
+ <receiver>CopyOnWriteDialogBase</receiver>
+ <slot>accept()</slot>
+ <hints>
+ <hint type="sourcelabel">
+ <x>248</x>
+ <y>254</y>
+ </hint>
+ <hint type="destinationlabel">
+ <x>157</x>
+ <y>274</y>
+ </hint>
+ </hints>
+ </connection>
+ <connection>
+ <sender>buttonBox</sender>
+ <signal>rejected()</signal>
+ <receiver>CopyOnWriteDialogBase</receiver>
+ <slot>reject()</slot>
+ <hints>
+ <hint type="sourcelabel">
+ <x>316</x>
+ <y>260</y>
+ </hint>
+ <hint type="destinationlabel">
+ <x>286</x>
+ <y>274</y>
+ </hint>
+ </hints>
+ </connection>
+ </connections>
+</ui>
diff --git a/muse2/muse/widgets/utils.cpp b/muse2/muse/widgets/utils.cpp
index e9fbc9e3..ab1d74fd 100644
--- a/muse2/muse/widgets/utils.cpp
+++ b/muse2/muse/widgets/utils.cpp
@@ -36,6 +36,7 @@
#include <QMimeData>
#include <QPainter>
#include <QPointF>
+#include <QFileInfo>
#include "audio.h"
#include "audiodev.h"
@@ -566,4 +567,36 @@ int get_paste_len()
return end_tick - begin_tick;
}
+//---------------------------------------------------------
+// getUniqueFileName
+// Sets newAbsFilePath to origFilepath or a new version if found
+// Return true if success
+//---------------------------------------------------------
+
+bool getUniqueFileName(const QString& origFilepath, QString& newAbsFilePath)
+ {
+ QFileInfo fi(origFilepath);
+ if(!fi.exists())
+ {
+ newAbsFilePath = fi.absoluteFilePath();
+ return true;
+ }
+
+ QString pre = fi.absolutePath() + QString('/') + fi.baseName() + QString('_');
+ QString post = QString('.') + fi.completeSuffix();
+ for(int i = 1; i < 100000; ++i)
+ {
+ fi.setFile(pre + QString::number(i) + post);
+ if(!fi.exists())
+ {
+ newAbsFilePath = fi.absoluteFilePath();
+ return true;
+ }
+ }
+
+ printf("Could not find a suitable filename (more than 100000 files based on %s - clean up!\n", origFilepath.toLatin1().constData());
+ return false;
+ }
+
+
} // namespace MusECore
diff --git a/muse2/muse/widgets/utils.h b/muse2/muse/widgets/utils.h
index 07899a84..a558e73c 100644
--- a/muse2/muse/widgets/utils.h
+++ b/muse2/muse/widgets/utils.h
@@ -58,7 +58,9 @@ extern QPainterPath roundedPath(int x, int y, int w, int h, int xrad, int yrad,
extern QIcon colorRect(const QColor& color, int width, int height);
extern int get_paste_len();
-} // namespace MusECores
+extern bool getUniqueFileName(const QString& filename, QString& newAbsFilePath);
+
+} // namespace MusECore
#endif